BrookStreamFactory.h 5.83 KB
Newer Older
Mark Friedrichs's avatar
Mark Friedrichs committed
1
2
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
#ifndef OPENMM_BROOKSTREAMFACTORY_H_
#define OPENMM_BROOKSTREAMFACTORY_H_

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

#include "StreamFactory.h"
Mark Friedrichs's avatar
Update  
Mark Friedrichs committed
36
#include "Platform.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
37
38
39
40
41
42
43
44

namespace OpenMM {

/**
 * This StreamFactory creates all streams for BrookPlatform.
 */

class BrookStreamFactory : public StreamFactory {
Mark Friedrichs's avatar
Update  
Mark Friedrichs committed
45
46
47
48
49
50
51
52

   public:

      BrookStreamFactory( );
	  ~BrookStreamFactory( );

      // 'external' streams 

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
53
54
55
      static const std::string ParticlePositions;
      static const std::string ParticleVelocities;
      static const std::string ParticleForces;
Mark Friedrichs's avatar
Update  
Mark Friedrichs committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

      /** 
       * Create StreamImpl
       *
       * @param name     stream name
       * @param size     stream size
       * @param type     data type (float, float2, ...)
       * @param platform platform reference
       * @param context  context (currently ignored)
       * 
       * @return StreamImpl
       */
      
      StreamImpl* createStreamImpl( std::string name, int size, Stream::DataType type, const Platform& platform, OpenMMContextImpl& context ) const;

      /** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
72
       * Get particle stream width
Mark Friedrichs's avatar
Update  
Mark Friedrichs committed
73
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
74
       * @return particle stream width
Mark Friedrichs's avatar
Update  
Mark Friedrichs committed
75
76
77
78
       *
       *
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
79
      int getDefaultParticleStreamWidth( void ) const;
Mark Friedrichs's avatar
Update  
Mark Friedrichs committed
80
81

      /** 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
82
       * Set particle stream width
Mark Friedrichs's avatar
Update  
Mark Friedrichs committed
83
       * 
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
84
       * @param particleStreamWidth  particle stream width
Mark Friedrichs's avatar
Update  
Mark Friedrichs committed
85
86
87
       *
       * @return DefaultReturnValue
       *
Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
88
       * @throw OpenMMException if particleStreamWidth < 1
Mark Friedrichs's avatar
Update  
Mark Friedrichs committed
89
90
91
       *
       */

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
92
      int setDefaultParticleStreamWidth( int particleStreamWidth );
Mark Friedrichs's avatar
Update  
Mark Friedrichs committed
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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

      /** 
       * Get randomNumber stream width
       * 
       * @return randomNumber stream width
       *
       *
       */

      int getDefaultRandomNumberStreamWidth( void ) const;

      /** 
       * Set randomNumber stream width
       * 
       * @param randomNumberStreamWidth  randomNumber stream width
       *
       * @return DefaultReturnValue
       *
       * @throw OpenMMException if randomNumberStreamWidth < 1
       *
       */

      int setDefaultRandomNumberStreamWidth( int randomNumberStreamWidth );

      /** 
       * Get randomNumber stream size
       * 
       * @return randomNumber stream size
       *
       *
       */

      int getDefaultRandomNumberStreamSize( void ) const;

      /** 
       * Set randomNumber stream size
       * 
       * @param randomNumberStreamSize  randomNumber stream size
       *
       * @return DefaultReturnValue
       *
       * @throw OpenMMException if randomNumberStreamSize < 1
       *
       */

      int setDefaultRandomNumberStreamSize( int randomNumberStreamSize );

      /** 
       * Get default dangle value
       * 
       * @return default dangle value
       *
       */

      double getDefaultDangleValue( void ) const;

      /** 
       * Set default dangle value
       * 
       * @param DefaultDangleValue default dangle value
       *
       * @return DefaultReturnValue
       *
       */

      int setDefaultDangleValue( double defaultDangleValue );

   private:

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
162
      static const int DefaultStreamParticleWidth         = 32;
Mark Friedrichs's avatar
Update  
Mark Friedrichs committed
163

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
164
165
      static const int DefaultStreamRandomNumberWidth     = 1024;
      static const int DefaultStreamRandomNumberSize      = 1024*1024;
Mark Friedrichs's avatar
Update  
Mark Friedrichs committed
166
167
168
169
170
171

      static const double DefaultDangleValue;

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

Mark Friedrichs's avatar
Mods  
Mark Friedrichs committed
172
      int _defaultParticleStreamWidth;
Mark Friedrichs's avatar
Update  
Mark Friedrichs committed
173
174
175
176
177
178

      int _defaultStreamRandomNumberWidth;
      int _defaultStreamRandomNumberSize;

      double _defaultDangleValue;

Mark Friedrichs's avatar
Mark Friedrichs committed
179
180
181
182
183
};

} // namespace OpenMM

#endif /*OPENMM_BROOKSTREAMFACTORY_H_*/