Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
2ab3b77d
Unverified
Commit
2ab3b77d
authored
Nov 16, 2023
by
Peter Eastman
Committed by
GitHub
Nov 16, 2023
Browse files
Serialization proxy for ATMForce did not record the particles (#4317)
parent
31abb2f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
serialization/src/ATMForceProxy.cpp
serialization/src/ATMForceProxy.cpp
+11
-0
serialization/tests/TestSerializeATMForce.cpp
serialization/tests/TestSerializeATMForce.cpp
+10
-0
No files found.
serialization/src/ATMForceProxy.cpp
View file @
2ab3b77d
...
@@ -60,6 +60,13 @@ void ATMForceProxy::serialize(const void* object, SerializationNode& node) const
...
@@ -60,6 +60,13 @@ void ATMForceProxy::serialize(const void* object, SerializationNode& node) const
SerializationNode
&
f
=
forces
.
createChildNode
(
"Force"
);
SerializationNode
&
f
=
forces
.
createChildNode
(
"Force"
);
f
.
createChildNode
(
"Force"
,
&
force
.
getForce
(
i
));
f
.
createChildNode
(
"Force"
,
&
force
.
getForce
(
i
));
}
}
SerializationNode
&
particles
=
node
.
createChildNode
(
"Particles"
);
for
(
int
i
=
0
;
i
<
force
.
getNumParticles
();
i
++
)
{
Vec3
d1
,
d0
;
force
.
getParticleParameters
(
i
,
d1
,
d0
);
particles
.
createChildNode
(
"Particle"
).
setDoubleProperty
(
"d1x"
,
d1
[
0
]).
setDoubleProperty
(
"d1y"
,
d1
[
1
]).
setDoubleProperty
(
"d1z"
,
d1
[
2
])
.
setDoubleProperty
(
"d0x"
,
d0
[
0
]).
setDoubleProperty
(
"d0y"
,
d0
[
1
]).
setDoubleProperty
(
"d0z"
,
d0
[
2
]);
}
}
}
void
*
ATMForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
void
*
ATMForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
...
@@ -80,6 +87,10 @@ void* ATMForceProxy::deserialize(const SerializationNode& node) const {
...
@@ -80,6 +87,10 @@ void* ATMForceProxy::deserialize(const SerializationNode& node) const {
const
SerializationNode
&
forces
=
node
.
getChildNode
(
"Forces"
);
const
SerializationNode
&
forces
=
node
.
getChildNode
(
"Forces"
);
for
(
auto
&
f
:
forces
.
getChildren
())
for
(
auto
&
f
:
forces
.
getChildren
())
force
->
addForce
(
f
.
getChildren
()[
0
].
decodeObject
<
Force
>
());
force
->
addForce
(
f
.
getChildren
()[
0
].
decodeObject
<
Force
>
());
const
SerializationNode
&
particles
=
node
.
getChildNode
(
"Particles"
);
for
(
auto
&
p
:
particles
.
getChildren
())
force
->
addParticle
(
Vec3
(
p
.
getDoubleProperty
(
"d1x"
),
p
.
getDoubleProperty
(
"d1y"
),
p
.
getDoubleProperty
(
"d1z"
)),
Vec3
(
p
.
getDoubleProperty
(
"d0x"
),
p
.
getDoubleProperty
(
"d0y"
),
p
.
getDoubleProperty
(
"d0z"
)));
return
force
;
return
force
;
}
}
catch
(...)
{
catch
(...)
{
...
...
serialization/tests/TestSerializeATMForce.cpp
View file @
2ab3b77d
...
@@ -55,6 +55,8 @@ void testSerialization() {
...
@@ -55,6 +55,8 @@ void testSerialization() {
HarmonicAngleForce
*
v2
=
new
HarmonicAngleForce
();
HarmonicAngleForce
*
v2
=
new
HarmonicAngleForce
();
v2
->
addAngle
(
3
,
11
,
15
,
0.4
,
0.2
);
v2
->
addAngle
(
3
,
11
,
15
,
0.4
,
0.2
);
force
.
addForce
(
v2
);
force
.
addForce
(
v2
);
force
.
addParticle
(
Vec3
(
1
,
2
,
3
));
force
.
addParticle
(
Vec3
(
0
,
0
,
-
1
),
Vec3
(
3
,
2
,
1
));
// Serialize and then deserialize it.
// Serialize and then deserialize it.
...
@@ -83,6 +85,14 @@ void testSerialization() {
...
@@ -83,6 +85,14 @@ void testSerialization() {
XmlSerializer
::
serialize
<
Force
>
(
&
force2
.
getForce
(
i
),
"Force"
,
buffer2
);
XmlSerializer
::
serialize
<
Force
>
(
&
force2
.
getForce
(
i
),
"Force"
,
buffer2
);
ASSERT_EQUAL
(
buffer1
.
str
(),
buffer2
.
str
());
ASSERT_EQUAL
(
buffer1
.
str
(),
buffer2
.
str
());
}
}
ASSERT_EQUAL
(
force
.
getNumParticles
(),
force2
.
getNumParticles
());
for
(
int
i
=
0
;
i
<
force
.
getNumParticles
();
i
++
)
{
Vec3
d1a
,
d1b
,
d0a
,
d0b
;
force
.
getParticleParameters
(
i
,
d1a
,
d0a
);
force2
.
getParticleParameters
(
i
,
d1b
,
d0b
);
ASSERT_EQUAL_VEC
(
d1a
,
d1b
,
0.0
);
ASSERT_EQUAL_VEC
(
d0a
,
d0b
,
0.0
);
}
}
}
int
main
()
{
int
main
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment