"wrappers/vscode:/vscode.git/clone" did not exist on "79ed6274f7750201c08dbc66da29c0890bae0ec6"
Commit 4beb144e authored by peastman's avatar peastman
Browse files

Merge pull request #1384 from peastman/setglobal

Fixed error in computing global variables
parents 1085085d 5e6862fd
......@@ -6661,12 +6661,12 @@ void CudaIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegrat
if (cu.getUseDoublePrecision() || cu.getUseMixedPrecision()) {
double value;
summedValue->download(&value);
globalValuesDouble[stepTarget[step].variableIndex] = value;
recordGlobalValue(value, stepTarget[step]);
}
else {
float value;
summedValue->download(&value);
globalValuesDouble[stepTarget[step].variableIndex] = value;
recordGlobalValue(value, stepTarget[step]);
}
}
else if (stepType[step] == CustomIntegrator::UpdateContextState) {
......
......@@ -6939,12 +6939,12 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
if (cl.getUseDoublePrecision() || cl.getUseMixedPrecision()) {
double value;
summedValue->download(&value);
globalValuesDouble[stepTarget[step].variableIndex] = value;
recordGlobalValue(value, stepTarget[step]);
}
else {
float value;
summedValue->download(&value);
globalValuesDouble[stepTarget[step].variableIndex] = value;
recordGlobalValue(value, stepTarget[step]);
}
}
else if (stepType[step] == CustomIntegrator::UpdateContextState) {
......
......@@ -391,9 +391,11 @@ void testSum() {
}
CustomIntegrator integrator(0.005);
integrator.addGlobalVariable("ke", 0);
integrator.addGlobalVariable("kecopy", 0);
integrator.addComputePerDof("v", "v+dt*f/m");
integrator.addComputePerDof("x", "x+dt*v");
integrator.addComputeSum("ke", "m*v*v/2");
integrator.addComputeGlobal("kecopy", "ke");
Context context(system, integrator, platform);
context.setPositions(positions);
......@@ -402,6 +404,7 @@ void testSum() {
for (int i = 0; i < 100; ++i) {
State state = context.getState(State::Energy);
ASSERT_EQUAL_TOL(state.getKineticEnergy(), integrator.getGlobalVariable(0), 1e-5);
ASSERT_EQUAL(integrator.getGlobalVariable(0), integrator.getGlobalVariable(1));
integrator.step(1);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment