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

#include <ComputeStir.h>

Inheritance diagram for ComputeStir:
ComputeHomePatch Compute

Public Member Functions

 ComputeStir (ComputeID c, PatchID pid)
 
virtual ~ComputeStir ()
 
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,2001 by The Board of Trustees of the University of Illinois. All rights reserved.

Definition at line 18 of file ComputeStir.h.

Constructor & Destructor Documentation

ComputeStir::ComputeStir ( ComputeID  c,
PatchID  pid 
)

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

Definition at line 19 of file ComputeStir.C.

References Node::Object(), ReductionMgr::Object(), reduction, REDUCTIONS_BASIC, Node::simParameters, simParams, SimParameters::stirAxis, SimParameters::stirPivot, Vector::unit(), and ReductionMgr::willSubmit().

20  : ComputeHomePatch(c,pid)
21 {
22 
23 
24 
25 
27  axisUnit = simParams->stirAxis.unit();
28  pivot = simParams->stirPivot;
29 
30 
32 
33  //nitVars(p, axisDir);
34  initVars();
35 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:178
SubmitReduction * willSubmit(int setID, int size=-1)
Definition: ReductionMgr.C:365
zVector stirPivot
SubmitReduction * reduction
Definition: ComputeStir.h:27
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:278
zVector stirAxis
#define simParams
Definition: Output.C:127
Vector unit(void) const
Definition: Vector.h:182
ComputeHomePatch(ComputeID c, PatchID pid)
ComputeStir::~ComputeStir ( )
virtual

Definition at line 39 of file ComputeStir.C.

References reduction.

41 {
42 delete reduction;
43 }
SubmitReduction * reduction
Definition: ComputeStir.h:27

Member Function Documentation

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

Implements ComputeHomePatch.

Definition at line 288 of file ComputeStir.C.

References ADD_TENSOR_OBJECT, ADD_VECTOR_OBJECT, cross(), Vector::dot(), Results::f, Patch::flags, forces, Molecule::get_stir_startTheta(), ComputeHomePatch::homePatch, CompAtomExt::id, Molecule::is_atom_stirred(), SubmitReduction::item(), Patch::lattice, Vector::length(), Node::molecule, Results::normal, ComputeHomePatch::numAtoms, CollectionMgr::Object(), Node::Object(), outer(), ComputeHomePatch::patch, reduction, REDUCTION_MISC_ENERGY, Lattice::reverse_transform(), CollectionMgr::sendDataStream(), Node::simParameters, Flags::step, SimParameters::stirK, SubmitReduction::submit(), Vector::x, Vector::y, and Vector::z.

288  {
289 
290 
291  Molecule *molecule = Node::Object()->molecule;
293  Lattice &lattice = homePatch->lattice;
294  char statbuf[1024];
295  Vector curPos; //current atom position
296  Vector proj; //projection on the axis ray
297  Vector forceDir; //direction to apply force in for torque
298  Vector theForce; // the force to apply
299  Vector targPos; //target Position
300  BigReal rayDist, height,targTheta,forceMag;
301  //intermediate calc. results for readability
302 
303  //convert from degrees/timestep to radians/timestep
304  int currentStep = patch->flags.step;
305 
306  //Vector = simParams->eField;
308 
309  int GlobalId;
310  Force *forces = r->f[Results::normal];
311  BigReal energy = 0;
312  Force extForce = 0.;
313  Tensor extVirial;
314 
315  //CkPrintf("DEBUG: In ComputeStir::doForce");
316  // Loop through and check each atom
317  //CkPrintf ("DEBUG: now to loop atoms, numAtoms = %d\n",numAtoms);
318  for (int i=0; i<numAtoms; i++) {
319  if (molecule->is_atom_stirred(p[i].id))
320  {
321  //CkPrintf ("DEBUG: now to get stir params");
322 
323 
324  molecule->get_stir_startTheta (p[i].id);
325 
326  curPos = lattice.reverse_transform(p[i].position,p[i].transform);
327 
328  rayDist = distanceToRay(axisUnit,pivot,curPos);
329  proj = projectionOnRay (axisUnit,pivot,curPos);
330  height = findHeight (proj);
331  targTheta = (omega * currentStep) + \
332  startingTheta + \
333  molecule->get_stir_startTheta (p[i].id);
334 
335  targPos = placeThetaRadius (targTheta,height,rayDist);
336 
337  //project the actual displacement ontoh a unit vector along ( (axis) cross (moment arm) ),
338  //so we are applying only a torque
339 
340  forceDir = (cross(axisUnit, (curPos - proj))).unit();
341  forceMag = forceDir.dot(targPos - curPos);
342 
343  //unitDisp = disp.unit();
344 
345  theForce = (simParams->stirK) * forceMag * forceDir;
346 
347  forces[i] += theForce;
348  extForce += theForce;
349  extVirial += outer(theForce,curPos);
350 
351 
352  //CkPrintf ("DEBUG: now to get sprintf x y z's");
353  sprintf (statbuf, "DEBUG: step= %d atom i= %d globID= %d T= %g %g %g C= %g %g %g F= %g %g %g startTheta= %g targTheta= %g forceMag= %g F.len= %g FC.len= %g\n",currentStep,i,p[i].id, targPos.x, targPos.y, targPos.z, curPos.x, curPos.y, curPos.z,theForce.x, theForce.y, theForce.z, molecule->get_stir_startTheta (p[i].id), targTheta, forceMag, theForce.length(), forces[i].length());
354 
355 
357 
359 
360  }
361 
362  //CkPrintf ("DEBUG: got past check for stirred\n");
363  //GlobalId = p[i].id;
364  //sprintf (statbuf, "DEBUG: i= %d Global= %d\n",i,GlobalId);
365  //dout << "DEBUG: i= " << i << " Global=" << GlobalId <<"\n"<<endd;
366  //CollectionMgr::Object()->sendDataStream(statbuf);
367 
368  }
369 
371  ADD_VECTOR_OBJECT(reduction,REDUCTION_EXT_FORCE_NORMAL,extForce);
372  ADD_TENSOR_OBJECT(reduction,REDUCTION_VIRIAL_NORMAL,extVirial);
373  reduction->submit();
374 
375 }
static Node * Object()
Definition: Node.h:86
static CollectionMgr * Object()
Definition: CollectionMgr.h:30
Lattice & lattice
Definition: Patch.h:126
Definition: Vector.h:64
#define ADD_TENSOR_OBJECT(R, RL, D)
Definition: ReductionMgr.h:43
SimParameters * simParameters
Definition: Node.h:178
static __thread float4 * forces
BigReal & item(int i)
Definition: ReductionMgr.h:312
__device__ __forceinline__ float3 cross(const float3 v1, const float3 v2)
BigReal z
Definition: Vector.h:66
Real get_stir_startTheta(int atomnum) const
Definition: Molecule.h:1314
SubmitReduction * reduction
Definition: ComputeStir.h:27
BigReal length(void) const
Definition: Vector.h:169
Flags flags
Definition: Patch.h:127
BigReal dot(const Vector &v2)
Definition: Vector.h:222
Bool is_atom_stirred(int atomnum) const
Definition: Molecule.h:1428
Force * f[maxNumForces]
Definition: PatchTypes.h:67
BigReal x
Definition: Vector.h:66
Tensor outer(const Vector &v1, const Vector &v2)
Definition: Tensor.h:241
#define simParams
Definition: Output.C:127
Position reverse_transform(Position data, const Transform &t) const
Definition: Lattice.h:138
Definition: Tensor.h:15
BigReal y
Definition: Vector.h:66
#define ADD_VECTOR_OBJECT(R, RL, D)
Definition: ReductionMgr.h:27
void submit(void)
Definition: ReductionMgr.h:323
Molecule * molecule
Definition: Node.h:176
void sendDataStream(const char *)
HomePatch * homePatch
double BigReal
Definition: common.h:112
int step
Definition: PatchTypes.h:16

Member Data Documentation

SubmitReduction* ComputeStir::reduction

Definition at line 27 of file ComputeStir.h.

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


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