Commit c66270ad authored by peastman's avatar peastman
Browse files

Merge pull request #1338 from peastman/centroidserialize

Fixed a bug in serializing CustomCentroidBondForce
parents 71de4b1b 202c24d9
......@@ -64,7 +64,8 @@ void CustomCentroidBondForceProxy::serialize(const void* object, SerializationNo
for (int j = 0; j < (int) particles.size(); j++) {
SerializationNode& node = group.createChildNode("Particle");
node.setIntProperty("p", particles[j]);
node.setDoubleProperty("weight", weights[j]);
if (j < weights.size())
node.setDoubleProperty("weight", weights[j]);
}
}
SerializationNode& bonds = node.createChildNode("Bonds");
......@@ -115,7 +116,8 @@ void* CustomCentroidBondForceProxy::deserialize(const SerializationNode& node) c
vector<double> weights;
for (int j = 0; j < (int) group.getChildren().size(); j++) {
particles.push_back(group.getChildren()[j].getIntProperty("p"));
weights.push_back(group.getChildren()[j].getDoubleProperty("weight"));
if (group.getChildren()[j].hasProperty("weight"))
weights.push_back(group.getChildren()[j].getDoubleProperty("weight"));
}
force->addGroup(particles, weights);
}
......
......@@ -51,7 +51,8 @@ void testSerialization() {
vector<double> weights;
for (int j = 0; j < i+1; j++) {
particles.push_back(i+j);
weights.push_back(1.0/(i+1));
if (i < 2)
weights.push_back(1.0/(i+1));
}
force.addGroup(particles, weights);
}
......
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