NAMD
Public Member Functions | Public Attributes | List of all members
ComputeCylindricalBC Class Reference

#include <ComputeCylindricalBC.h>

Inheritance diagram for ComputeCylindricalBC:
ComputeHomePatch Compute

Public Member Functions

 ComputeCylindricalBC (ComputeID c, PatchID pid)
 
virtual ~ComputeCylindricalBC ()
 
virtual void doForce (FullAtom *p, Results *r)
 
- Public Member Functions inherited from ComputeHomePatch
 ComputeHomePatch (ComputeID c, PatchID pid)
 
virtual ~ComputeHomePatch ()
 
virtual void initialize ()
 
virtual void atomUpdate ()
 
virtual void doWork ()
 
- Public Member Functions inherited from Compute
 Compute (ComputeID)
 
int type ()
 
virtual ~Compute ()
 
void setNumPatches (int n)
 
int getNumPatches ()
 
virtual void patchReady (PatchID, int doneMigration, int seq)
 
virtual int noWork ()
 
virtual void finishPatch (int)
 
int sequence (void)
 
int priority (void)
 
int getGBISPhase (void)
 
virtual void gbisP2PatchReady (PatchID, int seq)
 
virtual void gbisP3PatchReady (PatchID, int seq)
 

Public Attributes

SubmitReductionreduction
 
- Public Attributes inherited from Compute
const ComputeID cid
 
LDObjHandle ldObjHandle
 
LocalWorkMsg *const localWorkMsg
 

Additional Inherited Members

- Protected Member Functions inherited from Compute
void enqueueWork ()
 
- Protected Attributes inherited from ComputeHomePatch
int numAtoms
 
Patchpatch
 
HomePatchhomePatch
 
- Protected Attributes inherited from Compute
int computeType
 
int basePriority
 
int gbisPhase
 
int gbisPhasePriority [3]
 

Detailed Description

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 13 of file ComputeCylindricalBC.h.

Constructor & Destructor Documentation

ComputeCylindricalBC::ComputeCylindricalBC ( ComputeID  c,
PatchID  pid 
)

Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 25 of file ComputeCylindricalBC.C.

References SimParameters::cylindricalBCAxis, SimParameters::cylindricalBCexp1, SimParameters::cylindricalBCexp2, SimParameters::cylindricalBCk1, SimParameters::cylindricalBCk2, SimParameters::cylindricalBCl1, SimParameters::cylindricalBCl2, SimParameters::cylindricalBCr1, SimParameters::cylindricalBCr2, SimParameters::cylindricalCenter, FALSE, Node::Object(), ReductionMgr::Object(), reduction, REDUCTIONS_BASIC, Node::simParameters, simParams, TRUE, and ReductionMgr::willSubmit().

26  : ComputeHomePatch(c,pid)
27 {
29 
31 
32  // Get parameters from the SimParameters object
33  axis = simParams->cylindricalBCAxis;
34  r1 = simParams->cylindricalBCr1;
35  r2 = simParams->cylindricalBCr2;
36  r1_2 = r1*r1;
37  r2_2 = r2*r2;
38  k1 = simParams->cylindricalBCk1;
39  k2 = simParams->cylindricalBCk2;
40  exp1 = simParams->cylindricalBCexp1;
41  exp2 = simParams->cylindricalBCexp2;
42  //Additions for ends
43  l1 = simParams->cylindricalBCl1;
44  l2 = simParams->cylindricalBCl2;
45  l1_2 = l1*l1;
46  l2_2 = l2*l2;
47 
48  // Check to see if this is one set of parameters or two
49  if (r2 > -1.0)
50  {
51  twoForces = TRUE;
52  }
53  else
54  {
55  twoForces = FALSE;
56  }
57 
58  center = simParams->cylindricalCenter;
59 
60 }
static Node * Object()
Definition: Node.h:86
SubmitReduction * reduction
BigReal cylindricalBCl1
BigReal cylindricalBCl2
SimParameters * simParameters
Definition: Node.h:178
#define FALSE
Definition: common.h:116
SubmitReduction * willSubmit(int setID, int size=-1)
Definition: ReductionMgr.C:365
BigReal cylindricalBCk2
BigReal cylindricalBCk1
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:278
zVector cylindricalCenter
char cylindricalBCAxis
BigReal cylindricalBCr2
#define simParams
Definition: Output.C:127
BigReal cylindricalBCr1
#define TRUE
Definition: common.h:117
ComputeHomePatch(ComputeID c, PatchID pid)
ComputeCylindricalBC::~ComputeCylindricalBC ( )
virtual

Definition at line 72 of file ComputeCylindricalBC.C.

References reduction.

74 {
75  delete reduction;
76 }
SubmitReduction * reduction

Member Function Documentation

void ComputeCylindricalBC::doForce ( FullAtom p,
Results r 
)
virtual

Implements ComputeHomePatch.

Definition at line 93 of file ComputeCylindricalBC.C.

References Results::f, forces, SubmitReduction::item(), Results::normal, ComputeHomePatch::numAtoms, CompAtom::position, reduction, REDUCTION_BC_ENERGY, SubmitReduction::submit(), Vector::x, x, Vector::y, and Vector::z.

94 {
95  Vector diff; // Distance from atom to center of cylinder
96  Vector f; // Calculated force vector
97  int i, j; // Loop counters
98  BigReal dist, dist_2; // Distance from atom to center, and this
99  // distance squared
100  BigReal rval; // Difference between distance from atom
101  // to center and radius of cylinder
102  BigReal eval; // Energy value for this atom
103  BigReal fval; // Force magnitude for this atom
104 
105  // aliases to work with old code
106  FullAtom *x = p;
107  Force *forces = r->f[Results::normal];
108  BigReal energy = 0;
109 
110  // Loop through and check each atom
111  for (i=0; i<numAtoms; i++)
112  {
113  // Calculate the vector from the atom to the center of the
114  // cylinder
115  diff.x = ( axis == 'x' ? 0.0 : x[i].position.x - center.x );
116  diff.y = ( axis == 'y' ? 0.0 : x[i].position.y - center.y );
117  diff.z = ( axis == 'z' ? 0.0 : x[i].position.z - center.z );
118 
119  // Calculate the distance squared
120  dist_2 = diff.x*diff.x + diff.y*diff.y + diff.z*diff.z;
121 
122  // Look to see if we are outside either radius
123  if ( (dist_2 > r1_2) || (twoForces && (dist_2 > r2_2)) )
124  {
125  // Calculate the distance to the center
126  dist = sqrt(dist_2);
127 
128  // Normalize the direction vector
129  diff /= dist;
130 
131  // Check to see if we are outside radius 1
132  if (dist > r1)
133  {
134  // Assign the force vector to the
135  // unit direction vector
136  f.x = diff.x;
137  f.y = diff.y;
138  f.z = diff.z;
139 
140  // Calculate the energy which is
141  // e = k1*(r_i-r_center)^exp1
142  eval = k1;
143  rval = fabs(dist - r1);
144 
145  for (j=0; j<exp1; j++)
146  {
147  eval *= rval;
148  }
149 
150  energy += eval;
151 
152  // Now calculate the force which is
153  // e = -k1*exp1*(r_i-r_center1)^(exp1-1)
154  fval = -exp1*k1;
155 
156  for (j=0; j<exp1-1; j++)
157  {
158  fval *= rval;
159  }
160 
161  // Multiply the force magnitude to the
162  // unit direction vector to get the
163  // resulting force
164  f *= fval;
165 
166  // Add the force to the force vectors
167  forces[i].x += f.x;
168  forces[i].y += f.y;
169  forces[i].z += f.z;
170  }
171 
172  // Check to see if there is a second radius
173  // and if we are outside of it
174  if (twoForces && (dist > r2) )
175  {
176  // Assign the force vector to the
177  // unit direction vector
178  f.x = diff.x;
179  f.y = diff.y;
180  f.z = diff.z;
181 
182  // Calculate the energy which is
183  // e = k2*(r_i-r_center2)^exp2
184  eval = k2;
185  rval = fabs(dist - r2);
186 
187  for (j=0; j<exp2; j++)
188  {
189  eval *= rval;
190  }
191 
192  energy += eval;
193 
194  // Now calculate the force which is
195  // e = -k2*exp2*(r_i-r_center2)^(exp2-1)
196  fval = -exp2*k2;
197 
198  for (j=0; j<exp2-1; j++)
199  {
200  fval *= rval;
201  }
202 
203  // Multiply the force magnitude to the
204  // unit direction vector to get the
205  // resulting force
206  f *= fval;
207 
208  // Add the force to the force vectors
209  forces[i].x += f.x;
210  forces[i].y += f.y;
211  forces[i].z += f.z;
212  }
213  }
214  }
215  // Loop through and check each atom
216  for (i=0; i<numAtoms; i++)
217  {
218  // Calculate the vector from the atom to the center of the
219  // cylinder
220  diff.x = ( axis != 'x' ? 0.0 : x[i].position.x - center.x );
221  diff.y = ( axis != 'y' ? 0.0 : x[i].position.y - center.y );
222  diff.z = ( axis != 'z' ? 0.0 : x[i].position.z - center.z );
223 
224  // Calculate the distance squared
225  dist_2 = diff.x*diff.x + diff.y*diff.y + diff.z*diff.z;
226 
227  // Look to see if we are outside either radius
228  if ( (dist_2 > l1_2) || (twoForces && (dist_2 > l2_2)) )
229  {
230  // Calculate the distance to the center
231  dist = sqrt(dist_2);
232 
233  // Normalize the direction vector
234  diff /= dist;
235 
236  // Check to see if we are outside radius 1
237  if (dist > l1)
238  {
239 //printf ("Do faces one force z=%f\n", dist);
240  // Assign the force vector to the
241  // unit direction vector
242  f.x = diff.x;
243  f.y = diff.y;
244  f.z = diff.z;
245 
246  // Calculate the energy which is
247  // e = k1*(r_i-r_center)^exp1
248  eval = k1;
249  rval = fabs(dist - l1);
250 
251  for (j=0; j<exp1; j++)
252  {
253  eval *= rval;
254  }
255 
256  energy += eval;
257 
258  // Now calculate the force which is
259  // e = -k1*exp1*(r_i-r_center1)^(exp1-1)
260  fval = -exp1*k1;
261 
262  for (j=0; j<exp1-1; j++)
263  {
264  fval *= rval;
265  }
266 
267  // Multiply the force magnitude to the
268  // unit direction vector to get the
269  // resulting force
270  f *= fval;
271 
272  // Add the force to the force vectors
273  forces[i].x += f.x;
274  forces[i].y += f.y;
275  forces[i].z += f.z;
276  }
277 
278  // Check to see if there is a second radius
279  // and if we are outside of it
280  if (twoForces && (dist > l2) )
281  {
282 //printf ("Do faces two force z=%f\n", dist);
283  // Assign the force vector to the
284  // unit direction vector
285  f.x = diff.x;
286  f.y = diff.y;
287  f.z = diff.z;
288 
289  // Calculate the energy which is
290  // e = k2*(r_i-r_center2)^exp2
291  eval = k2;
292  rval = fabs(dist - l2);
293 
294  for (j=0; j<exp2; j++)
295  {
296  eval *= rval;
297  }
298 
299  energy += eval;
300 
301  // Now calculate the force which is
302  // e = -k2*exp2*(r_i-r_center2)^(exp2-1)
303  fval = -exp2*k2;
304 
305  for (j=0; j<exp2-1; j++)
306  {
307  fval *= rval;
308  }
309 
310  // Multiply the force magnitude to the
311  // unit direction vector to get the
312  // resulting force
313  f *= fval;
314 
315  // Add the force to the force vectors
316  forces[i].x += f.x;
317  forces[i].y += f.y;
318  forces[i].z += f.z;
319  }
320  }
321  }
322 
323  reduction->item(REDUCTION_BC_ENERGY) += energy;
324  reduction->submit();
325 
326 }
SubmitReduction * reduction
Definition: Vector.h:64
static __thread float4 * forces
BigReal & item(int i)
Definition: ReductionMgr.h:312
BigReal z
Definition: Vector.h:66
Position position
Definition: NamdTypes.h:53
Force * f[maxNumForces]
Definition: PatchTypes.h:67
BigReal x
Definition: Vector.h:66
BigReal y
Definition: Vector.h:66
void submit(void)
Definition: ReductionMgr.h:323
gridSize x
double BigReal
Definition: common.h:112

Member Data Documentation

SubmitReduction* ComputeCylindricalBC::reduction

Definition at line 37 of file ComputeCylindricalBC.h.

Referenced by ComputeCylindricalBC(), doForce(), and ~ComputeCylindricalBC().


The documentation for this class was generated from the following files: