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
0ee983bc
Unverified
Commit
0ee983bc
authored
Mar 05, 2019
by
peastman
Committed by
GitHub
Mar 05, 2019
Browse files
Merge pull request #2279 from peastman/ccma
Optimized building constraint matrix
parents
cc5ecb7c
f24a84f8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
platforms/reference/src/SimTKReference/ReferenceCCMAAlgorithm.cpp
...s/reference/src/SimTKReference/ReferenceCCMAAlgorithm.cpp
+16
-8
No files found.
platforms/reference/src/SimTKReference/ReferenceCCMAAlgorithm.cpp
View file @
0ee983bc
/* Portions copyright (c) 2006-201
7
Stanford University and Simbios.
/* Portions copyright (c) 2006-201
9
Stanford University and Simbios.
* Contributors: Peter Eastman, Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -33,6 +33,7 @@
#include "openmm/Vec3.h"
#include "openmm/internal/ThreadPool.h"
#include <map>
#include <set>
#include <utility>
using
namespace
OpenMM
;
...
...
@@ -69,19 +70,26 @@ ReferenceCCMAAlgorithm::ReferenceCCMAAlgorithm(int numberOfAtoms,
for
(
int
i
=
0
;
i
<
(
int
)
angles
.
size
();
i
++
)
atomAngles
[
angles
[
i
].
atom2
].
push_back
(
i
);
vector
<
vector
<
pair
<
int
,
double
>
>
>
matrix
(
numberOfConstraints
);
vector
<
set
<
int
>
>
atomConstraints
(
numberOfAtoms
);
for
(
int
j
=
0
;
j
<
numberOfConstraints
;
j
++
)
{
for
(
int
k
=
0
;
k
<
numberOfConstraints
;
k
++
)
{
atomConstraints
[
_atomIndices
[
j
].
first
].
insert
(
j
);
atomConstraints
[
_atomIndices
[
j
].
second
].
insert
(
j
);
}
for
(
int
j
=
0
;
j
<
numberOfConstraints
;
j
++
)
{
int
atomj0
=
_atomIndices
[
j
].
first
;
int
atomj1
=
_atomIndices
[
j
].
second
;
double
invMass0
=
1
/
masses
[
atomj0
];
double
invMass1
=
1
/
masses
[
atomj1
];
set
<
int
>
constraints
=
atomConstraints
[
atomj0
];
constraints
.
insert
(
atomConstraints
[
atomj1
].
begin
(),
atomConstraints
[
atomj1
].
end
());
for
(
int
k
:
constraints
)
{
if
(
j
==
k
)
{
matrix
[
j
].
push_back
(
pair
<
int
,
double
>
(
j
,
1.0
));
continue
;
}
double
scale
;
int
atomj0
=
_atomIndices
[
j
].
first
;
int
atomj1
=
_atomIndices
[
j
].
second
;
int
atomk0
=
_atomIndices
[
k
].
first
;
int
atomk1
=
_atomIndices
[
k
].
second
;
double
invMass0
=
1
/
masses
[
atomj0
];
double
invMass1
=
1
/
masses
[
atomj1
];
int
atoma
,
atomb
,
atomc
;
if
(
atomj0
==
atomk0
)
{
atoma
=
atomj1
;
...
...
@@ -113,8 +121,8 @@ ReferenceCCMAAlgorithm::ReferenceCCMAAlgorithm(int numberOfAtoms,
// Look for a third constraint forming a triangle with these two.
bool
foundConstraint
=
false
;
for
(
int
other
=
0
;
other
<
numberOf
Constraints
;
other
++
)
{
if
(
(
_atomIndices
[
other
].
first
==
atom
a
&&
_atomIndices
[
other
].
second
==
atomc
)
||
(
_atomIndices
[
other
].
first
==
atomc
&&
_atomIndices
[
other
].
second
==
atom
a
)
)
{
for
(
int
other
:
atom
Constraints
[
atoma
]
)
{
if
(
_atomIndices
[
other
].
first
==
atom
c
||
_atomIndices
[
other
].
second
==
atom
c
)
{
double
d1
=
_distance
[
j
];
double
d2
=
_distance
[
k
];
double
d3
=
_distance
[
other
];
...
...
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