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
f5aebbd4
Commit
f5aebbd4
authored
Sep 22, 2009
by
Peter Eastman
Browse files
Eliminated Stream and related classes, replacing their functionality with UpdateStateDataKernel.
parent
21d67074
Changes
64
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
176 additions
and
115 deletions
+176
-115
platforms/reference/src/ReferenceKernels.cpp
platforms/reference/src/ReferenceKernels.cpp
+112
-49
platforms/reference/src/ReferenceKernels.h
platforms/reference/src/ReferenceKernels.h
+34
-3
platforms/reference/src/ReferencePlatform.cpp
platforms/reference/src/ReferencePlatform.cpp
+30
-6
platforms/reference/src/ReferenceStreamFactory.cpp
platforms/reference/src/ReferenceStreamFactory.cpp
+0
-57
No files found.
platforms/reference/src/ReferenceKernels.cpp
View file @
f5aebbd4
This diff is collapsed.
Click to expand it.
platforms/reference/src/ReferenceKernels.h
View file @
f5aebbd4
...
...
@@ -99,11 +99,12 @@ public:
};
/**
* This kernel is invoked to get or set the current time.
* This kernel provides methods for setting and retrieving various state data: time, positions,
* velocities, and forces.
*/
class
ReferenceUpdate
Time
Kernel
:
public
Update
Time
Kernel
{
class
ReferenceUpdate
StateData
Kernel
:
public
Update
StateData
Kernel
{
public:
ReferenceUpdate
Time
Kernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
Update
Time
Kernel
(
name
,
platform
),
data
(
data
)
{
ReferenceUpdate
StateData
Kernel
(
std
::
string
name
,
const
Platform
&
platform
,
ReferencePlatform
::
PlatformData
&
data
)
:
Update
StateData
Kernel
(
name
,
platform
),
data
(
data
)
{
}
/**
* Initialize the kernel.
...
...
@@ -123,6 +124,36 @@ public:
* @param context the context in which to execute this kernel
*/
void
setTime
(
ContextImpl
&
context
,
double
time
);
/**
* Get the positions of all particles.
*
* @param positions on exit, this contains the particle positions
*/
void
getPositions
(
ContextImpl
&
context
,
std
::
vector
<
Vec3
>&
positions
);
/**
* Set the positions of all particles.
*
* @param positions a vector containg the particle positions
*/
void
setPositions
(
ContextImpl
&
context
,
const
std
::
vector
<
Vec3
>&
positions
);
/**
* Get the velocities of all particles.
*
* @param velocities on exit, this contains the particle velocities
*/
void
getVelocities
(
ContextImpl
&
context
,
std
::
vector
<
Vec3
>&
velocities
);
/**
* Set the velocities of all particles.
*
* @param velocities a vector containg the particle velocities
*/
void
setVelocities
(
ContextImpl
&
context
,
const
std
::
vector
<
Vec3
>&
velocities
);
/**
* Get the current forces on all particles.
*
* @param forces on exit, this contains the forces
*/
void
getForces
(
ContextImpl
&
context
,
std
::
vector
<
Vec3
>&
forces
);
private:
ReferencePlatform
::
PlatformData
&
data
;
};
...
...
platforms/reference/src/ReferencePlatform.cpp
View file @
f5aebbd4
...
...
@@ -40,7 +40,7 @@ using namespace OpenMM;
ReferencePlatform
::
ReferencePlatform
()
{
ReferenceKernelFactory
*
factory
=
new
ReferenceKernelFactory
();
registerKernelFactory
(
CalcForcesAndEnergyKernel
::
Name
(),
factory
);
registerKernelFactory
(
Update
Time
Kernel
::
Name
(),
factory
);
registerKernelFactory
(
Update
StateData
Kernel
::
Name
(),
factory
);
registerKernelFactory
(
CalcHarmonicBondForceKernel
::
Name
(),
factory
);
registerKernelFactory
(
CalcHarmonicAngleForceKernel
::
Name
(),
factory
);
registerKernelFactory
(
CalcPeriodicTorsionForceKernel
::
Name
(),
factory
);
...
...
@@ -63,15 +63,39 @@ bool ReferencePlatform::supportsDoublePrecision() const {
return
(
sizeof
(
RealOpenMM
)
>=
sizeof
(
double
));
}
const
StreamFactory
&
ReferencePlatform
::
getDefaultStreamFactory
()
const
{
return
defaultStreamFactory
;
}
void
ReferencePlatform
::
contextCreated
(
ContextImpl
&
context
)
const
{
context
.
setPlatformData
(
new
PlatformData
());
context
.
setPlatformData
(
new
PlatformData
(
context
.
getSystem
().
getNumParticles
()
));
}
void
ReferencePlatform
::
contextDestroyed
(
ContextImpl
&
context
)
const
{
PlatformData
*
data
=
reinterpret_cast
<
PlatformData
*>
(
context
.
getPlatformData
());
delete
data
;
}
ReferencePlatform
::
PlatformData
::
PlatformData
(
int
numParticles
)
:
time
(
0.0
),
stepCount
(
0
),
numParticles
(
numParticles
)
{
RealOpenMM
**
positions
=
new
RealOpenMM
*
[
numParticles
];
RealOpenMM
**
velocities
=
new
RealOpenMM
*
[
numParticles
];
RealOpenMM
**
forces
=
new
RealOpenMM
*
[
numParticles
];
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
positions
[
i
]
=
new
RealOpenMM
[
3
];
velocities
[
i
]
=
new
RealOpenMM
[
3
];
forces
[
i
]
=
new
RealOpenMM
[
3
];
}
this
->
positions
=
positions
;
this
->
velocities
=
velocities
;
this
->
forces
=
forces
;
}
ReferencePlatform
::
PlatformData
::~
PlatformData
()
{
RealOpenMM
**
positions
=
(
RealOpenMM
**
)
this
->
positions
;
RealOpenMM
**
velocities
=
(
RealOpenMM
**
)
this
->
velocities
;
RealOpenMM
**
forces
=
(
RealOpenMM
**
)
this
->
forces
;
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
delete
[]
positions
[
i
];
delete
[]
velocities
[
i
];
delete
[]
forces
[
i
];
}
delete
[]
positions
;
delete
[]
velocities
;
delete
[]
forces
;
}
platforms/reference/src/ReferenceStreamFactory.cpp
deleted
100644 → 0
View file @
21d67074
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/OpenMMException.h"
#include "ReferenceStreamFactory.h"
#include "ReferenceFloatStreamImpl.h"
#include "ReferenceIntStreamImpl.h"
using
namespace
OpenMM
;
StreamImpl
*
ReferenceStreamFactory
::
createStreamImpl
(
std
::
string
name
,
int
size
,
Stream
::
DataType
type
,
const
Platform
&
platform
,
ContextImpl
&
context
)
const
{
switch
(
type
)
{
case
Stream
::
Float
:
case
Stream
::
Float2
:
case
Stream
::
Float3
:
case
Stream
::
Float4
:
case
Stream
::
Double
:
case
Stream
::
Double2
:
case
Stream
::
Double3
:
case
Stream
::
Double4
:
return
new
ReferenceFloatStreamImpl
(
name
,
size
,
type
,
platform
);
case
Stream
::
Integer
:
case
Stream
::
Integer2
:
case
Stream
::
Integer3
:
case
Stream
::
Integer4
:
return
new
ReferenceIntStreamImpl
(
name
,
size
,
type
,
platform
);
}
throw
OpenMMException
(
"Tried to create a Stream with an illegal DataType."
);
}
Prev
1
2
3
4
Next
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