BrookCommon.h 10.1 KB
Newer Older
Mark Friedrichs's avatar
Mark Friedrichs committed
1
2
#ifndef OPENMM_BROOK_COMMON_H_
#define OPENMM_BROOK_COMMON_H_
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

/* -------------------------------------------------------------------------- *
 *                                   OpenMM                                   *
 * -------------------------------------------------------------------------- *
 * This is part of the OpenMM molecular simulation toolkit originating from   *
 * Simbios, the NIH National Center for Physics-Based Simulation of           *
 * Biological Structures at Stanford, funded under the NIH Roadmap for        *
 * Medical Research, grant U54 GM072970. See https://simtk.org.               *
 *                                                                            *
 * Portions copyright (c) 2008 Stanford University and the Authors.           *
 * Authors: Peter Eastman, Mark Friedrichs                                    *
 * Contributors:                                                              *
 *                                                                            *
 * Permission is hereby granted, free of charge, to any person obtaining a    *
 * copy of this software and associated documentation files (the "Software"), *
 * to deal in the Software without restriction, including without limitation  *
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
 * and/or sell copies of the Software, and to permit persons to whom the      *
 * Software is furnished to do so, subject to the following conditions:       *
 *                                                                            *
 * The above copyright notice and this permission notice shall be included in *
 * all copies or substantial portions of the Software.                        *
 *                                                                            *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
 * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,    *
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR      *
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE  *
 * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
 * -------------------------------------------------------------------------- */

#include <vector>
#include <set>

Mark Friedrichs's avatar
Mark Friedrichs committed
38
39
#include "BrookFloatStreamInternal.h"
#include "BrookIntStreamInternal.h"
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "BrookPlatform.h"

namespace OpenMM {

/**
 * This kernel is invoked by StandardMMForceField to calculate the forces acting on the system.
 */
class BrookCommon {

   public:
  
      // return values

      static const int DefaultReturnValue = 0;
      static const int ErrorReturnValue   = -1;

Mark Friedrichs's avatar
Mark Friedrichs committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
      // ---------------------------------------------------------------------------------------

      // Stream names
     
      // bonded stream names

      static const std::string BondedAtomIndicesStream;
      static const std::string BondedParametersStream;
      static const std::string UnrolledForceStream;
      static const std::string BondedChargeStream;
      static const std::string BondedInverseMapStreams;

      // nonbonded stream names

      static const std::string NonBondedExclusionStream;
      static const std::string OuterVdwStream;
      static const std::string InnerSigmaStream;
      static const std::string InnerEpsilonStream;
      static const std::string NonBondedChargeStream;
      static const std::string PartialForceStream;

      // OBC Gbsa streams

      static const std::string ObcAtomicRadiiStream;
      static const std::string ObcScaledAtomicRadiiStream;
      static const std::string ObcAtomicRadiiWithDielectricOffsetStream;
      static const std::string ObcBornRadiiStream;
      static const std::string ObcBornRadii2Stream;
      static const std::string ObcIntermediateForceStream;
      static const std::string ObcChainStream;

Mark Friedrichs's avatar
Mark Friedrichs committed
87
88
89
90
91
92
      // Stochastic Dynamics streams

      static const std::string SDPC1Stream;
      static const std::string SDPC2Stream;
      static const std::string SD2XStream;
      static const std::string SD1VStream;
Mark Friedrichs's avatar
Mark Friedrichs committed
93
94
95
      static const std::string VPrimeStream;
      static const std::string XPrimeStream;
      static const std::string InverseMassStream;
Mark Friedrichs's avatar
Mark Friedrichs committed
96
97
98
99
100
101
102
103
104
105
106

      // Shake streams

      static const std::string ShakeAtomIndicesStream;
      static const std::string ShakeAtomParameterStream;
      static const std::string ShakeXCons0Stream;
      static const std::string ShakeXCons1Stream;
      static const std::string ShakeXCons2Stream;
      static const std::string ShakeXCons3Stream;
      static const std::string ShakeInverseMapStream;

Mark Friedrichs's avatar
Mark Friedrichs committed
107
108
109
110
      // Random number generator streams

      static const std::string ShuffleStream;

111
112
113
114
115
      // BrookVelocityCenterOfMassRemoval streams

      static const std::string BrookVelocityCenterOfMassRemovalWorkStream;
      static const std::string BrookVelocityCenterOfMassRemovalMassStream;

Mark Friedrichs's avatar
Mark Friedrichs committed
116
117
118
119
120
121
122
      // ---------------------------------------------------------------------------------------

     /** 
      * Constructor
      * 
      */
     
123
124
      BrookCommon( );
  
Mark Friedrichs's avatar
Mark Friedrichs committed
125
126
127
128
129
     /** 
      * Destructor
      * 
      */
     
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
      ~BrookCommon();
  
      /**
       * Return number of atoms
       * 
       * @return number of atoms
       *
       */

      int getNumberOfAtoms( void ) const; 

      /** 
       * Get atom ceiling parameter
       * 
       * @return atom ceiling parameter
       *
       */
      
      int getAtomSizeCeiling( void ) const;
      
      /**
       * Get atom stream width
       *
       * @param platform platform reference
       *
       * @return atom stream width
       */

      int getAtomStreamWidth( const Platform& platform ); 

      /**
       * Get atom stream width
       *
       * @return atom stream width
       */

      int getAtomStreamWidth( void ) const; 

      /**
       * Get atom stream height
       *
       * @param platform platform reference
       *
       * @return atom stream height
       */

      int getAtomStreamHeight( const Platform& platform ); 

      /**
       * Get atom stream height
       *
       * @return atom stream height
       */

      int getAtomStreamHeight( void ) const;

      /**
       * Get atom stream size
       * 
       * @param platform platform reference
       *
       * @return atom stream size
       */

      int getAtomStreamSize( const Platform& platform ); 

      /**
       * Get atom stream size
       * 
       * @return atom stream size
       */

      int getAtomStreamSize( void ) const; 

      /** 
       * Set log file reference
       * 
       * @param  log file reference
       *
       * @return DefaultReturnValue
       *
       */
      
      int setLog( FILE* log );

      /* 
       * Get contents of object
       *
       * @param level of dump
       *
       * @return string containing contents
       *
       * */
      
      std::string getContents( int level ) const;

Mark Friedrichs's avatar
Mark Friedrichs committed
226
227
228
229
230
231
232
233
      /** 
       * Get log file reference
       * 
       * @return  log file reference
       *
       */
      
      FILE* getLog( void ) const;
Mark Friedrichs's avatar
Mark Friedrichs committed
234

Mark Friedrichs's avatar
Mark Friedrichs committed
235
      /** 
Mark Friedrichs's avatar
Mark Friedrichs committed
236
       * Get verbose flag
Mark Friedrichs's avatar
Mark Friedrichs committed
237
238
239
240
241
242
243
244
245
246
247
248
249
250
       *
       * @return  verbosity flag
       *
       */
    
      int getVerbosity( void ) const;

      /** 
       * Set verbosity flag
       *
       * @param verbosity flag
       *
       */
    
Mark Friedrichs's avatar
Mark Friedrichs committed
251
      int setVerbosity( int verbosity );
Mark Friedrichs's avatar
Mark Friedrichs committed
252

Mark Friedrichs's avatar
Mark Friedrichs committed
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
      /* 
       * Given number of stream elements and width, returns the appropriate
       * height of the stream
       *
       * @param streamSize   stream size 
       * @param width        stream width
       *
       * @return stream height
       *
       */
      
      static int getStreamHeight( int streamSize, int streamWidth );
      
      /* 
       * Given number of stream elements, get stream width & height
       *
       * @param streamSize    stream size 
       * @param streamWidth   output stream width
       * @param streamHeight  output stream height
       *
       * @return stream height
       *
       */
      
      static void getStreamDimensions( int streamSize, int *streamWidth, int *streamHeight );
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313

      /* 
       * Allocate array
       *
       * @param length        length of array
       * @param width         width  of array
       *
       * @return ptr to array
       *
       */
      
      RealOpenMM** allocateRealArray( int length, int width ) const;
      
      /* 
       * Free array
       *
       * @param array         array to be freed (assumed allocated using BrookCommon::allocateRealArray
       *
       * @return DefaultReturnValue
       *
       */
      
      int disposeRealArray( RealOpenMM** array ) const;

      /* 
       * Copy 1D BrookOpenMMFloat* array to 2D array of RealOpenMM
       *
       * @param length        length of array
       * @param width         width  of array
       * @param array1D       array to copy
       *
       * @return ptr to array
       *
       */
      
      RealOpenMM** copy1DArrayTo2DArray( int length, int width, BrookOpenMMFloat* array1D ) const;
Mark Friedrichs's avatar
Mark Friedrichs committed
314
      
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
   protected:
   
      // number of atoms

      int _numberOfAtoms;

      // atom stream dimensions

      int _atomStreamWidth;
      int _atomStreamHeight;
      int _atomStreamSize;

      // atom size mod

      int _atomSizeModified;

      // log file reference

      FILE* _log;

Mark Friedrichs's avatar
Mark Friedrichs committed
335
336
337
338
      // verbosity

      int _verbosity;

339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
      /**
       * Set number of atoms
       * 
       * @param numberOfAtoms number of atoms
       *
       */

      int setNumberOfAtoms( int numberOfAtoms ); 

      /** 
       * Get atom stream dimensions
       * 
       * @param platform                  platform
       *
       */
      
      void _getAtomStreamDimensions( const Platform& platform );
      
      /* 
       * Get line
       *
       * @param tab         tab
       * @param description description
       * @param value       value
       *
       * @return string containing contents
       *
       * */
      
      std::string _getLine( const std::string& tab, const std::string& description, const std::string& value ) const;
      
};

} // namespace OpenMM

Mark Friedrichs's avatar
Mark Friedrichs committed
374
#endif /* OPENMM_BROOK_COMMON_H_ */