Commit a13e3d18 authored by John Chodera (MSKCC)'s avatar John Chodera (MSKCC)
Browse files

Added missing serialization support for CustomNonbondedForce interaction groups.

parent 230819d1
......@@ -76,6 +76,20 @@ void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode&
SerializationNode& functions = node.createChildNode("Functions");
for (int i = 0; i < force.getNumTabulatedFunctions(); i++)
functions.createChildNode("Function", &force.getTabulatedFunction(i)).setStringProperty("name", force.getTabulatedFunctionName(i));
SerializationNode& interactionGroups = node.createChildNode("InteractionGroups");
for (int i = 0; i < force.getNumInteractionGroups(); i++) {
SerializationNode& interactionGroup = interactionGroups.createChildNode("InteractionGroup");
std::set<int> set1;
std::set<int> set2;
force.getInteractionGroupParameters(i, set1, set2);
SerializationNode& set1node = interactionGroup.createChildNode("Set1");
for (std::set<int>::iterator it = set1.begin(); it != set1.end(); ++it)
set1node.createChildNode("Particle").setIntProperty("index", *it);
SerializationNode& set2node = interactionGroup.createChildNode("Set2");
for (std::set<int>::iterator it = set1.begin(); it != set1.end(); ++it)
set2node.createChildNode("Particle").setIntProperty("index", *it);
}
}
void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) const {
......@@ -129,6 +143,21 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
force->addTabulatedFunction(function.getStringProperty("name"), new Continuous1DFunction(values, function.getDoubleProperty("min"), function.getDoubleProperty("max")));
}
}
const SerializationNode& interactionGroups = node.getChildNode("InteractionGroups");
for (int i = 0; i < (int) interactionGroups.getChildren().size(); i++) {
const SerializationNode& interactionGroup = interactionGroups.getChildren()[i];
// Get set 1.
const SerializationNode& set1node = interactionGroup.getChildNode("Set1");
std::set<int> set1;
for (int j = 0; j < (int) set1node.getChildren().size(); j++)
set1.insert(set1node.getChildren()[j].getIntProperty("index"));
// Get set 2.
const SerializationNode& set2node = interactionGroup.getChildNode("Set2");
std::set<int> set2;
for (int j = 0; j < (int) set2node.getChildren().size(); j++)
set2.insert(set2node.getChildren()[j].getIntProperty("index"));
force->addInteractionGroup(set1, set2);
}
return force;
}
catch (...) {
......
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