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
50090f90
Commit
50090f90
authored
Aug 08, 2008
by
Mark Friedrichs
Browse files
Base class for bonded/nonbonded classes
parent
4d5051b6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
541 additions
and
0 deletions
+541
-0
platforms/brook/src/BrookCommon.cpp
platforms/brook/src/BrookCommon.cpp
+323
-0
platforms/brook/src/BrookCommon.h
platforms/brook/src/BrookCommon.h
+218
-0
No files found.
platforms/brook/src/BrookCommon.cpp
0 → 100644
View file @
50090f90
/* -------------------------------------------------------------------------- *
* 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: Mark Friedrichs *
* 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 <math.h>
#include <sstream>
#include "BrookCommon.h"
#include "BrookPlatform.h"
#include "BrookStreamFactory.h"
#include "OpenMMException.h"
using
namespace
OpenMM
;
using
namespace
std
;
/**
* Constructor
*
*/
BrookCommon
::
BrookCommon
(
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::BrookCommon";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
_numberOfAtoms
=
0
;
_atomSizeModified
=
0
;
_atomStreamWidth
=
-
1
;
_atomStreamHeight
=
-
1
;
_atomStreamSize
=
-
1
;
_log
=
NULL
;
}
/**
* Destructor
*
*/
BrookCommon
::~
BrookCommon
(
){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookCommon::~BrookCommon";
//static const int debug = 1;
// ---------------------------------------------------------------------------------------
}
/**
* Get number of atoms
*
* @return number of atoms
*
*/
int
BrookCommon
::
getNumberOfAtoms
(
void
)
const
{
return
_numberOfAtoms
;
}
/**
* Get number of atoms
*
* @param numberOfAtoms number of atoms
* @return number of atoms
*
*/
int
BrookCommon
::
setNumberOfAtoms
(
int
numberOfAtoms
){
if
(
numberOfAtoms
!=
_numberOfAtoms
){
_atomSizeModified
=
numberOfAtoms
;
}
_numberOfAtoms
=
numberOfAtoms
;
return
_numberOfAtoms
;
}
/**
* Get atom stream width
*
* @param platform platform
*
* @return atom stream width
*
*/
int
BrookCommon
::
getAtomStreamWidth
(
const
Platform
&
platform
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::getAtomStreamWidth";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
// get atom stream width
if
(
_atomStreamWidth
<
0
){
_getAtomStreamDimensions
(
platform
);
}
return
_atomStreamWidth
;
}
/**
* Get atom stream width
*
* @return atom stream width
*
*/
int
BrookCommon
::
getAtomStreamWidth
(
void
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::getAtomStreamWidth";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
return
_atomStreamWidth
;
}
/**
* Get atom stream height
*
* @param platform platform
*
* @return atom stream height
*
*/
int
BrookCommon
::
getAtomStreamHeight
(
const
Platform
&
platform
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::getAtomStreamHeight";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
// get atom stream height
if
(
_atomStreamHeight
<
0
){
_getAtomStreamDimensions
(
platform
);
}
return
_atomStreamHeight
;
}
/**
* Get atom stream height
*
* @return atom stream height
*
*/
int
BrookCommon
::
getAtomStreamHeight
(
void
)
const
{
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::getAtomStreamHeight";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
return
_atomStreamHeight
;
}
/**
* Get atom stream size
*
* @param platform platform
*
* @return atom stream size
*
*/
int
BrookCommon
::
getAtomStreamSize
(
const
Platform
&
platform
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::getAtomStreamSize";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
// get atom stream size
if
(
_atomStreamSize
<
0
){
_getAtomStreamDimensions
(
platform
);
}
return
_atomStreamSize
;
}
/**
* Get atom stream size
*
* @return atom stream size
*
*/
int
BrookCommon
::
getAtomStreamSize
(
void
)
const
{
return
_atomStreamSize
;
}
/**
* Get atom stream dimensions
*
* @param platform platform
*
*/
void
BrookCommon
::
_getAtomStreamDimensions
(
const
Platform
&
platform
){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "BrookCommon::_getAtomStreamDimensions";
// static const int debug = 1;
// ---------------------------------------------------------------------------------------
// get atom stream size
const
BrookPlatform
brookPlatform
=
dynamic_cast
<
const
BrookPlatform
&>
(
platform
);
const
BrookStreamFactory
&
brookStreamFactory
=
dynamic_cast
<
const
BrookStreamFactory
&>
(
platform
.
getDefaultStreamFactory
()
);
BrookStreamInfo
*
brookStreamInfo
=
brookStreamFactory
.
getBrookStreamInfo
(
BrookStreamFactory
::
AtomPositions
);
_atomStreamWidth
=
brookStreamInfo
->
getStreamWidth
();
_atomStreamSize
=
brookPlatform
.
getStreamSize
(
getNumberOfAtoms
(),
_atomStreamWidth
,
NULL
);
_atomStreamHeight
=
(
int
)
(
((
float
)
_atomStreamSize
)
/
(
(
float
)
_atomStreamWidth
)
+
0.001
);
return
;
}
/**
* Get log file reference
*
* @return log file reference
*
*/
FILE
*
BrookCommon
::
getLog
(
void
)
const
{
return
_log
;
}
/**
* Set log file reference
*
* @param log file reference
*
* @return DefaultReturnValue
*
*/
int
BrookCommon
::
setLog
(
FILE
*
log
){
_log
=
log
;
return
BrookCommon
::
DefaultReturnValue
;
}
/*
* Get contents of object
*
* @param tab tab
* @param description description
* @param value value
*
* @return string containing contents
*
* */
std
::
string
BrookCommon
::
_getLine
(
const
std
::
string
&
tab
,
const
std
::
string
&
description
,
const
std
::
string
&
value
)
const
{
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"BrookCommon::_getLine"
;
static
const
unsigned
int
MAX_LINE_CHARS
=
256
;
char
line
[
MAX_LINE_CHARS
];
// ---------------------------------------------------------------------------------------
std
::
stringstream
message
;
memset
(
line
,
' '
,
MAX_LINE_CHARS
);
#ifdef WIN32
(
void
)
sprintf_s
(
line
,
MAX_LINE_CHARS
,
"%s %-40s %s"
,
tab
.
c_str
(),
description
.
c_str
(),
value
.
c_str
()
);
#else
(
void
)
sprintf
(
line
,
"%s %-40s %s"
,
tab
.
c_str
(),
description
.
c_str
(),
value
.
c_str
()
);
#endif
message
<<
std
::
string
(
line
)
<<
std
::
endl
;
return
message
.
str
();
}
platforms/brook/src/BrookCommon.h
0 → 100644
View file @
50090f90
#ifndef BrookCommon_H_
#define BrookCommon_H_
/* -------------------------------------------------------------------------- *
* 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, Mark Friedrichs *
* 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 <vector>
#include <set>
#include "BrookFloatStreamImpl.h"
#include "BrookIntStreamImpl.h"
#include "BrookPlatform.h"
namespace
OpenMM
{
/**
* This kernel is invoked by StandardMMForceField to calculate the forces acting on the system.
*/
class
BrookCommon
{
public:
// return values
static
const
int
DefaultReturnValue
=
0
;
static
const
int
ErrorReturnValue
=
-
1
;
BrookCommon
(
);
~
BrookCommon
();
/**
* Return number of atoms
*
* @return number of atoms
*
*/
int
getNumberOfAtoms
(
void
)
const
;
/**
* Get atom ceiling parameter
*
* @return atom ceiling parameter
*
*/
int
getAtomSizeCeiling
(
void
)
const
;
/**
* Get atom stream width
*
* @param platform platform reference
*
* @return atom stream width
*/
int
getAtomStreamWidth
(
const
Platform
&
platform
);
/**
* Get atom stream width
*
* @return atom stream width
*/
int
getAtomStreamWidth
(
void
)
const
;
/**
* Get atom stream height
*
* @param platform platform reference
*
* @return atom stream height
*/
int
getAtomStreamHeight
(
const
Platform
&
platform
);
/**
* Get atom stream height
*
* @return atom stream height
*/
int
getAtomStreamHeight
(
void
)
const
;
/**
* Get atom stream size
*
* @param platform platform reference
*
* @return atom stream size
*/
int
getAtomStreamSize
(
const
Platform
&
platform
);
/**
* Get atom stream size
*
* @return atom stream size
*/
int
getAtomStreamSize
(
void
)
const
;
/**
* Set log file reference
*
* @param log file reference
*
* @return DefaultReturnValue
*
*/
int
setLog
(
FILE
*
log
);
/*
* Get contents of object
*
* @param level of dump
*
* @return string containing contents
*
* */
std
::
string
getContents
(
int
level
)
const
;
protected:
// number of atoms
int
_numberOfAtoms
;
// atom stream dimensions
int
_atomStreamWidth
;
int
_atomStreamHeight
;
int
_atomStreamSize
;
// atom size mod
int
_atomSizeModified
;
// log file reference
FILE
*
_log
;
/**
* Set number of atoms
*
* @param numberOfAtoms number of atoms
*
*/
int
setNumberOfAtoms
(
int
numberOfAtoms
);
/**
* Get atom stream dimensions
*
* @param platform platform
*
*/
void
_getAtomStreamDimensions
(
const
Platform
&
platform
);
/**
* Get log file reference
*
* @return log file reference
*
*/
FILE
*
getLog
(
void
)
const
;
/*
* Get line
*
* @param tab tab
* @param description description
* @param value value
*
* @return string containing contents
*
* */
std
::
string
_getLine
(
const
std
::
string
&
tab
,
const
std
::
string
&
description
,
const
std
::
string
&
value
)
const
;
};
}
// namespace OpenMM
#endif
/*OPENMM_BROOKKERNELS_H_*/
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