Commit 202c24d9 authored by peastman's avatar peastman
Browse files

Fixed a bug in serializing CustomCentroidBondForce

parent 71de4b1b
......@@ -64,6 +64,7 @@ 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]);
if (j < weights.size())
node.setDoubleProperty("weight", weights[j]);
}
}
......@@ -115,6 +116,7 @@ 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"));
if (group.getChildren()[j].hasProperty("weight"))
weights.push_back(group.getChildren()[j].getDoubleProperty("weight"));
}
force->addGroup(particles, weights);
......
......@@ -51,6 +51,7 @@ void testSerialization() {
vector<double> weights;
for (int j = 0; j < i+1; j++) {
particles.push_back(i+j);
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