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
f24a84f8
Commit
f24a84f8
authored
Mar 05, 2019
by
peastman
Browse files
Optimized building constraint matrix
parent
8ce5a685
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 @
f24a84f8
/* 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
* Contributors: Peter Eastman, Pande Group
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* Permission is hereby granted, free of charge, to any person obtaining
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include "openmm/Vec3.h"
#include "openmm/Vec3.h"
#include "openmm/internal/ThreadPool.h"
#include "openmm/internal/ThreadPool.h"
#include <map>
#include <map>
#include <set>
#include <utility>
#include <utility>
using
namespace
OpenMM
;
using
namespace
OpenMM
;
...
@@ -69,19 +70,26 @@ ReferenceCCMAAlgorithm::ReferenceCCMAAlgorithm(int numberOfAtoms,
...
@@ -69,19 +70,26 @@ ReferenceCCMAAlgorithm::ReferenceCCMAAlgorithm(int numberOfAtoms,
for
(
int
i
=
0
;
i
<
(
int
)
angles
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
angles
.
size
();
i
++
)
atomAngles
[
angles
[
i
].
atom2
].
push_back
(
i
);
atomAngles
[
angles
[
i
].
atom2
].
push_back
(
i
);
vector
<
vector
<
pair
<
int
,
double
>
>
>
matrix
(
numberOfConstraints
);
vector
<
vector
<
pair
<
int
,
double
>
>
>
matrix
(
numberOfConstraints
);
vector
<
set
<
int
>
>
atomConstraints
(
numberOfAtoms
);
for
(
int
j
=
0
;
j
<
numberOfConstraints
;
j
++
)
{
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
)
{
if
(
j
==
k
)
{
matrix
[
j
].
push_back
(
pair
<
int
,
double
>
(
j
,
1.0
));
matrix
[
j
].
push_back
(
pair
<
int
,
double
>
(
j
,
1.0
));
continue
;
continue
;
}
}
double
scale
;
double
scale
;
int
atomj0
=
_atomIndices
[
j
].
first
;
int
atomj1
=
_atomIndices
[
j
].
second
;
int
atomk0
=
_atomIndices
[
k
].
first
;
int
atomk0
=
_atomIndices
[
k
].
first
;
int
atomk1
=
_atomIndices
[
k
].
second
;
int
atomk1
=
_atomIndices
[
k
].
second
;
double
invMass0
=
1
/
masses
[
atomj0
];
double
invMass1
=
1
/
masses
[
atomj1
];
int
atoma
,
atomb
,
atomc
;
int
atoma
,
atomb
,
atomc
;
if
(
atomj0
==
atomk0
)
{
if
(
atomj0
==
atomk0
)
{
atoma
=
atomj1
;
atoma
=
atomj1
;
...
@@ -113,8 +121,8 @@ ReferenceCCMAAlgorithm::ReferenceCCMAAlgorithm(int numberOfAtoms,
...
@@ -113,8 +121,8 @@ ReferenceCCMAAlgorithm::ReferenceCCMAAlgorithm(int numberOfAtoms,
// Look for a third constraint forming a triangle with these two.
// Look for a third constraint forming a triangle with these two.
bool
foundConstraint
=
false
;
bool
foundConstraint
=
false
;
for
(
int
other
=
0
;
other
<
numberOf
Constraints
;
other
++
)
{
for
(
int
other
:
atom
Constraints
[
atoma
]
)
{
if
(
(
_atomIndices
[
other
].
first
==
atom
a
&&
_atomIndices
[
other
].
second
==
atomc
)
||
(
_atomIndices
[
other
].
first
==
atomc
&&
_atomIndices
[
other
].
second
==
atom
a
)
)
{
if
(
_atomIndices
[
other
].
first
==
atom
c
||
_atomIndices
[
other
].
second
==
atom
c
)
{
double
d1
=
_distance
[
j
];
double
d1
=
_distance
[
j
];
double
d2
=
_distance
[
k
];
double
d2
=
_distance
[
k
];
double
d3
=
_distance
[
other
];
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