Commit 51475608 authored by Peter Eastman's avatar Peter Eastman
Browse files

Deleted lots of obsolete code

parent 398f0609
......@@ -137,11 +137,6 @@ class ReferenceShakeConstraint : public ReferenceConstraint {
int getLightAtomIndex( void );
};
typedef std::vector<ReferenceShakeConstraint*> ShakeVector;
typedef ShakeVector::iterator ShakeVectorI;
typedef std::map<int, ShakeVector*> IntShakeMap;
typedef IntShakeMap::iterator IntShakeMapI;
// ---------------------------------------------------------------------------------------
#endif // __ReferenceShakeConstraint_H__
......@@ -36,15 +36,3 @@ const int SimTKOpenMMCommon::DefaultReturn = 0;
const int SimTKOpenMMCommon::ErrorReturn = -1;
const RealOpenMM SimTKOpenMMCommon::BigCutoffValue = 1.0e+05;
// units
const int SimTKOpenMMCommon::MdUnits = 1;
const int SimTKOpenMMCommon::KcalAngUnits = 2;
// specify RealOpenMM number format
const int SimTKOpenMMCommon::HighStringStreamNumberWidth = 20;
const int SimTKOpenMMCommon::HighStringStreamNumberPrecision = 12;
const RealOpenMM SimTKOpenMMCommon::DegreeToRadians = (RealOpenMM) 0.017453292;
......@@ -30,76 +30,18 @@
// STL includes
#include <vector>
#include <map>
#include <set>
#include <string>
// generic c includes
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <assert.h>
// ---------------------------------------------------------------------------------------
#include "RealVec.h"
#include "SimTKOpenMMWindowLinux.h"
// ---------------------------------------------------------------------------------------
typedef std::vector<int> IntVector;
typedef IntVector::iterator IntVectorI;
typedef IntVector::const_iterator IntVectorCI;
typedef IntVector::reverse_iterator IntVectorRI;
typedef IntVector::const_reverse_iterator IntVectorCRI;
typedef std::map<int, int> IntIntMap;
typedef IntIntMap::iterator IntIntMapI;
typedef IntIntMap::const_iterator IntIntMapCI;
typedef std::set<int> IntSet;
typedef IntSet::iterator IntSetI;
typedef IntSet::const_iterator IntSetCI;
typedef std::vector<IntSet> IntSetVector;
typedef IntSetVector::iterator IntSetVectorI;
typedef IntSetVector::const_iterator IntSetVectorCI;
typedef std::multiset<int> IntMultiSet;
typedef IntMultiSet::iterator IntMultiSetI;
typedef IntMultiSet::const_iterator IntMultiSetCI;
typedef std::vector<std::string> StringVector;
typedef StringVector::iterator StringVectorI;
typedef StringVector::const_iterator StringVectorCI;
typedef std::map<std::string, std::string> StringStringMap;
typedef StringStringMap::iterator StringStringMapI;
typedef StringStringMap::const_iterator StringStringMapCI;
typedef std::vector<RealOpenMM> RealOpenMMVector;
typedef RealOpenMMVector::iterator RealOpenMMVectorI;
typedef RealOpenMMVector::const_iterator RealOpenMMVectorCI;
typedef std::vector<RealOpenMM*> RealOpenMMPtrVector;
typedef RealOpenMMPtrVector::iterator RealOpenMMPtrVectorI;
typedef RealOpenMMPtrVector::const_iterator RealOpenMMPtrVectorCI;
typedef std::vector<RealOpenMM**> RealOpenMMPtrPtrVector;
typedef RealOpenMMPtrPtrVector::iterator RealOpenMMPtrPtrVectorI;
typedef RealOpenMMPtrPtrVector::const_iterator RealOpenMMPtrPtrVectorCI;
typedef std::map<std::string, RealOpenMM> StringRealOpenMMMap;
typedef StringRealOpenMMMap::iterator StringRealOpenMMMapI;
typedef StringRealOpenMMMap::const_iterator StringRealOpenMMMapCI;
typedef std::map<std::string, int> StringIntMap;
typedef StringIntMap::iterator StringIntMapI;
typedef StringIntMap::const_iterator StringIntMapCI;
// ---------------------------------------------------------------------------------------
class SimTKOpenMMCommon {
......@@ -118,83 +60,6 @@ class SimTKOpenMMCommon {
static const int DefaultReturn;
static const int ErrorReturn;
// units
static const int MdUnits;
static const int KcalAngUnits;
// specify RealOpenMM number format
static const int HighStringStreamNumberWidth;
static const int HighStringStreamNumberPrecision;
static const RealOpenMM DegreeToRadians;
/**---------------------------------------------------------------------------------------
Get string w/ minimum desired width
@param inputString input string
@param desiredSize minimum desired size of output string
@param spacer string to append to inputString to get desired width (" ")
@return DefaultReturn
--------------------------------------------------------------------------------------- */
static std::string getSpacedString( const std::string&, int desiredSize = 25,
const std::string& spacer = " " );
};
// ---------------------------------------------------------------------------------------
// StringComparisonForMap: used to compare strings in STL maps w/ strings as keys
#ifndef StringComparisonForMapPtrBlcok
#define StringComparisonForMapPtrBlcok
// above define should be removed once CommonTk is removed
class StringComparisonForMapPtr : public std::binary_function< std::string*, std::string*, bool > {
public:
bool operator()( const std::string* str1, const std::string* str2 ) const {
return strcmp( str1->c_str(), str2->c_str() ) < 0;
}
};
class StringComparisonForMap : public std::binary_function< const std::string&, const std::string&, bool > {
public:
bool operator()( const std::string& str1, const std::string& str2 ) const {
return strcmp( str1.c_str(), str2.c_str() ) < 0;
}
};
#endif
// ---------------------------------------------------------------------------------------
// Used to compare integers for sorting, ...
int numericCompareI( const void* point1, const void* point2 );
// ---------------------------------------------------------------------------------------
// string-string map and iterator definitions
typedef std::map<std::string, std::string, StringComparisonForMap> StringMap;
typedef StringMap::iterator StringMapI;
typedef StringMap::const_iterator StringMapCI;
// string set and iterator definitions
typedef std::set<std::string, StringComparisonForMap> StringSet;
typedef StringSet::iterator StringSetI;
typedef StringSet::const_iterator StringSetCI;
// ---------------------------------------------------------------------------------------
#endif // __SimTKOpenMMCommon_H__
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* 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.
*/
// class of shared, static utility methods
#include "SimTKOpenMMGpuUtilities.h"
#include "SimTKOpenMMUtilities.h"
// fabs(), ...
#include <math.h>
//#define UseGromacsMalloc 1
//#ifdef UseGromacsMalloc
//extern "C" {
//#include "smalloc.h"
//}
//#endif
/* ---------------------------------------------------------------------------------------
Helper method to repack RealOpenMM arrays (Simbios)
@param numberOfEntries entries/sub-array
@param subarraySize number of subarrays
@param array array
Input: array = [subArray_1 subArray_2 subArray_3 ... subArray_Stacked]
where each subArray_i is 1 x numberOfEntries
Output: array = [ subArray_1_1 subArray_2_1 subArray_3_1 ... subArray_Stacked_1
subArray_1_2 subArray_2_2 subArray_3_2 ... subArray_Stacked_2
subArray_1_3 subArray_2_3 subArray_3_3 ... subArray_Stacked_3
...
subArray_1_N subArray_2_N subArray_3_N ... subArray_Stacked_N ]
where N = numberOfEntries
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMGpuUtilities::repackArray1( int numberOfEntries, int subarraySize,
RealOpenMM* array ){
// ---------------------------------------------------------------------------------------
RealOpenMM* tempArray;
// static const char* methodName = "\nSimTKOpenMMGpuUtilities::rePackArray";
// ---------------------------------------------------------------------------------------
unsigned int sizeOfArray = sizeof( RealOpenMM )*numberOfEntries*subarraySize;
tempArray = (RealOpenMM*) SimTKOpenMMUtilities::Xmalloc( "tempArray",
__FILE__, __LINE__,
sizeOfArray );
memcpy( tempArray, array, sizeOfArray );
int arrayIndex = 0;
for( int jj = 0; jj < subarraySize; jj++ ){
for( int ii = 0; ii < numberOfEntries; ii++ ){
array[arrayIndex++] = tempArray[jj*numberOfEntries+ii];
}
}
SimTKOpenMMUtilities::Xfree( "tempArray", __FILE__, __LINE__, tempArray );
return SimTKOpenMMCommon::DefaultReturn;
}
/* ---------------------------------------------------------------------------------------
Copy an array into a packed (e.g., RealOpenMM4 array) (Simbios)
Example: copy Born radii into last slot of force array \n
@param numberOfEntries entries/sub-array (no. atoms)
@param subarraySize number of subarrays (4 for RealOpenMM4)
@param fullArray full array (force array in example)
@param copySlot index of slot to copied into (3 in example, since want Born radius in .w slot)
@param arrayToCopy array to copy (Born array)
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMGpuUtilities::copySubArray( int numberOfEntries, int subarraySize, RealOpenMM* fullArray,
int copySlot, RealOpenMM* arrayToCopy ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nSimTKOpenMMGpuUtilities::copySubArray";
// ---------------------------------------------------------------------------------------
int arrayIndex = copySlot;
for( int ii = 0; ii < numberOfEntries; ii++ ){
fullArray[arrayIndex] = arrayToCopy[ii];
arrayIndex += subarraySize;
}
return SimTKOpenMMCommon::DefaultReturn;
}
/* ---------------------------------------------------------------------------------------
Helper method to repack RealOpenMM arrays (Simbios)
@param numberOfEntries entries/sub-array
@param subarraySize number of subarrays
@param array array
Input: array = [subArray_1 subArray_2 subArray_3 ... subArray_N] \n
where each subArray_i is vector of length M=numberOfEntries \n
Output: array = [ subArray_1_1 subArray_2_1 subArray_3_1 ... subArray_N_1 \n
subArray_1_2 subArray_2_2 subArray_3_2 ... subArray_N_2 \n
subArray_1_3 subArray_2_3 subArray_3_3 ... subArray_N_3 \n
... \n
subArray_1_M subArray_2_M subArray_3_M ... subArray_M ] \n
where N = numberOfEntries \n
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMGpuUtilities::repackArray( int numberOfEntries, int subarraySize, RealOpenMM* array ){
// ---------------------------------------------------------------------------------------
RealOpenMM* tempArray;
// static const char* methodName = "\nSimTKOpenMMGpuUtilities::rePackArray";
// ---------------------------------------------------------------------------------------
unsigned int sizeOfArray = sizeof( RealOpenMM )*numberOfEntries*subarraySize;
tempArray = (RealOpenMM*) SimTKOpenMMUtilities::Xmalloc( "tempArray", __FILE__, __LINE__,
sizeOfArray );
memcpy( tempArray, array, sizeOfArray );
int arrayIndex = 0;
for( int ii = 0; ii < numberOfEntries; ii++ ){
for( int jj = 0; jj < subarraySize; jj++ ){
array[arrayIndex++] = tempArray[jj*numberOfEntries+ii];
}
}
SimTKOpenMMUtilities::Xfree( "tempArray", __FILE__, __LINE__, tempArray );
return SimTKOpenMMCommon::DefaultReturn;
}
/* ---------------------------------------------------------------------------------------
Helper method to repack RealOpenMM arrays (Simbios)
@param numberOfEntries entries/sub-array
@param subarraySize number of subarrays
@param array repacked output array
@param inputArrays inputArrays[subarraySize][numberOfEntries]
Output: array = [ inputArrays[0][0] inputArrays[1][0] inputArrays[2][0] inputArrays[3][0] \n
inputArrays[0][1] inputArrays[1][1] inputArrays[2][1] inputArrays[3][1] \n
inputArrays[0][2] inputArrays[1][2] inputArrays[2][2] inputArrays[3][2] \n
... \n
inputArrays[0][numberOfEntries] ... inputArrays[subarraySize-1][numberOfEntries] \n
] \n
where N = numberOfEntries \n
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMGpuUtilities::repackArrayOfArrays( int numberOfEntries, int subarraySize,
RealOpenMM* array, RealOpenMM** inputArrays ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nSimTKOpenMMGpuUtilities::repackArrayOfArrays";
// ---------------------------------------------------------------------------------------
unsigned int sizeOfBlock = sizeof( RealOpenMM )*numberOfEntries;
RealOpenMM* RealOpenMMPtr = array;
for( int ii = 0; ii < subarraySize; ii++ ){
memcpy( RealOpenMMPtr, inputArrays[ii], sizeOfBlock );
RealOpenMMPtr += numberOfEntries;
}
return repackArray( numberOfEntries, subarraySize, array );
}
/* ---------------------------------------------------------------------------------------
Collapse 2D array into packed single array (Simbios)
Example: forces[3][N] -> array of size N containing RealOpenMM3 values
@param numberOfEntries entries (no. atoms)
@param iUnroll iUnroll
@param jUnroll jUnroll
@param arrays arrays to be merged (dimension is [iUnroll][numberOfEntries/iUnroll]
@param mergeArray output array (if null, then allocated)
@param log logging file descriptor
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
RealOpenMM* SimTKOpenMMGpuUtilities::collapseArrays( int numberOfEntries, int iUnroll, int jUnroll,
RealOpenMM** arrays, RealOpenMM* mergeArray,
FILE* log ){
// ---------------------------------------------------------------------------------------
static const char* methodName = "\nSimTKOpenMMGpuUtilities::collapseArrays";
static bool printOn = false;
// ---------------------------------------------------------------------------------------
printOn = printOn && log != NULL;
if( mergeArray == NULL ){
unsigned int sizeOfArray = sizeof( RealOpenMM )*numberOfEntries*jUnroll;
mergeArray = (RealOpenMM*) SimTKOpenMMUtilities::Xmalloc( "mergeArray", __FILE__, __LINE__,
sizeOfArray );
}
int arrayIndex = 0;
int arrayOffset = 0;
if( printOn ){
(void) fprintf( log, "\n%s %d %d %d", methodName, numberOfEntries, iUnroll, jUnroll );
}
for( int ii = 0; ii < numberOfEntries/iUnroll; ii++ ){
for( int kk = 0; kk < iUnroll; kk++ ){
for( int jj = 0; jj < jUnroll; jj++ ){
mergeArray[arrayIndex++] = arrays[kk][arrayOffset+jj];
}
if( printOn ){
(void) fprintf( log, "\n%d %d [%.4f %.4f %.4f %.4f]", ii,kk,
arrays[kk][arrayOffset+0],
arrays[kk][arrayOffset+1],
arrays[kk][arrayOffset+2],
arrays[kk][arrayOffset+3] );
}
}
arrayOffset += jUnroll;
}
return mergeArray;
}
/* ---------------------------------------------------------------------------------------
Merge 2 arrays based on sentinel value (Simbios)
Overflow array, if present, signals which entries had nonsentinel in both arrays
Example \n
array1 = { 1, 2, 3, s, s, s, 4, 5, s } \n
array2 = { s, s, 6, 8, 9, 3, s, 7, s } \n
merge array = { 1, 2, 3, 8, 9, 3, 4, 5, s } \n
overflow array = { s, s, 6, s, s, s, s, 7, s } \n
@param numberOfEntries entries (no. atoms)
@param sentinelValue sentinel value
@param array1 first array
@param array2 second array
@param mergeArray output merge array
@param overflowArray output overflow array (if null, then ignored)
@param log logging file descriptor
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMGpuUtilities::mergeArraysBasedSentinelValue( int numberOfEntries,
RealOpenMM sentinelValue,
RealOpenMM* array1, RealOpenMM* array2,
RealOpenMM* mergeArray, RealOpenMM* overflowArray,
FILE* log ){
// ---------------------------------------------------------------------------------------
int hits[3];
RealOpenMM* arrays[4];
const RealOpenMM tolerance = (RealOpenMM) 0.00001;
// static const char* methodName = "\nSimTKOpenMMGpuUtilities::sentinelArraysBasedInitializedValue";
// ---------------------------------------------------------------------------------------
arrays[0] = array1;
arrays[1] = array2;
arrays[2] = mergeArray;
arrays[3] = overflowArray;
for( int ii = 0; ii < numberOfEntries; ii++ ){
RealOpenMM value;
RealOpenMM overflowValue = sentinelValue;
for( int jj = 0; jj < 2; jj++ ){
hits[jj] = fabs( arrays[jj][ii] - sentinelValue ) < tolerance ? 1 : 0;
}
// both missing
if( hits[0] && hits[1] ){
value = sentinelValue;
// single hit
} else if( !hits[0] && hits[1] ){
value = arrays[0][ii];
} else if( hits[0] && !hits[1] ){
value = arrays[1][ii];
} else {
// both present -- add to overflow array if available
value = arrays[0][ii];
overflowValue = arrays[1][ii];
}
arrays[2][ii] = value;
if( arrays[3] != NULL ){
arrays[3][ii] = overflowValue;
}
}
return SimTKOpenMMCommon::DefaultReturn;
}
/* ---------------------------------------------------------------------------------------
Helper method to store values from CPU loop in position seen in GPU output (Simbios)
--------------------------------------------------------------------------------------- */
int SimTKOpenMMGpuUtilities::storeInGpuFormat( int atomI, int atomJ, int debugAtomJ,
int jUnroll, int numberOfStreams,
RealOpenMM** debugStreams,
RealOpenMM* RealOpenMMValues[2],
RealOpenMM unsetDebugValue, bool useUpper,
FILE* log ){
// ---------------------------------------------------------------------------------------
int diffIndices[2][2];
// static const char* methodName = "\nSimTKOpenMMGpuUtilities::storeInGpuFormat";
// ---------------------------------------------------------------------------------------
diffIndices[0][0] = atomI - debugAtomJ;
diffIndices[0][1] = atomJ;
diffIndices[1][0] = atomJ - debugAtomJ;
diffIndices[1][1] = atomI;
for( int ii = 0; ii < 2; ii++ ){
if( diffIndices[ii][0] >= 0 && diffIndices[ii][0] < jUnroll ){
for( int jj = 0; jj < numberOfStreams; jj++ ){
RealOpenMM* RealOpenMMPtr = &(debugStreams[jj][jUnroll*diffIndices[ii][1]]);
RealOpenMMPtr += diffIndices[ii][0];
/*
if( log && atomI < 10 && atomJ < 10 ){
(void) fprintf( log, "%s i=%d j=%d dbg=%d dff=%d crnt=%.4f new=%.4f ii=%d jj=%d", methodName,
atomI, atomJ, debugAtomJ, diffIndices[ii][0], *RealOpenMMPtr,
RealOpenMMValues[jj][diffIndices[ii][0]], ii, jj );
}
*/
/*
if( fabs( *RealOpenMMPtr - unsetDebugValue ) < 1.0e-04 ||
(atomI > atomJ && useUpper) ){
*RealOpenMMPtr = RealOpenMMValues[jj][diffIndices[ii][0]];
}
*/
*RealOpenMMPtr = RealOpenMMValues[jj][diffIndices[ii][0]];
}
}
}
return SimTKOpenMMCommon::DefaultReturn;
}
/* ---------------------------------------------------------------------------------------
Helper method to compare cpu and gpu computed arrays
@param numberOfAtoms entries (no. atoms)
@param chunkSize chunk size (usually 3 or 4)
@param cpuArray cpuArray[0-(chunkSize-1)][0,entries-1]
@param gpuArray gpuArray[chunkSize*entries]
@param tolerance check if relative difference is greater \n
than this tolerance
@param compareColumn array of size [chunkSize] signalling whether \n
column i is to be compared; it may be NULL
@param absoluteMin error if abs(cpu) + abs(gpu) > absoluteMin \n
set negative to ignore this condition
@param printOn if not set, then no printing
@param header id header -- optional
@param log logging file descriptor
@return number of failed entries
--------------------------------------------------------------------------------------- */
int SimTKOpenMMGpuUtilities::compareCpuGpuArrays( int numberOfAtoms, int chunkSize,
RealOpenMM** cpuArray, RealOpenMM* gpuArray, RealOpenMM tolerance,
int* compareColumn, RealOpenMM absoluteMin,
int printOn, const char* header, FILE* log ){
// ---------------------------------------------------------------------------------------
char failedString[20];
// static const char* methodName = "\nSimTKOpenMMGpuUtilities::compareCpuGpuArrays";
// ---------------------------------------------------------------------------------------
printOn = printOn && log != NULL;
// print header
failedString[chunkSize] = '\0';
if( printOn ){
(void) fprintf( log, "\n" );
if( header ){
(void) fprintf( log, "%s", header );
}
(void) fprintf( log, " atoms=%d tol=%.3e absCutoff=%.3e printOn=%d",
numberOfAtoms, tolerance, absoluteMin, printOn );
}
// look for differences and print if flags set appropriately
int returnFailed = 0;
int offset = 0;
int printedOnce = 0;
for( int ii = 0; ii < numberOfAtoms; ii++ ){
int localFailed = 0;
for( int jj = 0; jj < chunkSize; jj++ ){
if( compareColumn == NULL || compareColumn[jj] ){
RealOpenMM f1 = fabs( cpuArray[jj][ii] ) + fabs( gpuArray[offset+jj] );
if( f1 > 0.0f ){
RealOpenMM diff = fabs( (cpuArray[jj][ii] - gpuArray[offset+jj]) )/f1;
if( diff > tolerance && f1 > absoluteMin ){
localFailed = 1;
returnFailed += 1;
failedString[jj] = 'X';
} else {
failedString[jj] = ' ';
}
}
} else {
failedString[jj] = ' ';
}
}
// print
if( log && (printOn || localFailed) ){
const char* numberFormat = "%9.4f ";
if( !printedOnce ){
(void) fprintf( log, "\n CpuF GpuF" );
printedOnce = 1;
}
(void) fprintf( log, "\n%d [", ii );
for( int jj = 0; jj < chunkSize; jj++ ){
if( compareColumn == NULL || compareColumn[jj] ){
(void) fprintf( log, numberFormat, cpuArray[jj][ii] );
}
}
(void) fprintf( log, "] [" );
for( int jj = 0; jj < chunkSize; jj++ ){
if( compareColumn == NULL || compareColumn[jj] ){
(void) fprintf( log, numberFormat, gpuArray[offset + jj] );
}
}
(void) fprintf( log, "] [%s]", failedString );
}
offset += chunkSize;
}
// flush buffer
if( log ){
(void) fflush( log );
}
return returnFailed;
}
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* 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.
*/
#ifndef __SimTKOpenMMGpuUtilities_H_
#define __SimTKOpenMMGpuUtilities_H_
// ---------------------------------------------------------------------------------------
// reserve the option to change between Real and double
#include "SimTKOpenMMRealType.h"
#include "SimTKOpenMMCommon.h"
// ---------------------------------------------------------------------------------------
// class of shared, static utility methods
#include <stdio.h>
#include <string.h>
#include <string>
#include <stdlib.h>
#include <sstream>
// #include <string>
// ---------------------------------------------------------------------------------------
/**---------------------------------------------------------------------------------------
Class of static methods to be shared
Most methods are standalone 'utility' methods
--------------------------------------------------------------------------------------- */
class SimTKOpenMMGpuUtilities {
public:
// dummy constructor/destructor
SimTKOpenMMGpuUtilities(){};
~SimTKOpenMMGpuUtilities(){};
/**---------------------------------------------------------------------------------------
Helper method to repack RealOpenMM arrays (Simbios)
@param numberOfEntries entries/sub-array
@param subarraySize number of subarrays
@param array array
Input array = [subArray_1 subArray_2 subArray_3 ... subArray_Stacked] \n
where each subArray_i is 1 x numberOfEntries
Output array = [ subArray_1_1 subArray_2_1 subArray_3_1 ... subArray_Stacked_1 \n
subArray_1_2 subArray_2_2 subArray_3_2 ... subArray_Stacked_2 \n
subArray_1_3 subArray_2_3 subArray_3_3 ... subArray_Stacked_3 \n
... \n
subArray_1_N subArray_2_N subArray_3_N ... subArray_Stacked_N ] \n
where N = numberOfEntries
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int repackArray1( int numberOfEntries, int subarraySize, RealOpenMM* array );
/**---------------------------------------------------------------------------------------
Copy an array into a packed (e.g., RealOpenMM4 array) (Simbios)
Example copy Born radii into last slot of force array
@param numberOfEntries entries/sub-array (no. atoms)
@param subarraySize number of subarrays (4 for RealOpenMM4)
@param fullArray full array (force array in example)
@param copySlot index of slot to copied into (3 in example, since want Born radius in .w slot)
@param arrayToCopy array to copy (Born array)
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int copySubArray( int numberOfEntries, int subarraySize, RealOpenMM* fullArray,
int copySlot, RealOpenMM* arrayToCopy );
/**---------------------------------------------------------------------------------------
Helper method to repack RealOpenMM arrays (Simbios)
@param numberOfEntries entries/sub-array
@param subarraySize number of subarrays
@param array array
Input array = [subArray_1 subArray_2 subArray_3 ... subArray_N] \n
where each subArray_i is vector of length M=numberOfEntries \n
Output array = [ subArray_1_1 subArray_2_1 subArray_3_1 ... subArray_N_1 \n
subArray_1_2 subArray_2_2 subArray_3_2 ... subArray_N_2 \n
subArray_1_3 subArray_2_3 subArray_3_3 ... subArray_N_3 \n
... \n
subArray_1_M subArray_2_M subArray_3_M ... subArray_M ] \n
where N = numberOfEntries \n
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int repackArray( int numberOfEntries, int subarraySize, RealOpenMM* array );
/**---------------------------------------------------------------------------------------
Helper method to repack RealOpenMM arrays (Simbios)
@param numberOfEntries entries/sub-array
@param subarraySize number of subarrays
@param array repacked output array
@param inputArrays inputArrays[subarraySize][numberOfEntries]
Output array = [ inputArrays[0][0] inputArrays[1][0] inputArrays[2][0] inputArrays[3][0] \n
inputArrays[0][1] inputArrays[1][1] inputArrays[2][1] inputArrays[3][1] \n
inputArrays[0][2] inputArrays[1][2] inputArrays[2][2] inputArrays[3][2] \n
... \n
inputArrays[0][numberOfEntries] ... inputArrays[subarraySize-1][numberOfEntries] \n
] \n
where N = numberOfEntries \n
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int repackArrayOfArrays( int numberOfEntries, int subarraySize,
RealOpenMM* array, RealOpenMM** inputArrays );
/**---------------------------------------------------------------------------------------
Collapse 2D array into packed single array (Simbios)
Example forces[3][N] -> array of size N containing RealOpenMM3 values
@param numberOfEntries entries (no. atoms)
@param iUnroll iUnroll
@param jUnroll jUnroll
@param arrays arrays to be merged (dimension is [iUnroll][numberOfEntries/iUnroll]
@param mergeArray output array (if null, then allocated)
@param log logging file descriptor
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static RealOpenMM* collapseArrays( int numberOfEntries, int iUnroll, int jUnroll,
RealOpenMM** arrays, RealOpenMM* mergeArray, FILE* log );
/**---------------------------------------------------------------------------------------
Merge 2 arrays based on sentinel value (Simbios)
Overflow array, if present, signals which entries had nonsentinel in both arrays
Example \n
array1 = { 1, 2, 3, s, s, s, 4, 5, s } \n
array2 = { s, s, 6, 8, 9, 3, s, 7, s } \n
merge array = { 1, 2, 3, 8, 9, 3, 4, 5, s } \n
overflow array = { s, s, 6, s, s, s, s, 7, s } \n
@param numberOfEntries entries (no. atoms)
@param sentinelValue sentinel value
@param array1 first array
@param array2 second array
@param mergeArray output merge array
@param overflowArray output overflow array (if null, then ignored)
@param log logging file descriptor
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int mergeArraysBasedSentinelValue( int numberOfEntries,
RealOpenMM sentinelValue,
RealOpenMM* array1, RealOpenMM* array2,
RealOpenMM* mergeArray, RealOpenMM* overflowArray,
FILE* log );
/**---------------------------------------------------------------------------------------
Helper method to store values from CPU loop in position seen in GPU output (Simbios)
--------------------------------------------------------------------------------------- */
static int storeInGpuFormat( int atomI, int atomJ, int debugAtomJ,
int jUnroll, int numberOfStreams,
RealOpenMM** debugStreams, RealOpenMM* RealOpenMMValues[2],
RealOpenMM unsetDebugValue, bool useUpper, FILE* log );
/**---------------------------------------------------------------------------------------
Helper method to compare cpu and gpu computed arrays
@param numberOfAtoms entries (no. atoms)
@param chunkSize chunk size (usually 3 or 4)
@param cpuArray cpuArray[0-(chunkSize-1)][0,entries-1]
@param gpuArray gpuArray[chunkSize*entries]
@param tolerance check if relative difference is greater
than this tolerance
@param compareColumn array of size [chunkSize] signalling whether
column i is to be compared; it may be NULL
@param absoluteMin error if abs(cpu) + abs(gpu) > absoluteMin
set negative to ignore this condition
@param printOn if not set, then no printing
@param header id header -- optional
@param log logging file descriptor
@return number of failed entries
--------------------------------------------------------------------------------------- */
static int compareCpuGpuArrays( int numberOfAtoms, int chunkSize,
RealOpenMM** cpuArray, RealOpenMM* gpuArray,
RealOpenMM tolerance,
int* compareColumn, RealOpenMM absoluteMin,
int printOn, const char* header, FILE* log );
// ---------------------------------------------------------------------------------------
};
// ---------------------------------------------------------------------------------------
#endif // __SimTKOpenMMGpuUtilities_H__
......@@ -25,7 +25,7 @@
#ifndef __SimTKOpenMMLog_H__
#define __SimTKOpenMMLog_H__
#include <stdio.h>
#include <cstdio>
#include <sstream>
#include "SimTKOpenMMCommon.h"
#include "openmm/internal/windowsExport.h"
......
......@@ -26,7 +26,7 @@
#ifndef __RealSimTk_H__
#define __RealSimTk_H__
#include <math.h>
#include <cmath>
// Set RealOpenMMType to 2 for double precision, 1 for float
......
......@@ -110,280 +110,6 @@ int SimTKOpenMMUtilities::getDistanceSquaredFromSpecifiedPoint( RealOpenMM** ato
return SimTKOpenMMCommon::DefaultReturn;
}
/* ---------------------------------------------------------------------------------------
Helper method to allocate RealOpenMM arrays (Simbios)
@param bufferIndex buffer index
@param allocatedSz array of allocated sizes
@param bufferArray array of allocated RealOpenMM arrays
@param requestedSize requested size
@param dataAction action flag: -1 = free memory \n
1 = zero memory
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMUtilities::allocateRealOpenMMBufferArray( int bufferIndex, int* allocatedSz,
RealOpenMM** bufferArray,
int requestedSize, int dataAction ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nSimTKOpenMMUtilities::allocateRealOpenMMBufferArray";
// ---------------------------------------------------------------------------------------
// clear data
if( dataAction == -1 ){
if( allocatedSz[bufferIndex] && bufferArray[bufferIndex] ){
SimTKOpenMMUtilities::Xfree( "bufferArray", __FILE__, __LINE__, bufferArray[bufferIndex] );
allocatedSz[bufferIndex] = 0;
bufferArray[bufferIndex] = NULL;
}
}
// return if requested size is less than allocated
if( allocatedSz[bufferIndex] > requestedSize ){
return SimTKOpenMMCommon::DefaultReturn;
}
// free space if currently allocated
if( allocatedSz[bufferIndex] && bufferArray[bufferIndex] ){
SimTKOpenMMUtilities::Xfree( "bufferArray", __FILE__, __LINE__, bufferArray[bufferIndex] );
}
// allocate
// bufferArray[bufferIndex] = (RealOpenMM*) malloc( requestedSize*sizeof( RealOpenMM ) );
bufferArray[bufferIndex] = (RealOpenMM*) SimTKOpenMMUtilities::Xmalloc( "bufferArray", __FILE__, __LINE__,
requestedSize*sizeof( RealOpenMM ) );
allocatedSz[bufferIndex] = requestedSize;
// zero?
if( dataAction == 1 ){
memset( bufferArray[bufferIndex], 0, requestedSize*sizeof( RealOpenMM ) );
}
return SimTKOpenMMCommon::DefaultReturn;
}
/* ---------------------------------------------------------------------------------------
Print atom coordinates, ...
@param numberAtoms numberAtoms
@param atomCoordinates atomCoordinates (may be NULL)
@param numberOf1Darrays number of 1-d arrays (may be 0)
@param oneDArrays 1-d arrays
@param idString id string to be printed if set
@param log print messages to log file
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMUtilities::printCoordinateAnd1DArrays( int numberAtoms,
RealOpenMM** atomCoordinates,
int numberOf1Darrays,
RealOpenMM** oneDArrays,
const char* idString, FILE* log ){
// ---------------------------------------------------------------------------------------
if( log == NULL ){
return SimTKOpenMMCommon::DefaultReturn;
}
if( idString ){
(void) fprintf( log, "\n%s", idString );
}
for( int ii = 0; ii < numberAtoms; ii++ ){
if( atomCoordinates != NULL ){
(void) fprintf( log, "\n%d %12.4f %12.4f %12.4f",
ii + 1, atomCoordinates[ii][0], atomCoordinates[ii][1], atomCoordinates[ii][2] );
} else {
(void) fprintf( log, "\n" );
}
for( int jj = 0; jj < numberOf1Darrays; jj++ ){
(void) fprintf( log, " %12.4f", oneDArrays[jj][ii] );
}
}
(void) fflush(log);
// ---------------------------------------------------------------------------------------
return SimTKOpenMMCommon::DefaultReturn;
}
/* ---------------------------------------------------------------------------------------
Free array of strings
@param arraySz atom index
@param arrayOfStrings array of strings
@return SimTKOpenMMCommon::DefaultReturn
Used for freeing an array of strings
@see getAtomIdStringGivenAtomIndex()
--------------------------------------------------------------------------------------- */
int SimTKOpenMMUtilities::freeArrayOfStrings( int arraySz, char** arrayOfStrings ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nSimTKOpenMMUtilities::freeArrayOfStrings";
// ---------------------------------------------------------------------------------------
// free memory if allocated
for( int ii = 0; ii < arraySz; ii++ ){
if( arrayOfStrings[ii] ){
SimTKOpenMMUtilities::Xfree( "atomIdStrings", __FILE__, __LINE__, arrayOfStrings[ii] );
}
}
SimTKOpenMMUtilities::Xfree( "arrayOfStrings", __FILE__, __LINE__, arrayOfStrings );
return SimTKOpenMMCommon::DefaultReturn;
}
/* ---------------------------------------------------------------------------------------
Tab string in place
@param string string to tab; assume string is of at least length=tab + 1
@param tab tab spacing length
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMUtilities::tabStringInPlace( char* string, int tab ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nSimTKOpenMMUtilities::tabStringInPlace";
// ---------------------------------------------------------------------------------------
for( int ii = (int) strlen( string ); ii < tab; ii++ ){
string[ii] = ' ';
}
string[tab] = '\0';
return SimTKOpenMMCommon::DefaultReturn;
}
/* ---------------------------------------------------------------------------------------
Write debug fields (Simbios)
@param numberOfFields number of fields to print
@param fields fields
@param numberOfStringFields number of string fields to print
@param stringFields string fields
@param comment comment (optinal -- ignored if NULL)
@param debugFileName output debug file name
@param action 0 open file and return w/o printing \n
1 open file and print \n
2 close file (no print) \n
@param log if set, then print error messages to log file
@return debugFile unless file coud not be opened (or other errors )
or file is closed -- for these cases return NULL
stringFields printed after RealOpenMM fields
--------------------------------------------------------------------------------------- */
FILE* SimTKOpenMMUtilities::writeDebugFile( int numberOfFields, const RealOpenMM* fields,
int numberOfStringFields,
const StringVector& stringFields,
const char* comment, const char* debugFileName, int action,
FILE* debugFile, FILE* log ){
// ---------------------------------------------------------------------------------------
static const char* methodName = "\nSimTKOpenMMUtilities::writeDebugFile";
// ---------------------------------------------------------------------------------------
if( debugFileName != NULL && (action <= WriteDebugFile || debugFile == NULL) ){
// open file
#ifdef _MSC_VER
fopen_s( &debugFile, debugFileName, "w" );
#else
debugFile = fopen( debugFileName, "w" );
#endif
if( debugFile != NULL ){
if( log != NULL ){
(void) fprintf( log, "%s opened file=<%s>.", methodName, debugFileName );
(void) fflush( log );
}
} else {
if( log != NULL ){
(void) fprintf( log, "%s could not open file=<%s> -- abort output.",
methodName, debugFileName );
(void) fflush( log );
}
return NULL;
}
if( action == OpenDebugFile ){
return debugFile;
}
} else if( action == CloseDebugFile ){
// close file
if( debugFile ){
if( log != NULL ){
(void) fprintf( log, "%s closed debug file=<%s>.",
methodName, debugFileName == NULL ? "??" : debugFileName );
(void) fflush( log );
}
(void) fclose( debugFile );
}
return NULL;
}
if( comment != NULL ){
(void) fprintf( debugFile, "%s", comment );
}
if( numberOfFields > 0 || numberOfStringFields > 0 ){
(void) fprintf( debugFile, "\n" );
if( numberOfFields > 0 || fields != NULL ){
for( int ii = 0; ii < numberOfFields; ii++ ){
(void) fprintf( debugFile, "%.5e ", fields[ii] );
}
}
if( numberOfStringFields > 0 ){
for( StringVectorCI ii = stringFields.begin(); ii != stringFields.end() ; ii++ ){
(void) fprintf( debugFile, "%s ", (*ii).c_str() );
}
}
}
(void) fflush( debugFile );
return debugFile;
}
/* ---------------------------------------------------------------------------------------
Allocate 1D RealOpenMM array (Simbios)
......@@ -414,8 +140,7 @@ RealOpenMM* SimTKOpenMMUtilities::allocateOneDRealOpenMMArray( int iSize, RealOp
if( array1D == NULL ){
array1D = (RealOpenMM*) SimTKOpenMMUtilities::Xmalloc( idString.c_str(), __FILE__, __LINE__,
iSize*sizeof( RealOpenMM ) );
array1D = new RealOpenMM[iSize];
}
......@@ -461,13 +186,11 @@ RealOpenMM** SimTKOpenMMUtilities::allocateTwoDRealOpenMMArray( int iSize, int j
if( array2D == NULL ){
array2D = (RealOpenMM**) SimTKOpenMMUtilities::Xmalloc( idString.c_str(), __FILE__, __LINE__,
iSize*sizeof( RealOpenMM* ) );
array2D = new RealOpenMM*[iSize];
std::string blockString = idString;
blockString.append( "Block" );
RealOpenMM* block = (RealOpenMM*) SimTKOpenMMUtilities::Xmalloc( blockString.c_str(), __FILE__, __LINE__,
jSize*iSize*sizeof( RealOpenMM ) );
RealOpenMM* block = new RealOpenMM[jSize*iSize];
for( int ii = 0; ii < iSize; ii++ ){
array2D[ii] = block;
......@@ -508,8 +231,8 @@ int SimTKOpenMMUtilities::freeTwoDRealOpenMMArray( RealOpenMM** array2D, const s
std::string blockString = idString;
blockString.append( "Block" );
SimTKOpenMMUtilities::Xfree( blockString.c_str(), __FILE__, __LINE__, array2D[0] );
SimTKOpenMMUtilities::Xfree( idString.c_str(), __FILE__, __LINE__, array2D );
delete[] array2D[0];
delete[] array2D;
}
return SimTKOpenMMCommon::DefaultReturn;
......@@ -537,7 +260,7 @@ int SimTKOpenMMUtilities::freeOneDRealOpenMMArray( RealOpenMM* array1D, const st
// ---------------------------------------------------------------------------------------
if( array1D != NULL ){
SimTKOpenMMUtilities::Xfree( idString.c_str(), __FILE__, __LINE__, array1D );
delete[] array1D;
}
return SimTKOpenMMCommon::DefaultReturn;
......@@ -602,89 +325,6 @@ int SimTKOpenMMUtilities::initialize2DRealOpenMMArray( int iSize, int jSize,
return SimTKOpenMMCommon::DefaultReturn;
}
/* ---------------------------------------------------------------------------------------
Malloc memory of size bytesToAllocate and zero
@param bytesToAllocate bytes to allocate
@return ptr to allocated memory; NULL if bytesToAllocate <= 0
--------------------------------------------------------------------------------------- */
char* SimTKOpenMMUtilities::allocateAndZero( unsigned int bytesToAllocate ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nSimTKOpenMMUtilities::allocateAndZero";
// ---------------------------------------------------------------------------------------
if( bytesToAllocate <= 0 ){
return NULL;
}
char* ptrToMemory = (char*) SimTKOpenMMUtilities::Xmalloc( "ptrToMemory",
__FILE__, __LINE__,
bytesToAllocate*sizeof( char ) );
memset( ptrToMemory, 0, bytesToAllocate );
return ptrToMemory;
}
/* ---------------------------------------------------------------------------------------
Normalize 3-vector -- helper method
@param vector 3-vector to normalize
--------------------------------------------------------------------------------------- */
void SimTKOpenMMUtilities::normalizeVector3( RealOpenMM* vector ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nSimTKOpenMMUtilities::normalizeVector3";
// ---------------------------------------------------------------------------------------
RealOpenMM sum = vector[0]*vector[0] + vector[1]*vector[1] + vector[2]*vector[2];
sum = sum > 0.0 ? (RealOpenMM) (1.0/SQRT( sum )) : (RealOpenMM) 0.0;
vector[0] *= sum;
vector[1] *= sum;
vector[2] *= sum;
return;
}
/* ---------------------------------------------------------------------------------------
Remove 3-vector -- helper method
@param vectorToRemove vector to remove
@param vector vector to from which 'vectorToRemove' is to be removed
vector is normalized after the component is subtracted out
--------------------------------------------------------------------------------------- */
void SimTKOpenMMUtilities::removeVector3( RealOpenMM* vectorToRemove, RealOpenMM* vector ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nSimTKOpenMMUtilities::removeVector3";
// ---------------------------------------------------------------------------------------
RealOpenMM dot = vectorToRemove[0]*vector[0] + vectorToRemove[1]*vector[1] + vectorToRemove[2]*vector[2];
vector[0] -= dot*vectorToRemove[0];
vector[1] -= dot*vectorToRemove[1];
vector[2] -= dot*vectorToRemove[2];
normalizeVector3( vector );
}
/* ---------------------------------------------------------------------------------------
Compute cross product of two 3-vectors and place in 3rd vector -- helper method
......@@ -716,713 +356,6 @@ void SimTKOpenMMUtilities::crossProductVector3( RealOpenMM* vectorX,
return;
}
/**---------------------------------------------------------------------------------------
Compute matrix product of 3x3 matrix and 3-vector and place in 3rd vector -- helper method
vectorZ = matrixX . vectorY
@param matrixX matrixX
@param vectorY y-vector
@param vectorZ z-vector
@return vector is vectorZ
--------------------------------------------------------------------------------------- */
void SimTKOpenMMUtilities::matrixProductVector3( RealOpenMM* matrixX,
RealOpenMM* vectorY,
RealOpenMM* vectorZ ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nSimTKOpenMMUtilities::matrixProductVector3";
// ---------------------------------------------------------------------------------------
vectorZ[0] = matrixX[0]*vectorY[0] + matrixX[3]*vectorY[1] + matrixX[6]*vectorY[2];
vectorZ[1] = matrixX[1]*vectorY[0] + matrixX[4]*vectorY[1] + matrixX[7]*vectorY[2];
vectorZ[2] = matrixX[2]*vectorY[0] + matrixX[5]*vectorY[1] + matrixX[8]*vectorY[2];
return;
}
/**---------------------------------------------------------------------------------------
Compute cross product between two 3x3 matrices
@param vectorZ = matrixX x matrixY
@param matrixX matrixX
@param matrixY matrixY
@param vectorZ z-vector
@return vector is vectorZ
--------------------------------------------------------------------------------------- */
void SimTKOpenMMUtilities::matrixCrossProductMatrix3( RealOpenMM* matrixX,
RealOpenMM* matrixY,
RealOpenMM* vectorZ ){
// ---------------------------------------------------------------------------------------
// static const int indices[3][2] = { { 3, 6 }, { 6, 0 }, { 0 , 3 } };
// static const char* methodName = "\nSimTKOpenMMUtilities::matrixCrossProductMatrix3";
RealOpenMM* xPtr[3];
RealOpenMM* yPtr[3];
// ---------------------------------------------------------------------------------------
xPtr[0] = matrixX;
xPtr[1] = matrixX + 3;
xPtr[2] = matrixX + 6;
yPtr[0] = matrixY;
yPtr[1] = matrixY + 3;
yPtr[2] = matrixY + 6;
vectorZ[0] = DOT3( xPtr[1], yPtr[2] ) - DOT3( xPtr[2], yPtr[1] );
vectorZ[1] = DOT3( xPtr[2], yPtr[0] ) - DOT3( xPtr[0], yPtr[2] );
vectorZ[2] = DOT3( xPtr[0], yPtr[1] ) - DOT3( xPtr[1], yPtr[0] );
return;
}
/* ---------------------------------------------------------------------------------------
Centralized malloc/new
@param name ptr name
@param fileName file name
@param line file line no.
@param file line size in bytes to be allocated
@return ptr to allocated object
--------------------------------------------------------------------------------------- */
void* SimTKOpenMMUtilities::Xmalloc( const char* name, const char* fileName, int line, unsigned int size ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nSimTKOpenMMUtilities::Xmalloc";
// ---------------------------------------------------------------------------------------
#ifdef UseGromacsMalloc
return save_malloc( name, fileName, line, size );
#else
return (void*) new char[size];
#endif
}
/* ---------------------------------------------------------------------------------------
Centralized free/delete
@param name ptr name
@param fileName file name
@param line file line no.
@param ptr ptr to be freed
--------------------------------------------------------------------------------------- */
void SimTKOpenMMUtilities::Xfree( const char* name, const char* fileName, int line, void* ptr ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nSimTKOpenMMUtilities::Xfree";
// ---------------------------------------------------------------------------------------
#ifdef UseGromacsMalloc
return save_free( name, fileName, line, ptr );
#else
delete[] (char*) ptr;
return;
#endif
}
/* ---------------------------------------------------------------------------------------
Format array of reals
@param message input string stream
@param realArray array of RealOpenMMs
@param numberOfFields number of fields (optional - defaults to 3)
@param factor scale factor
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMUtilities::formatRealStringStream( std::stringstream& message,
const RealOpenMM* realArray,
int numberOfFields, RealOpenMM factor ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nSimTKOpenMMUtilities::Xfree";
// ---------------------------------------------------------------------------------------
for( int ii = 0; ii < numberOfFields; ii++ ){
message << factor*realArray[ii] << " ";
}
return SimTKOpenMMCommon::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Tokenize a string (static method) (Simbios)
@param lineBuffer string to tokenize
@param tokenArray upon return vector of tokens
@param delimiter token delimter
@return number of args
--------------------------------------------------------------------------------------- */
int SimTKOpenMMUtilities::tokenizeString( char* lineBuffer, StringVector& tokenArray,
const std::string delimiter ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMUtilities::tokenizeString";
// ---------------------------------------------------------------------------------------
// (void) fprintf( stdout, "\nIn SimTKOpenMMUtilities::tokenizeString <%s>", lineBuffer );
// (void) fflush( stdout );
char *ptr_c = NULL;
for( ; (ptr_c = SimTKOpenMMUtilities::strsep( &lineBuffer, delimiter.c_str() )) != NULL; ){
if( *ptr_c ){
tokenArray.push_back( std::string( ptr_c ) );
}
}
return (int) tokenArray.size();
}
/**---------------------------------------------------------------------------------------
Local version of strncasecmp (missing in Windows) (static method) (Simbios)
@param string1 first string
@param string2 second string
@param matchLength match length
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMUtilities::localStrncasecmp( const char *string1, const char *string2, int matchLength ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMUtilities::localStrncasecmp"
char ch1,ch2;
// ---------------------------------------------------------------------------------------
if( matchLength == 0 ){
return SimTKOpenMMCommon::DefaultReturn;
}
do {
ch1 = toupper(*(string1++));
ch2 = toupper(*(string2++));
if( ch1 != ch2 )return (ch1-ch2);
matchLength--;
} while( ch1 && matchLength );
return SimTKOpenMMCommon::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Check that string is valid integer
@param stringToCheck string to check
@return true if string is a valid integer
--------------------------------------------------------------------------------------- */
bool SimTKOpenMMUtilities::isValidInteger( std::string stringToCheck ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMUtilities::isValidInteger";
// ---------------------------------------------------------------------------------------
int ii;
return checkString<int>(ii, stringToCheck, std::dec );
}
/**---------------------------------------------------------------------------------------
Check that string is valid RealOpenMM
@param stringToCheck string to check
@return true if string is a valid RealOpenMM
--------------------------------------------------------------------------------------- */
bool SimTKOpenMMUtilities::isValidRealOpenMM( std::string stringToCheck ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMUtilities::isValidRealOpenMM";
// ---------------------------------------------------------------------------------------
RealOpenMM ii;
return checkString<RealOpenMM>(ii, stringToCheck, std::dec );
}
/**---------------------------------------------------------------------------------------
Read file into string vector (Simbios)
@param fileName file name
@param fileContents string vector containing file contents upon return
one string per line
@return SimTKOpenMMCommon::DefaultReturn unless file could not be opened
--------------------------------------------------------------------------------------- */
int SimTKOpenMMUtilities::readFileIntoStringVector( const std::string& fileName,
StringVector& fileContents ){
// ---------------------------------------------------------------------------------------
static int bufferSize = 2048;
static char buffer[2048];
static const std::string methodName = "\nSimTKOpenMMUtilities::readFileIntoStringVector";
// ---------------------------------------------------------------------------------------
// open file
FILE* file = NULL;
#ifdef _MSC_VER
fopen_s( &file, fileName.c_str(), "r" );
#else
file = fopen( fileName.c_str(), "r" );
#endif
if( file != NULL ){
std::stringstream message;
message << methodName.c_str() << " opened file=<" << fileName.c_str() << ">.";
SimTKOpenMMLog::printMessage( message );
} else {
std::stringstream message;
message << methodName.c_str() << " could not open file=<" << fileName.c_str() << ">.";
//(void) fprintf( stderr, "\n%s\n", message.str().c_str() );
//(void) fflush( stderr );
SimTKOpenMMLog::printMessage( message );
return SimTKOpenMMCommon::ErrorReturn;
}
// loop over all lines in file, checking for end-of-file
int lineNumber = 0;
while( !feof( file ) ){
// read next line
int bufferLen;
lineNumber++;
if( fgets( buffer, bufferSize, file ) != NULL ){
bufferLen = (int) strlen( buffer );
if( bufferLen > 0 ){
buffer[bufferLen-1] = '\0';
}
// (void) fprintf( log, "%s", buffer );
// (void) fflush( log );
fileContents.push_back( buffer );
}
}
// done
(void) fclose( file );
if( file ){
//std::stringstream message;
//message << methodName.c_str() << " read " << lineNumber << " lines from file=<" << fileName->c_str() << ">.";
// AmoebaLog::printMessage( message );
}
return SimTKOpenMMCommon::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Read file into string vector (Simbios)
@param charArray character array
@param arrayLength array length
@param arrayContents string vector containing array contents upon return
one string per line
@return SimTKOpenMMCommon::DefaultReturn unless file could not be opened
--------------------------------------------------------------------------------------- */
int SimTKOpenMMUtilities::readCharacterArrayIntoStringVector( const char* charArray, int arrayLength,
StringVector& fileContents ){
// ---------------------------------------------------------------------------------------
static int bufferSize = 2048;
static char buffer[2048];
static const std::string methodName = "\nSimTKOpenMMUtilities::readCharacterArrayIntoStringVector";
// ---------------------------------------------------------------------------------------
// loop over all lines in file, checking for end-of-file
int byteIndex = 0;
//int lineIndex = 0;
while( byteIndex < arrayLength ){
// get next line
int lineLength = 0;
int done = 0;
while( byteIndex < arrayLength && lineLength < bufferSize && !done ){
buffer[lineLength++] = charArray[byteIndex++];
if( (int) charArray[byteIndex] == 10 || (int) charArray[byteIndex] == 13 ){
while( (int) charArray[byteIndex] < 32 && byteIndex < arrayLength )byteIndex++;
done = 1;
}
}
buffer[lineLength] = '\0';
//lineIndex++;
// (void) fprintf( stdout, "%s readCharacterArrayIntoStringVector: %d %d <%s>", methodName.c_str(), lineIndex, lineLength, buffer );
// (void) fflush( stdout );
fileContents.push_back( buffer );
}
return SimTKOpenMMCommon::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Tokenize a string (static method) (Simbios)
@param line string to tokenize
@param tokenVector upon return vector of tokens
@param delimiter token delimter
@param clearTokenVector if true, clear tokenVector
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMUtilities::tokenizeString( const std::string& line, StringVector& tokenVector,
const std::string& delimiter, int clearTokenVector ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMUtilities::tokenizeString";
static int bufferSz = 8192;
static char* lineBuffer = NULL;
// ---------------------------------------------------------------------------------------
char *ptr_c;
// clear token vector
if( clearTokenVector ){
tokenVector.clear();
}
// allocate space for line buffer and copy via sprintf()
if( lineBuffer == NULL || bufferSz < (int) line.size() ){
if( lineBuffer != NULL ){
free( lineBuffer );
}
if( bufferSz < (int) line.size() ){
bufferSz = (int) (2*line.size());
}
lineBuffer = (char*) malloc( bufferSz*sizeof( char ) );
}
#ifdef _MSC_VER
(void) sprintf_s( lineBuffer, bufferSz, "%s", line.c_str() );
#else
(void) sprintf( lineBuffer, "%s", line.c_str() );
#endif
// parse
while( (ptr_c = SimTKOpenMMUtilities::strsep( &lineBuffer, delimiter.c_str() )) != NULL ){
if( *ptr_c ){
tokenVector.push_back( std::string( ptr_c ) );
}
}
return SimTKOpenMMCommon::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Replacement of sorts for strtok() (static method) (Simbios)
Used to parse parameter file lines
Should be moved to Utilities file
@param lineBuffer string to tokenize
@param delimiter token delimter
@return number of args; if return value equals maxTokens, then more tokens than allocated
--------------------------------------------------------------------------------------- */
char* SimTKOpenMMUtilities::strsep( char** lineBuffer, const char* delimiter ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nTinkerParameterSet::strsep"
char *s;
const char *spanp;
int c, sc;
char *tok;
// ---------------------------------------------------------------------------------------
s = *lineBuffer;
if( s == NULL ){
return (NULL);
}
for( tok = s;; ){
c = *s++;
spanp = delimiter;
do {
if( (sc = *spanp++) == c ){
if( c == 0 ){
s = NULL;
} else {
s[-1] = 0;
}
*lineBuffer = s;
return( tok );
}
} while( sc != 0 );
}
}
/**---------------------------------------------------------------------------------------
Return lower case copy of string
@param string string
@return lower cased string
--------------------------------------------------------------------------------------- */
//int SimTKOpenMMUtilities::toLower( std::string& string ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nSimTKOpenMMUtilities::toLower"
// ---------------------------------------------------------------------------------------
// transform string to lower case
// std::transform( string.begin(), string.end(), string.begin(), (int(*)(int)) std::tolower);
//return SimTKOpenMMCommon::DefaultReturn;
//}
/**---------------------------------------------------------------------------------------
Write file (helper method) (Simbios)
@param lineVector line entries for file
@param inputFileName inputFileName
@return SimTKOpenMMCommon::ErrorReturn if error -- else SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMUtilities::writeFile( const StringVector& lineVector, const std::string& fileName ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "\nSimTKOpenMMUtilities::writeFile";
// ---------------------------------------------------------------------------------------
// open file
FILE* file = NULL;
#ifdef _MSC_VER
fopen_s( &file, fileName.c_str(), "w" );
#else
file = fopen( fileName.c_str(), "w" );
#endif
if( file != NULL ){
//std::stringstream message;
//message << methodName.c_str() << " opened file=<" << fileName.c_str() << ">.";
//SimTKOpenMMLog::printMessage( message );
} else {
std::stringstream message;
message << methodName.c_str() << " could not open file=<" << fileName.c_str() << ">.";
SimTKOpenMMLog::printMessage( message );
return SimTKOpenMMCommon::ErrorReturn;
}
// ---------------------------------------------------------------------------------------
// loop over lines
int bodyLines = (int) lineVector.size();
for( StringVectorCI ii = lineVector.begin(); ii != lineVector.end(); ii++ ){
if( (*ii).length() > 1 ){
(void) fprintf( file, "%s\n", (*ii).c_str() );
} else {
bodyLines--;
}
}
(void) fflush( file );
(void) fclose( file );
/*
std::stringstream message;
message << " :: closed file=<" << fileName.c_str() << "> number of body lines in file=" << bodyLines;
SimTKOpenMMLog::printMessage( message );
*/
return SimTKOpenMMCommon::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Get statistics on an array
@param numberOfEntries number of entries in array
@param array array
@param average average of array on output
@param stdDev std dev of array on output
@param minValue min value in array on output
@param minIndex index of min value in array on output
@param maxValue max value in array on output
@param maxIndex index of max value in array on output
if numberOfEntries <= 0, return 0 for all RealOpenMM values and -1 for index values
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMUtilities::getArrayStatistics( int numberOfEntries, const RealOpenMM* array,
RealOpenMM* average, RealOpenMM* stdDev,
RealOpenMM* minValue, int* minIndex,
RealOpenMM* maxValue, int* maxIndex ){
// ---------------------------------------------------------------------------------------
static const std::string methodName = "\nSimTKOpenMMUtilities::getArrayStatistics";
static const RealOpenMM zero = 1.0;
static const RealOpenMM one = 1.0;
// ---------------------------------------------------------------------------------------
if( numberOfEntries <= 0 ){
*average = *stdDev = *minValue = *maxValue = zero;
*maxIndex = *minIndex = -1;
return SimTKOpenMMCommon::DefaultReturn;
}
*average = array[0];
*stdDev = (*average)*(*average);
*minValue = array[0];
*maxValue = array[0];
*maxIndex = *minIndex = 0;
for( int ii = 1; ii < numberOfEntries; ii++ ){
*average += array[ii];
*stdDev += array[ii]*array[ii];
if( array[ii] < *minValue ){
*minValue = array[ii];
*minIndex = ii;
}
if( array[ii] > *maxValue ){
*maxValue = array[ii];
*maxIndex = ii;
}
}
RealOpenMM numberOfEntriesR = (RealOpenMM) numberOfEntries;
*average /= numberOfEntriesR;
*stdDev = *stdDev - numberOfEntriesR*(*average)*(*average);
if( numberOfEntriesR > one ){
*stdDev = SQRT( (*stdDev)/(numberOfEntriesR - one) );
}
return SimTKOpenMMCommon::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Get one 2D array to another
@param dimension1 first dimension
@param dimension2 second dimension
@param arrayToAdd array to add [dimension1][dimension2]
@param sumArray summed array to add [dimension1][dimension2]
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int SimTKOpenMMUtilities::addTwoDimArray( int dimension1, int dimension2,
RealOpenMM** arrayToAdd, RealOpenMM** sumArray ){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "\nSimTKOpenMMUtilities::addTwoDimArray";
// ---------------------------------------------------------------------------------------
for( int ii = 0; ii < dimension1; ii++ ){
for( int jj = 0; jj < dimension2; jj++ ){
sumArray[ii][jj] += arrayToAdd[ii][jj];
}
}
return SimTKOpenMMCommon::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Get normally distributed random number
......
......@@ -31,19 +31,7 @@
#include "sfmt/SFMT.h"
#include "openmm/internal/windowsExport.h"
#include <stdio.h>
#include <string.h>
#include <string>
#include <stdlib.h>
#include <sstream>
// template is used to check if a string is integer, real, ...
template <class T>
bool checkString( T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&) ){
std::istringstream iss(s);
return !(iss >> f >> t).fail();
}
/**---------------------------------------------------------------------------------------
......@@ -64,10 +52,6 @@ class OPENMM_EXPORT SimTKOpenMMUtilities {
public:
// file flag enums
enum FileFlags { OpenDebugFile, WriteDebugFile, CloseDebugFile };
// dummy constructor/destructor
SimTKOpenMMUtilities(){};
......@@ -111,95 +95,6 @@ class OPENMM_EXPORT SimTKOpenMMUtilities {
int numberOfAtoms, RealOpenMM* distances,
FILE* log );
/**---------------------------------------------------------------------------------------
Helper method to allocate RealOpenMM arrays (Simbios)
@param bufferIndex buffer index
@param allocatedSz array of allocated sizes
@param bufferArray array of allocated RealOpenMM arrays
@param requestedSize requested size
@param dataAction action flag: -1 = free memory \n
1 = zero memory
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int allocateRealOpenMMBufferArray( int bufferIndex, int* allocatedSz,
RealOpenMM** bufferArray,
int requestedSize, int dataAction );
/**---------------------------------------------------------------------------------------
Print atom coordinates, ...
@param numberAtoms numberAtoms
@param atomCoordinates atomCoordinates (may be NULL)
@param numberOf1Darrays number of 1-d arrays (may be 0)
@param oneDArrays 1-d arrays
@param idString id string to be printed if set
@param log print messages to log file
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int printCoordinateAnd1DArrays( int numberAtoms, RealOpenMM** atomCoordinates,
int numberOf1Darrays, RealOpenMM** oneDArrays,
const char* idString, FILE* log );
/**---------------------------------------------------------------------------------------
Free array of strings
@param arraySz atom index
@param arrayOfStrings array of strings
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int freeArrayOfStrings( int arraySz, char** arrayOfStrings );
/**---------------------------------------------------------------------------------------
Tab string in place
@param string string to tab; assume string is of at least length=tab + 1
@param tab tab length
--------------------------------------------------------------------------------------- */
static int tabStringInPlace( char* string, int tab );
/**---------------------------------------------------------------------------------------
Write debug fields (Simbios)
@param numberOfFields number of fields to print
@param fields fields
@param numberOfStringFields number of string fields to print
@param stringFields string fields
@param comment comment (optinal -- ignored if NULL)
@param debugFileName output debug file name
@param action 0 open file and @return w/o printing
1 open file and print
2 close file (no print)
@param debugFile debug file reference
@param log if set, then print error messages to log file
@return debugFile unless file is closed
stringFields printed after RealOpenMM fields
--------------------------------------------------------------------------------------- */
static FILE* writeDebugFile( int numberOfFields, const RealOpenMM* fields,
int numberOfStringFields, const StringVector& stringFields,
const char* comment, const char* debugFileName, int action,
FILE* debugFile, FILE* log );
/**---------------------------------------------------------------------------------------
Allocate 1D RealOpenMM array (Simbios)
......@@ -292,40 +187,6 @@ class OPENMM_EXPORT SimTKOpenMMUtilities {
static int initialize2DRealOpenMMArray( int iSize, int jSize,
RealOpenMM** array2D, RealOpenMM initialValue );
/**---------------------------------------------------------------------------------------
Malloc memory of size bytesToAllocate and zero
@param bytesToAllocate bytes to allocate
@return ptr to allocated memory; NULL if bytesToAllocate <= 0
--------------------------------------------------------------------------------------- */
static char* allocateAndZero( unsigned int bytesToAllocate );
/**---------------------------------------------------------------------------------------
Normalize 3-vector -- helper method
@param vector vector to normalize
--------------------------------------------------------------------------------------- */
static void normalizeVector3( RealOpenMM* vector );
/**---------------------------------------------------------------------------------------
Remove 3-vector -- helper method
@param vectorToRemove vector to remove
@param vector vector to from which 'vectorToRemove' is to be removed \n
vector is normalized after the component is subtracted out
--------------------------------------------------------------------------------------- */
static void removeVector3( RealOpenMM* vectorToRemove, RealOpenMM* vector );
/**---------------------------------------------------------------------------------------
Compute cross product of two 3-vectors and place in 3rd vector -- helper method
......@@ -342,250 +203,6 @@ class OPENMM_EXPORT SimTKOpenMMUtilities {
static void crossProductVector3( RealOpenMM* vectorX, RealOpenMM* vectorY, RealOpenMM* vectorZ );
/**---------------------------------------------------------------------------------------
Compute matrix product of 3x3 matrix and 3-vector and place in 3rd vector -- helper method
@param vectorZ = matrixX . vectorY
@param matrixX matrixX
@param vectorY y-vector
@param vectorZ z-vector
@return vector is vectorZ
--------------------------------------------------------------------------------------- */
static void matrixProductVector3( RealOpenMM* matrixX, RealOpenMM* vectorY, RealOpenMM* vectorZ );
/**---------------------------------------------------------------------------------------
Compute cross product between two 3x3 matrices
@param vectorZ = matrixX . matrixY
@param matrixX matrixX
@param matrixY matrixY
@param vectorZ z-vector
@return vector is vectorZ
--------------------------------------------------------------------------------------- */
static void matrixCrossProductMatrix3( RealOpenMM* matrixX, RealOpenMM* matrixY, RealOpenMM* vectorZ );
/* ---------------------------------------------------------------------------------------
Centralized malloc/new
@param name ptr name
@param fileName file name
@param line file line no.
@param file line size in bytes to be allocated
@return ptr to allocated object
--------------------------------------------------------------------------------------- */
static void* Xmalloc( const char* name, const char* fileName, int line, unsigned int size );
/* ---------------------------------------------------------------------------------------
Centralized free/delete
@param name ptr name
@param fileName file name
@param line file line no.
@param ptr ptr to be freed
--------------------------------------------------------------------------------------- */
static void Xfree( const char* name, const char* fileName, int line, void* ptr );
/* ---------------------------------------------------------------------------------------
Format array of reals
@param message input string stream
@param realArray array of RealOpenMMs
@param numberOfFields number of fields (optional - defaults to 3)
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int formatRealStringStream( std::stringstream& message, const RealOpenMM* realArray,
int numberOfFields = 3, RealOpenMM factor = (RealOpenMM) 1.0f );
/**---------------------------------------------------------------------------------------
Tokenize a string (static method) (Simbios)
@param lineBuffer string to tokenize
@param tokenArray upon return vectory of tokens
@param delimiter token delimter
@return number of args
--------------------------------------------------------------------------------------- */
static int tokenizeString( char* lineBuffer, StringVector& tokenArray, const std::string delimiter = "\t\n " );
/**---------------------------------------------------------------------------------------
Tokenize a string (static method) (Simbios)
@param line string to tokenize
@param tokenVector upon return vector of tokens
@param delimiter token delimter
@param clearTokenVector if true, clear tokenVector
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int tokenizeString( const std::string& line, StringVector& tokenVector,
const std::string& delimiter, int clearTokenVector );
/**---------------------------------------------------------------------------------------
Local version of strncasecmp (missing in Windows) (static method) (Simbios)
@param string1 first string
@param string2 second string
@param matchLength match length
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int localStrncasecmp( const char *string1, const char *string2, int matchLength );
/**---------------------------------------------------------------------------------------
Check that string is valid integer
@param stringToCheck string to check
@return true if string is a valid integer
--------------------------------------------------------------------------------------- */
static bool isValidInteger( std::string stringToCheck );
/**---------------------------------------------------------------------------------------
Check that string is valid RealOpenMM
@param stringToCheck string to check
@return true if string is a valid RealOpenMM
--------------------------------------------------------------------------------------- */
static bool isValidRealOpenMM( std::string stringToCheck );
/**---------------------------------------------------------------------------------------
Read file into string vector (Simbios)
@param fileName file name
@param fileContents string vector containing file contents upon return
one string per line
@return SimTKOpenMMCommon::DefaultReturn unless file could not be opened
--------------------------------------------------------------------------------------- */
static int readFileIntoStringVector( const std::string& fileName, StringVector& fileContents );
/**---------------------------------------------------------------------------------------
Read file into string vector (Simbios)
@param charArray character array
@param arrayLength array length
@param arrayContents string vector containing array contents upon return
one string per line
@return SimTKOpenMMCommon::DefaultReturn unless file could not be opened
--------------------------------------------------------------------------------------- */
static int readCharacterArrayIntoStringVector( const char* charArray, int arrayLength,
StringVector& fileContents );
/**---------------------------------------------------------------------------------------
Replacement of sorts for strtok() (static method) (Simbios)
Used to parse parameter file lines
Should be moved to Utilities file
@param lineBuffer string to tokenize
@param delimiter token delimter
@return number of args; if return value equals maxTokens, then more tokens than allocated
--------------------------------------------------------------------------------------- */
static char* strsep( char** lineBuffer, const char* delimiter );
/**---------------------------------------------------------------------------------------
Write file (helper method) (Simbios)
@param lineVector line entries for file
@param inputFileName inputFileName
@return SimTKOpenMMCommon::ErrorReturn if error -- else SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int writeFile( const StringVector& lineVector, const std::string& fileName );
/**---------------------------------------------------------------------------------------
Get statistics on an array
@param numberOfEntries number of entries in array
@param array array
@param average average of array on output
@param stdDev std dev of array on output
@param minValue min value in array on output
@param minIndex index of min value in array on output
@param maxValue max value in array on output
@param maxIndex index of max value in array on output
if numberOfEntries <= 0, return 0 for all RealOpenMM values and -1 for index values
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int getArrayStatistics( int numberOfEntries, const RealOpenMM* array,
RealOpenMM* average, RealOpenMM* stdDev,
RealOpenMM* minValue, int* minIndex,
RealOpenMM* maxValue, int* maxIndex );
/**---------------------------------------------------------------------------------------
Get one 2D array to another
@param dimension1 first dimension
@param dimension2 second dimension
@param arrayToAdd array to add [dimension1][dimension2]
@param sumArray summed array to add [dimension1][dimension2]
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
static int addTwoDimArray( int dimension1, int dimension2, RealOpenMM** arrayToAdd,
RealOpenMM** sumArray );
/**---------------------------------------------------------------------------------------
Get normally distributed random number
......
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* 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.
*/
#ifndef __SimTKOpenMMWindowLinux_H_
#define __SimTKOpenMMWindowLinux_H__
#ifdef WIN32
#define FOPEN fopen_s
#else
#define FOPEN fopen
#endif
#endif // __SimTKOpenMMWindowLinux_H__
This source diff could not be displayed because it is too large. You can view the blob instead.
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* 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.
*/
#ifndef __TwoDimArraySimTk_H_
#define __TwoDimArraySimTk_H_
// ---------------------------------------------------------------------------------------
//#include "SimTKOpenMMUtilities.h"
#include "SimTKOpenMMUtilities.h"
/**---------------------------------------------------------------------------------------
Class for 2D arrays
--------------------------------------------------------------------------------------- */
template <typename T> class TwoDimArraySimTk {
private:
int _rowSize;
int _columnSize;
T** _2Darray;
T* _2DMemoryBlock;
std::string _name;
public:
TwoDimArraySimTk( int rowSize, int columnSize );
~TwoDimArraySimTk();
/**---------------------------------------------------------------------------------------
Get 2D array
@return ptr to array
--------------------------------------------------------------------------------------- */
T** get2DArray( void ) const { return _2Darray; };
/**---------------------------------------------------------------------------------------
Get print string
@return std::string
--------------------------------------------------------------------------------------- */
std::string getPrintString( void ) const;
/**---------------------------------------------------------------------------------------
Get name
@return array name
--------------------------------------------------------------------------------------- */
std::string getName( void ) const { return _name; };
/**---------------------------------------------------------------------------------------
Set name
@param array name
--------------------------------------------------------------------------------------- */
void setName( std::string name ){ _name = name; };
};
/**---------------------------------------------------------------------------------------
TwoDimArraySimTk constructor
@param rowSize row dimension
@param columnSize column dimension
--------------------------------------------------------------------------------------- */
template <typename T>
TwoDimArraySimTk<T>::TwoDimArraySimTk( int rowSize, int columnSize ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nTwoDimArraySimTk<T>::TwoDimArraySimTk";
// ---------------------------------------------------------------------------------------
_name = "NotSet";
_rowSize = rowSize;
_columnSize = columnSize;
#ifdef useXMalloc
_2Darray = (T**) SimTKOpenMMUtilities::Xmalloc( "TwoDimArraySimTk", __FILE__, __LINE__, rowSize*sizeof( T* ) );
_2DMemoryBlock = (T*) SimTKOpenMMUtilities::Xmalloc( "block", __FILE__, __LINE__, columnSize*rowSize*sizeof( T ) );
#else
_2Darray = (T**) SimTKOpenMMUtilities::Xmalloc( "TwoDimArraySimTk", __FILE__, __LINE__, rowSize*sizeof( T* ) );
_2DMemoryBlock = (T*) SimTKOpenMMUtilities::Xmalloc( "block", __FILE__, __LINE__, columnSize*rowSize*sizeof( T ) );
#endif
T* blockPtr = _2DMemoryBlock;
for( int ii = 0; ii < rowSize; ii++ ){
_2Darray[ii] = blockPtr;
blockPtr += columnSize;
}
memset( _2DMemoryBlock, 0, columnSize*rowSize*sizeof( T ) );
// (void) fprintf( stdout, "\nTwoDimArraySimTk %s ", getPrintString().c_str() );
// (void) fflush( stdout );
}
/**---------------------------------------------------------------------------------------
TwoDimArraySimTk destructor
array[i][j]
@param rowSize row dimension
@param columnSize column dimension
--------------------------------------------------------------------------------------- */
template <typename T> TwoDimArraySimTk<T>::~TwoDimArraySimTk( ){
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nTwoDimArraySimTk<T>::~TwoDimArraySimTk";
// ---------------------------------------------------------------------------------------
if( _2DMemoryBlock ){
SimTKOpenMMUtilities::Xfree( "2DMemoryBlock", __FILE__, __LINE__, _2DMemoryBlock );
}
if( _2Darray ){
SimTKOpenMMUtilities::Xfree( "2Darray", __FILE__, __LINE__, _2Darray );
}
}
/**---------------------------------------------------------------------------------------
TwoDimArraySimTk print string
@return id string
--------------------------------------------------------------------------------------- */
template <typename T> std::string TwoDimArraySimTk<T>::getPrintString( void ) const {
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nTwoDimArraySimTk<T>::getPrintString";
// ---------------------------------------------------------------------------------------
std::stringstream message;
message << _name << " [ " << _rowSize << ", " << _columnSize << " ] sizeT=" << sizeof( T );
message << " array=" << (unsigned int) _2Darray << " block=" << (unsigned int) _2DMemoryBlock;
// message << " array=" << (void *) _2Darray << " block=" << (void*) _2DMemoryBlock;
return message.str();
}
/**---------------------------------------------------------------------------------------
Typdefs to make code more readable
--------------------------------------------------------------------------------------- */
typedef TwoDimArraySimTk<Real> TwoDimRealArraySimTk;
typedef std::vector<TwoDimRealArraySimTk*> TwoDimRealArraySimTkVector;
typedef std::vector<TwoDimRealArraySimTk*>::iterator TwoDimRealArraySimTkVectorI;
#endif // __TwoDimArraySimTk_H_
......@@ -42,19 +42,6 @@ using namespace std;
CpuImplicitSolvent* CpuImplicitSolvent::_cpuImplicitSolvent = NULL;
// info file related-stuff
std::string CpuImplicitSolvent::_defaultInfoFileName = std::string( "CpuImplicitSolventInfo" );
// key for info file: base file name
const std::string CpuImplicitSolvent::CpuImplicitSolventBaseFileName = std::string( "CpuImplicitSolventBaseFileName" );
// key for info file: file generation frequency
const std::string CpuImplicitSolvent::CpuImplicitSolventFileGenerationFrequency = std::string( "CpuImplicitSolventFileGenerationFrequency" );
/**---------------------------------------------------------------------------------------
CpuImplicitSolvent constructor
......@@ -115,9 +102,6 @@ void CpuImplicitSolvent::_initializeDataMembers( void ){
_forceCallIndex = 0;
_implicitSolventEnergy = (RealOpenMM) 0.0;
_baseFileName = SimTKOpenMMCommon::NotSet;
_outputFileFrequency = 1;
}
/**---------------------------------------------------------------------------------------
......@@ -740,243 +724,6 @@ int CpuImplicitSolvent::computeAceNonPolarForce( const ImplicitSolventParameters
}
/**---------------------------------------------------------------------------------------
Get BaseFileName
@return baseFileName
--------------------------------------------------------------------------------------- */
const std::string& CpuImplicitSolvent::getBaseFileName( void ) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nCpuImplicitSolvent::getBaseFileName";
// ---------------------------------------------------------------------------------------
return _baseFileName;
}
/**---------------------------------------------------------------------------------------
Set BaseFileName
@param input baseFileName
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int CpuImplicitSolvent::setBaseFileName( const std::string& baseFileName ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nCpuImplicitSolvent::setBaseFileName";
// ---------------------------------------------------------------------------------------
_baseFileName = baseFileName;
return SimTKOpenMMCommon::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Set OutputFileFrequency
@param input outputFileFrequency
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int CpuImplicitSolvent::setOutputFileFrequency( int outputFileFrequency ){
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nCpuImplicitSolvent::setOutputFileFrequency";
// ---------------------------------------------------------------------------------------
_outputFileFrequency = outputFileFrequency;
return SimTKOpenMMCommon::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Get OutputFileFrequency
@return output file frequency
--------------------------------------------------------------------------------------- */
int CpuImplicitSolvent::getOutputFileFrequency( void ) const {
// ---------------------------------------------------------------------------------------
// static const std::string methodName = "\nCpuImplicitSolvent::getOutputFileFrequency";
// ---------------------------------------------------------------------------------------
return _outputFileFrequency;
}
/**---------------------------------------------------------------------------------------
Read info file
@param infoFileName file name to read
@return SimTKOpenMMCommon::DefaultReturn if ok; else SimTKOpenMMCommon::ErrorReturn; if major
problem, program will exit
--------------------------------------------------------------------------------------- */
int CpuImplicitSolvent::readInfoFile( const std::string infoFileName ){
// ---------------------------------------------------------------------------------------
const int bufferSize = 2048;
char buffer[bufferSize];
static const std::string methodName = "\nCpuImplicitSolvent::readInfoFile";
// ---------------------------------------------------------------------------------------
FILE* infoFile = NULL;
#ifdef _MSC_VER
fopen_s( &infoFile, infoFileName.c_str(), "r" );
#else
infoFile = fopen( infoFileName.c_str(), "r" );
#endif
if( infoFile == NULL ){
#ifdef _MSC_VER
fopen_s( &infoFile, _defaultInfoFileName.c_str(), "r" );
#else
infoFile = fopen( _defaultInfoFileName.c_str(), "r" );
#endif
if( infoFile == NULL ){
std::stringstream message;
message << methodName << " fopen failed on info file=<" << _defaultInfoFileName << "> and file=<" << infoFileName << ">";
SimTKOpenMMLog::printMessage( message );
return SimTKOpenMMCommon::ErrorReturn;
} else {
std::stringstream message;
message << methodName << " opened info file=<" << _defaultInfoFileName << ">.";
SimTKOpenMMLog::printMessage( message );
}
} else {
std::stringstream message;
message << methodName << " opened info file=<" << infoFileName << ">.";
SimTKOpenMMLog::printMessage( message );
}
/* Sample file:
*/
int errors = 0;
while( fgets( buffer, bufferSize, infoFile ) ){
std::stringstream message;
std::string fileName = std::string( );
size_t bufferLen = strlen( buffer );
if( bufferLen > 0 ){
buffer[bufferLen-1] = '\0';
}
message << "\n<" << buffer << ">";
//fprintf( amoebaLog->getLogFile(), "\nreadInfoFile <%s>", buffer );
//fflush( amoebaLog->getLogFile() );
StringVector tokens;
SimTKOpenMMUtilities::tokenizeString( buffer, tokens );
bool done = false;
for( StringVectorI ii = tokens.begin(); ii != tokens.end() && !done; ii++ ){
std::string token = *ii;
size_t tokenLength = token.length();
bool recognized = false;
// skip comments and blank lines
if( tokenLength < 2 || !token.compare( "#" ) ){
done = true;
recognized = true;
// base file name
} else if( !token.compare( CpuImplicitSolvent::CpuImplicitSolventBaseFileName ) ){
recognized = true;
setBaseFileName( *(++ii) );
// file frequency
} else if( !token.compare( CpuImplicitSolvent::CpuImplicitSolventFileGenerationFrequency ) ){
recognized = true;
std::string value = *(++ii);
if( SimTKOpenMMUtilities::isValidInteger( value ) ){
setOutputFileFrequency( atoi( value.c_str() ) );
} else {
message << "\nToken=<" << token << "> is not a valid integer for key=" << CpuImplicitSolvent::CpuImplicitSolventFileGenerationFrequency;
}
// keys used by objects other than 'CpuImplicitSolvent'
} else {
/*
recognized = true;
std::string key = *ii;
ii++;
if( ii != tokens.end() ){
_inputArguments[key] = *ii;
} else {
_inputArguments[key] = CpuImplicitSolventCommon::Comment;
}
*/
}
if( !recognized ){
message << "\nToken=<" << token << "> not recognized.";
}
}
SimTKOpenMMLog::printMessage( message );
}
(void) fclose( infoFile );
// report if errors
if( errors ){
std::stringstream message;
message << "\nErrors -- aborting.\n";
SimTKOpenMMLog::printMessage( message );
exit(-1);
} else {
std::stringstream message;
message << "\nNo errors detected parsing info file " << infoFileName << "\n";
/*
message << "\nNumber of hash arguments=" << _amoebaInputArguments.size() << " <key,value> pairs listed below:\n";
for( StringStringMapCI ii = _amoebaInputArguments.begin(); ii != _amoebaInputArguments.end(); ii++ ){
message << "\n <" << (*ii).first << ">=<" << (*ii).second << ">";
}
*/
message << "\n\n";
SimTKOpenMMLog::printMessage( message );
}
return SimTKOpenMMCommon::DefaultReturn;
}
/**---------------------------------------------------------------------------------------
Get string w/ state
......@@ -1014,80 +761,3 @@ std::string CpuImplicitSolvent::getStateString( const char* title ) const {
return message.str();
}
/* ---------------------------------------------------------------------------------------
Override C++ new w/ Gromac's smalloc/sfree (Simbios)
@param size bytes to allocate
@return ptr to allocated memory
--------------------------------------------------------------------------------------- */
/*
void* CpuImplicitSolvent::operator new( size_t size ){
void *ptr;
smalloc(ptr, (int) size);
// (void) fprintf( stdout, "\nCpuImplicitSolvent new called -- size=%u", size );
// (void) fflush( stdout );
return ptr;
} */
/* ---------------------------------------------------------------------------------------
Override C++ delete w/ Gromac's sfree (Simbios)
@param ptr ptr to block to free
--------------------------------------------------------------------------------------- */
/*
void CpuImplicitSolvent::operator delete( void *ptr ){
// (void) fprintf( stdout, "\nCpuImplicitSolvent delete called." );
// (void) fflush( stdout );
sfree( ptr );
} */
/* ---------------------------------------------------------------------------------------
Override C++ new w/ Gromac's smalloc/sfree (Simbios)
@param size bytes to allocate
@return ptr to allocated memory
--------------------------------------------------------------------------------------- */
/*
void* CpuImplicitSolvent::operator new[]( size_t size ){
void *ptr;
smalloc(ptr, (int) size);
// (void) fprintf( stdout, "\nCpuImplicitSolvent new[] called -- size=%u", size );
// (void) fflush( stdout );
return ptr;
} */
/* ---------------------------------------------------------------------------------------
Override C++ delete w/ Gromac's sfree (Simbios)
@param ptr ptr to block to free
--------------------------------------------------------------------------------------- */
/*
void CpuImplicitSolvent::operator delete[]( void *ptr ){
// (void) fprintf( stdout, "\nCpuImplicitSolvent delete[] called." );
// (void) fflush( stdout );
sfree( ptr );
}
*/
......@@ -32,27 +32,8 @@
class OPENMM_EXPORT CpuImplicitSolvent {
public:
// fields in info file
const static std::string CpuImplicitSolventBaseFileName;
const static std::string CpuImplicitSolventFileGenerationFrequency;
private:
// default info file name
static std::string _defaultInfoFileName;
// base file name
std::string _baseFileName;
// frequency to output diagnostic files
int _outputFileFrequency;
// used for direct calls
static CpuImplicitSolvent* _cpuImplicitSolvent;
......@@ -155,14 +136,6 @@ class OPENMM_EXPORT CpuImplicitSolvent {
virtual ~CpuImplicitSolvent( );
// override of new/delete -- used when run in PS3 framework(?)
// static void* operator new( size_t size );
// static void operator delete( void *p );
// static void* operator new[]( size_t size );
// static void operator delete[]( void *p );
/**---------------------------------------------------------------------------------------
Delete static _cpuImplicitSolvent object if set
......@@ -419,112 +392,6 @@ class OPENMM_EXPORT CpuImplicitSolvent {
--------------------------------------------------------------------------------------- */
std::string getStateString( const char* title ) const;
/**---------------------------------------------------------------------------------------
Get BaseFileName
@return baseFileName
--------------------------------------------------------------------------------------- */
const std::string& getBaseFileName( void ) const;
/**---------------------------------------------------------------------------------------
Set BaseFileName
@param input baseFileName
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int setBaseFileName( const std::string& baseFileName );
/**---------------------------------------------------------------------------------------
Get OutputFileFrequency
@return outputFileFrequency
--------------------------------------------------------------------------------------- */
int getOutputFileFrequency( void ) const;
/**---------------------------------------------------------------------------------------
Set OutputFileFrequency
@param input outputFileFrequency
@return SimTKOpenMMCommon::DefaultReturn
--------------------------------------------------------------------------------------- */
int setOutputFileFrequency( int outputFileFrequency );
/**---------------------------------------------------------------------------------------
Read info file
@param infoFileName file name to read
@return CpuImplicitSolventCommon::DefaultReturn if ok; else CpuImplicitSolventCommon::ErrorReturn; if major
problem, program will exit
--------------------------------------------------------------------------------------- */
int readInfoFile( const std::string infoFileName );
/**---------------------------------------------------------------------------------------
Get output file name (helper method) (Simbios)
fileName = (inputFileName || getBaseFileName()) . getForceCallIndex() . suffix
if inputFileName is NULL, then use getBaseFileName() as base file name
if getForceCallIndex() > 0, insert '.getForceCallIndex()'
append suffix, if not NULL
@param inputFileName inputFileName
@param suffix file suffix
@return file name
--------------------------------------------------------------------------------------- */
std::string getOutputFileName( const std::string* inputFileName, const std::string* suffix ) const;
/**---------------------------------------------------------------------------------------
Write Tinker xyz file (Simbios)
@param numberOfAtoms number of atoms
@param atomCoordinates atom coordinates
@param atomNames atom names
@param header header
@param xyzFileName output file name
@param bondsArray bond array -- used to print 1-2 bonds
@return 0 unless error detected
Currently no attempt is made to get the atom name/type to accurately
reflect the Tinker names/types. Rather method is used to output atoms
in Gromacs order and then reorder those in a corresponding xyz file
w/ the correct atom names/types so that they match the Gromacs order
This makes it easier to compare results between Gromacs and Tinker
--------------------------------------------------------------------------------------- */
/*
static int writeXyzFile( int numberOfAtoms, const std::vector<OpenMM::RealVec>& atomCoordinates,
const char** atomNames,
const std::string& header, const std::string& xyzFileName,
const implicitSolventBonds** bondsArray ); */
};
// ---------------------------------------------------------------------------------------
......
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group
*
* 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.
*/
#ifndef __SimTKOpenMMWindowLinux_H_
#define __SimTKOpenMMWindowLinux_H__
#ifdef WIN32
#define FOPEN fopen_s
#else
#define FOPEN fopen
#endif
#endif // __SimTKOpenMMWindowLinux_H__
......@@ -105,10 +105,6 @@ cpuSetObcParameters( int numberOfAtoms, RealOpenMM* atomicRadii, RealOpenMM* obc
CpuImplicitSolvent::setCpuImplicitSolvent( cpuObc );
// set base file name, ...
//cpuObc->readInfoFile( "CpuImplicitSolventInfo" );
// include/do not include ACE approximation (nonpolar solvation)
cpuObc->setIncludeAceApproximation( includeAceApproximation );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment