NAMD
Classes | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
HomePatch Class Reference

#include <HomePatch.h>

Inheritance diagram for HomePatch:
Patch

Classes

struct  checkpoint_t
 
struct  RattleList
 

Public Member Functions

 ~HomePatch ()
 
void registerProxy (RegisterProxyMsg *)
 
void unregisterProxy (UnregisterProxyMsg *)
 
void receiveResults (ProxyResultVarsizeMsg *msg)
 
void receiveResults (ProxyResultMsg *msg)
 
void receiveResult (ProxyGBISP1ResultMsg *msg)
 
void receiveResult (ProxyGBISP2ResultMsg *msg)
 
void receiveResults (ProxyCombinedResultRawMsg *msg)
 
void depositMigration (MigrateAtomsMsg *)
 
void useSequencer (Sequencer *sequencerPtr)
 
void runSequencer (void)
 
void positionsReady (int doMigration=0)
 
void saveForce (const int ftag=Results::normal)
 
void addForceToMomentum (FullAtom *__restrict atom_arr, const Force *__restrict force_arr, const BigReal dt, int num_atoms)
 
void addForceToMomentum3 (FullAtom *__restrict atom_arr, const Force *__restrict force_arr1, const Force *__restrict force_arr2, const Force *__restrict force_arr3, const BigReal dt1, const BigReal dt2, const BigReal dt3, int num_atoms)
 
void addVelocityToPosition (FullAtom *__restrict atom_arr, const BigReal dt, int num_atoms)
 
int hardWallDrude (const BigReal, Tensor *virial, SubmitReduction *)
 
void addRattleForce (const BigReal invdt, Tensor &wc)
 
void buildRattleList ()
 
int rattle1old (const BigReal, Tensor *virial, SubmitReduction *)
 
int rattle1 (const BigReal, Tensor *virial, SubmitReduction *)
 
void rattle2 (const BigReal, Tensor *virial)
 
void minimize_rattle2 (const BigReal, Tensor *virial, bool forces=false)
 
void mollyAverage ()
 
void mollyMollify (Tensor *virial)
 
void loweAndersenVelocities ()
 
void loweAndersenFinish ()
 
void setGBISIntrinsicRadii ()
 
void gbisComputeAfterP1 ()
 
void gbisComputeAfterP2 ()
 
void gbisP2Ready ()
 
void gbisP3Ready ()
 
void setLcpoType ()
 
void checkpoint (void)
 
void revert (void)
 
void exchangeCheckpoint (int scriptTask, int &bpc)
 
void recvCheckpointReq (int task, const char *key, int replica, int pe)
 
void recvCheckpointLoad (CheckpointAtomsMsg *msg)
 
void recvCheckpointStore (CheckpointAtomsMsg *msg)
 
void recvCheckpointAck ()
 
void exchangeAtoms (int scriptTask)
 
void recvExchangeReq (int req)
 
void recvExchangeMsg (ExchangeAtomsMsg *msg)
 
void replaceForces (ExtForce *f)
 
void qmSwapAtoms ()
 
void submitLoadStats (int timestep)
 
FullAtomListgetAtomList ()
 
void buildSpanningTree (void)
 
void sendNodeAwareSpanningTree ()
 
void recvNodeAwareSpanningTree (ProxyNodeAwareSpanningTreeMsg *msg)
 
void sendSpanningTree ()
 
void recvSpanningTree (int *t, int n)
 
void sendProxies ()
 
- Public Member Functions inherited from Patch
 Patch (PatchID pd)
 
int hasNewAtoms ()
 
virtual ~Patch ()
 
Box< Patch, CompAtom > * registerPositionPickup (Compute *cid)
 
void unregisterPositionPickup (Compute *cid, Box< Patch, CompAtom > **const box)
 
Box< Patch, CompAtom > * registerAvgPositionPickup (Compute *cid)
 
void unregisterAvgPositionPickup (Compute *cid, Box< Patch, CompAtom > **const box)
 
Box< Patch, CompAtom > * registerVelocityPickup (Compute *cid)
 
void unregisterVelocityPickup (Compute *cid, Box< Patch, CompAtom > **const box)
 
Box< Patch, Real > * registerIntRadPickup (Compute *cid)
 
void unregisterIntRadPickup (Compute *cid, Box< Patch, Real > **const box)
 
Box< Patch, GBReal > * registerPsiSumDeposit (Compute *cid)
 
void unregisterPsiSumDeposit (Compute *cid, Box< Patch, GBReal > **const box)
 
Box< Patch, Real > * registerBornRadPickup (Compute *cid)
 
void unregisterBornRadPickup (Compute *cid, Box< Patch, Real > **const box)
 
Box< Patch, GBReal > * registerDEdaSumDeposit (Compute *cid)
 
void unregisterDEdaSumDeposit (Compute *cid, Box< Patch, GBReal > **const box)
 
Box< Patch, Real > * registerDHdrPrefixPickup (Compute *cid)
 
void unregisterDHdrPrefixPickup (Compute *cid, Box< Patch, Real > **const box)
 
Box< Patch, int > * registerLcpoTypePickup (Compute *cid)
 
void unregisterLcpoTypePickup (Compute *cid, Box< Patch, int > **const box)
 
Box< Patch, Results > * registerForceDeposit (Compute *cid)
 
void unregisterForceDeposit (Compute *cid, Box< Patch, Results > **const box)
 
void positionsReady (int n=0)
 
void positionBoxClosed (void)
 
void forceBoxClosed (void)
 
void avgPositionBoxClosed (void)
 
void velocityBoxClosed (void)
 
void intRadBoxClosed (void)
 
void psiSumBoxClosed (void)
 
void bornRadBoxClosed (void)
 
void dEdaSumBoxClosed (void)
 
void dHdrPrefixBoxClosed (void)
 
void gbisP2Ready ()
 
void gbisP3Ready ()
 
void lcpoTypeBoxClosed (void)
 
int getNumAtoms ()
 
int getNumFixedAtoms ()
 
void setNumFixedAtoms (int numFixed)
 
PatchID getPatchID ()
 
int getNumComputes ()
 
CompAtomExtgetCompAtomExtInfo ()
 
CudaAtomgetCudaAtomList ()
 

Public Attributes

int marginViolations
 
std::vector< int > settleList
 
std::vector< RattleListrattleList
 
std::vector< RattleParamrattleParam
 
std::vector< int > noconstList
 
bool rattleListValid
 
std::vector< VectorvelNew
 
std::vector< VectorposNew
 
int checkpoint_task
 
std::map< std::string,
checkpoint_t * > 
checkpoints
 
int exchange_dst
 
int exchange_src
 
int exchange_req
 
ExchangeAtomsMsgexchange_msg
 
LDObjHandle ldObjHandle
 
- Public Attributes inherited from Patch
Latticelattice
 
Flags flags
 

Protected Member Functions

virtual void boxClosed (int)
 
void doPairlistCheck ()
 
void doGroupSizeCheck ()
 
void doMarginCheck ()
 
void doAtomMigration ()
 

Protected Attributes

int inMigration
 
int numMlBuf
 
MigrateAtomsMsgmsgbuf [PatchMap::MaxOneAway]
 
- Protected Attributes inherited from Patch
const PatchID patchID
 
int numAtoms
 
int numFixedAtoms
 
CompAtomList p
 
CompAtomList p_avg
 
CompAtomList v
 
AtomMapperatomMapper
 
RealList intRad
 
GBRealList psiSum
 
GBRealList psiFin
 
RealList bornRad
 
RealList dHdrPrefix
 
GBRealList dEdaSum
 
IntList lcpoType
 
CompAtomExtList pExt
 
CompAtomavgPositionPtrBegin
 
CompAtomavgPositionPtrEnd
 
CompAtomvelocityPtrBegin
 
CompAtomvelocityPtrEnd
 
CudaAtomcudaAtomPtr
 
ForceList f [Results::maxNumForces]
 
Results results
 
int computesSortedByPriority
 
int firstHoldableCompute
 
OwnerBox< Patch, CompAtompositionBox
 
ComputePtrList positionComputeList
 
OwnerBox< Patch, CompAtomavgPositionBox
 
ComputePtrList avgPositionComputeList
 
OwnerBox< Patch, CompAtomvelocityBox
 
ComputePtrList velocityComputeList
 
OwnerBox< Patch, RealintRadBox
 
ComputePtrList intRadComputeList
 
OwnerBox< Patch, GBRealpsiSumBox
 
ComputePtrList psiSumComputeList
 
OwnerBox< Patch, RealbornRadBox
 
ComputePtrList bornRadComputeList
 
OwnerBox< Patch, GBRealdEdaSumBox
 
ComputePtrList dEdaSumComputeList
 
OwnerBox< Patch, RealdHdrPrefixBox
 
ComputePtrList dHdrPrefixComputeList
 
OwnerBox< Patch, int > lcpoTypeBox
 
ComputePtrList lcpoTypeComputeList
 
OwnerBox< Patch, ResultsforceBox
 
ComputePtrList forceComputeList
 
int boxesOpen
 
int _hasNewAtoms
 
int * child
 
int nChild
 

Friends

class PatchMgr
 
class Sequencer
 
class ComputeGlobal
 

Detailed Description

Definition at line 273 of file HomePatch.h.

Constructor & Destructor Documentation

HomePatch::~HomePatch ( )

Definition at line 321 of file HomePatch.C.

References Patch::atomMapper, ResizeArray< T >::begin(), ResizeArray< T >::end(), and AtomMapper::unregisterIDsFullAtom().

322 {
323  atomMapper->unregisterIDsFullAtom(atom.begin(),atom.end());
324 #ifdef NODEAWARE_PROXY_SPANNINGTREE
325  ptnTree.resize(0);
326  #ifdef USE_NODEPATCHMGR
327  delete [] nodeChildren;
328  #endif
329 #endif
330  delete [] child;
331 }
AtomMapper * atomMapper
Definition: Patch.h:152
iterator end(void)
Definition: ResizeArray.h:37
void unregisterIDsFullAtom(const FullAtom *begin, const FullAtom *end)
Definition: AtomMap.C:100
iterator begin(void)
Definition: ResizeArray.h:36

Member Function Documentation

void HomePatch::addForceToMomentum ( FullAtom *__restrict  atom_arr,
const Force *__restrict  force_arr,
const BigReal  dt,
int  num_atoms 
)

Definition at line 1932 of file HomePatch.C.

References SimParameters::fixedAtomsOn, num_atoms, Node::Object(), and Node::simParameters.

Referenced by Sequencer::addForceToMomentum().

1937  {
1939 
1940  if ( simParams->fixedAtomsOn ) {
1941  for ( int i = 0; i < num_atoms; ++i ) {
1942  if ( atom_arr[i].atomFixed ) {
1943  atom_arr[i].velocity = 0;
1944  } else {
1945  BigReal dt_mass = dt * atom_arr[i].recipMass; // dt/mass
1946  atom_arr[i].velocity.x += force_arr[i].x * dt_mass;
1947  atom_arr[i].velocity.y += force_arr[i].y * dt_mass;
1948  atom_arr[i].velocity.z += force_arr[i].z * dt_mass;
1949  }
1950  }
1951  } else {
1952  for ( int i = 0; i < num_atoms; ++i ) {
1953  BigReal dt_mass = dt * atom_arr[i].recipMass; // dt/mass
1954  atom_arr[i].velocity.x += force_arr[i].x * dt_mass;
1955  atom_arr[i].velocity.y += force_arr[i].y * dt_mass;
1956  atom_arr[i].velocity.z += force_arr[i].z * dt_mass;
1957  }
1958  }
1959 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:178
BigReal z
Definition: Vector.h:66
Velocity velocity
Definition: NamdTypes.h:101
BigReal x
Definition: Vector.h:66
#define simParams
Definition: Output.C:127
BigReal y
Definition: Vector.h:66
double recipMass
Definition: NamdTypes.h:103
static __thread int num_atoms
double BigReal
Definition: common.h:112
void HomePatch::addForceToMomentum3 ( FullAtom *__restrict  atom_arr,
const Force *__restrict  force_arr1,
const Force *__restrict  force_arr2,
const Force *__restrict  force_arr3,
const BigReal  dt1,
const BigReal  dt2,
const BigReal  dt3,
int  num_atoms 
)

Definition at line 1961 of file HomePatch.C.

References SimParameters::fixedAtomsOn, num_atoms, Node::Object(), and Node::simParameters.

Referenced by Sequencer::addForceToMomentum3().

1970  {
1972 
1973  if ( simParams->fixedAtomsOn ) {
1974  for ( int i = 0; i < num_atoms; ++i ) {
1975  if ( atom_arr[i].atomFixed ) {
1976  atom_arr[i].velocity = 0;
1977  } else {
1978  BigReal rmass = atom_arr[i].recipMass; // 1/mass
1979  atom_arr[i].velocity.x += (force_arr1[i].x*dt1
1980  + force_arr2[i].x*dt2 + force_arr3[i].x*dt3) * rmass;
1981  atom_arr[i].velocity.y += (force_arr1[i].y*dt1
1982  + force_arr2[i].y*dt2 + force_arr3[i].y*dt3) * rmass;
1983  atom_arr[i].velocity.z += (force_arr1[i].z*dt1
1984  + force_arr2[i].z*dt2 + force_arr3[i].z*dt3) * rmass;
1985  }
1986  }
1987  } else {
1988  for ( int i = 0; i < num_atoms; ++i ) {
1989  BigReal rmass = atom_arr[i].recipMass; // 1/mass
1990  atom_arr[i].velocity.x += (force_arr1[i].x*dt1
1991  + force_arr2[i].x*dt2 + force_arr3[i].x*dt3) * rmass;
1992  atom_arr[i].velocity.y += (force_arr1[i].y*dt1
1993  + force_arr2[i].y*dt2 + force_arr3[i].y*dt3) * rmass;
1994  atom_arr[i].velocity.z += (force_arr1[i].z*dt1
1995  + force_arr2[i].z*dt2 + force_arr3[i].z*dt3) * rmass;
1996  }
1997  }
1998 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:178
BigReal z
Definition: Vector.h:66
Velocity velocity
Definition: NamdTypes.h:101
BigReal x
Definition: Vector.h:66
#define simParams
Definition: Output.C:127
BigReal y
Definition: Vector.h:66
double recipMass
Definition: NamdTypes.h:103
static __thread int num_atoms
double BigReal
Definition: common.h:112
void HomePatch::addRattleForce ( const BigReal  invdt,
Tensor wc 
)

Definition at line 2371 of file HomePatch.C.

References Patch::f, Results::normal, Patch::numAtoms, outer(), and velNew.

Referenced by rattle1().

2371  {
2372  for (int ig = 0; ig < numAtoms; ++ig ) {
2373  Force df = (velNew[ig] - atom[ig].velocity) * ( atom[ig].mass * invdt );
2374  Tensor vir = outer(df, atom[ig].position);
2375  wc += vir;
2376  f[Results::normal][ig] += df;
2377  atom[ig].velocity = velNew[ig];
2378  }
2379 }
Definition: Vector.h:64
int numAtoms
Definition: Patch.h:144
Tensor outer(const Vector &v1, const Vector &v2)
Definition: Tensor.h:241
Definition: Tensor.h:15
std::vector< Vector > velNew
Definition: HomePatch.h:388
ForceList f[Results::maxNumForces]
Definition: Patch.h:207
void HomePatch::addVelocityToPosition ( FullAtom *__restrict  atom_arr,
const BigReal  dt,
int  num_atoms 
)

Definition at line 2000 of file HomePatch.C.

References SimParameters::fixedAtomsOn, num_atoms, Node::Object(), and Node::simParameters.

Referenced by Sequencer::addVelocityToPosition().

2004  {
2006  if ( simParams->fixedAtomsOn ) {
2007  for ( int i = 0; i < num_atoms; ++i ) {
2008  if ( ! atom_arr[i].atomFixed ) {
2009  atom_arr[i].position.x += atom_arr[i].velocity.x * dt;
2010  atom_arr[i].position.y += atom_arr[i].velocity.y * dt;
2011  atom_arr[i].position.z += atom_arr[i].velocity.z * dt;
2012  }
2013  }
2014  } else {
2015  for ( int i = 0; i < num_atoms; ++i ) {
2016  atom_arr[i].position.x += atom_arr[i].velocity.x * dt;
2017  atom_arr[i].position.y += atom_arr[i].velocity.y * dt;
2018  atom_arr[i].position.z += atom_arr[i].velocity.z * dt;
2019  }
2020  }
2021 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:178
BigReal z
Definition: Vector.h:66
Position position
Definition: NamdTypes.h:53
Velocity velocity
Definition: NamdTypes.h:101
BigReal x
Definition: Vector.h:66
#define simParams
Definition: Output.C:127
BigReal y
Definition: Vector.h:66
static __thread int num_atoms
void HomePatch::boxClosed ( int  box)
protectedvirtual

Implements Patch.

Definition at line 334 of file HomePatch.C.

References Sequencer::awaken(), Patch::boxesOpen, DebugM, Patch::dEdaSumBox, Flags::doGBIS, Flags::doNonbonded, Patch::f, Patch::flags, ExtForce::force, OwnerBox< Owner, Data >::isOpen(), Results::maxNumForces, Results::normal, Patch::numAtoms, Patch::patchID, Patch::psiSumBox, and ResizeArray< T >::size().

334  {
335  // begin gbis
336  if (box == 5) {// end of phase 1
337  phase1BoxClosedCalled = true;
338  if (!psiSumBox.isOpen() && numGBISP1Arrived == proxy.size()) {
339  if (flags.doGBIS && flags.doNonbonded) {
340  sequencer->awaken();
341  }
342  } else {
343  //need to wait until proxies arrive before awakening
344  }
345  } else if (box == 6) {// intRad
346  //do nothing
347  } else if (box == 7) {// bornRad
348  //do nothing
349  } else if (box == 8) {// end of phase 2
350  phase2BoxClosedCalled = true;
351  //if no proxies, AfterP1 can't be called from receive
352  //so it will be called from here
353  if (!dEdaSumBox.isOpen() && numGBISP2Arrived == proxy.size()) {
354  if (flags.doGBIS && flags.doNonbonded) {
355  sequencer->awaken();
356  }
357  } else {
358  //need to wait until proxies arrive before awakening
359  }
360  } else if (box == 9) {
361  //do nothing
362  } else if (box == 10) {
363  //lcpoType Box closed: do nothing
364  } else {
365  //do nothing
366  }
367  // end gbis
368 
369  if ( ! --boxesOpen ) {
370  if ( replacementForces ) {
371  for ( int i = 0; i < numAtoms; ++i ) {
372  if ( replacementForces[i].replace ) {
373  for ( int j = 0; j < Results::maxNumForces; ++j ) { f[j][i] = 0; }
374  f[Results::normal][i] = replacementForces[i].force;
375  }
376  }
377  replacementForces = 0;
378  }
379  DebugM(1,patchID << ": " << CthSelf() << " awakening sequencer "
380  << sequencer->thread << "(" << patchID << ") @" << CmiTimer() << "\n");
381  // only awaken suspended threads. Then say it is suspended.
382 
383  phase3BoxClosedCalled = true;
384  if (flags.doGBIS) {
385  if (flags.doNonbonded) {
386  sequencer->awaken();
387  } else {
388  if (numGBISP1Arrived == proxy.size() &&
389  numGBISP2Arrived == proxy.size() &&
390  numGBISP3Arrived == proxy.size()) {
391  sequencer->awaken();//all boxes closed and all proxies arrived
392  }
393  }
394  } else {//non-gbis awaken
395  sequencer->awaken();
396  }
397  } else {
398  DebugM(1,patchID << ": " << boxesOpen << " boxes left to close.\n");
399  }
400 }
#define DebugM(x, y)
Definition: Debug.h:59
Flags flags
Definition: Patch.h:127
void awaken(void)
Definition: Sequencer.h:29
int boxesOpen
Definition: Patch.h:243
int numAtoms
Definition: Patch.h:144
int doNonbonded
Definition: PatchTypes.h:22
Force force
Definition: NamdTypes.h:202
const PatchID patchID
Definition: Patch.h:143
OwnerBox< Patch, GBReal > dEdaSumBox
Definition: Patch.h:229
int doGBIS
Definition: PatchTypes.h:28
int size(void) const
Definition: ResizeArray.h:127
ForceList f[Results::maxNumForces]
Definition: Patch.h:207
int isOpen()
Definition: OwnerBox.h:51
OwnerBox< Patch, GBReal > psiSumBox
Definition: Patch.h:225
void HomePatch::buildRattleList ( )

Definition at line 2229 of file HomePatch.C.

References RattleParam::dsq, SimParameters::fixedAtomsOn, RattleParam::ia, RattleParam::ib, HomePatch::RattleList::icnt, HomePatch::RattleList::ig, NAMD_die(), noconstList, Patch::numAtoms, Node::Object(), posNew, rattleList, rattleParam, RattleParam::rma, RattleParam::rmb, settle1init(), settleList, Node::simParameters, SimParameters::useSettle, velNew, WAT_SWM4, WAT_TIP4, and SimParameters::watmodel.

Referenced by rattle1().

2229  {
2230 
2232  const int fixedAtomsOn = simParams->fixedAtomsOn;
2233  const int useSettle = simParams->useSettle;
2234 
2235  // Re-size to containt numAtoms elements
2236  velNew.resize(numAtoms);
2237  posNew.resize(numAtoms);
2238 
2239  // Size of a hydrogen group for water
2240  int wathgsize = 3;
2241  int watmodel = simParams->watmodel;
2242  if (watmodel == WAT_TIP4) wathgsize = 4;
2243  else if (watmodel == WAT_SWM4) wathgsize = 5;
2244 
2245  // Initialize the settle algorithm with water parameters
2246  // settle1() assumes all waters are identical,
2247  // and will generate bad results if they are not.
2248  // XXX this will move to Molecule::build_atom_status when that
2249  // version is debugged
2250  if ( ! settle_initialized ) {
2251  for ( int ig = 0; ig < numAtoms; ig += atom[ig].hydrogenGroupSize ) {
2252  // find a water
2253  if (atom[ig].rigidBondLength > 0) {
2254  int oatm;
2255  if (simParams->watmodel == WAT_SWM4) {
2256  oatm = ig+3; // skip over Drude and Lonepair
2257  //printf("ig=%d mass_ig=%g oatm=%d mass_oatm=%g\n",
2258  // ig, atom[ig].mass, oatm, atom[oatm].mass);
2259  }
2260  else {
2261  oatm = ig+1;
2262  // Avoid using the Om site to set this by mistake
2263  if (atom[ig].mass < 0.5 || atom[ig+1].mass < 0.5) {
2264  oatm += 1;
2265  }
2266  }
2267 
2268  // initialize settle water parameters
2269  settle1init(atom[ig].mass, atom[oatm].mass,
2270  atom[ig].rigidBondLength,
2271  atom[oatm].rigidBondLength,
2272  settle_mOrmT, settle_mHrmT, settle_ra,
2273  settle_rb, settle_rc, settle_rra);
2274  settle_initialized = 1;
2275  break; // done with init
2276  }
2277  }
2278  }
2279 
2280  Vector ref[10];
2281  BigReal rmass[10];
2282  BigReal dsq[10];
2283  int fixed[10];
2284  int ial[10];
2285  int ibl[10];
2286 
2287  int numSettle = 0;
2288  int numRattle = 0;
2289  int posRattleParam = 0;
2290 
2291  settleList.clear();
2292  rattleList.clear();
2293  noconstList.clear();
2294  rattleParam.clear();
2295 
2296  for ( int ig = 0; ig < numAtoms; ig += atom[ig].hydrogenGroupSize ) {
2297  int hgs = atom[ig].hydrogenGroupSize;
2298  if ( hgs == 1 ) {
2299  // only one atom in group
2300  noconstList.push_back(ig);
2301  continue;
2302  }
2303  int anyfixed = 0;
2304  for (int i = 0; i < hgs; ++i ) {
2305  ref[i] = atom[ig+i].position;
2306  rmass[i] = (atom[ig+i].mass > 0. ? 1. / atom[ig+i].mass : 0.);
2307  fixed[i] = ( fixedAtomsOn && atom[ig+i].atomFixed );
2308  if ( fixed[i] ) {
2309  anyfixed = 1;
2310  rmass[i] = 0.;
2311  }
2312  }
2313  int icnt = 0;
2314  BigReal tmp = atom[ig].rigidBondLength;
2315  if (tmp > 0.0) { // for water
2316  if (hgs != wathgsize) {
2317  char errmsg[256];
2318  sprintf(errmsg, "Water molecule starting with atom %d contains %d atoms "
2319  "but the specified water model requires %d atoms.\n",
2320  atom[ig].id+1, hgs, wathgsize);
2321  NAMD_die(errmsg);
2322  }
2323  // Use SETTLE for water unless some of the water atoms are fixed,
2324  if (useSettle && !anyfixed) {
2325  // Store to Settle -list
2326  settleList.push_back(ig);
2327  continue;
2328  }
2329  if ( !(fixed[1] && fixed[2]) ) {
2330  dsq[icnt] = tmp * tmp;
2331  ial[icnt] = 1;
2332  ibl[icnt] = 2;
2333  ++icnt;
2334  }
2335  } // if (tmp > 0.0)
2336  for (int i = 1; i < hgs; ++i ) { // normal bonds to mother atom
2337  if ( ( tmp = atom[ig+i].rigidBondLength ) > 0 ) {
2338  if ( !(fixed[0] && fixed[i]) ) {
2339  dsq[icnt] = tmp * tmp;
2340  ial[icnt] = 0;
2341  ibl[icnt] = i;
2342  ++icnt;
2343  }
2344  }
2345  }
2346  if ( icnt == 0 ) {
2347  // no constraints
2348  noconstList.push_back(ig);
2349  continue;
2350  }
2351  // Store to Rattle -list
2352  RattleList rattleListElem;
2353  rattleListElem.ig = ig;
2354  rattleListElem.icnt = icnt;
2355  rattleList.push_back(rattleListElem);
2356  for (int i = 0; i < icnt; ++i ) {
2357  int a = ial[i];
2358  int b = ibl[i];
2359  RattleParam rattleParamElem;
2360  rattleParamElem.ia = a;
2361  rattleParamElem.ib = b;
2362  rattleParamElem.dsq = dsq[i];
2363  rattleParamElem.rma = rmass[a];
2364  rattleParamElem.rmb = rmass[b];
2365  rattleParam.push_back(rattleParamElem);
2366  }
2367  }
2368 
2369 }
static Node * Object()
Definition: Node.h:86
int ib
Definition: Settle.h:57
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
BigReal dsq
Definition: Settle.h:58
std::vector< RattleList > rattleList
Definition: HomePatch.h:381
#define WAT_SWM4
Definition: common.h:190
int numAtoms
Definition: Patch.h:144
std::vector< int > settleList
Definition: HomePatch.h:380
void NAMD_die(const char *err_msg)
Definition: common.C:83
std::vector< Vector > posNew
Definition: HomePatch.h:389
std::vector< RattleParam > rattleParam
Definition: HomePatch.h:382
#define simParams
Definition: Output.C:127
BigReal rmb
Definition: Settle.h:60
BigReal rma
Definition: Settle.h:59
void settle1init(BigReal pmO, BigReal pmH, BigReal hhdist, BigReal ohdist, BigReal &mOrmT, BigReal &mHrmT, BigReal &ra, BigReal &rb, BigReal &rc, BigReal &rra)
initialize cached water properties
Definition: Settle.C:40
int ia
Definition: Settle.h:56
#define WAT_TIP4
Definition: common.h:189
std::vector< Vector > velNew
Definition: HomePatch.h:388
std::vector< int > noconstList
Definition: HomePatch.h:383
double BigReal
Definition: common.h:112
void HomePatch::buildSpanningTree ( void  )

Definition at line 674 of file HomePatch.C.

References ResizeArray< T >::begin(), compDistance(), ResizeArray< T >::end(), ResizeArray< T >::find(), NAMD_bug(), PatchMap::numNodesWithPatches(), PatchMap::numPatchesOnNode(), PatchMap::Object(), Patch::patchID, proxySpanDim, ResizeArray< T >::resize(), sendSpanningTree(), ResizeArray< T >::setall(), ResizeArray< T >::size(), and ResizeArray< T >::swap().

Referenced by ProxyMgr::buildProxySpanningTree().

675 {
676  nChild = 0;
677  int psize = proxy.size();
678  if (psize == 0) return;
679  NodeIDList oldtree; oldtree.swap(tree);
680  int oldsize = oldtree.size();
681  tree.resize(psize + 1);
682  tree.setall(-1);
683  tree[0] = CkMyPe();
684  int s=1, e=psize+1;
686  int patchNodesLast =
687  ( PatchMap::Object()->numNodesWithPatches() < ( 0.7 * CkNumPes() ) );
688  int nNonPatch = 0;
689 #if 1
690  // try to put it to the same old tree
691  for ( pli = proxy.begin(); pli != proxy.end(); ++pli )
692  {
693  int oldindex = oldtree.find(*pli);
694  if (oldindex != -1 && oldindex < psize) {
695  tree[oldindex] = *pli;
696  }
697  }
698  s=1; e=psize;
699  for ( pli = proxy.begin(); pli != proxy.end(); ++pli )
700  {
701  if (tree.find(*pli) != -1) continue; // already assigned
702  if ( patchNodesLast && PatchMap::Object()->numPatchesOnNode(*pli) ) {
703  while (tree[e] != -1) { e--; if (e==-1) e = psize; }
704  tree[e] = *pli;
705  } else {
706  while (tree[s] != -1) { s++; if (s==psize+1) s = 1; }
707  tree[s] = *pli;
708  nNonPatch++;
709  }
710  }
711 #if 1
712  if (oldsize==0 && nNonPatch) {
713  // first time, sort by distance
714  qsort(&tree[1], nNonPatch, sizeof(int), compDistance);
715  }
716 #endif
717 
718  //CkPrintf("home: %d:(%d) %d %d %d %d %d\n", patchID, tree.size(),tree[0],tree[1],tree[2],tree[3],tree[4]);
719 
720 #if USE_TOPOMAP && USE_SPANNING_TREE
721 
722  //Right now only works for spanning trees with two levels
723  int *treecopy = new int [psize];
724  int subroots[proxySpanDim];
725  int subsizes[proxySpanDim];
726  int subtrees[proxySpanDim][proxySpanDim];
727  int idxes[proxySpanDim];
728  int i = 0;
729 
730  for(i=0;i<proxySpanDim;i++){
731  subsizes[i] = 0;
732  idxes[i] = i;
733  }
734 
735  for(i=0;i<psize;i++){
736  treecopy[i] = tree[i+1];
737  }
738 
739  TopoManager tmgr;
740  tmgr.sortRanksByHops(treecopy,nNonPatch);
741  tmgr.sortRanksByHops(treecopy+nNonPatch,
742  psize-nNonPatch);
743 
744  /* build tree and subtrees */
745  nChild = findSubroots(proxySpanDim,subroots,psize,treecopy);
746  delete [] treecopy;
747 
748  for(int i=1;i<psize+1;i++){
749  int isSubroot=0;
750  for(int j=0;j<nChild;j++)
751  if(tree[i]==subroots[j]){
752  isSubroot=1;
753  break;
754  }
755  if(isSubroot) continue;
756 
757  int bAdded = 0;
758  tmgr.sortIndexByHops(tree[i], subroots,
759  idxes, proxySpanDim);
760  for(int j=0;j<proxySpanDim;j++){
761  if(subsizes[idxes[j]]<proxySpanDim){
762  subtrees[idxes[j]][(subsizes[idxes[j]])++] = tree[i];
763  bAdded = 1;
764  break;
765  }
766  }
767  if( psize > proxySpanDim && ! bAdded ) {
768  NAMD_bug("HomePatch BGL Spanning Tree error: Couldn't find subtree for leaf\n");
769  }
770  }
771 
772 #else /* USE_TOPOMAP && USE_SPANNING_TREE */
773 
774  for (int i=1; i<=proxySpanDim; i++) {
775  if (tree.size() <= i) break;
776  child[i-1] = tree[i];
777  nChild++;
778  }
779 #endif
780 #endif
781 
782 #if 0
783  // for debugging
784  CkPrintf("[%d] Spanning tree for %d with %d children %d nNonPatch %d\n", CkMyPe(), patchID, psize, nNonPatch);
785  for (int i=0; i<psize+1; i++) {
786  CkPrintf("%d ", tree[i]);
787  }
788  CkPrintf("\n");
789 #endif
790  // send to children nodes
792 }
int numNodesWithPatches(void)
Definition: PatchMap.h:61
static PatchMap * Object()
Definition: PatchMap.h:27
int find(const Elem &e) const
Definition: ResizeArray.h:137
static int compDistance(const void *a, const void *b)
Definition: HomePatch.C:456
void NAMD_bug(const char *err_msg)
Definition: common.C:123
iterator end(void)
Definition: ResizeArray.h:37
void setall(const Elem &elem)
Definition: ResizeArray.h:90
void sendSpanningTree()
Definition: HomePatch.C:659
void resize(int i)
Definition: ResizeArray.h:84
void swap(ResizeArray< Elem > &ra)
Definition: ResizeArray.h:64
const PatchID patchID
Definition: Patch.h:143
int numPatchesOnNode(int node)
Definition: PatchMap.h:60
int size(void) const
Definition: ResizeArray.h:127
int proxySpanDim
Definition: ProxyMgr.C:48
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::checkpoint ( void  )

Definition at line 3449 of file HomePatch.C.

References ResizeArray< T >::copy(), and Patch::lattice.

Referenced by Sequencer::algorithm().

3449  {
3450  checkpoint_atom.copy(atom);
3451  checkpoint_lattice = lattice;
3452 
3453  // DMK - Atom Separation (water vs. non-water)
3454  #if NAMD_SeparateWaters != 0
3455  checkpoint_numWaterAtoms = numWaterAtoms;
3456  #endif
3457 }
void copy(ResizeArray< Elem > &ra)
Definition: ResizeArray.h:59
Lattice & lattice
Definition: Patch.h:126
void HomePatch::depositMigration ( MigrateAtomsMsg msg)

Definition at line 3996 of file HomePatch.C.

References ResizeArray< T >::add(), Lattice::apply_transform(), Sequencer::awaken(), ResizeArray< T >::begin(), DebugM, ResizeArray< T >::end(), inMigration, Patch::lattice, MigrateAtomsMsg::migrationList, msgbuf, Lattice::nearest(), numMlBuf, Patch::patchID, Lattice::reverse_transform(), and ResizeArray< T >::size().

Referenced by MigrateAtomsCombinedMsg::distribute(), and doAtomMigration().

3997 {
3998 
3999  if (!inMigration) { // We have to buffer changes due to migration
4000  // until our patch is in migration mode
4001  msgbuf[numMlBuf++] = msg;
4002  return;
4003  }
4004 
4005 
4006  // DMK - Atom Separation (water vs. non-water)
4007  #if NAMD_SeparateWaters != 0
4008 
4009 
4010  // Merge the incoming list of atoms with the current list of
4011  // atoms. Note that mergeSeparatedAtomList() will apply any
4012  // required transformations to the incoming atoms as it is
4013  // separating them.
4014  mergeAtomList(msg->migrationList);
4015 
4016 
4017  #else
4018 
4019  // Merge the incoming list of atoms with the current list of
4020  // atoms. Apply transformations to the incoming atoms as they are
4021  // added to this patch's list.
4022  {
4023  MigrationList &migrationList = msg->migrationList;
4025  Transform mother_transform;
4026  for (mi = migrationList.begin(); mi != migrationList.end(); mi++) {
4027  DebugM(1,"Migrating atom " << mi->id << " to patch "
4028  << patchID << " with position " << mi->position << "\n");
4029  if ( mi->migrationGroupSize ) {
4030  if ( mi->migrationGroupSize != mi->hydrogenGroupSize ) {
4031  Position pos = mi->position;
4032  int mgs = mi->migrationGroupSize;
4033  int c = 1;
4034  for ( int j=mi->hydrogenGroupSize; j<mgs;
4035  j+=(mi+j)->hydrogenGroupSize ) {
4036  pos += (mi+j)->position;
4037  ++c;
4038  }
4039  pos *= 1./c;
4040  // iout << "mgroup " << mi->id << " at " << pos << "\n" << endi;
4041  mother_transform = mi->transform;
4042  pos = lattice.nearest(pos,center,&mother_transform);
4043  mi->position = lattice.reverse_transform(mi->position,mi->transform);
4044  mi->position = lattice.apply_transform(mi->position,mother_transform);
4045  mi->transform = mother_transform;
4046  } else {
4047  mi->position = lattice.nearest(mi->position,center,&(mi->transform));
4048  mother_transform = mi->transform;
4049  }
4050  } else {
4051  mi->position = lattice.reverse_transform(mi->position,mi->transform);
4052  mi->position = lattice.apply_transform(mi->position,mother_transform);
4053  mi->transform = mother_transform;
4054  }
4055  atom.add(*mi);
4056  }
4057  }
4058 
4059 
4060  #endif // if (NAMD_SeparateWaters != 0)
4061 
4062 
4063  numAtoms = atom.size();
4064  delete msg;
4065 
4066  DebugM(3,"Counter on " << patchID << " = " << patchMigrationCounter << "\n");
4067  if (!--patchMigrationCounter) {
4068  DebugM(3,"All Migrations are in for patch "<<patchID<<"\n");
4069  allMigrationIn = true;
4070  patchMigrationCounter = numNeighbors;
4071  if (migrationSuspended) {
4072  DebugM(3,"patch "<<patchID<<" is being awakened\n");
4073  migrationSuspended = false;
4074  sequencer->awaken();
4075  return;
4076  }
4077  else {
4078  DebugM(3,"patch "<<patchID<<" was not suspended\n");
4079  }
4080  }
4081 }
Lattice & lattice
Definition: Patch.h:126
Definition: Vector.h:64
MigrationList migrationList
#define DebugM(x, y)
Definition: Debug.h:59
int inMigration
Definition: HomePatch.h:492
Position nearest(Position data, ScaledPosition ref) const
Definition: Lattice.h:90
void awaken(void)
Definition: Sequencer.h:29
iterator end(void)
Definition: ResizeArray.h:37
int numAtoms
Definition: Patch.h:144
MigrateAtomsMsg * msgbuf[PatchMap::MaxOneAway]
Definition: HomePatch.h:494
int add(const Elem &elem)
Definition: ResizeArray.h:97
Position apply_transform(Position data, const Transform &t) const
Definition: Lattice.h:132
const PatchID patchID
Definition: Patch.h:143
Position reverse_transform(Position data, const Transform &t) const
Definition: Lattice.h:138
int size(void) const
Definition: ResizeArray.h:127
int numMlBuf
Definition: HomePatch.h:493
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::doAtomMigration ( )
protected

Definition at line 3840 of file HomePatch.C.

References ResizeArray< T >::add(), atomIndex, Patch::atomMapper, ResizeArray< T >::begin(), DebugM, ResizeArray< T >::del(), depositMigration(), ResizeArray< T >::end(), inMigration, Patch::lattice, marginViolations, MigrationInfo::mList, msgbuf, NAMD_EVENT_STOP, numMlBuf, PatchMgr::Object(), Patch::patchID, ResizeArray< T >::resize(), Lattice::scale(), PatchMgr::sendMigrationMsgs(), ResizeArray< T >::size(), Sequencer::suspend(), AtomMapper::unregisterIDsFullAtom(), Vector::x, Vector::y, and Vector::z.

Referenced by positionsReady().

3841 {
3842  int i;
3843 
3844  for (i=0; i<numNeighbors; i++) {
3845  realInfo[i].mList.resize(0);
3846  }
3847 
3848  // Purge the AtomMap
3849  atomMapper->unregisterIDsFullAtom(atom.begin(),atom.end());
3850 
3851  // Determine atoms that need to migrate
3852 
3853  BigReal minx = min.x;
3854  BigReal miny = min.y;
3855  BigReal minz = min.z;
3856  BigReal maxx = max.x;
3857  BigReal maxy = max.y;
3858  BigReal maxz = max.z;
3859 
3860  int xdev, ydev, zdev;
3861  int delnum = 0;
3862 
3863  FullAtomList::iterator atom_i = atom.begin();
3864  FullAtomList::iterator atom_e = atom.end();
3865 
3866  // DMK - Atom Separation (water vs. non-water)
3867  #if NAMD_SeparateWaters != 0
3868  FullAtomList::iterator atom_first = atom_i;
3869  int numLostWaterAtoms = 0;
3870  #endif
3871 
3872  while ( atom_i != atom_e ) {
3873  // Even though this code iterates through all atoms successively
3874  // it moves entire hydrogen/migration groups as follows:
3875  // Only the parent atom of the hydrogen/migration group has
3876  // nonzero migrationGroupSize. Values determined for xdev,ydev,zdev
3877  // will persist through the remaining group members so that each
3878  // following atom will again be added to the same mList.
3879  if ( atom_i->migrationGroupSize ) {
3880  Position pos = atom_i->position;
3881  if ( atom_i->migrationGroupSize != atom_i->hydrogenGroupSize ) {
3882  // If there are multiple hydrogen groups in a migration group
3883  // (e.g. for supporting lone pairs)
3884  // the following code takes the average position (midpoint)
3885  // of their parents.
3886  int mgs = atom_i->migrationGroupSize;
3887  int c = 1;
3888  for ( int j=atom_i->hydrogenGroupSize; j<mgs;
3889  j+=(atom_i+j)->hydrogenGroupSize ) {
3890  pos += (atom_i+j)->position;
3891  ++c;
3892  }
3893  pos *= 1./c;
3894  // iout << "mgroup " << atom_i->id << " at " << pos << "\n" << endi;
3895  }
3896 
3897  // Scaling the position below transforms space within patch from
3898  // what could have been a rotated parallelepiped into
3899  // orthogonal coordinates, where we can use minmax comparison
3900  // to detect which of our nearest neighbors this
3901  // parent atom might have entered.
3902  ScaledPosition s = lattice.scale(pos);
3903 
3904  // check if atom is within bounds
3905  if (s.x < minx) xdev = 0;
3906  else if (maxx <= s.x) xdev = 2;
3907  else xdev = 1;
3908 
3909  if (s.y < miny) ydev = 0;
3910  else if (maxy <= s.y) ydev = 2;
3911  else ydev = 1;
3912 
3913  if (s.z < minz) zdev = 0;
3914  else if (maxz <= s.z) zdev = 2;
3915  else zdev = 1;
3916 
3917  }
3918 
3919  if (mInfo[xdev][ydev][zdev]) { // process atom for migration
3920  // Don't migrate if destination is myself
3921 
3922  // See if we have a migration list already
3923  MigrationList &mCur = mInfo[xdev][ydev][zdev]->mList;
3924  DebugM(3,"Migrating atom " << atom_i->id << " from patch "
3925  << patchID << " with position " << atom_i->position << "\n");
3926  mCur.add(*atom_i);
3927 
3928  ++delnum;
3929 
3930 
3931  // DMK - Atom Separation (water vs. non-water)
3932  #if NAMD_SeparateWaters != 0
3933  // Check to see if this atom is part of a water molecule. If
3934  // so, numWaterAtoms needs to be adjusted to refect the lost of
3935  // this atom.
3936  // NOTE: The atom separation code assumes that if the oxygen
3937  // atom of the hydrogen group making up the water molecule is
3938  // migrated to another HomePatch, the hydrogens will also
3939  // move!!!
3940  int atomIndex = atom_i - atom_first;
3941  if (atomIndex < numWaterAtoms)
3942  numLostWaterAtoms++;
3943  #endif
3944 
3945 
3946  } else {
3947  // By keeping track of delnum total being deleted from FullAtomList
3948  // the else clause allows us to fill holes as we visit each atom.
3949 
3950  if ( delnum ) { *(atom_i-delnum) = *atom_i; }
3951 
3952  }
3953 
3954  ++atom_i;
3955  }
3956 
3957  // DMK - Atom Separation (water vs. non-water)
3958  #if NAMD_SeparateWaters != 0
3959  numWaterAtoms -= numLostWaterAtoms;
3960  #endif
3961 
3962 
3963  int delpos = numAtoms - delnum;
3964  DebugM(4,"numAtoms " << numAtoms << " deleted " << delnum << "\n");
3965  atom.del(delpos,delnum);
3966 
3967  numAtoms = atom.size();
3968 
3969  PatchMgr::Object()->sendMigrationMsgs(patchID, realInfo, numNeighbors);
3970 
3971  // signal depositMigration() that we are inMigration mode
3972  inMigration = true;
3973 
3974  // Drain the migration message buffer
3975  for (i=0; i<numMlBuf; i++) {
3976  DebugM(1, "Draining migration buffer ("<<i<<","<<numMlBuf<<")\n");
3978  }
3979  numMlBuf = 0;
3980 
3981  NAMD_EVENT_STOP(1, NamdProfileEvent::ATOM_MIGRATIONS);
3982 
3983  if (!allMigrationIn) {
3984  DebugM(3,"All Migrations NOT in, we are suspending patch "<<patchID<<"\n");
3985  migrationSuspended = true;
3986  sequencer->suspend();
3987  migrationSuspended = false;
3988  }
3989  allMigrationIn = false;
3990 
3991  inMigration = false;
3992  marginViolations = 0;
3993 }
void depositMigration(MigrateAtomsMsg *)
Definition: HomePatch.C:3996
#define NAMD_EVENT_STOP(eon, id)
int marginViolations
Definition: HomePatch.h:333
Lattice & lattice
Definition: Patch.h:126
void del(int index, int num=1)
Definition: ResizeArray.h:104
Definition: Vector.h:64
#define DebugM(x, y)
Definition: Debug.h:59
BigReal z
Definition: Vector.h:66
int inMigration
Definition: HomePatch.h:492
AtomMapper * atomMapper
Definition: Patch.h:152
__global__ void const int const TileList *__restrict__ TileExcl *__restrict__ const int *__restrict__ const int const float2 *__restrict__ const int *__restrict__ const float3 const float3 const float3 const float4 *__restrict__ const float cudaTextureObject_t cudaTextureObject_t cudaTextureObject_t const int const float const PatchPairRecord *__restrict__ const int *__restrict__ atomIndex
iterator end(void)
Definition: ResizeArray.h:37
int numAtoms
Definition: Patch.h:144
BigReal x
Definition: Vector.h:66
void sendMigrationMsgs(PatchID, MigrationInfo *, int)
Definition: PatchMgr.C:175
MigrateAtomsMsg * msgbuf[PatchMap::MaxOneAway]
Definition: HomePatch.h:494
int add(const Elem &elem)
Definition: ResizeArray.h:97
void suspend(void)
Definition: Sequencer.C:136
void resize(int i)
Definition: ResizeArray.h:84
MigrationList mList
Definition: Migration.h:22
const PatchID patchID
Definition: Patch.h:143
BigReal y
Definition: Vector.h:66
ScaledPosition scale(Position p) const
Definition: Lattice.h:83
int size(void) const
Definition: ResizeArray.h:127
void unregisterIDsFullAtom(const FullAtom *begin, const FullAtom *end)
Definition: AtomMap.C:100
int numMlBuf
Definition: HomePatch.h:493
static PatchMgr * Object()
Definition: PatchMgr.h:152
double BigReal
Definition: common.h:112
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::doGroupSizeCheck ( )
protected

Definition at line 3719 of file HomePatch.C.

References ResizeArray< T >::begin(), Flags::doNonbonded, ResizeArray< T >::end(), Patch::flags, SimParameters::hgroupCutoff, Flags::maxGroupRadius, NAMD_bug(), Node::Object(), Node::simParameters, x, y, and z.

Referenced by positionsReady().

3720 {
3721  if ( ! flags.doNonbonded ) return;
3722 
3724  BigReal hgcut = 0.5 * simParams->hgroupCutoff; hgcut *= hgcut;
3725  BigReal maxrad2 = 0.;
3726 
3727  FullAtomList::iterator p_i = atom.begin();
3728  FullAtomList::iterator p_e = atom.end();
3729 
3730  while ( p_i != p_e ) {
3731  const int hgs = p_i->hydrogenGroupSize;
3732  if ( ! hgs ) break; // avoid infinite loop on bug
3733  int ngs = hgs;
3734  if ( ngs > 5 ) ngs = 5; // XXX why? limit to at most 5 atoms per group
3735  BigReal x = p_i->position.x;
3736  BigReal y = p_i->position.y;
3737  BigReal z = p_i->position.z;
3738  int i;
3739  for ( i = 1; i < ngs; ++i ) { // limit spatial extent
3740  p_i[i].nonbondedGroupSize = 0;
3741  BigReal dx = p_i[i].position.x - x;
3742  BigReal dy = p_i[i].position.y - y;
3743  BigReal dz = p_i[i].position.z - z;
3744  BigReal r2 = dx * dx + dy * dy + dz * dz;
3745  if ( r2 > hgcut ) break;
3746  else if ( r2 > maxrad2 ) maxrad2 = r2;
3747  }
3748  p_i->nonbondedGroupSize = i;
3749  for ( ; i < hgs; ++i ) {
3750  p_i[i].nonbondedGroupSize = 1;
3751  }
3752  p_i += hgs;
3753  }
3754 
3755  if ( p_i != p_e ) {
3756  NAMD_bug("hydrogenGroupSize is zero in HomePatch::doGroupSizeCheck");
3757  }
3758 
3759  flags.maxGroupRadius = sqrt(maxrad2);
3760 
3761 }
static Node * Object()
Definition: Node.h:86
BigReal hgroupCutoff
SimParameters * simParameters
Definition: Node.h:178
Flags flags
Definition: Patch.h:127
void NAMD_bug(const char *err_msg)
Definition: common.C:123
iterator end(void)
Definition: ResizeArray.h:37
gridSize z
int doNonbonded
Definition: PatchTypes.h:22
#define simParams
Definition: Output.C:127
gridSize y
gridSize x
BigReal maxGroupRadius
Definition: PatchTypes.h:42
double BigReal
Definition: common.h:112
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::doMarginCheck ( )
protected

Definition at line 3763 of file HomePatch.C.

References Lattice::a(), Lattice::a_r(), Lattice::b(), Lattice::b_r(), ResizeArray< T >::begin(), Lattice::c(), Lattice::c_r(), SimParameters::cutoff, ResizeArray< T >::end(), Patch::lattice, SimParameters::margin, marginViolations, NAMD_die(), Node::Object(), SimParameters::patchDimension, Lattice::scale(), Node::simParameters, Vector::unit(), Vector::x, Vector::y, and Vector::z.

Referenced by positionsReady().

3764 {
3766 
3767  BigReal sysdima = lattice.a_r().unit() * lattice.a();
3768  BigReal sysdimb = lattice.b_r().unit() * lattice.b();
3769  BigReal sysdimc = lattice.c_r().unit() * lattice.c();
3770 
3771  BigReal minSize = simParams->patchDimension - simParams->margin;
3772 
3773  if ( ( aAwayDist*sysdima < minSize*0.9999 ) ||
3774  ( bAwayDist*sysdimb < minSize*0.9999 ) ||
3775  ( cAwayDist*sysdimc < minSize*0.9999 ) ) {
3776 
3777  NAMD_die("Periodic cell has become too small for original patch grid!\n"
3778  "Possible solutions are to restart from a recent checkpoint,\n"
3779  "increase margin, or disable useFlexibleCell for liquid simulation.");
3780  }
3781 
3782  BigReal cutoff = simParams->cutoff;
3783 
3784  BigReal margina = 0.5 * ( aAwayDist - cutoff / sysdima );
3785  BigReal marginb = 0.5 * ( bAwayDist - cutoff / sysdimb );
3786  BigReal marginc = 0.5 * ( cAwayDist - cutoff / sysdimc );
3787 
3788  if ( (margina < -0.0001) || (marginb < -0.0001) || (marginc < -0.0001) ) {
3789  NAMD_die("Periodic cell has become too small for original patch grid!\n"
3790  "There are probably many margin violations already reported.\n"
3791  "Possible solutions are to restart from a recent checkpoint,\n"
3792  "increase margin, or disable useFlexibleCell for liquid simulation.");
3793  }
3794 
3795  BigReal minx = min.x - margina;
3796  BigReal miny = min.y - marginb;
3797  BigReal minz = min.z - marginc;
3798  BigReal maxx = max.x + margina;
3799  BigReal maxy = max.y + marginb;
3800  BigReal maxz = max.z + marginc;
3801 
3802  int xdev, ydev, zdev;
3803  int problemCount = 0;
3804 
3805  FullAtomList::iterator p_i = atom.begin();
3806  FullAtomList::iterator p_e = atom.end();
3807  for ( ; p_i != p_e; ++p_i ) {
3808 
3809  ScaledPosition s = lattice.scale(p_i->position);
3810 
3811  // check if atom is within bounds
3812  if (s.x < minx) xdev = 0;
3813  else if (maxx <= s.x) xdev = 2;
3814  else xdev = 1;
3815 
3816  if (s.y < miny) ydev = 0;
3817  else if (maxy <= s.y) ydev = 2;
3818  else ydev = 1;
3819 
3820  if (s.z < minz) zdev = 0;
3821  else if (maxz <= s.z) zdev = 2;
3822  else zdev = 1;
3823 
3824  if (mInfo[xdev][ydev][zdev]) { // somewhere else to be
3825  ++problemCount;
3826  }
3827 
3828  }
3829 
3830  marginViolations = problemCount;
3831  // if ( problemCount ) {
3832  // iout << iERROR <<
3833  // "Found " << problemCount << " margin violations!\n" << endi;
3834  // }
3835 
3836 }
static Node * Object()
Definition: Node.h:86
Vector a_r() const
Definition: Lattice.h:268
int marginViolations
Definition: HomePatch.h:333
Lattice & lattice
Definition: Patch.h:126
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
Vector c_r() const
Definition: Lattice.h:270
BigReal z
Definition: Vector.h:66
Vector b_r() const
Definition: Lattice.h:269
iterator end(void)
Definition: ResizeArray.h:37
BigReal x
Definition: Vector.h:66
void NAMD_die(const char *err_msg)
Definition: common.C:83
#define simParams
Definition: Output.C:127
BigReal y
Definition: Vector.h:66
Vector b() const
Definition: Lattice.h:253
ScaledPosition scale(Position p) const
Definition: Lattice.h:83
BigReal patchDimension
Vector a() const
Definition: Lattice.h:252
Vector unit(void) const
Definition: Vector.h:182
Vector c() const
Definition: Lattice.h:254
double BigReal
Definition: common.h:112
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::doPairlistCheck ( )
protected

Definition at line 3628 of file HomePatch.C.

References ResizeArray< T >::begin(), Patch::flags, Patch::getPatchID(), Patch::lattice, Vector::length2(), Flags::maxAtomMovement, NAMD_EVENT_START_EX, NAMD_EVENT_STOP, NamdProfileEventStr, Patch::numAtoms, Node::Object(), SimParameters::pairlistGrow, SimParameters::pairlistShrink, Flags::pairlistTolerance, SimParameters::pairlistTrigger, CompAtom::position, ResizeArray< T >::resize(), Flags::savePairlists, Node::simParameters, Lattice::unscale(), Flags::usePairlists, Vector::x, Vector::y, and Vector::z.

Referenced by positionsReady().

3629 {
3630 #if 0
3631 #if defined(NAMD_NVTX_ENABLED) || defined(NAMD_CMK_TRACE_ENABLED)
3632  char dpcbuf[32];
3633  sprintf(dpcbuf, "%s: %d", NamdProfileEventStr[NamdProfileEvent::DO_PAIRLIST_CHECK], this->getPatchID());
3634  NAMD_EVENT_START_EX(1, NamdProfileEvent::DO_PAIRLIST_CHECK, dpcbuf);
3635 #endif
3636 #endif
3637 
3639 
3640  if ( numAtoms == 0 || ! flags.usePairlists ) {
3641  flags.pairlistTolerance = 0.;
3642  flags.maxAtomMovement = 99999.;
3643 #if 0
3644  NAMD_EVENT_STOP(1, NamdProfileEvent::DO_PAIRLIST_CHECK);
3645 #endif
3646  return;
3647  }
3648 
3649  int i; int n = numAtoms;
3650  CompAtom *p_i = p.begin();
3651 
3652  if ( flags.savePairlists ) {
3653  flags.pairlistTolerance = doPairlistCheck_newTolerance;
3654  flags.maxAtomMovement = 0.;
3655  doPairlistCheck_newTolerance *= (1. - simParams->pairlistShrink);
3656  doPairlistCheck_lattice = lattice;
3657  doPairlistCheck_positions.resize(numAtoms);
3658  CompAtom *psave_i = doPairlistCheck_positions.begin();
3659  for ( i=0; i<n; ++i ) { psave_i[i] = p_i[i]; }
3660 #if 0
3661  NAMD_EVENT_STOP(1, NamdProfileEvent::DO_PAIRLIST_CHECK);
3662 #endif
3663  return;
3664  }
3665 
3666  Lattice &lattice_old = doPairlistCheck_lattice;
3667  Position center_cur = lattice.unscale(center);
3668  Position center_old = lattice_old.unscale(center);
3669  Vector center_delta = center_cur - center_old;
3670 
3671  // find max deviation to corner (any neighbor shares a corner)
3672  BigReal max_cd = 0.;
3673  for ( i=0; i<2; ++i ) {
3674  for ( int j=0; j<2; ++j ) {
3675  for ( int k=0; k<2; ++k ) {
3676  ScaledPosition corner( i ? min.x : max.x ,
3677  j ? min.y : max.y ,
3678  k ? min.z : max.z );
3679  Vector corner_delta =
3680  lattice.unscale(corner) - lattice_old.unscale(corner);
3681  corner_delta -= center_delta;
3682  BigReal cd = corner_delta.length2();
3683  if ( cd > max_cd ) max_cd = cd;
3684  }
3685  }
3686  }
3687  max_cd = sqrt(max_cd);
3688 
3689  // find max deviation of atoms relative to center
3690  BigReal max_pd = 0.;
3691  CompAtom *p_old_i = doPairlistCheck_positions.begin();
3692  for ( i=0; i<n; ++i ) {
3693  Vector p_delta = p_i[i].position - p_old_i[i].position;
3694  p_delta -= center_delta;
3695  BigReal pd = p_delta.length2();
3696  if ( pd > max_pd ) max_pd = pd;
3697  }
3698  max_pd = sqrt(max_pd);
3699 
3700  BigReal max_tol = max_pd + max_cd;
3701 
3702  flags.maxAtomMovement = max_tol;
3703 
3704  // if ( max_tol > flags.pairlistTolerance ) iout << "tolerance " << max_tol << " > " << flags.pairlistTolerance << "\n" << endi;
3705 
3706  if ( max_tol > ( (1. - simParams->pairlistTrigger) *
3707  doPairlistCheck_newTolerance ) ) {
3708  doPairlistCheck_newTolerance *= (1. + simParams->pairlistGrow);
3709  }
3710 
3711  if ( max_tol > doPairlistCheck_newTolerance ) {
3712  doPairlistCheck_newTolerance = max_tol / (1. - simParams->pairlistTrigger);
3713  }
3714 #if 0
3715  NAMD_EVENT_STOP(1, NamdProfileEvent::DO_PAIRLIST_CHECK);
3716 #endif
3717 }
static Node * Object()
Definition: Node.h:86
#define NAMD_EVENT_STOP(eon, id)
BigReal pairlistTrigger
Lattice & lattice
Definition: Patch.h:126
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
int savePairlists
Definition: PatchTypes.h:39
BigReal z
Definition: Vector.h:66
char const *const NamdProfileEventStr[]
int usePairlists
Definition: PatchTypes.h:38
Position position
Definition: NamdTypes.h:53
Flags flags
Definition: Patch.h:127
CompAtomList p
Definition: Patch.h:146
int numAtoms
Definition: Patch.h:144
BigReal x
Definition: Vector.h:66
BigReal maxAtomMovement
Definition: PatchTypes.h:41
PatchID getPatchID()
Definition: Patch.h:114
BigReal length2(void) const
Definition: Vector.h:173
#define simParams
Definition: Output.C:127
void resize(int i)
Definition: ResizeArray.h:84
#define NAMD_EVENT_START_EX(eon, id, str)
Position unscale(ScaledPosition s) const
Definition: Lattice.h:77
BigReal y
Definition: Vector.h:66
BigReal pairlistTolerance
Definition: PatchTypes.h:40
BigReal pairlistShrink
BigReal pairlistGrow
double BigReal
Definition: common.h:112
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::exchangeAtoms ( int  scriptTask)

Definition at line 3573 of file HomePatch.C.

References ExchangeAtomsMsg::atoms, ResizeArray< T >::begin(), exchange_dst, exchange_msg, exchange_req, exchange_src, ExchangeAtomsMsg::lattice, Patch::lattice, ExchangeAtomsMsg::numAtoms, Patch::numAtoms, Node::Object(), PatchMgr::Object(), Patch::patchID, ExchangeAtomsMsg::pid, recvExchangeReq(), SCRIPT_ATOMRECV, SCRIPT_ATOMSEND, SCRIPT_ATOMSENDRECV, SimParameters::scriptArg1, SimParameters::scriptArg2, PatchMgr::sendExchangeReq(), and Node::simParameters.

Referenced by Sequencer::algorithm().

3573  {
3575  // CkPrintf("exchangeAtoms %d %d %d %d\n", CmiMyPartition(), scriptTask, (int)(simParams->scriptArg1), (int)(simParams->scriptArg2));
3576  if ( scriptTask == SCRIPT_ATOMSEND || scriptTask == SCRIPT_ATOMSENDRECV ) {
3577  exchange_dst = (int) simParams->scriptArg1;
3578  // create and save outgoing message
3583  memcpy(exchange_msg->atoms,atom.begin(),numAtoms*sizeof(FullAtom));
3584  if ( exchange_req >= 0 ) {
3586  }
3587  }
3588  if ( scriptTask == SCRIPT_ATOMRECV || scriptTask == SCRIPT_ATOMSENDRECV ) {
3589  exchange_src = (int) simParams->scriptArg2;
3591  }
3592 }
static Node * Object()
Definition: Node.h:86
BigReal scriptArg2
Lattice & lattice
Definition: Patch.h:126
int exchange_dst
Definition: HomePatch.h:441
SimParameters * simParameters
Definition: Node.h:178
void sendExchangeReq(int pid, int src)
Definition: PatchMgr.C:386
ExchangeAtomsMsg * exchange_msg
Definition: HomePatch.h:444
Lattice lattice
Definition: PatchMgr.h:109
int numAtoms
Definition: Patch.h:144
BigReal scriptArg1
int exchange_req
Definition: HomePatch.h:443
int exchange_src
Definition: HomePatch.h:442
#define simParams
Definition: Output.C:127
const PatchID patchID
Definition: Patch.h:143
void recvExchangeReq(int req)
Definition: HomePatch.C:3594
FullAtom * atoms
Definition: PatchMgr.h:112
static PatchMgr * Object()
Definition: PatchMgr.h:152
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::exchangeCheckpoint ( int  scriptTask,
int &  bpc 
)

Definition at line 3477 of file HomePatch.C.

References checkpoint_task, Node::Object(), PatchMgr::Object(), Patch::patchID, SimParameters::scriptIntArg1, SimParameters::scriptStringArg1, PatchMgr::sendCheckpointReq(), and Node::simParameters.

Referenced by Sequencer::algorithm().

3477  { // initiating replica
3479  checkpoint_task = scriptTask;
3480  const int remote = simParams->scriptIntArg1;
3481  const char *key = simParams->scriptStringArg1;
3482  PatchMgr::Object()->sendCheckpointReq(patchID, remote, key, scriptTask);
3483 }
static Node * Object()
Definition: Node.h:86
char scriptStringArg1[128]
SimParameters * simParameters
Definition: Node.h:178
#define simParams
Definition: Output.C:127
const PatchID patchID
Definition: Patch.h:143
int checkpoint_task
Definition: HomePatch.h:428
void sendCheckpointReq(int pid, int remote, const char *key, int task)
Definition: PatchMgr.C:270
static PatchMgr * Object()
Definition: PatchMgr.h:152
void HomePatch::gbisComputeAfterP1 ( )

Definition at line 3146 of file HomePatch.C.

References SimParameters::alpha_max, Patch::bornRad, SimParameters::coulomb_radius_offset, Patch::flags, SimParameters::gbis_beta, SimParameters::gbis_delta, SimParameters::gbis_gamma, gbisP2Ready(), Patch::intRad, Patch::numAtoms, Node::Object(), Patch::pExt, Patch::psiFin, Patch::psiSum, Flags::sequence, and Node::simParameters.

3146  {
3147 
3149  BigReal alphaMax = simParams->alpha_max;
3150  BigReal delta = simParams->gbis_delta;
3151  BigReal beta = simParams->gbis_beta;
3152  BigReal gamma = simParams->gbis_gamma;
3153  BigReal coulomb_radius_offset = simParams->coulomb_radius_offset;
3154 
3155  BigReal rhoi;
3156  BigReal rhoi0;
3157  //calculate bornRad from psiSum
3158  for (int i = 0; i < numAtoms; i++) {
3159  rhoi0 = intRad[2*i];
3160  rhoi = rhoi0+coulomb_radius_offset;
3161  psiFin[i] += psiSum[i];
3162  psiFin[i] *= rhoi0;
3163  bornRad[i]=1/(1/rhoi0-1/rhoi*tanh(psiFin[i]*(delta+psiFin[i]*(-beta+gamma*psiFin[i]))));
3164  bornRad[i] = (bornRad[i] > alphaMax) ? alphaMax : bornRad[i];
3165 #ifdef PRINT_COMP
3166  CkPrintf("BORNRAD(%04i)[%04i] = % .4e\n",flags.sequence,pExt[i].id,bornRad[i]);
3167 #endif
3168  }
3169 
3170  gbisP2Ready();
3171 }
static Node * Object()
Definition: Node.h:86
RealList intRad
Definition: Patch.h:155
SimParameters * simParameters
Definition: Node.h:178
BigReal gbis_gamma
GBRealList psiFin
Definition: Patch.h:157
BigReal coulomb_radius_offset
Flags flags
Definition: Patch.h:127
BigReal alpha_max
GBRealList psiSum
Definition: Patch.h:156
BigReal gbis_beta
int numAtoms
Definition: Patch.h:144
int sequence
Definition: PatchTypes.h:18
void gbisP2Ready()
Definition: HomePatch.C:3218
#define simParams
Definition: Output.C:127
RealList bornRad
Definition: Patch.h:158
BigReal gbis_delta
CompAtomExtList pExt
Definition: Patch.h:174
double BigReal
Definition: common.h:112
void HomePatch::gbisComputeAfterP2 ( )

Definition at line 3174 of file HomePatch.C.

References Patch::bornRad, COULOMB, SimParameters::coulomb_radius_offset, Patch::dEdaSum, Patch::dHdrPrefix, SimParameters::dielectric, Patch::flags, SimParameters::gbis_beta, SimParameters::gbis_delta, SimParameters::gbis_gamma, gbisP3Ready(), Patch::intRad, SimParameters::kappa, Patch::numAtoms, Node::Object(), Patch::pExt, Patch::psiFin, Flags::sequence, Node::simParameters, and SimParameters::solvent_dielectric.

3174  {
3175 
3177  BigReal delta = simParams->gbis_delta;
3178  BigReal beta = simParams->gbis_beta;
3179  BigReal gamma = simParams->gbis_gamma;
3180  BigReal epsilon_s = simParams->solvent_dielectric;
3181  BigReal epsilon_p = simParams->dielectric;
3182  BigReal epsilon_s_i = 1/simParams->solvent_dielectric;
3183  BigReal epsilon_p_i = 1/simParams->dielectric;
3184  BigReal coulomb_radius_offset = simParams->coulomb_radius_offset;
3185  BigReal kappa = simParams->kappa;
3186  BigReal fij, expkappa, Dij, dEdai, dedasum;
3187  BigReal rhoi, rhoi0, psii, nbetapsi;
3188  BigReal gammapsi2, tanhi, daidr;
3189  for (int i = 0; i < numAtoms; i++) {
3190  //add diagonal dEda term
3191  dHdrPrefix[i] += dEdaSum[i];//accumulated from proxies
3192  fij = bornRad[i];//inf
3193  expkappa = exp(-kappa*fij);//0
3194  Dij = epsilon_p_i - expkappa*epsilon_s_i;//dielectric term
3195  //calculate dHij prefix
3196  dEdai = -0.5*COULOMB*atom[i].charge*atom[i].charge
3197  *(kappa*epsilon_s_i*expkappa-Dij/fij)/bornRad[i];
3198  dHdrPrefix[i] += dEdai;
3199  dedasum = dHdrPrefix[i];
3200 
3201  rhoi0 = intRad[2*i];
3202  rhoi = rhoi0+coulomb_radius_offset;
3203  psii = psiFin[i];
3204  nbetapsi = -beta*psii;
3205  gammapsi2 = gamma*psii*psii;
3206  tanhi = tanh(psii*(delta+nbetapsi+gammapsi2));
3207  daidr = bornRad[i]*bornRad[i]*rhoi0/rhoi*(1-tanhi*tanhi)
3208  * (delta+nbetapsi+nbetapsi+gammapsi2+gammapsi2+gammapsi2);
3209  dHdrPrefix[i] *= daidr;//dHdrPrefix previously equaled dEda
3210 #ifdef PRINT_COMP
3211  CkPrintf("DHDR(%04i)[%04i] = % .4e\n",flags.sequence,pExt[i].id,dHdrPrefix[i]);
3212 #endif
3213  }
3214  gbisP3Ready();
3215 }
static Node * Object()
Definition: Node.h:86
RealList intRad
Definition: Patch.h:155
BigReal solvent_dielectric
SimParameters * simParameters
Definition: Node.h:178
#define COULOMB
Definition: common.h:44
BigReal gbis_gamma
RealList dHdrPrefix
Definition: Patch.h:159
GBRealList psiFin
Definition: Patch.h:157
GBRealList dEdaSum
Definition: Patch.h:160
void gbisP3Ready()
Definition: HomePatch.C:3238
BigReal coulomb_radius_offset
Flags flags
Definition: Patch.h:127
BigReal gbis_beta
int numAtoms
Definition: Patch.h:144
int sequence
Definition: PatchTypes.h:18
#define simParams
Definition: Output.C:127
RealList bornRad
Definition: Patch.h:158
BigReal gbis_delta
BigReal dielectric
CompAtomExtList pExt
Definition: Patch.h:174
double BigReal
Definition: common.h:112
void HomePatch::gbisP2Ready ( )

Definition at line 3218 of file HomePatch.C.

References ResizeArray< T >::begin(), ProxyGBISP2DataMsg::bornRad, Patch::bornRad, ProxyGBISP2DataMsg::destPe, Patch::flags, GB2_PROXY_DATA_PRIORITY, Patch::gbisP2Ready(), Patch::numAtoms, ProxyGBISP2DataMsg::origPe, ProxyGBISP2DataMsg::patch, PATCH_PRIORITY, Patch::patchID, PRIORITY_SIZE, Flags::sequence, SET_PRIORITY, and ResizeArray< T >::size().

Referenced by gbisComputeAfterP1().

3218  {
3219  if (proxy.size() > 0) {
3220  CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
3221  for (int i = 0; i < proxy.size(); i++) {
3222  int node = proxy[i];
3224  msg->patch = patchID;
3225  msg->origPe = CkMyPe();
3226  memcpy(msg->bornRad,bornRad.begin(),numAtoms*sizeof(Real));
3227  msg->destPe = node;
3228  int seq = flags.sequence;
3230  SET_PRIORITY(msg,seq,priority);
3231  cp[node].recvData(msg);
3232  }
3233  }
3235 }
float Real
Definition: common.h:107
Flags flags
Definition: Patch.h:127
#define PRIORITY_SIZE
Definition: Priorities.h:13
void gbisP2Ready()
Definition: Patch.C:569
int numAtoms
Definition: Patch.h:144
int sequence
Definition: PatchTypes.h:18
RealList bornRad
Definition: Patch.h:158
const PatchID patchID
Definition: Patch.h:143
int size(void) const
Definition: ResizeArray.h:127
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18
#define GB2_PROXY_DATA_PRIORITY
Definition: Priorities.h:58
#define PATCH_PRIORITY(PID)
Definition: Priorities.h:25
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::gbisP3Ready ( )

Definition at line 3238 of file HomePatch.C.

References ResizeArray< T >::begin(), ProxyGBISP3DataMsg::destPe, ProxyGBISP3DataMsg::dHdrPrefix, Patch::dHdrPrefix, ProxyGBISP3DataMsg::dHdrPrefixLen, Flags::doFullElectrostatics, Patch::flags, GB3_PROXY_DATA_PRIORITY, Patch::gbisP3Ready(), ProxyGBISP3DataMsg::origPe, ProxyGBISP3DataMsg::patch, PATCH_PRIORITY, Patch::patchID, PRIORITY_SIZE, Flags::sequence, SET_PRIORITY, and ResizeArray< T >::size().

Referenced by gbisComputeAfterP2().

3238  {
3239  if (proxy.size() > 0) {
3240  CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
3241  //only nonzero message should be sent for doFullElec
3242  int msgAtoms = (flags.doFullElectrostatics) ? numAtoms : 0;
3243  for (int i = 0; i < proxy.size(); i++) {
3244  int node = proxy[i];
3246  msg->patch = patchID;
3247  msg->dHdrPrefixLen = msgAtoms;
3248  msg->origPe = CkMyPe();
3249  memcpy(msg->dHdrPrefix, dHdrPrefix.begin(), msgAtoms*sizeof(Real));
3250  msg->destPe = node;
3251  int seq = flags.sequence;
3253  SET_PRIORITY(msg,seq,priority);
3254  cp[node].recvData(msg);
3255  }
3256  }
3258 }
float Real
Definition: common.h:107
RealList dHdrPrefix
Definition: Patch.h:159
Flags flags
Definition: Patch.h:127
#define PRIORITY_SIZE
Definition: Priorities.h:13
int doFullElectrostatics
Definition: PatchTypes.h:23
int numAtoms
Definition: Patch.h:144
int sequence
Definition: PatchTypes.h:18
void gbisP3Ready()
Definition: Patch.C:586
const PatchID patchID
Definition: Patch.h:143
Real * dHdrPrefix
Definition: ProxyMgr.h:59
int size(void) const
Definition: ResizeArray.h:127
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18
#define GB3_PROXY_DATA_PRIORITY
Definition: Priorities.h:66
#define PATCH_PRIORITY(PID)
Definition: Priorities.h:25
iterator begin(void)
Definition: ResizeArray.h:36
FullAtomList& HomePatch::getAtomList ( )
inline

Definition at line 455 of file HomePatch.h.

Referenced by ComputeHomePatch::doWork(), and dumpbench().

455 { return (atom); }
int HomePatch::hardWallDrude ( const BigReal  timestep,
Tensor virial,
SubmitReduction ppreduction 
)

Definition at line 2023 of file HomePatch.C.

References BOLTZMANN, Lattice::c(), SimParameters::drudeBondLen, SimParameters::drudeHardWallOn, SimParameters::drudeTemp, endi(), SimParameters::fixedAtomsOn, iERROR(), iout, SubmitReduction::item(), Patch::lattice, Node::molecule, Patch::numAtoms, Node::Object(), Lattice::origin(), outer(), partition(), SimParameters::pressureProfileSlabs, SimParameters::rigidDie, Node::simParameters, TIMEFACTOR, Vector::x, Tensor::xx, Vector::y, Tensor::yy, Vector::z, z, and Tensor::zz.

Referenced by Sequencer::hardWallDrude().

2025 {
2026  Molecule *mol = Node::Object()->molecule;
2028  const BigReal kbt=BOLTZMANN*simParams->drudeTemp;
2029  const int fixedAtomsOn = simParams->fixedAtomsOn;
2030  const BigReal dt = timestep / TIMEFACTOR;
2031  const BigReal invdt = (dt == 0.) ? 0. : 1.0 / dt; // precalc 1/dt
2032  int i, ia, ib, j;
2033  int dieOnError = simParams->rigidDie;
2034  Tensor wc; // constraint virial
2035  BigReal idz, zmin, delta_T, maxtime=timestep,v_Bond;
2036  int nslabs;
2037 
2038  // start data for hard wall boundary between drude and its host atom
2039  // static int Count=0;
2040  int Idx;
2041  double r_wall, r_wall_SQ, rab, rab_SQ, dr, mass_a, mass_b, mass_sum;
2042  Vector v_ab, vb_1, vp_1, vb_2, vp_2, new_vel_a, new_vel_b, new_pos_a, new_pos_b, *new_pos, *new_vel;
2043  double dot_v_r_1, dot_v_r_2;
2044  double vb_cm, dr_a, dr_b;
2045  // end data for hard wall boundary between drude and its host atom
2046 
2047  // start calculation of hard wall boundary between drude and its host atom
2048  if (simParams->drudeHardWallOn) {
2049  if (ppreduction) {
2050  nslabs = simParams->pressureProfileSlabs;
2051  idz = nslabs/lattice.c().z;
2052  zmin = lattice.origin().z - 0.5*lattice.c().z;
2053  }
2054 
2055  r_wall = simParams->drudeBondLen;
2056  r_wall_SQ = r_wall*r_wall;
2057  // Count++;
2058  for (i=1; i<numAtoms; i++) {
2059  if ( (0.05 < atom[i].mass) && ((atom[i].mass < 1.0)) ) { // drude particle
2060  ia = i-1;
2061  ib = i;
2062 
2063  v_ab = atom[ib].position - atom[ia].position;
2064  rab_SQ = v_ab.x*v_ab.x + v_ab.y*v_ab.y + v_ab.z*v_ab.z;
2065 
2066  if (rab_SQ > r_wall_SQ) { // to impose the hard wall constraint
2067  rab = sqrt(rab_SQ);
2068  if ( (rab > (2.0*r_wall)) && dieOnError ) { // unexpected situation
2069  iout << iERROR << "HardWallDrude> "
2070  << "The drude is too far away from atom "
2071  << (atom[ia].id + 1) << " d = " << rab << "!\n" << endi;
2072  return -1; // triggers early exit
2073  }
2074 
2075  v_ab.x /= rab;
2076  v_ab.y /= rab;
2077  v_ab.z /= rab;
2078 
2079  if ( fixedAtomsOn && atom[ia].atomFixed ) { // the heavy atom is fixed
2080  if (atom[ib].atomFixed) { // the drude is fixed too
2081  continue;
2082  }
2083  else { // only the heavy atom is fixed
2084  dot_v_r_2 = atom[ib].velocity.x*v_ab.x
2085  + atom[ib].velocity.y*v_ab.y + atom[ib].velocity.z*v_ab.z;
2086  vb_2 = dot_v_r_2 * v_ab;
2087  vp_2 = atom[ib].velocity - vb_2;
2088 
2089  dr = rab - r_wall;
2090  if(dot_v_r_2 == 0.0) {
2091  delta_T = maxtime;
2092  }
2093  else {
2094  delta_T = dr/fabs(dot_v_r_2); // the time since the collision occurs
2095  if(delta_T > maxtime ) delta_T = maxtime; // make sure it is not crazy
2096  }
2097 
2098  dot_v_r_2 = -dot_v_r_2*sqrt(kbt/atom[ib].mass)/fabs(dot_v_r_2);
2099 
2100  vb_2 = dot_v_r_2 * v_ab;
2101 
2102  new_vel_a = atom[ia].velocity;
2103  new_vel_b = vp_2 + vb_2;
2104 
2105  dr_b = -dr + delta_T*dot_v_r_2; // L = L_0 + dT *v_new, v was flipped
2106 
2107  new_pos_a = atom[ia].position;
2108  new_pos_b = atom[ib].position + dr_b*v_ab; // correct the position
2109  }
2110  }
2111  else {
2112  mass_a = atom[ia].mass;
2113  mass_b = atom[ib].mass;
2114  mass_sum = mass_a+mass_b;
2115 
2116  dot_v_r_1 = atom[ia].velocity.x*v_ab.x
2117  + atom[ia].velocity.y*v_ab.y + atom[ia].velocity.z*v_ab.z;
2118  vb_1 = dot_v_r_1 * v_ab;
2119  vp_1 = atom[ia].velocity - vb_1;
2120 
2121  dot_v_r_2 = atom[ib].velocity.x*v_ab.x
2122  + atom[ib].velocity.y*v_ab.y + atom[ib].velocity.z*v_ab.z;
2123  vb_2 = dot_v_r_2 * v_ab;
2124  vp_2 = atom[ib].velocity - vb_2;
2125 
2126  vb_cm = (mass_a*dot_v_r_1 + mass_b*dot_v_r_2)/mass_sum;
2127 
2128  dot_v_r_1 -= vb_cm;
2129  dot_v_r_2 -= vb_cm;
2130 
2131  dr = rab - r_wall;
2132 
2133  if(dot_v_r_2 == dot_v_r_1) {
2134  delta_T = maxtime;
2135  }
2136  else {
2137  delta_T = dr/fabs(dot_v_r_2 - dot_v_r_1); // the time since the collision occurs
2138  if(delta_T > maxtime ) delta_T = maxtime; // make sure it is not crazy
2139  }
2140 
2141  // the relative velocity between ia and ib. Drawn according to T_Drude
2142  v_Bond = sqrt(kbt/mass_b);
2143 
2144  // reflect the velocity along bond vector and scale down
2145  dot_v_r_1 = -dot_v_r_1*v_Bond*mass_b/(fabs(dot_v_r_1)*mass_sum);
2146  dot_v_r_2 = -dot_v_r_2*v_Bond*mass_a/(fabs(dot_v_r_2)*mass_sum);
2147 
2148  dr_a = dr*mass_b/mass_sum + delta_T*dot_v_r_1;
2149  dr_b = -dr*mass_a/mass_sum + delta_T*dot_v_r_2;
2150 
2151  new_pos_a = atom[ia].position + dr_a*v_ab; // correct the position
2152  new_pos_b = atom[ib].position + dr_b*v_ab;
2153  // atom[ia].position += (dr_a*v_ab); // correct the position
2154  // atom[ib].position += (dr_b*v_ab);
2155 
2156  dot_v_r_1 += vb_cm;
2157  dot_v_r_2 += vb_cm;
2158 
2159  vb_1 = dot_v_r_1 * v_ab;
2160  vb_2 = dot_v_r_2 * v_ab;
2161 
2162  new_vel_a = vp_1 + vb_1;
2163  new_vel_b = vp_2 + vb_2;
2164  }
2165 
2166  int ppoffset, partition;
2167  if ( invdt == 0 ) {
2168  atom[ia].position = new_pos_a;
2169  atom[ib].position = new_pos_b;
2170  }
2171  else if ( virial == 0 ) {
2172  atom[ia].velocity = new_vel_a;
2173  atom[ib].velocity = new_vel_b;
2174  }
2175  else {
2176  for ( j = 0; j < 2; j++ ) {
2177  if (j==0) { // atom ia, heavy atom
2178  Idx = ia;
2179  new_pos = &new_pos_a;
2180  new_vel = &new_vel_a;
2181  }
2182  else if (j==1) { // atom ib, drude
2183  Idx = ib;
2184  new_pos = &new_pos_b;
2185  new_vel = &new_vel_b;
2186  }
2187  Force df = (*new_vel - atom[Idx].velocity) *
2188  ( atom[Idx].mass * invdt );
2189  Tensor vir = outer(df, atom[Idx].position);
2190  wc += vir;
2191  atom[Idx].velocity = *new_vel;
2192  atom[Idx].position = *new_pos;
2193 
2194  if (ppreduction) {
2195  if (!j) {
2196  BigReal z = new_pos->z;
2197  int partition = atom[Idx].partition;
2198  int slab = (int)floor((z-zmin)*idz);
2199  if (slab < 0) slab += nslabs;
2200  else if (slab >= nslabs) slab -= nslabs;
2201  ppoffset = 3*(slab + nslabs*partition);
2202  }
2203  ppreduction->item(ppoffset ) += vir.xx;
2204  ppreduction->item(ppoffset+1) += vir.yy;
2205  ppreduction->item(ppoffset+2) += vir.zz;
2206  }
2207 
2208  }
2209  }
2210  }
2211  }
2212  }
2213 
2214  // if ( (Count>10000) && (Count%10==0) ) {
2215  // v_ab = atom[1].position - atom[0].position;
2216  // rab_SQ = v_ab.x*v_ab.x + v_ab.y*v_ab.y + v_ab.z*v_ab.z;
2217  // iout << "DBG_R: " << Count << " " << sqrt(rab_SQ) << "\n" << endi;
2218  // }
2219 
2220  }
2221 
2222  // end calculation of hard wall boundary between drude and its host atom
2223 
2224  if ( dt && virial ) *virial += wc;
2225 
2226  return 0;
2227 }
static Node * Object()
Definition: Node.h:86
#define BOLTZMANN
Definition: common.h:45
Lattice & lattice
Definition: Patch.h:126
static void partition(int *order, const FullAtom *atoms, int begin, int end)
Definition: SortAtoms.C:41
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
BigReal & item(int i)
Definition: ReductionMgr.h:312
BigReal z
Definition: Vector.h:66
#define iout
Definition: InfoStream.h:87
int pressureProfileSlabs
Vector origin() const
Definition: Lattice.h:262
gridSize z
BigReal drudeBondLen
int numAtoms
Definition: Patch.h:144
BigReal x
Definition: Vector.h:66
Tensor outer(const Vector &v1, const Vector &v2)
Definition: Tensor.h:241
BigReal xx
Definition: Tensor.h:17
BigReal zz
Definition: Tensor.h:19
#define simParams
Definition: Output.C:127
Definition: Tensor.h:15
BigReal y
Definition: Vector.h:66
BigReal yy
Definition: Tensor.h:18
#define TIMEFACTOR
Definition: common.h:46
std::ostream & iERROR(std::ostream &s)
Definition: InfoStream.C:109
infostream & endi(infostream &s)
Definition: InfoStream.C:38
Molecule * molecule
Definition: Node.h:176
Vector c() const
Definition: Lattice.h:254
double BigReal
Definition: common.h:112
BigReal drudeTemp
void HomePatch::loweAndersenFinish ( )

Definition at line 3112 of file HomePatch.C.

References DebugM.

3113 {
3114  DebugM(2, "loweAndersenFinish\n");
3115  v.resize(0);
3116 }
#define DebugM(x, y)
Definition: Debug.h:59
CompAtomList v
Definition: Patch.h:149
void resize(int i)
Definition: ResizeArray.h:84
void HomePatch::loweAndersenVelocities ( )

Definition at line 3097 of file HomePatch.C.

References DebugM, Node::molecule, Patch::numAtoms, Node::Object(), and Node::simParameters.

Referenced by positionsReady().

3098 {
3099  DebugM(2, "loweAndersenVelocities\n");
3100  Molecule *mol = Node::Object()->molecule;
3102  v.resize(numAtoms);
3103  for (int i = 0; i < numAtoms; ++i) {
3104  //v[i] = p[i];
3105  // co-opt CompAtom structure to pass velocity and mass information
3106  v[i].position = atom[i].velocity;
3107  v[i].charge = atom[i].mass;
3108  }
3109  DebugM(2, "loweAndersenVelocities\n");
3110 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:178
#define DebugM(x, y)
Definition: Debug.h:59
CompAtomList v
Definition: Patch.h:149
int numAtoms
Definition: Patch.h:144
#define simParams
Definition: Output.C:127
void resize(int i)
Definition: ResizeArray.h:84
Molecule * molecule
Definition: Node.h:176
void HomePatch::minimize_rattle2 ( const BigReal  timestep,
Tensor virial,
bool  forces = false 
)

Definition at line 2962 of file HomePatch.C.

References ResizeArray< T >::begin(), endi(), Patch::f, SimParameters::fixedAtomsOn, iout, iWARN(), Node::molecule, NAMD_bug(), NAMD_die(), Results::normal, Patch::numAtoms, Node::Object(), outer(), SimParameters::rigidDie, SimParameters::rigidIter, SimParameters::rigidTol, settle2(), Node::simParameters, TIMEFACTOR, SimParameters::useSettle, WAT_SWM4, WAT_TIP4, SimParameters::watmodel, Vector::x, Vector::y, and Vector::z.

Referenced by Sequencer::newMinimizeDirection(), and Sequencer::submitMinimizeReductions().

2963 {
2964  Molecule *mol = Node::Object()->molecule;
2966  Force *f1 = f[Results::normal].begin();
2967  const int fixedAtomsOn = simParams->fixedAtomsOn;
2968  const int useSettle = simParams->useSettle;
2969  const BigReal dt = timestep / TIMEFACTOR;
2970  Tensor wc; // constraint virial
2971  BigReal tol = simParams->rigidTol;
2972  int maxiter = simParams->rigidIter;
2973  int dieOnError = simParams->rigidDie;
2974  int i, iter;
2975  BigReal dsqi[10], tmp;
2976  int ial[10], ibl[10];
2977  Vector ref[10]; // reference position
2978  Vector refab[10]; // reference vector
2979  Vector vel[10]; // new velocity
2980  BigReal rmass[10]; // 1 / mass
2981  BigReal redmass[10]; // reduced mass
2982  int fixed[10]; // is atom fixed?
2983 
2984  // Size of a hydrogen group for water
2985  int wathgsize = 3;
2986  if (simParams->watmodel == WAT_TIP4) wathgsize = 4;
2987  else if (simParams->watmodel == WAT_SWM4) wathgsize = 5;
2988 
2989  // CkPrintf("In rattle2!\n");
2990  for ( int ig = 0; ig < numAtoms; ig += atom[ig].hydrogenGroupSize ) {
2991  // CkPrintf("ig=%d\n",ig);
2992  int hgs = atom[ig].hydrogenGroupSize;
2993  if ( hgs == 1 ) continue; // only one atom in group
2994  // cache data in local arrays and integrate positions normally
2995  int anyfixed = 0;
2996  for ( i = 0; i < hgs; ++i ) {
2997  ref[i] = atom[ig+i].position;
2998  vel[i] = ( forces ? f1[ig+i] : atom[ig+i].velocity );
2999  rmass[i] = 1.0;
3000  fixed[i] = ( fixedAtomsOn && atom[ig+i].atomFixed );
3001  if ( fixed[i] ) { anyfixed = 1; rmass[i] = 0.; }
3002  }
3003  int icnt = 0;
3004  if ( ( tmp = atom[ig].rigidBondLength ) > 0 ) { // for water
3005  if (hgs != wathgsize) {
3006  NAMD_bug("Hydrogen group error caught in rattle2().");
3007  }
3008  // Use SETTLE for water unless some of the water atoms are fixed,
3009  if (useSettle && !anyfixed) {
3010  if (simParams->watmodel == WAT_SWM4) {
3011  // SWM4 ordering: O D LP H1 H2
3012  // do swap(O,LP) and call settle with subarray O H1 H2
3013  // swap back after we return
3014  Vector lp_ref = ref[2];
3015  // Vector lp_vel = vel[2];
3016  ref[2] = ref[0];
3017  vel[2] = vel[0];
3018  settle2(1.0, 1.0, ref+2, vel+2, dt, virial);
3019  ref[0] = ref[2];
3020  vel[0] = vel[2];
3021  ref[2] = lp_ref;
3022  // vel[2] = vel[0]; // set LP vel to O vel
3023  }
3024  else {
3025  settle2(1.0, 1.0, ref, vel, dt, virial);
3026  if (simParams->watmodel == WAT_TIP4) {
3027  vel[3] = vel[0];
3028  }
3029  }
3030  for (i=0; i<hgs; i++) {
3031  ( forces ? f1[ig+i] : atom[ig+i].velocity ) = vel[i];
3032  }
3033  continue;
3034  }
3035  if ( !(fixed[1] && fixed[2]) ) {
3036  redmass[icnt] = 1. / (rmass[1] + rmass[2]);
3037  dsqi[icnt] = 1. / (tmp * tmp); ial[icnt] = 1; ibl[icnt] = 2; ++icnt;
3038  }
3039  }
3040  // CkPrintf("Loop 2\n");
3041  for ( i = 1; i < hgs; ++i ) { // normal bonds to mother atom
3042  if ( ( tmp = atom[ig+i].rigidBondLength ) > 0 ) {
3043  if ( !(fixed[0] && fixed[i]) ) {
3044  redmass[icnt] = 1. / (rmass[0] + rmass[i]);
3045  dsqi[icnt] = 1. / (tmp * tmp); ial[icnt] = 0;
3046  ibl[icnt] = i; ++icnt;
3047  }
3048  }
3049  }
3050  if ( icnt == 0 ) continue; // no constraints
3051  // CkPrintf("Loop 3\n");
3052  for ( i = 0; i < icnt; ++i ) {
3053  refab[i] = ref[ial[i]] - ref[ibl[i]];
3054  }
3055  // CkPrintf("Loop 4\n");
3056  int done;
3057  for ( iter = 0; iter < maxiter; ++iter ) {
3058  done = 1;
3059  for ( i = 0; i < icnt; ++i ) {
3060  int a = ial[i]; int b = ibl[i];
3061  Vector vab = vel[a] - vel[b];
3062  Vector &rab = refab[i];
3063  BigReal rabsqi = dsqi[i];
3064  BigReal rvab = rab.x*vab.x + rab.y*vab.y + rab.z*vab.z;
3065  if ( (fabs(rvab) * dt * rabsqi) > tol ) {
3066  Vector dp = rab * (-rvab * redmass[i] * rabsqi);
3067  wc += outer(dp,rab);
3068  vel[a] += rmass[a] * dp;
3069  vel[b] -= rmass[b] * dp;
3070  done = 0;
3071  }
3072  }
3073  if ( done ) break;
3074  //if (done) { if (iter > 0) CkPrintf("iter=%d\n", iter); break; }
3075  }
3076  if ( ! done ) {
3077  if ( dieOnError ) {
3078  NAMD_die("Exceeded maximum number of iterations in rattle2().");
3079  } else {
3080  iout << iWARN <<
3081  "Exceeded maximum number of iterations in rattle2().\n" << endi;
3082  }
3083  }
3084  // store data back to patch
3085  for ( i = 0; i < hgs; ++i ) {
3086  ( forces ? f1[ig+i] : atom[ig+i].velocity ) = vel[i];
3087  }
3088  }
3089  // CkPrintf("Leaving rattle2!\n");
3090  // check that there isn't a constant needed here!
3091  *virial += wc / ( 0.5 * dt );
3092 
3093 }
static Node * Object()
Definition: Node.h:86
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
static __thread float4 * forces
BigReal z
Definition: Vector.h:66
std::ostream & iWARN(std::ostream &s)
Definition: InfoStream.C:108
BigReal rigidTol
#define iout
Definition: InfoStream.h:87
int settle2(BigReal mO, BigReal mH, const Vector *pos, Vector *vel, BigReal dt, Tensor *virial)
Definition: Settle.C:705
void NAMD_bug(const char *err_msg)
Definition: common.C:123
#define WAT_SWM4
Definition: common.h:190
int numAtoms
Definition: Patch.h:144
BigReal x
Definition: Vector.h:66
void NAMD_die(const char *err_msg)
Definition: common.C:83
Tensor outer(const Vector &v1, const Vector &v2)
Definition: Tensor.h:241
#define simParams
Definition: Output.C:127
Definition: Tensor.h:15
BigReal y
Definition: Vector.h:66
#define TIMEFACTOR
Definition: common.h:46
#define WAT_TIP4
Definition: common.h:189
infostream & endi(infostream &s)
Definition: InfoStream.C:38
ForceList f[Results::maxNumForces]
Definition: Patch.h:207
Molecule * molecule
Definition: Node.h:176
double BigReal
Definition: common.h:112
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::mollyAverage ( )

Definition at line 3312 of file HomePatch.C.

References average(), endi(), SimParameters::fixedAtomsOn, iout, iWARN(), Node::molecule, SimParameters::mollyIter, SimParameters::mollyTol, NAMD_die(), Patch::numAtoms, Node::Object(), Patch::p_avg, ResizeArray< T >::resize(), and Node::simParameters.

Referenced by positionsReady().

3313 {
3314  Molecule *mol = Node::Object()->molecule;
3316  BigReal tol = simParams->mollyTol;
3317  int maxiter = simParams->mollyIter;
3318  int i, iter;
3319  HGArrayBigReal dsq;
3320  BigReal tmp;
3321  HGArrayInt ial, ibl;
3322  HGArrayVector ref; // reference position
3323  HGArrayVector refab; // reference vector
3324  HGArrayBigReal rmass; // 1 / mass
3325  BigReal *lambda; // Lagrange multipliers
3326  CompAtom *avg; // averaged position
3327  int numLambdas = 0;
3328  HGArrayInt fixed; // is atom fixed?
3329 
3330  // iout<<iINFO << "mollyAverage: "<<std::endl<<endi;
3332  for ( i=0; i<numAtoms; ++i ) p_avg[i] = p[i];
3333 
3334  for ( int ig = 0; ig < numAtoms; ig += atom[ig].hydrogenGroupSize ) {
3335  int hgs = atom[ig].hydrogenGroupSize;
3336  if ( hgs == 1 ) continue; // only one atom in group
3337  for ( i = 0; i < hgs; ++i ) {
3338  ref[i] = atom[ig+i].position;
3339  rmass[i] = 1. / atom[ig+i].mass;
3340  fixed[i] = ( simParams->fixedAtomsOn && atom[ig+i].atomFixed );
3341  if ( fixed[i] ) rmass[i] = 0.;
3342  }
3343  avg = &(p_avg[ig]);
3344  int icnt = 0;
3345 
3346  if ( ( tmp = atom[ig].rigidBondLength ) > 0 ) { // for water
3347  if ( hgs != 3 ) {
3348  NAMD_die("Hydrogen group error caught in mollyAverage(). It's a bug!\n");
3349  }
3350  if ( !(fixed[1] && fixed[2]) ) {
3351  dsq[icnt] = tmp * tmp; ial[icnt] = 1; ibl[icnt] = 2; ++icnt;
3352  }
3353  }
3354  for ( i = 1; i < hgs; ++i ) { // normal bonds to mother atom
3355  if ( ( tmp = atom[ig+i].rigidBondLength ) > 0 ) {
3356  if ( !(fixed[0] && fixed[i]) ) {
3357  dsq[icnt] = tmp * tmp; ial[icnt] = 0; ibl[icnt] = i; ++icnt;
3358  }
3359  }
3360  }
3361  if ( icnt == 0 ) continue; // no constraints
3362  numLambdas += icnt;
3363  molly_lambda.resize(numLambdas);
3364  lambda = &(molly_lambda[numLambdas - icnt]);
3365  for ( i = 0; i < icnt; ++i ) {
3366  refab[i] = ref[ial[i]] - ref[ibl[i]];
3367  }
3368  // iout<<iINFO<<"hgs="<<hgs<<" m="<<icnt<<std::endl<<endi;
3369  iter=average(avg,ref,lambda,hgs,icnt,rmass,dsq,ial,ibl,refab,tol,maxiter);
3370  if ( iter == maxiter ) {
3371  iout << iWARN << "Exceeded maximum number of iterations in mollyAverage().\n"<<endi;
3372  }
3373  }
3374 
3375  // for ( i=0; i<numAtoms; ++i ) {
3376  // if ( ( p_avg[i].position - p[i].position ).length2() > 1.0 ) {
3377  // iout << iERROR << "MOLLY moved atom " << (p[i].id + 1) << " from "
3378  // << p[i].position << " to " << p_avg[i].position << "\n" << endi;
3379  // }
3380  // }
3381 
3382 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:178
std::ostream & iWARN(std::ostream &s)
Definition: InfoStream.C:108
#define iout
Definition: InfoStream.h:87
BigReal mollyTol
BigReal HGArrayBigReal[MAXHGS]
Definition: HomePatch.C:63
CompAtomList p_avg
Definition: Patch.h:147
CompAtomList p
Definition: Patch.h:146
int numAtoms
Definition: Patch.h:144
void NAMD_die(const char *err_msg)
Definition: common.C:83
int HGArrayInt[MAXHGS]
Definition: HomePatch.C:62
#define simParams
Definition: Output.C:127
void resize(int i)
Definition: ResizeArray.h:84
infostream & endi(infostream &s)
Definition: InfoStream.C:38
zVector HGArrayVector[MAXHGS]
Definition: HomePatch.C:64
Molecule * molecule
Definition: Node.h:176
double BigReal
Definition: common.h:112
int average(CompAtom *qtilde, const HGArrayVector &q, BigReal *lambda, const int n, const int m, const HGArrayBigReal &imass, const HGArrayBigReal &length2, const HGArrayInt &ial, const HGArrayInt &ibl, const HGArrayVector &refab, const BigReal tolf, const int ntrial)
Definition: HomePatch.C:4490
void HomePatch::mollyMollify ( Tensor virial)

Definition at line 3386 of file HomePatch.C.

References Patch::f, SimParameters::fixedAtomsOn, Node::molecule, mollify(), NAMD_die(), Patch::numAtoms, Node::Object(), outer(), Patch::p_avg, ResizeArray< T >::resize(), Node::simParameters, and Results::slow.

3387 {
3388  Molecule *mol = Node::Object()->molecule;
3390  Tensor wc; // constraint virial
3391  int i;
3392  HGArrayInt ial, ibl;
3393  HGArrayVector ref; // reference position
3394  CompAtom *avg; // averaged position
3395  HGArrayVector refab; // reference vector
3396  HGArrayVector force; // new force
3397  HGArrayBigReal rmass; // 1 / mass
3398  BigReal *lambda; // Lagrange multipliers
3399  int numLambdas = 0;
3400  HGArrayInt fixed; // is atom fixed?
3401 
3402  for ( int ig = 0; ig < numAtoms; ig += atom[ig].hydrogenGroupSize ) {
3403  int hgs = atom[ig].hydrogenGroupSize;
3404  if (hgs == 1 ) continue; // only one atom in group
3405  for ( i = 0; i < hgs; ++i ) {
3406  ref[i] = atom[ig+i].position;
3407  force[i] = f[Results::slow][ig+i];
3408  rmass[i] = 1. / atom[ig+i].mass;
3409  fixed[i] = ( simParams->fixedAtomsOn && atom[ig+i].atomFixed );
3410  if ( fixed[i] ) rmass[i] = 0.;
3411  }
3412  int icnt = 0;
3413  // c-ji I'm only going to mollify water for now
3414  if ( atom[ig].rigidBondLength > 0 ) { // for water
3415  if ( hgs != 3 ) {
3416  NAMD_die("Hydrogen group error caught in mollyMollify(). It's a bug!\n");
3417  }
3418  if ( !(fixed[1] && fixed[2]) ) {
3419  ial[icnt] = 1; ibl[icnt] = 2; ++icnt;
3420  }
3421  }
3422  for ( i = 1; i < hgs; ++i ) { // normal bonds to mother atom
3423  if ( atom[ig+i].rigidBondLength > 0 ) {
3424  if ( !(fixed[0] && fixed[i]) ) {
3425  ial[icnt] = 0; ibl[icnt] = i; ++icnt;
3426  }
3427  }
3428  }
3429 
3430  if ( icnt == 0 ) continue; // no constraints
3431  lambda = &(molly_lambda[numLambdas]);
3432  numLambdas += icnt;
3433  for ( i = 0; i < icnt; ++i ) {
3434  refab[i] = ref[ial[i]] - ref[ibl[i]];
3435  }
3436  avg = &(p_avg[ig]);
3437  mollify(avg,ref,lambda,force,hgs,icnt,rmass,ial,ibl,refab);
3438  // store data back to patch
3439  for ( i = 0; i < hgs; ++i ) {
3440  wc += outer(force[i]-f[Results::slow][ig+i],ref[i]);
3441  f[Results::slow][ig+i] = force[i];
3442  }
3443  }
3444  // check that there isn't a constant needed here!
3445  *virial += wc;
3446  p_avg.resize(0);
3447 }
static Node * Object()
Definition: Node.h:86
SimParameters * simParameters
Definition: Node.h:178
BigReal HGArrayBigReal[MAXHGS]
Definition: HomePatch.C:63
void mollify(CompAtom *qtilde, const HGArrayVector &q0, const BigReal *lambda, HGArrayVector &force, const int n, const int m, const HGArrayBigReal &imass, const HGArrayInt &ial, const HGArrayInt &ibl, const HGArrayVector &refab)
Definition: HomePatch.C:4672
CompAtomList p_avg
Definition: Patch.h:147
int numAtoms
Definition: Patch.h:144
void NAMD_die(const char *err_msg)
Definition: common.C:83
Tensor outer(const Vector &v1, const Vector &v2)
Definition: Tensor.h:241
int HGArrayInt[MAXHGS]
Definition: HomePatch.C:62
#define simParams
Definition: Output.C:127
void resize(int i)
Definition: ResizeArray.h:84
Definition: Tensor.h:15
zVector HGArrayVector[MAXHGS]
Definition: HomePatch.C:64
ForceList f[Results::maxNumForces]
Definition: Patch.h:207
Molecule * molecule
Definition: Node.h:176
double BigReal
Definition: common.h:112
void HomePatch::positionsReady ( int  doMigration = 0)

Definition at line 925 of file HomePatch.C.

References ProxyDataMsg::avgPlLen, ProxyDataMsg::avgPositionList, Patch::avgPositionPtrBegin, Patch::avgPositionPtrEnd, ResizeArray< T >::begin(), CompAtom::charge, COULOMB, ProxyDataMsg::cudaAtomList, Patch::cudaAtomPtr, DebugM, ComputeNonbondedUtil::dielectric_1, doAtomMigration(), Flags::doGBIS, doGroupSizeCheck(), Flags::doLCPO, Flags::doLoweAndersen, doMarginCheck(), Flags::doMolly, doPairlistCheck(), ResizeArray< T >::end(), SimParameters::fixedAtomsForces, SimParameters::fixedAtomsOn, ProxyDataMsg::flags, Patch::flags, Patch::getPatchID(), Patch::intRad, ProxyDataMsg::intRadList, Patch::lattice, Patch::lcpoType, ProxyDataMsg::lcpoTypeList, loweAndersenVelocities(), mollyAverage(), NAMD_EVENT_START_EX, NAMD_EVENT_STOP, NamdProfileEventStr, Patch::numAtoms, PatchMap::numNodesWithPatches(), PatchMap::numPatchesOnNode(), PatchMap::Object(), Sync::Object(), Node::Object(), ProxyMgr::Object(), Patch::p_avg, ProxyDataMsg::patch, PATCH_PRIORITY, Patch::patchID, Sync::PatchReady(), Patch::pExt, ProxyDataMsg::plExtLen, ProxyDataMsg::plLen, CompAtom::position, ProxyDataMsg::positionExtList, ProxyDataMsg::positionList, Patch::positionsReady(), PRIORITY_SIZE, PROXY_DATA_PRIORITY, proxySendSpanning, proxySpanDim, CudaAtom::q, SimParameters::qmLSSOn, qmSwapAtoms(), rattleListValid, ResizeArray< T >::resize(), ComputeNonbondedUtil::scaling, ProxyMgr::sendProxyAll(), ProxyMgr::sendProxyData(), Flags::sequence, SET_PRIORITY, setGBISIntrinsicRadii(), setLcpoType(), Node::simParameters, ResizeArray< T >::size(), sortAtomsForCUDA(), CompAtomExt::sortOrder, SimParameters::staticAtomAssignment, Lattice::unscale(), SimParameters::useAVXTiles, Patch::v, ProxyDataMsg::velocityList, Patch::velocityPtrBegin, Patch::velocityPtrEnd, ProxyDataMsg::vlLen, Vector::x, CudaAtom::x, Vector::y, CudaAtom::y, Vector::z, and CudaAtom::z.

926 {
928 
929  flags.sequence++;
930 
931  if (!patchMapRead) { readPatchMap(); }
932 
933  if (numNeighbors && ! simParams->staticAtomAssignment) {
934  if (doMigration) {
935  rattleListValid = false;
936  doAtomMigration();
937  } else {
938  doMarginCheck();
939  }
940  }
941 
942 #if defined(NAMD_NVTX_ENABLED) || defined(NAMD_CMK_TRACE_ENABLED)
943  char prbuf[32];
944  sprintf(prbuf, "%s: %d", NamdProfileEventStr[NamdProfileEvent::POSITIONS_READY], this->getPatchID());
945  NAMD_EVENT_START_EX(1, NamdProfileEvent::POSITIONS_READY, prbuf);
946 #endif
947 
948  if (doMigration && simParams->qmLSSOn)
949  qmSwapAtoms();
950 
951 #if defined(NAMD_CUDA) || defined(NAMD_MIC) || defined(NAMD_AVXTILES)
952  #ifdef NAMD_AVXTILES
953  if ( simParams->useAVXTiles ) {
954  #endif
955  if ( doMigration ) {
956  int n = numAtoms;
957  FullAtom *a_i = atom.begin();
958  #if defined(NAMD_CUDA) || defined(NAMD_AVXTILES) || \
959  (defined(NAMD_MIC) && MIC_SORT_ATOMS != 0)
960  int *ao = new int[n];
961  int nfree;
962  if ( simParams->fixedAtomsOn && ! simParams->fixedAtomsForces ) {
963  int k = 0;
964  int k2 = n;
965  for ( int j=0; j<n; ++j ) {
966  // put fixed atoms at end
967  if ( a_i[j].atomFixed ) ao[--k2] = j;
968  else ao[k++] = j;
969  }
970  nfree = k;
971  } else {
972  nfree = n;
973  for ( int j=0; j<n; ++j ) {
974  ao[j] = j;
975  }
976  }
977 
978  sortAtomsForCUDA(ao,a_i,nfree,n);
979 
980  for ( int i=0; i<n; ++i ) {
981  a_i[i].sortOrder = ao[i];
982  }
983  delete [] ao;
984  #else
985  for (int i = 0; i < n; ++i) {
986  a_i[i].sortOrder = i;
987  }
988  #endif
989  }
990 
991  {
992  const double charge_scaling = sqrt(COULOMB * ComputeNonbondedUtil::scaling * ComputeNonbondedUtil::dielectric_1);
993  const Vector ucenter = lattice.unscale(center);
994  const BigReal ucenter_x = ucenter.x;
995  const BigReal ucenter_y = ucenter.y;
996  const BigReal ucenter_z = ucenter.z;
997  const int n = numAtoms;
998  #if defined(NAMD_MIC) && (MIC_HANDCODE_FORCE_SOA_VS_AOS == 0)
999  int n_16 = n;
1000  n_16 = (n + 15) & (~15);
1001  cudaAtomList.resize(n_16);
1002  CudaAtom *ac = cudaAtomPtr = cudaAtomList.begin();
1003  mic_position_t *atom_x = ((mic_position_t*)ac) + (0 * n_16);
1004  mic_position_t *atom_y = ((mic_position_t*)ac) + (1 * n_16);
1005  mic_position_t *atom_z = ((mic_position_t*)ac) + (2 * n_16);
1006  mic_position_t *atom_q = ((mic_position_t*)ac) + (3 * n_16);
1007  #elif defined(NAMD_AVXTILES)
1008  int n_avx = (n + 15) & (~15);
1009  cudaAtomList.resize(n_avx);
1010  CudaAtom *ac = cudaAtomPtr = cudaAtomList.begin();
1011  tiles.realloc(n, ac);
1012  #else
1013  cudaAtomList.resize(n);
1014  CudaAtom *ac = cudaAtomPtr = cudaAtomList.begin();
1015  #endif
1016  const FullAtom *a = atom.begin();
1017  for ( int k=0; k<n; ++k ) {
1018  #if defined(NAMD_MIC) && (MIC_HANDCODE_FORCE_SOA_VS_AOS == 0)
1019  int j = a[k].sortOrder;
1020  atom_x[k] = a[j].position.x - ucenter_x;
1021  atom_y[k] = a[j].position.y - ucenter_y;
1022  atom_z[k] = a[j].position.z - ucenter_z;
1023  atom_q[k] = charge_scaling * a[j].charge;
1024  #else
1025  int j = a[k].sortOrder;
1026  ac[k].x = a[j].position.x - ucenter_x;
1027  ac[k].y = a[j].position.y - ucenter_y;
1028  ac[k].z = a[j].position.z - ucenter_z;
1029  ac[k].q = charge_scaling * a[j].charge;
1030  #endif
1031  }
1032  #ifdef NAMD_AVXTILES
1033  {
1034  if (n > 0) {
1035  int j = a[n-1].sortOrder;
1036  for ( int k=n; k<n_avx; ++k ) {
1037  ac[k].x = a[j].position.x - ucenter_x;
1038  ac[k].y = a[j].position.y - ucenter_y;
1039  ac[k].z = a[j].position.z - ucenter_z;
1040  }
1041  }
1042  }
1043  #endif
1044  }
1045  #ifdef NAMD_AVXTILES
1046  // If "Tiles" mode disabled, no use of the CUDA data structures
1047  } else doMigration = doMigration && numNeighbors;
1048  #endif
1049 #else
1050  doMigration = doMigration && numNeighbors;
1051 #endif
1052  doMigration = doMigration || ! patchMapRead;
1053 
1054  doMigration = doMigration || doAtomUpdate;
1055  doAtomUpdate = false;
1056 
1057  // Workaround for oversize groups:
1058  // reset nonbondedGroupSize (ngs) before force calculation,
1059  // making sure that subset of hydrogen group starting with
1060  // parent atom are all within 0.5 * hgroupCutoff.
1061  // XXX hydrogentGroupSize remains constant but is checked for nonzero
1062  // XXX should be skipped for CUDA, ngs not used by CUDA kernels
1063  // XXX should this also be skipped for KNL kernels?
1064  // ngs used by ComputeNonbondedBase.h - CPU nonbonded kernels
1065  // ngs used by ComputeGBIS.C - CPU GB nonbonded kernels
1066 #if ! defined(NAMD_CUDA)
1067 #if defined(NAMD_AVXTILES)
1068  if (!simParams->useAVXTiles)
1069 #endif
1070  doGroupSizeCheck();
1071 #endif
1072 
1073  // Copy information needed by computes and proxys to Patch::p.
1074  // Resize only if atoms were migrated
1075  if (doMigration) {
1076  p.resize(numAtoms);
1077  pExt.resize(numAtoms);
1078  }
1079  CompAtom *p_i = p.begin();
1080  CompAtomExt *pExt_i = pExt.begin();
1081  FullAtom *a_i = atom.begin();
1082  int i; int n = numAtoms;
1083  for ( i=0; i<n; ++i ) {
1084  p_i[i] = a_i[i];
1085  pExt_i[i] = a_i[i];
1086  }
1087 
1088  // Measure atom movement to test pairlist validity
1089  doPairlistCheck();
1090 
1091  if (flags.doMolly) mollyAverage();
1092  // BEGIN LA
1094  // END LA
1095 
1096  if (flags.doGBIS) {
1097  //reset for next time step
1098  numGBISP1Arrived = 0;
1099  phase1BoxClosedCalled = false;
1100  numGBISP2Arrived = 0;
1101  phase2BoxClosedCalled = false;
1102  numGBISP3Arrived = 0;
1103  phase3BoxClosedCalled = false;
1104  if (doMigration || isNewProxyAdded)
1106  }
1107 
1108  if (flags.doLCPO) {
1109  if (doMigration || isNewProxyAdded) {
1110  setLcpoType();
1111  }
1112  }
1113 
1114  // Must Add Proxy Changes when migration completed!
1116  int *pids = NULL;
1117  int pidsPreAllocated = 1;
1118  int npid;
1119  if (proxySendSpanning == 0) {
1120  npid = proxy.size();
1121  pids = new int[npid];
1122  pidsPreAllocated = 0;
1123  int *pidi = pids;
1124  int *pide = pids + proxy.size();
1125  int patchNodesLast =
1126  ( PatchMap::Object()->numNodesWithPatches() < ( 0.7 * CkNumPes() ) );
1127  for ( pli = proxy.begin(); pli != proxy.end(); ++pli )
1128  {
1129  if ( patchNodesLast && PatchMap::Object()->numPatchesOnNode(*pli) ) {
1130  *(--pide) = *pli;
1131  } else {
1132  *(pidi++) = *pli;
1133  }
1134  }
1135  }
1136  else {
1137 #ifdef NODEAWARE_PROXY_SPANNINGTREE
1138  #ifdef USE_NODEPATCHMGR
1139  npid = numNodeChild;
1140  pids = nodeChildren;
1141  #else
1142  npid = nChild;
1143  pids = child;
1144  #endif
1145 #else
1146  npid = nChild;
1147  pidsPreAllocated = 0;
1148  pids = new int[proxySpanDim];
1149  for (int i=0; i<nChild; i++) pids[i] = child[i];
1150 #endif
1151  }
1152  if (npid) { //have proxies
1153  int seq = flags.sequence;
1154  int priority = PROXY_DATA_PRIORITY + PATCH_PRIORITY(patchID);
1155  //begin to prepare proxy msg and send it
1156  int pdMsgPLLen = p.size();
1157  int pdMsgAvgPLLen = 0;
1158  if(flags.doMolly) {
1159  pdMsgAvgPLLen = p_avg.size();
1160  }
1161  // BEGIN LA
1162  int pdMsgVLLen = 0;
1163  if (flags.doLoweAndersen) {
1164  pdMsgVLLen = v.size();
1165  }
1166  // END LA
1167 
1168  int intRadLen = 0;
1169  if (flags.doGBIS && (doMigration || isNewProxyAdded)) {
1170  intRadLen = numAtoms * 2;
1171  }
1172 
1173  //LCPO
1174  int lcpoTypeLen = 0;
1175  if (flags.doLCPO && (doMigration || isNewProxyAdded)) {
1176  lcpoTypeLen = numAtoms;
1177  }
1178 
1179  int pdMsgPLExtLen = 0;
1180  if(doMigration || isNewProxyAdded) {
1181  pdMsgPLExtLen = pExt.size();
1182  }
1183 
1184  int cudaAtomLen = 0;
1185 #if defined(NAMD_CUDA)
1186  cudaAtomLen = numAtoms;
1187 #elif defined(NAMD_AVXTILES)
1188  if (simParams->useAVXTiles)
1189  cudaAtomLen = (numAtoms + 15) & (~15);
1190 #elif defined(NAMD_MIC)
1191  #if MIC_HANDCODE_FORCE_SOA_VS_AOS != 0
1192  cudaAtomLen = numAtoms;
1193  #else
1194  cudaAtomLen = (numAtoms + 15) & (~15);
1195  #endif
1196 #endif
1197 
1198  ProxyDataMsg *nmsg = new (pdMsgPLLen, pdMsgAvgPLLen, pdMsgVLLen, intRadLen,
1199  lcpoTypeLen, pdMsgPLExtLen, cudaAtomLen, PRIORITY_SIZE) ProxyDataMsg; // BEGIN LA, END LA
1200 
1201  SET_PRIORITY(nmsg,seq,priority);
1202  nmsg->patch = patchID;
1203  nmsg->flags = flags;
1204  nmsg->plLen = pdMsgPLLen;
1205  //copying data to the newly created msg
1206  memcpy(nmsg->positionList, p.begin(), sizeof(CompAtom)*pdMsgPLLen);
1207  nmsg->avgPlLen = pdMsgAvgPLLen;
1208  if(flags.doMolly) {
1209  memcpy(nmsg->avgPositionList, p_avg.begin(), sizeof(CompAtom)*pdMsgAvgPLLen);
1210  }
1211  // BEGIN LA
1212  nmsg->vlLen = pdMsgVLLen;
1213  if (flags.doLoweAndersen) {
1214  memcpy(nmsg->velocityList, v.begin(), sizeof(CompAtom)*pdMsgVLLen);
1215  }
1216  // END LA
1217 
1218  if (flags.doGBIS && (doMigration || isNewProxyAdded)) {
1219  for (int i = 0; i < numAtoms * 2; i++) {
1220  nmsg->intRadList[i] = intRad[i];
1221  }
1222  }
1223 
1224  if (flags.doLCPO && (doMigration || isNewProxyAdded)) {
1225  for (int i = 0; i < numAtoms; i++) {
1226  nmsg->lcpoTypeList[i] = lcpoType[i];
1227  }
1228  }
1229 
1230  nmsg->plExtLen = pdMsgPLExtLen;
1231  if(doMigration || isNewProxyAdded){
1232  memcpy(nmsg->positionExtList, pExt.begin(), sizeof(CompAtomExt)*pdMsgPLExtLen);
1233  }
1234 
1235 // DMK
1236 #if defined(NAMD_CUDA) || defined(NAMD_MIC) || defined(NAMD_AVXTILES)
1237  #ifdef NAMD_AVXTILES
1238  if (simParams->useAVXTiles)
1239  #endif
1240  memcpy(nmsg->cudaAtomList, cudaAtomPtr, sizeof(CudaAtom)*cudaAtomLen);
1241 #endif
1242 
1243 #if NAMD_SeparateWaters != 0
1244  //DMK - Atom Separation (water vs. non-water)
1245  nmsg->numWaterAtoms = numWaterAtoms;
1246 #endif
1247 
1248 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) && (CMK_SMP) && defined(NAMDSRC_IMMQD_HACK)
1249  nmsg->isFromImmMsgCall = 0;
1250 #endif
1251 
1252  #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG)
1253  DebugFileTrace *dft = DebugFileTrace::Object();
1254  dft->openTrace();
1255  dft->writeTrace("HP::posReady: for HomePatch[%d], sending proxy msg to: ", patchID);
1256  for(int i=0; i<npid; i++) {
1257  dft->writeTrace("%d ", pids[i]);
1258  }
1259  dft->writeTrace("\n");
1260  dft->closeTrace();
1261  #endif
1262 
1263 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
1264  if (isProxyChanged || localphs == NULL)
1265  {
1266 //CmiPrintf("[%d] Build persistent: isProxyChanged: %d %p\n", CkMyPe(), isProxyChanged, localphs);
1267  //CmiAssert(isProxyChanged);
1268  if (nphs) {
1269  for (int i=0; i<nphs; i++) {
1270  CmiDestoryPersistent(localphs[i]);
1271  }
1272  delete [] localphs;
1273  }
1274  localphs = new PersistentHandle[npid];
1275  int persist_size = sizeof(envelope) + sizeof(ProxyDataMsg) + sizeof(CompAtom)*(pdMsgPLLen+pdMsgAvgPLLen+pdMsgVLLen) + intRadLen*sizeof(Real) + lcpoTypeLen*sizeof(int) + sizeof(CompAtomExt)*pdMsgPLExtLen + sizeof(CudaAtom)*cudaAtomLen + PRIORITY_SIZE/8 + 2048;
1276  for (int i=0; i<npid; i++) {
1277 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
1278  if (proxySendSpanning)
1279  localphs[i] = CmiCreateNodePersistent(pids[i], persist_size, sizeof(envelope)+sizeof(ProxyDataMsg));
1280  else
1281 #endif
1282  localphs[i] = CmiCreatePersistent(pids[i], persist_size, sizeof(envelope)+sizeof(ProxyDataMsg));
1283  }
1284  nphs = npid;
1285  }
1286  CmiAssert(nphs == npid && localphs != NULL);
1287  CmiUsePersistentHandle(localphs, nphs);
1288 #endif
1289  if(doMigration || isNewProxyAdded) {
1290  ProxyMgr::Object()->sendProxyAll(nmsg,npid,pids);
1291  }else{
1292  ProxyMgr::Object()->sendProxyData(nmsg,npid,pids);
1293  }
1294 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
1295  CmiUsePersistentHandle(NULL, 0);
1296 #endif
1297  isNewProxyAdded = 0;
1298  }
1299  isProxyChanged = 0;
1300  if(!pidsPreAllocated) delete [] pids;
1301  DebugM(4, "patchID("<<patchID<<") doing positions Ready\n");
1302 
1303 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
1304  positionPtrBegin = p.begin();
1305  positionPtrEnd = p.end();
1306 #endif
1307 
1308  if(flags.doMolly) {
1311  }
1312  // BEGIN LA
1313  if (flags.doLoweAndersen) {
1314  velocityPtrBegin = v.begin();
1315  velocityPtrEnd = v.end();
1316  }
1317  // END LA
1318 
1319  Patch::positionsReady(doMigration);
1320 
1321  patchMapRead = 1;
1322 
1323  // gzheng
1324  Sync::Object()->PatchReady();
1325 
1326  NAMD_EVENT_STOP(1, NamdProfileEvent::POSITIONS_READY);
1327 
1328 }
static Node * Object()
Definition: Node.h:86
#define NAMD_EVENT_STOP(eon, id)
int * lcpoTypeList
Definition: ProxyMgr.h:112
float q
Definition: NamdTypes.h:154
int numNodesWithPatches(void)
Definition: PatchMap.h:61
RealList intRad
Definition: Patch.h:155
int sortOrder
Definition: NamdTypes.h:87
static ProxyMgr * Object()
Definition: ProxyMgr.h:394
Lattice & lattice
Definition: Patch.h:126
static PatchMap * Object()
Definition: PatchMap.h:27
CompAtom * velocityPtrEnd
Definition: Patch.h:202
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
float z
Definition: NamdTypes.h:154
float Real
Definition: common.h:107
#define COULOMB
Definition: common.h:44
#define DebugM(x, y)
Definition: Debug.h:59
BigReal z
Definition: Vector.h:66
float x
Definition: NamdTypes.h:154
CompAtom * avgPositionPtrEnd
Definition: Patch.h:198
char const *const NamdProfileEventStr[]
Position position
Definition: NamdTypes.h:53
void positionsReady(int n=0)
Definition: Patch.C:402
#define PROXY_DATA_PRIORITY
Definition: Priorities.h:40
CompAtomList v
Definition: Patch.h:149
void doGroupSizeCheck()
Definition: HomePatch.C:3719
CompAtom * avgPositionList
Definition: ProxyMgr.h:104
void loweAndersenVelocities()
Definition: HomePatch.C:3097
int doLoweAndersen
Definition: PatchTypes.h:26
CompAtom * velocityList
Definition: ProxyMgr.h:107
void sortAtomsForCUDA(int *order, const FullAtom *atoms, int nfree, int n)
Definition: SortAtoms.C:119
CudaAtom * cudaAtomPtr
Definition: Patch.h:205
bool rattleListValid
Definition: HomePatch.h:385
Flags flags
Definition: Patch.h:127
Charge charge
Definition: NamdTypes.h:54
#define PRIORITY_SIZE
Definition: Priorities.h:13
void qmSwapAtoms()
Definition: HomePatch.C:866
IntList lcpoType
Definition: Patch.h:164
CudaAtom * cudaAtomList
Definition: ProxyMgr.h:123
iterator end(void)
Definition: ResizeArray.h:37
CompAtomList p_avg
Definition: Patch.h:147
Bool staticAtomAssignment
int plExtLen
Definition: ProxyMgr.h:121
CompAtomList p
Definition: Patch.h:146
static Sync * Object()
Definition: Sync.h:50
int numAtoms
Definition: Patch.h:144
BigReal x
Definition: Vector.h:66
int sequence
Definition: PatchTypes.h:18
void setLcpoType()
Definition: HomePatch.C:3120
CompAtom * avgPositionPtrBegin
Definition: Patch.h:197
void doPairlistCheck()
Definition: HomePatch.C:3628
void doAtomMigration()
Definition: HomePatch.C:3840
void PatchReady(void)
Definition: Sync.C:150
void setGBISIntrinsicRadii()
Definition: HomePatch.C:3131
PatchID patch
Definition: ProxyMgr.h:97
Flags flags
Definition: ProxyMgr.h:98
void sendProxyData(ProxyDataMsg *, int, int *)
Definition: ProxyMgr.C:1563
Real * intRadList
Definition: ProxyMgr.h:110
float y
Definition: NamdTypes.h:154
PatchID getPatchID()
Definition: Patch.h:114
CompAtom * positionList
Definition: ProxyMgr.h:102
#define simParams
Definition: Output.C:127
void resize(int i)
Definition: ResizeArray.h:84
#define NAMD_EVENT_START_EX(eon, id, str)
void sendProxyAll(ProxyDataMsg *, int, int *)
Definition: ProxyMgr.C:1677
Position unscale(ScaledPosition s) const
Definition: Lattice.h:77
const PatchID patchID
Definition: Patch.h:143
void mollyAverage()
Definition: HomePatch.C:3312
BigReal y
Definition: Vector.h:66
int doLCPO
Definition: PatchTypes.h:29
CompAtomExt * positionExtList
Definition: ProxyMgr.h:122
int numPatchesOnNode(int node)
Definition: PatchMap.h:60
int doGBIS
Definition: PatchTypes.h:28
int size(void) const
Definition: ResizeArray.h:127
#define SET_PRIORITY(MSG, SEQ, PRIO)
Definition: Priorities.h:18
int avgPlLen
Definition: ProxyMgr.h:103
int proxySpanDim
Definition: ProxyMgr.C:48
CompAtomExtList pExt
Definition: Patch.h:174
void doMarginCheck()
Definition: HomePatch.C:3763
int doMolly
Definition: PatchTypes.h:24
double BigReal
Definition: common.h:112
#define PATCH_PRIORITY(PID)
Definition: Priorities.h:25
CompAtom * velocityPtrBegin
Definition: Patch.h:201
int proxySendSpanning
Definition: ProxyMgr.C:45
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::qmSwapAtoms ( )

Definition at line 866 of file HomePatch.C.

References ResizeArray< T >::begin(), CompAtom::charge, SortedArray< Type >::find(), Molecule::get_numQMAtoms(), Molecule::get_qmAtmChrg(), Molecule::get_qmAtmIndx(), Molecule::get_qmAtomGroup(), CompAtomExt::id, lssSubs(), Node::molecule, LSSSubsDat::newCharge, LSSSubsDat::newID, LSSSubsDat::newVdWType, Patch::numAtoms, Node::Object(), SimParameters::PMEOn, Node::simParameters, and CompAtom::vdwType.

Referenced by positionsReady().

867 {
868  // This is used for LSS in QM/MM simulations.
869  // Changes atom labels so that we effectively exchange solvent
870  // molecules between classical and quantum modes.
871 
873  int numQMAtms = Node::Object()->molecule->get_numQMAtoms();
874  const Real * const qmAtomGroup = Node::Object()->molecule->get_qmAtomGroup() ;
875  const int *qmAtmIndx = Node::Object()->molecule->get_qmAtmIndx() ;
876  Real *qmAtmChrg = Node::Object()->molecule->get_qmAtmChrg() ;
877 
878  ComputeQMMgr *mgrP = CProxy_ComputeQMMgr::ckLocalBranch(
879  CkpvAccess(BOCclass_group).computeQMMgr) ;
880 
881  FullAtom *a_i = atom.begin();
882 
883  for (int i=0; i<numAtoms; ++i ) {
884 
885  LSSSubsDat *subP = lssSubs(mgrP).find( LSSSubsDat(a_i[i].id) ) ;
886 
887  if ( subP != NULL ) {
888  a_i[i].id = subP->newID ;
889  a_i[i].vdwType = subP->newVdWType ;
890 
891  // If we are swappign a classical atom with a QM one, the charge
892  // will need extra handling.
893  if (qmAtomGroup[subP->newID] > 0 && simParams->PMEOn) {
894  // We make sure that the last atom charge calculated for the
895  // QM atom being transfered here is available for PME
896  // in the next step.
897 
898  // Loops over all QM atoms (in all QM groups) comparing their
899  // global indices (the sequential atom ID from NAMD).
900  for (int qmIter=0; qmIter<numQMAtms; qmIter++) {
901 
902  if (qmAtmIndx[qmIter] == subP->newID) {
903  qmAtmChrg[qmIter] = subP->newCharge;
904  break;
905  }
906 
907  }
908 
909  // For QM atoms, the charge in the full atom structure is zero.
910  // Electrostatic interactions between QM atoms and their
911  // environment is handled in ComputeQM.
912  a_i[i].charge = 0;
913  }
914  else {
915  // If we are swappign a QM atom with a Classical one, only the charge
916  // in the full atomstructure needs updating, since it used to be zero.
917  a_i[i].charge = subP->newCharge ;
918  }
919  }
920  }
921 
922  return;
923 }
static Node * Object()
Definition: Node.h:86
SortedArray< LSSSubsDat > & lssSubs(ComputeQMMgr *mgr)
Definition: ComputeQM.C:595
const int * get_qmAtmIndx()
Definition: Molecule.h:823
SimParameters * simParameters
Definition: Node.h:178
int get_numQMAtoms()
Definition: Molecule.h:825
float Real
Definition: common.h:107
Charge charge
Definition: NamdTypes.h:54
int newVdWType
Definition: ComputeQM.h:33
const Real * get_qmAtomGroup() const
Definition: Molecule.h:819
Real * get_qmAtmChrg()
Definition: Molecule.h:822
int numAtoms
Definition: Patch.h:144
Real newCharge
Definition: ComputeQM.h:34
#define simParams
Definition: Output.C:127
short vdwType
Definition: NamdTypes.h:55
Elem * find(const Elem &elem)
int newID
Definition: ComputeQM.h:32
Molecule * molecule
Definition: Node.h:176
iterator begin(void)
Definition: ResizeArray.h:36
int HomePatch::rattle1 ( const BigReal  timestep,
Tensor virial,
SubmitReduction ppreduction 
)

Definition at line 2381 of file HomePatch.C.

References addRattleForce(), buildRattleList(), endi(), SimParameters::fixedAtomsOn, iERROR(), iout, iWARN(), noconstList, Patch::numAtoms, Node::Object(), posNew, rattle1old(), rattleList, rattleListValid, rattleN(), rattlePair< 1 >(), rattleParam, SimParameters::rigidDie, SimParameters::rigidIter, SimParameters::rigidTol, settle1_SIMD< 1 >(), settle1_SIMD< 2 >(), settleList, Node::simParameters, TIMEFACTOR, SimParameters::useSettle, velNew, WAT_TIP3, SimParameters::watmodel, Vector::x, Vector::y, and Vector::z.

Referenced by Sequencer::minimize(), Sequencer::minimizeMoveDownhill(), Sequencer::newMinimizePosition(), and Sequencer::rattle1().

2382  {
2383 
2385  if (simParams->watmodel != WAT_TIP3 || ppreduction) {
2386  // Call old rattle1 -method instead
2387  return rattle1old(timestep, virial, ppreduction);
2388  }
2389 
2390  if (!rattleListValid) {
2391  buildRattleList();
2392  rattleListValid = true;
2393  }
2394 
2395  const int fixedAtomsOn = simParams->fixedAtomsOn;
2396  const int useSettle = simParams->useSettle;
2397  const BigReal dt = timestep / TIMEFACTOR;
2398  const BigReal invdt = (dt == 0.) ? 0. : 1.0 / dt; // precalc 1/dt
2399  const BigReal tol2 = 2.0 * simParams->rigidTol;
2400  int maxiter = simParams->rigidIter;
2401  int dieOnError = simParams->rigidDie;
2402 
2403  Vector ref[10]; // reference position
2404  Vector pos[10]; // new position
2405  Vector vel[10]; // new velocity
2406 
2407  // Manual un-roll
2408  int n = (settleList.size()/2)*2;
2409  for (int j=0;j < n;j+=2) {
2410  int ig;
2411  ig = settleList[j];
2412  for (int i = 0; i < 3; ++i ) {
2413  ref[i] = atom[ig+i].position;
2414  pos[i] = atom[ig+i].position + atom[ig+i].velocity * dt;
2415  }
2416  ig = settleList[j+1];
2417  for (int i = 0; i < 3; ++i ) {
2418  ref[i+3] = atom[ig+i].position;
2419  pos[i+3] = atom[ig+i].position + atom[ig+i].velocity * dt;
2420  }
2421  settle1_SIMD<2>(ref, pos,
2422  settle_mOrmT, settle_mHrmT, settle_ra,
2423  settle_rb, settle_rc, settle_rra);
2424 
2425  ig = settleList[j];
2426  for (int i = 0; i < 3; ++i ) {
2427  velNew[ig+i] = (pos[i] - ref[i])*invdt;
2428  posNew[ig+i] = pos[i];
2429  }
2430  ig = settleList[j+1];
2431  for (int i = 0; i < 3; ++i ) {
2432  velNew[ig+i] = (pos[i+3] - ref[i+3])*invdt;
2433  posNew[ig+i] = pos[i+3];
2434  }
2435 
2436  }
2437 
2438  if (settleList.size() % 2) {
2439  int ig = settleList[settleList.size()-1];
2440  for (int i = 0; i < 3; ++i ) {
2441  ref[i] = atom[ig+i].position;
2442  pos[i] = atom[ig+i].position + atom[ig+i].velocity * dt;
2443  }
2444  settle1_SIMD<1>(ref, pos,
2445  settle_mOrmT, settle_mHrmT, settle_ra,
2446  settle_rb, settle_rc, settle_rra);
2447  for (int i = 0; i < 3; ++i ) {
2448  velNew[ig+i] = (pos[i] - ref[i])*invdt;
2449  posNew[ig+i] = pos[i];
2450  }
2451  }
2452 
2453  int posParam = 0;
2454  for (int j=0;j < rattleList.size();++j) {
2455 
2456  BigReal refx[10];
2457  BigReal refy[10];
2458  BigReal refz[10];
2459 
2460  BigReal posx[10];
2461  BigReal posy[10];
2462  BigReal posz[10];
2463 
2464  int ig = rattleList[j].ig;
2465  int icnt = rattleList[j].icnt;
2466  int hgs = atom[ig].hydrogenGroupSize;
2467  for (int i = 0; i < hgs; ++i ) {
2468  ref[i] = atom[ig+i].position;
2469  pos[i] = atom[ig+i].position;
2470  if (!(fixedAtomsOn && atom[ig+i].atomFixed)) {
2471  pos[i] += atom[ig+i].velocity * dt;
2472  }
2473  refx[i] = ref[i].x;
2474  refy[i] = ref[i].y;
2475  refz[i] = ref[i].z;
2476  posx[i] = pos[i].x;
2477  posy[i] = pos[i].y;
2478  posz[i] = pos[i].z;
2479  }
2480 
2481  bool done;
2482  bool consFailure;
2483  if (icnt == 1) {
2484  rattlePair<1>(&rattleParam[posParam],
2485  refx, refy, refz,
2486  posx, posy, posz,
2487  consFailure);
2488  done = true;
2489  } else {
2490  rattleN(icnt, &rattleParam[posParam],
2491  refx, refy, refz,
2492  posx, posy, posz,
2493  tol2, maxiter,
2494  done, consFailure);
2495  }
2496 
2497  // Advance position in rattleParam
2498  posParam += icnt;
2499 
2500  for (int i = 0; i < hgs; ++i ) {
2501  pos[i].x = posx[i];
2502  pos[i].y = posy[i];
2503  pos[i].z = posz[i];
2504  }
2505 
2506  for (int i = 0; i < hgs; ++i ) {
2507  velNew[ig+i] = (pos[i] - ref[i])*invdt;
2508  posNew[ig+i] = pos[i];
2509  }
2510 
2511  if ( consFailure ) {
2512  if ( dieOnError ) {
2513  iout << iERROR << "Constraint failure in RATTLE algorithm for atom "
2514  << (atom[ig].id + 1) << "!\n" << endi;
2515  return -1; // triggers early exit
2516  } else {
2517  iout << iWARN << "Constraint failure in RATTLE algorithm for atom "
2518  << (atom[ig].id + 1) << "!\n" << endi;
2519  }
2520  } else if ( ! done ) {
2521  if ( dieOnError ) {
2522  iout << iERROR << "Exceeded RATTLE iteration limit for atom "
2523  << (atom[ig].id + 1) << "!\n" << endi;
2524  return -1; // triggers early exit
2525  } else {
2526  iout << iWARN << "Exceeded RATTLE iteration limit for atom "
2527  << (atom[ig].id + 1) << "!\n" << endi;
2528  }
2529  }
2530  }
2531  // Finally, we have to go through atoms that are not involved in rattle just so that we have
2532  // their positions and velocities up-to-date in posNew and velNew
2533  for (int j=0;j < noconstList.size();++j) {
2534  int ig = noconstList[j];
2535  int hgs = atom[ig].hydrogenGroupSize;
2536  for (int i = 0; i < hgs; ++i ) {
2537  velNew[ig+i] = atom[ig+i].velocity;
2538  posNew[ig+i] = atom[ig+i].position;
2539  }
2540  }
2541 
2542  if ( invdt == 0 ) {
2543  for (int ig = 0; ig < numAtoms; ++ig )
2544  atom[ig].position = posNew[ig];
2545  } else if ( virial == 0 ) {
2546  for (int ig = 0; ig < numAtoms; ++ig )
2547  atom[ig].velocity = velNew[ig];
2548  } else {
2549  Tensor wc; // constraint virial
2550  addRattleForce(invdt, wc);
2551  *virial += wc;
2552  }
2553 
2554  return 0;
2555 }
static Node * Object()
Definition: Node.h:86
template void settle1_SIMD< 1 >(const Vector *ref, Vector *pos, BigReal mOrmT, BigReal mHrmT, BigReal ra, BigReal rb, BigReal rc, BigReal rra)
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
std::ostream & iWARN(std::ostream &s)
Definition: InfoStream.C:108
BigReal rigidTol
#define iout
Definition: InfoStream.h:87
template void settle1_SIMD< 2 >(const Vector *ref, Vector *pos, BigReal mOrmT, BigReal mHrmT, BigReal ra, BigReal rb, BigReal rc, BigReal rra)
bool rattleListValid
Definition: HomePatch.h:385
std::vector< RattleList > rattleList
Definition: HomePatch.h:381
template void rattlePair< 1 >(const RattleParam *rattleParam, const BigReal *refx, const BigReal *refy, const BigReal *refz, BigReal *posx, BigReal *posy, BigReal *posz, bool &consFailure)
int rattle1old(const BigReal, Tensor *virial, SubmitReduction *)
Definition: HomePatch.C:2558
void buildRattleList()
Definition: HomePatch.C:2229
int numAtoms
Definition: Patch.h:144
std::vector< int > settleList
Definition: HomePatch.h:380
std::vector< Vector > posNew
Definition: HomePatch.h:389
#define WAT_TIP3
Definition: common.h:188
std::vector< RattleParam > rattleParam
Definition: HomePatch.h:382
#define simParams
Definition: Output.C:127
Definition: Tensor.h:15
#define TIMEFACTOR
Definition: common.h:46
std::vector< Vector > velNew
Definition: HomePatch.h:388
void rattleN(const int icnt, const RattleParam *rattleParam, const BigReal *refx, const BigReal *refy, const BigReal *refz, BigReal *posx, BigReal *posy, BigReal *posz, const BigReal tol2, const int maxiter, bool &done, bool &consFailure)
Definition: Settle.C:591
std::ostream & iERROR(std::ostream &s)
Definition: InfoStream.C:109
infostream & endi(infostream &s)
Definition: InfoStream.C:38
std::vector< int > noconstList
Definition: HomePatch.h:383
void addRattleForce(const BigReal invdt, Tensor &wc)
Definition: HomePatch.C:2371
double BigReal
Definition: common.h:112
int HomePatch::rattle1old ( const BigReal  timestep,
Tensor virial,
SubmitReduction ppreduction 
)

Definition at line 2558 of file HomePatch.C.

References Lattice::c(), endi(), Patch::f, SimParameters::fixedAtomsOn, iERROR(), iout, SubmitReduction::item(), iWARN(), Patch::lattice, Node::molecule, NAMD_die(), Results::normal, Patch::numAtoms, Node::Object(), Lattice::origin(), outer(), partition(), SimParameters::pressureProfileSlabs, SimParameters::rigidDie, SimParameters::rigidIter, SimParameters::rigidTol, settle1(), settle1init(), Node::simParameters, TIMEFACTOR, SimParameters::useSettle, WAT_SWM4, WAT_TIP4, SimParameters::watmodel, Vector::x, Tensor::xx, Vector::y, Tensor::yy, Vector::z, z, and Tensor::zz.

Referenced by rattle1().

2560 {
2561  Molecule *mol = Node::Object()->molecule;
2563  const int fixedAtomsOn = simParams->fixedAtomsOn;
2564  const int useSettle = simParams->useSettle;
2565  const BigReal dt = timestep / TIMEFACTOR;
2566  const BigReal invdt = (dt == 0.) ? 0. : 1.0 / dt; // precalc 1/dt
2567  BigReal tol2 = 2.0 * simParams->rigidTol;
2568  int maxiter = simParams->rigidIter;
2569  int dieOnError = simParams->rigidDie;
2570  int i, iter;
2571  BigReal dsq[10], tmp;
2572  int ial[10], ibl[10];
2573  Vector ref[10]; // reference position
2574  Vector refab[10]; // reference vector
2575  Vector pos[10]; // new position
2576  Vector vel[10]; // new velocity
2577  Vector netdp[10]; // total momentum change from constraint
2578  BigReal rmass[10]; // 1 / mass
2579  int fixed[10]; // is atom fixed?
2580  Tensor wc; // constraint virial
2581  BigReal idz, zmin;
2582  int nslabs;
2583 
2584  // Initialize the settle algorithm with water parameters
2585  // settle1() assumes all waters are identical,
2586  // and will generate bad results if they are not.
2587  // XXX this will move to Molecule::build_atom_status when that
2588  // version is debugged
2589  if ( ! settle_initialized ) {
2590  for ( int ig = 0; ig < numAtoms; ig += atom[ig].hydrogenGroupSize ) {
2591  // find a water
2592  if (atom[ig].rigidBondLength > 0) {
2593  int oatm;
2594  if (simParams->watmodel == WAT_SWM4) {
2595  oatm = ig+3; // skip over Drude and Lonepair
2596  //printf("ig=%d mass_ig=%g oatm=%d mass_oatm=%g\n",
2597  // ig, atom[ig].mass, oatm, atom[oatm].mass);
2598  }
2599  else {
2600  oatm = ig+1;
2601  // Avoid using the Om site to set this by mistake
2602  if (atom[ig].mass < 0.5 || atom[ig+1].mass < 0.5) {
2603  oatm += 1;
2604  }
2605  }
2606 
2607  // initialize settle water parameters
2608  settle1init(atom[ig].mass, atom[oatm].mass,
2609  atom[ig].rigidBondLength,
2610  atom[oatm].rigidBondLength,
2611  settle_mOrmT, settle_mHrmT, settle_ra,
2612  settle_rb, settle_rc, settle_rra);
2613  settle_initialized = 1;
2614  break; // done with init
2615  }
2616  }
2617  }
2618 
2619  if (ppreduction) {
2620  nslabs = simParams->pressureProfileSlabs;
2621  idz = nslabs/lattice.c().z;
2622  zmin = lattice.origin().z - 0.5*lattice.c().z;
2623  }
2624 
2625  // Size of a hydrogen group for water
2626  int wathgsize = 3;
2627  int watmodel = simParams->watmodel;
2628  if (watmodel == WAT_TIP4) wathgsize = 4;
2629  else if (watmodel == WAT_SWM4) wathgsize = 5;
2630 
2631  for ( int ig = 0; ig < numAtoms; ig += atom[ig].hydrogenGroupSize ) {
2632  int hgs = atom[ig].hydrogenGroupSize;
2633  if ( hgs == 1 ) continue; // only one atom in group
2634  // cache data in local arrays and integrate positions normally
2635  int anyfixed = 0;
2636  for ( i = 0; i < hgs; ++i ) {
2637  ref[i] = atom[ig+i].position;
2638  pos[i] = atom[ig+i].position;
2639  vel[i] = atom[ig+i].velocity;
2640  rmass[i] = (atom[ig+i].mass > 0. ? 1. / atom[ig+i].mass : 0.);
2641  //printf("rmass of %i is %f\n", ig+i, rmass[i]);
2642  fixed[i] = ( fixedAtomsOn && atom[ig+i].atomFixed );
2643  //printf("fixed status of %i is %i\n", i, fixed[i]);
2644  // undo addVelocityToPosition to get proper reference coordinates
2645  if ( fixed[i] ) { anyfixed = 1; rmass[i] = 0.; } else pos[i] += vel[i] * dt;
2646  }
2647  int icnt = 0;
2648  if ( ( tmp = atom[ig].rigidBondLength ) > 0 ) { // for water
2649  if (hgs != wathgsize) {
2650  char errmsg[256];
2651  sprintf(errmsg, "Water molecule starting with atom %d contains %d atoms "
2652  "but the specified water model requires %d atoms.\n",
2653  atom[ig].id+1, hgs, wathgsize);
2654  NAMD_die(errmsg);
2655  }
2656  // Use SETTLE for water unless some of the water atoms are fixed,
2657  if (useSettle && !anyfixed) {
2658  if (simParams->watmodel == WAT_SWM4) {
2659  // SWM4 ordering: O D LP H1 H2
2660  // do swap(O,LP) and call settle with subarray O H1 H2
2661  // swap back after we return
2662  Vector lp_ref = ref[2];
2663  Vector lp_pos = pos[2];
2664  Vector lp_vel = vel[2];
2665  ref[2] = ref[0];
2666  pos[2] = pos[0];
2667  vel[2] = vel[0];
2668  settle1(ref+2, pos+2, vel+2, invdt,
2669  settle_mOrmT, settle_mHrmT, settle_ra,
2670  settle_rb, settle_rc, settle_rra);
2671  ref[0] = ref[2];
2672  pos[0] = pos[2];
2673  vel[0] = vel[2];
2674  ref[2] = lp_ref;
2675  pos[2] = lp_pos;
2676  vel[2] = lp_vel;
2677  // determine for LP updated pos and vel
2678  swm4_omrepos(ref, pos, vel, invdt);
2679  }
2680  else {
2681  settle1(ref, pos, vel, invdt,
2682  settle_mOrmT, settle_mHrmT, settle_ra,
2683  settle_rb, settle_rc, settle_rra);
2684  if (simParams->watmodel == WAT_TIP4) {
2685  tip4_omrepos(ref, pos, vel, invdt);
2686  }
2687  }
2688 
2689  // which slab the hydrogen group will belong to
2690  // for pprofile calculations.
2691  int ppoffset, partition;
2692  if ( invdt == 0 ) for ( i = 0; i < wathgsize; ++i ) {
2693  atom[ig+i].position = pos[i];
2694  } else if ( virial == 0 ) for ( i = 0; i < wathgsize; ++i ) {
2695  atom[ig+i].velocity = vel[i];
2696  } else for ( i = 0; i < wathgsize; ++i ) {
2697  Force df = (vel[i] - atom[ig+i].velocity) * ( atom[ig+i].mass * invdt );
2698  Tensor vir = outer(df, ref[i]);
2699  wc += vir;
2700  f[Results::normal][ig+i] += df;
2701  atom[ig+i].velocity = vel[i];
2702  if (ppreduction) {
2703  // put all the atoms from a water in the same slab. Atom 0
2704  // should be the parent atom.
2705  if (!i) {
2706  BigReal z = pos[i].z;
2707  partition = atom[ig].partition;
2708  int slab = (int)floor((z-zmin)*idz);
2709  if (slab < 0) slab += nslabs;
2710  else if (slab >= nslabs) slab -= nslabs;
2711  ppoffset = 3*(slab + nslabs*partition);
2712  }
2713  ppreduction->item(ppoffset ) += vir.xx;
2714  ppreduction->item(ppoffset+1) += vir.yy;
2715  ppreduction->item(ppoffset+2) += vir.zz;
2716  }
2717  }
2718  continue;
2719  }
2720  if ( !(fixed[1] && fixed[2]) ) {
2721  dsq[icnt] = tmp * tmp; ial[icnt] = 1; ibl[icnt] = 2; ++icnt;
2722  }
2723  }
2724  for ( i = 1; i < hgs; ++i ) { // normal bonds to mother atom
2725  if ( ( tmp = atom[ig+i].rigidBondLength ) > 0 ) {
2726  if ( !(fixed[0] && fixed[i]) ) {
2727  dsq[icnt] = tmp * tmp; ial[icnt] = 0; ibl[icnt] = i; ++icnt;
2728  }
2729  }
2730  }
2731  if ( icnt == 0 ) continue; // no constraints
2732  for ( i = 0; i < icnt; ++i ) {
2733  refab[i] = ref[ial[i]] - ref[ibl[i]];
2734  }
2735  for ( i = 0; i < hgs; ++i ) {
2736  netdp[i] = 0.;
2737  }
2738  int done;
2739  int consFailure;
2740  for ( iter = 0; iter < maxiter; ++iter ) {
2741 //if (iter > 0) CkPrintf("iteration %d\n", iter);
2742  done = 1;
2743  consFailure = 0;
2744  for ( i = 0; i < icnt; ++i ) {
2745  int a = ial[i]; int b = ibl[i];
2746  Vector pab = pos[a] - pos[b];
2747  BigReal pabsq = pab.x*pab.x + pab.y*pab.y + pab.z*pab.z;
2748  BigReal rabsq = dsq[i];
2749  BigReal diffsq = rabsq - pabsq;
2750  if ( fabs(diffsq) > (rabsq * tol2) ) {
2751  Vector &rab = refab[i];
2752  BigReal rpab = rab.x*pab.x + rab.y*pab.y + rab.z*pab.z;
2753  if ( rpab < ( rabsq * 1.0e-6 ) ) {
2754  done = 0;
2755  consFailure = 1;
2756  continue;
2757  }
2758  BigReal rma = rmass[a];
2759  BigReal rmb = rmass[b];
2760  BigReal gab = diffsq / ( 2.0 * ( rma + rmb ) * rpab );
2761  Vector dp = rab * gab;
2762  pos[a] += rma * dp;
2763  pos[b] -= rmb * dp;
2764  if ( invdt != 0. ) {
2765  dp *= invdt;
2766  netdp[a] += dp;
2767  netdp[b] -= dp;
2768  }
2769  done = 0;
2770  }
2771  }
2772  if ( done ) break;
2773  }
2774 
2775  if ( consFailure ) {
2776  if ( dieOnError ) {
2777  iout << iERROR << "Constraint failure in RATTLE algorithm for atom "
2778  << (atom[ig].id + 1) << "!\n" << endi;
2779  return -1; // triggers early exit
2780  } else {
2781  iout << iWARN << "Constraint failure in RATTLE algorithm for atom "
2782  << (atom[ig].id + 1) << "!\n" << endi;
2783  }
2784  } else if ( ! done ) {
2785  if ( dieOnError ) {
2786  iout << iERROR << "Exceeded RATTLE iteration limit for atom "
2787  << (atom[ig].id + 1) << "!\n" << endi;
2788  return -1; // triggers early exit
2789  } else {
2790  iout << iWARN << "Exceeded RATTLE iteration limit for atom "
2791  << (atom[ig].id + 1) << "!\n" << endi;
2792  }
2793  }
2794 
2795  // store data back to patch
2796  int ppoffset, partition;
2797  if ( invdt == 0 ) for ( i = 0; i < hgs; ++i ) {
2798  atom[ig+i].position = pos[i];
2799  } else if ( virial == 0 ) for ( i = 0; i < hgs; ++i ) {
2800  atom[ig+i].velocity = vel[i] + rmass[i] * netdp[i];
2801  } else for ( i = 0; i < hgs; ++i ) {
2802  Force df = netdp[i] * invdt;
2803  Tensor vir = outer(df, ref[i]);
2804  wc += vir;
2805  f[Results::normal][ig+i] += df;
2806  atom[ig+i].velocity = vel[i] + rmass[i] * netdp[i];
2807  if (ppreduction) {
2808  if (!i) {
2809  BigReal z = pos[i].z;
2810  int partition = atom[ig].partition;
2811  int slab = (int)floor((z-zmin)*idz);
2812  if (slab < 0) slab += nslabs;
2813  else if (slab >= nslabs) slab -= nslabs;
2814  ppoffset = 3*(slab + nslabs*partition);
2815  }
2816  ppreduction->item(ppoffset ) += vir.xx;
2817  ppreduction->item(ppoffset+1) += vir.yy;
2818  ppreduction->item(ppoffset+2) += vir.zz;
2819  }
2820  }
2821  }
2822  if ( dt && virial ) *virial += wc;
2823 
2824  return 0;
2825 }
static Node * Object()
Definition: Node.h:86
Lattice & lattice
Definition: Patch.h:126
static void partition(int *order, const FullAtom *atoms, int begin, int end)
Definition: SortAtoms.C:41
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
BigReal & item(int i)
Definition: ReductionMgr.h:312
BigReal z
Definition: Vector.h:66
std::ostream & iWARN(std::ostream &s)
Definition: InfoStream.C:108
BigReal rigidTol
#define iout
Definition: InfoStream.h:87
int pressureProfileSlabs
Vector origin() const
Definition: Lattice.h:262
#define WAT_SWM4
Definition: common.h:190
gridSize z
int numAtoms
Definition: Patch.h:144
BigReal x
Definition: Vector.h:66
void NAMD_die(const char *err_msg)
Definition: common.C:83
Tensor outer(const Vector &v1, const Vector &v2)
Definition: Tensor.h:241
BigReal xx
Definition: Tensor.h:17
BigReal zz
Definition: Tensor.h:19
#define simParams
Definition: Output.C:127
int settle1(const Vector *ref, Vector *pos, Vector *vel, BigReal invdt, BigReal mOrmT, BigReal mHrmT, BigReal ra, BigReal rb, BigReal rc, BigReal rra)
optimized settle1 algorithm, reuses water properties as much as possible
Definition: Settle.C:55
Definition: Tensor.h:15
BigReal y
Definition: Vector.h:66
BigReal yy
Definition: Tensor.h:18
void settle1init(BigReal pmO, BigReal pmH, BigReal hhdist, BigReal ohdist, BigReal &mOrmT, BigReal &mHrmT, BigReal &ra, BigReal &rb, BigReal &rc, BigReal &rra)
initialize cached water properties
Definition: Settle.C:40
#define TIMEFACTOR
Definition: common.h:46
#define WAT_TIP4
Definition: common.h:189
std::ostream & iERROR(std::ostream &s)
Definition: InfoStream.C:109
infostream & endi(infostream &s)
Definition: InfoStream.C:38
ForceList f[Results::maxNumForces]
Definition: Patch.h:207
Molecule * molecule
Definition: Node.h:176
Vector c() const
Definition: Lattice.h:254
double BigReal
Definition: common.h:112
void HomePatch::rattle2 ( const BigReal  timestep,
Tensor virial 
)

Definition at line 2828 of file HomePatch.C.

References endi(), SimParameters::fixedAtomsOn, iout, iWARN(), Node::molecule, NAMD_bug(), NAMD_die(), Patch::numAtoms, Node::Object(), outer(), SimParameters::rigidDie, SimParameters::rigidIter, SimParameters::rigidTol, settle2(), Node::simParameters, TIMEFACTOR, SimParameters::useSettle, WAT_SWM4, WAT_TIP4, SimParameters::watmodel, Vector::x, Vector::y, and Vector::z.

2829 {
2830  Molecule *mol = Node::Object()->molecule;
2832  const int fixedAtomsOn = simParams->fixedAtomsOn;
2833  const int useSettle = simParams->useSettle;
2834  const BigReal dt = timestep / TIMEFACTOR;
2835  Tensor wc; // constraint virial
2836  BigReal tol = simParams->rigidTol;
2837  int maxiter = simParams->rigidIter;
2838  int dieOnError = simParams->rigidDie;
2839  int i, iter;
2840  BigReal dsqi[10], tmp;
2841  int ial[10], ibl[10];
2842  Vector ref[10]; // reference position
2843  Vector refab[10]; // reference vector
2844  Vector vel[10]; // new velocity
2845  BigReal rmass[10]; // 1 / mass
2846  BigReal redmass[10]; // reduced mass
2847  int fixed[10]; // is atom fixed?
2848 
2849  // Size of a hydrogen group for water
2850  int wathgsize = 3;
2851  if (simParams->watmodel == WAT_TIP4) wathgsize = 4;
2852  else if (simParams->watmodel == WAT_SWM4) wathgsize = 5;
2853 
2854  // CkPrintf("In rattle2!\n");
2855  for ( int ig = 0; ig < numAtoms; ig += atom[ig].hydrogenGroupSize ) {
2856  // CkPrintf("ig=%d\n",ig);
2857  int hgs = atom[ig].hydrogenGroupSize;
2858  if ( hgs == 1 ) continue; // only one atom in group
2859  // cache data in local arrays and integrate positions normally
2860  int anyfixed = 0;
2861  for ( i = 0; i < hgs; ++i ) {
2862  ref[i] = atom[ig+i].position;
2863  vel[i] = atom[ig+i].velocity;
2864  rmass[i] = atom[ig+i].mass > 0. ? 1. / atom[ig+i].mass : 0.;
2865  fixed[i] = ( fixedAtomsOn && atom[ig+i].atomFixed );
2866  if ( fixed[i] ) { anyfixed = 1; rmass[i] = 0.; }
2867  }
2868  int icnt = 0;
2869  if ( ( tmp = atom[ig].rigidBondLength ) > 0 ) { // for water
2870  if (hgs != wathgsize) {
2871  NAMD_bug("Hydrogen group error caught in rattle2().");
2872  }
2873  // Use SETTLE for water unless some of the water atoms are fixed,
2874  if (useSettle && !anyfixed) {
2875  if (simParams->watmodel == WAT_SWM4) {
2876  // SWM4 ordering: O D LP H1 H2
2877  // do swap(O,LP) and call settle with subarray O H1 H2
2878  // swap back after we return
2879  Vector lp_ref = ref[2];
2880  // Vector lp_vel = vel[2];
2881  ref[2] = ref[0];
2882  vel[2] = vel[0];
2883  settle2(atom[ig].mass, atom[ig+3].mass, ref+2, vel+2, dt, virial);
2884  ref[0] = ref[2];
2885  vel[0] = vel[2];
2886  ref[2] = lp_ref;
2887  // vel[2] = vel[0]; // set LP vel to O vel
2888  }
2889  else {
2890  settle2(atom[ig].mass, atom[ig+1].mass, ref, vel, dt, virial);
2891  if (simParams->watmodel == WAT_TIP4) {
2892  vel[3] = vel[0];
2893  }
2894  }
2895  for (i=0; i<hgs; i++) {
2896  atom[ig+i].velocity = vel[i];
2897  }
2898  continue;
2899  }
2900  if ( !(fixed[1] && fixed[2]) ) {
2901  redmass[icnt] = 1. / (rmass[1] + rmass[2]);
2902  dsqi[icnt] = 1. / (tmp * tmp); ial[icnt] = 1; ibl[icnt] = 2; ++icnt;
2903  }
2904  }
2905  // CkPrintf("Loop 2\n");
2906  for ( i = 1; i < hgs; ++i ) { // normal bonds to mother atom
2907  if ( ( tmp = atom[ig+i].rigidBondLength ) > 0 ) {
2908  if ( !(fixed[0] && fixed[i]) ) {
2909  redmass[icnt] = 1. / (rmass[0] + rmass[i]);
2910  dsqi[icnt] = 1. / (tmp * tmp); ial[icnt] = 0;
2911  ibl[icnt] = i; ++icnt;
2912  }
2913  }
2914  }
2915  if ( icnt == 0 ) continue; // no constraints
2916  // CkPrintf("Loop 3\n");
2917  for ( i = 0; i < icnt; ++i ) {
2918  refab[i] = ref[ial[i]] - ref[ibl[i]];
2919  }
2920  // CkPrintf("Loop 4\n");
2921  int done;
2922  for ( iter = 0; iter < maxiter; ++iter ) {
2923  done = 1;
2924  for ( i = 0; i < icnt; ++i ) {
2925  int a = ial[i]; int b = ibl[i];
2926  Vector vab = vel[a] - vel[b];
2927  Vector &rab = refab[i];
2928  BigReal rabsqi = dsqi[i];
2929  BigReal rvab = rab.x*vab.x + rab.y*vab.y + rab.z*vab.z;
2930  if ( (fabs(rvab) * dt * rabsqi) > tol ) {
2931  Vector dp = rab * (-rvab * redmass[i] * rabsqi);
2932  wc += outer(dp,rab);
2933  vel[a] += rmass[a] * dp;
2934  vel[b] -= rmass[b] * dp;
2935  done = 0;
2936  }
2937  }
2938  if ( done ) break;
2939  //if (done) { if (iter > 0) CkPrintf("iter=%d\n", iter); break; }
2940  }
2941  if ( ! done ) {
2942  if ( dieOnError ) {
2943  NAMD_die("Exceeded maximum number of iterations in rattle2().");
2944  } else {
2945  iout << iWARN <<
2946  "Exceeded maximum number of iterations in rattle2().\n" << endi;
2947  }
2948  }
2949  // store data back to patch
2950  for ( i = 0; i < hgs; ++i ) {
2951  atom[ig+i].velocity = vel[i];
2952  }
2953  }
2954  // CkPrintf("Leaving rattle2!\n");
2955  // check that there isn't a constant needed here!
2956  *virial += wc / ( 0.5 * dt );
2957 
2958 }
static Node * Object()
Definition: Node.h:86
Definition: Vector.h:64
SimParameters * simParameters
Definition: Node.h:178
BigReal z
Definition: Vector.h:66
std::ostream & iWARN(std::ostream &s)
Definition: InfoStream.C:108
BigReal rigidTol
#define iout
Definition: InfoStream.h:87
int settle2(BigReal mO, BigReal mH, const Vector *pos, Vector *vel, BigReal dt, Tensor *virial)
Definition: Settle.C:705
void NAMD_bug(const char *err_msg)
Definition: common.C:123
#define WAT_SWM4
Definition: common.h:190
int numAtoms
Definition: Patch.h:144
BigReal x
Definition: Vector.h:66
void NAMD_die(const char *err_msg)
Definition: common.C:83
Tensor outer(const Vector &v1, const Vector &v2)
Definition: Tensor.h:241
#define simParams
Definition: Output.C:127
Definition: Tensor.h:15
BigReal y
Definition: Vector.h:66
#define TIMEFACTOR
Definition: common.h:46
#define WAT_TIP4
Definition: common.h:189
infostream & endi(infostream &s)
Definition: InfoStream.C:38
Molecule * molecule
Definition: Node.h:176
double BigReal
Definition: common.h:112
void HomePatch::receiveResult ( ProxyGBISP1ResultMsg msg)

Definition at line 3261 of file HomePatch.C.

References Sequencer::awaken(), Patch::boxesOpen, Flags::doNonbonded, Patch::flags, Patch::psiFin, ProxyGBISP1ResultMsg::psiSum, ProxyGBISP1ResultMsg::psiSumLen, and ResizeArray< T >::size().

Referenced by ProxyMgr::recvResult().

3261  {
3262  ++numGBISP1Arrived;
3263  for ( int i = 0; i < msg->psiSumLen; ++i ) {
3264  psiFin[i] += msg->psiSum[i];
3265  }
3266  delete msg;
3267 
3268  if (flags.doNonbonded) {
3269  //awaken if phase 1 done
3270  if (phase1BoxClosedCalled == true &&
3271  numGBISP1Arrived==proxy.size() ) {
3272  sequencer->awaken();
3273  }
3274  } else {
3275  //awaken if all phases done on noWork step
3276  if (boxesOpen == 0 &&
3277  numGBISP1Arrived == proxy.size() &&
3278  numGBISP2Arrived == proxy.size() &&
3279  numGBISP3Arrived == proxy.size()) {
3280  sequencer->awaken();
3281  }
3282  }
3283 }
GBRealList psiFin
Definition: Patch.h:157
Flags flags
Definition: Patch.h:127
void awaken(void)
Definition: Sequencer.h:29
int boxesOpen
Definition: Patch.h:243
int doNonbonded
Definition: PatchTypes.h:22
int size(void) const
Definition: ResizeArray.h:127
void HomePatch::receiveResult ( ProxyGBISP2ResultMsg msg)

Definition at line 3286 of file HomePatch.C.

References Sequencer::awaken(), Patch::boxesOpen, ProxyGBISP2ResultMsg::dEdaSum, ProxyGBISP2ResultMsg::dEdaSumLen, Patch::dHdrPrefix, Flags::doNonbonded, Patch::flags, and ResizeArray< T >::size().

3286  {
3287  ++numGBISP2Arrived;
3288  //accumulate dEda
3289  for ( int i = 0; i < msg->dEdaSumLen; ++i ) {
3290  dHdrPrefix[i] += msg->dEdaSum[i];
3291  }
3292  delete msg;
3293 
3294  if (flags.doNonbonded) {
3295  //awaken if phase 2 done
3296  if (phase2BoxClosedCalled == true &&
3297  numGBISP2Arrived==proxy.size() ) {
3298  sequencer->awaken();
3299  }
3300  } else {
3301  //awaken if all phases done on noWork step
3302  if (boxesOpen == 0 &&
3303  numGBISP1Arrived == proxy.size() &&
3304  numGBISP2Arrived == proxy.size() &&
3305  numGBISP3Arrived == proxy.size()) {
3306  sequencer->awaken();
3307  }
3308  }
3309 }
RealList dHdrPrefix
Definition: Patch.h:159
Flags flags
Definition: Patch.h:127
void awaken(void)
Definition: Sequencer.h:29
int boxesOpen
Definition: Patch.h:243
GBReal * dEdaSum
Definition: ProxyMgr.h:51
int doNonbonded
Definition: PatchTypes.h:22
int size(void) const
Definition: ResizeArray.h:127
void HomePatch::receiveResults ( ProxyResultVarsizeMsg msg)

Definition at line 796 of file HomePatch.C.

References OwnerBox< Owner, Data >::clientClose(), OwnerBox< Owner, Data >::clientOpen(), DebugM, Results::f, ProxyResultVarsizeMsg::flLen, ProxyResultVarsizeMsg::forceArr, Patch::forceBox, ProxyResultVarsizeMsg::isZero, Results::maxNumForces, ProxyResultVarsizeMsg::node, and Patch::patchID.

Referenced by ProxyMgr::recvResults().

796  {
797 
798  numGBISP3Arrived++;
799  DebugM(4, "patchID("<<patchID<<") receiveRes() nodeID("<<msg->node<<")\n");
800  int n = msg->node;
801  Results *r = forceBox.clientOpen();
802 
803  char *iszeroPtr = msg->isZero;
804  Force *msgFPtr = msg->forceArr;
805 
806  for ( int k = 0; k < Results::maxNumForces; ++k )
807  {
808  Force *rfPtr = r->f[k];
809  for(int i=0; i<msg->flLen[k]; i++, rfPtr++, iszeroPtr++) {
810  if((*iszeroPtr)!=1) {
811  *rfPtr += *msgFPtr;
812  msgFPtr++;
813  }
814  }
815  }
817  delete msg;
818 }
Data * clientOpen(int count=1)
Definition: OwnerBox.h:58
OwnerBox< Patch, Results > forceBox
Definition: Patch.h:239
int flLen[Results::maxNumForces]
Definition: ProxyMgr.h:179
Definition: Vector.h:64
#define DebugM(x, y)
Definition: Debug.h:59
Force * f[maxNumForces]
Definition: PatchTypes.h:67
void clientClose(int count=1)
Definition: OwnerBox.h:62
const PatchID patchID
Definition: Patch.h:143
void HomePatch::receiveResults ( ProxyResultMsg msg)

Definition at line 820 of file HomePatch.C.

References ResizeArray< T >::begin(), OwnerBox< Owner, Data >::clientClose(), OwnerBox< Owner, Data >::clientOpen(), DebugM, ResizeArray< T >::end(), Results::f, Patch::f, Patch::forceBox, ProxyResultMsg::forceList, Results::maxNumForces, ProxyResultMsg::node, and Patch::patchID.

820  {
821  numGBISP3Arrived++;
822  DebugM(4, "patchID("<<patchID<<") receiveRes() nodeID("<<msg->node<<")\n");
823  int n = msg->node;
824  Results *r = forceBox.clientOpen();
825  for ( int k = 0; k < Results::maxNumForces; ++k )
826  {
827  Force *f = r->f[k];
828  register ForceList::iterator f_i, f_e;
829  f_i = msg->forceList[k]->begin();
830  f_e = msg->forceList[k]->end();
831  for ( ; f_i != f_e; ++f_i, ++f ) *f += *f_i;
832  }
834  delete msg;
835 }
Data * clientOpen(int count=1)
Definition: OwnerBox.h:58
OwnerBox< Patch, Results > forceBox
Definition: Patch.h:239
Definition: Vector.h:64
#define DebugM(x, y)
Definition: Debug.h:59
iterator end(void)
Definition: ResizeArray.h:37
Force * f[maxNumForces]
Definition: PatchTypes.h:67
void clientClose(int count=1)
Definition: OwnerBox.h:62
ForceList * forceList[Results::maxNumForces]
Definition: ProxyMgr.h:168
NodeID node
Definition: ProxyMgr.h:166
const PatchID patchID
Definition: Patch.h:143
ForceList f[Results::maxNumForces]
Definition: Patch.h:207
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::receiveResults ( ProxyCombinedResultRawMsg msg)

Definition at line 837 of file HomePatch.C.

References OwnerBox< Owner, Data >::clientClose(), OwnerBox< Owner, Data >::clientOpen(), DebugM, Results::f, Patch::f, ProxyCombinedResultRawMsg::flLen, ProxyCombinedResultRawMsg::forceArr, Patch::forceBox, ProxyCombinedResultRawMsg::isForceNonZero, Results::maxNumForces, ProxyCombinedResultRawMsg::nodeSize, Patch::patchID, Vector::x, Vector::y, and Vector::z.

838 {
839  numGBISP3Arrived++;
840  DebugM(4, "patchID("<<patchID<<") receiveRes() #nodes("<<msg->nodeSize<<")\n");
841  Results *r = forceBox.clientOpen(msg->nodeSize);
842  register char* isNonZero = msg->isForceNonZero;
843  register Force* f_i = msg->forceArr;
844  for ( int k = 0; k < Results::maxNumForces; ++k )
845  {
846  Force *f = r->f[k];
847  int nf = msg->flLen[k];
848 #ifdef ARCH_POWERPC
849 #pragma disjoint (*f_i, *f)
850 #endif
851  for (int count = 0; count < nf; count++) {
852  if(*isNonZero){
853  f[count].x += f_i->x;
854  f[count].y += f_i->y;
855  f[count].z += f_i->z;
856  f_i++;
857  }
858  isNonZero++;
859  }
860  }
862 
863  delete msg;
864 }
Data * clientOpen(int count=1)
Definition: OwnerBox.h:58
OwnerBox< Patch, Results > forceBox
Definition: Patch.h:239
Definition: Vector.h:64
#define DebugM(x, y)
Definition: Debug.h:59
BigReal z
Definition: Vector.h:66
Force * f[maxNumForces]
Definition: PatchTypes.h:67
void clientClose(int count=1)
Definition: OwnerBox.h:62
BigReal x
Definition: Vector.h:66
const PatchID patchID
Definition: Patch.h:143
BigReal y
Definition: Vector.h:66
int flLen[Results::maxNumForces]
Definition: ProxyMgr.h:233
ForceList f[Results::maxNumForces]
Definition: Patch.h:207
void HomePatch::recvCheckpointAck ( )

Definition at line 3568 of file HomePatch.C.

Referenced by PatchMgr::recvCheckpointAck(), and recvCheckpointLoad().

3568  { // initiating replica
3569  CkpvAccess(_qd)->process();
3570 }
void HomePatch::recvCheckpointLoad ( CheckpointAtomsMsg msg)

Definition at line 3515 of file HomePatch.C.

References Patch::atomMapper, CheckpointAtomsMsg::atoms, ResizeArray< T >::begin(), CheckpointAtomsMsg::berendsenPressure_count, Sequencer::berendsenPressure_count, checkpoint_task, ResizeArray< T >::end(), CheckpointAtomsMsg::key, CheckpointAtomsMsg::lattice, Patch::lattice, NAMD_bug(), CheckpointAtomsMsg::numAtoms, Patch::numAtoms, Node::Object(), PatchMgr::Object(), Patch::patchID, CheckpointAtomsMsg::pe, CheckpointAtomsMsg::pid, rattleListValid, recvCheckpointAck(), AtomMapper::registerIDsFullAtom(), CheckpointAtomsMsg::replica, ResizeArray< T >::resize(), SCRIPT_CHECKPOINT_FREE, SCRIPT_CHECKPOINT_LOAD, SCRIPT_CHECKPOINT_STORE, SCRIPT_CHECKPOINT_SWAP, SimParameters::scriptIntArg1, SimParameters::scriptStringArg1, PatchMgr::sendCheckpointStore(), Node::simParameters, and AtomMapper::unregisterIDsFullAtom().

Referenced by PatchMgr::recvCheckpointLoad().

3515  { // initiating replica
3517  const int remote = simParams->scriptIntArg1;
3518  const char *key = simParams->scriptStringArg1;
3520  NAMD_bug("HomePatch::recvCheckpointLoad called during checkpointFree.");
3521  }
3522  if ( msg->replica != remote ) {
3523  NAMD_bug("HomePatch::recvCheckpointLoad message from wrong replica.");
3524  }
3526  CheckpointAtomsMsg *newmsg = new (numAtoms,1+strlen(key),0) CheckpointAtomsMsg;
3527  strcpy(newmsg->key,key);
3528  newmsg->lattice = lattice;
3529  newmsg->berendsenPressure_count = sequencer->berendsenPressure_count;
3530  newmsg->pid = patchID;
3531  newmsg->pe = CkMyPe();
3532  newmsg->replica = CmiMyPartition();
3533  newmsg->numAtoms = numAtoms;
3534  memcpy(newmsg->atoms,atom.begin(),numAtoms*sizeof(FullAtom));
3535  PatchMgr::Object()->sendCheckpointStore(newmsg, remote, msg->pe);
3536  }
3538  atomMapper->unregisterIDsFullAtom(atom.begin(),atom.end());
3539  lattice = msg->lattice;
3541  numAtoms = msg->numAtoms;
3542  atom.resize(numAtoms);
3543  memcpy(atom.begin(),msg->atoms,numAtoms*sizeof(FullAtom));
3544  doAtomUpdate = true;
3545  rattleListValid = false;
3546  if ( ! numNeighbors ) atomMapper->registerIDsFullAtom(atom.begin(),atom.end());
3547  }
3550  }
3551  delete msg;
3552 }
static Node * Object()
Definition: Node.h:86
char scriptStringArg1[128]
Lattice & lattice
Definition: Patch.h:126
void registerIDsFullAtom(const FullAtom *begin, const FullAtom *end)
Definition: AtomMap.C:50
SimParameters * simParameters
Definition: Node.h:178
AtomMapper * atomMapper
Definition: Patch.h:152
FullAtom * atoms
Definition: PatchMgr.h:89
bool rattleListValid
Definition: HomePatch.h:385
void recvCheckpointAck()
Definition: HomePatch.C:3568
void NAMD_bug(const char *err_msg)
Definition: common.C:123
iterator end(void)
Definition: ResizeArray.h:37
int numAtoms
Definition: Patch.h:144
int berendsenPressure_count
Definition: Sequencer.h:104
int berendsenPressure_count
Definition: PatchMgr.h:87
#define simParams
Definition: Output.C:127
void resize(int i)
Definition: ResizeArray.h:84
const PatchID patchID
Definition: Patch.h:143
int checkpoint_task
Definition: HomePatch.h:428
Lattice lattice
Definition: PatchMgr.h:82
void unregisterIDsFullAtom(const FullAtom *begin, const FullAtom *end)
Definition: AtomMap.C:100
void sendCheckpointStore(CheckpointAtomsMsg *msg, int dst, int dstpe)
Definition: PatchMgr.C:333
static PatchMgr * Object()
Definition: PatchMgr.h:152
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::recvCheckpointReq ( int  task,
const char *  key,
int  replica,
int  pe 
)

Definition at line 3485 of file HomePatch.C.

References CheckpointAtomsMsg::atoms, HomePatch::checkpoint_t::atoms, ResizeArray< T >::begin(), CheckpointAtomsMsg::berendsenPressure_count, HomePatch::checkpoint_t::berendsenPressure_count, checkpoints, CheckpointAtomsMsg::lattice, HomePatch::checkpoint_t::lattice, NAMD_die(), CheckpointAtomsMsg::numAtoms, HomePatch::checkpoint_t::numAtoms, PatchMgr::Object(), Patch::patchID, CheckpointAtomsMsg::pe, CheckpointAtomsMsg::pid, CheckpointAtomsMsg::replica, SCRIPT_CHECKPOINT_FREE, SCRIPT_CHECKPOINT_LOAD, SCRIPT_CHECKPOINT_SWAP, PatchMgr::sendCheckpointAck(), and PatchMgr::sendCheckpointLoad().

Referenced by PatchMgr::recvCheckpointReq().

3485  { // responding replica
3486  if ( task == SCRIPT_CHECKPOINT_FREE ) {
3487  if ( ! checkpoints.count(key) ) {
3488  NAMD_die("Unable to free checkpoint, requested key was never stored.");
3489  }
3490  delete checkpoints[key];
3491  checkpoints.erase(key);
3492  PatchMgr::Object()->sendCheckpointAck(patchID, replica, pe);
3493  return;
3494  }
3495  CheckpointAtomsMsg *msg;
3496  if ( task == SCRIPT_CHECKPOINT_LOAD || task == SCRIPT_CHECKPOINT_SWAP ) {
3497  if ( ! checkpoints.count(key) ) {
3498  NAMD_die("Unable to load checkpoint, requested key was never stored.");
3499  }
3500  checkpoint_t &cp = *checkpoints[key];
3501  msg = new (cp.numAtoms,1,0) CheckpointAtomsMsg;
3502  msg->lattice = cp.lattice;
3503  msg->berendsenPressure_count = cp.berendsenPressure_count;
3504  msg->numAtoms = cp.numAtoms;
3505  memcpy(msg->atoms,cp.atoms.begin(),cp.numAtoms*sizeof(FullAtom));
3506  } else {
3507  msg = new (0,1,0) CheckpointAtomsMsg;
3508  }
3509  msg->pid = patchID;
3510  msg->replica = CmiMyPartition();
3511  msg->pe = CkMyPe();
3512  PatchMgr::Object()->sendCheckpointLoad(msg, replica, pe);
3513 }
FullAtom * atoms
Definition: PatchMgr.h:89
void sendCheckpointAck(int pid, int dst, int dstpe)
Definition: PatchMgr.C:358
std::map< std::string, checkpoint_t * > checkpoints
Definition: HomePatch.h:435
void NAMD_die(const char *err_msg)
Definition: common.C:83
int berendsenPressure_count
Definition: PatchMgr.h:87
void sendCheckpointLoad(CheckpointAtomsMsg *msg, int dst, int dstpe)
Definition: PatchMgr.C:308
const PatchID patchID
Definition: Patch.h:143
Lattice lattice
Definition: PatchMgr.h:82
static PatchMgr * Object()
Definition: PatchMgr.h:152
void HomePatch::recvCheckpointStore ( CheckpointAtomsMsg msg)

Definition at line 3554 of file HomePatch.C.

References CheckpointAtomsMsg::atoms, HomePatch::checkpoint_t::atoms, ResizeArray< T >::begin(), CheckpointAtomsMsg::berendsenPressure_count, HomePatch::checkpoint_t::berendsenPressure_count, checkpoints, CheckpointAtomsMsg::key, CheckpointAtomsMsg::lattice, HomePatch::checkpoint_t::lattice, CheckpointAtomsMsg::numAtoms, HomePatch::checkpoint_t::numAtoms, PatchMgr::Object(), Patch::patchID, CheckpointAtomsMsg::pe, CheckpointAtomsMsg::replica, ResizeArray< T >::resize(), and PatchMgr::sendCheckpointAck().

Referenced by PatchMgr::recvCheckpointStore().

3554  { // responding replica
3555  if ( ! checkpoints.count(msg->key) ) {
3556  checkpoints[msg->key] = new checkpoint_t;
3557  }
3558  checkpoint_t &cp = *checkpoints[msg->key];
3559  cp.lattice = msg->lattice;
3560  cp.berendsenPressure_count = msg->berendsenPressure_count;
3561  cp.numAtoms = msg->numAtoms;
3562  cp.atoms.resize(cp.numAtoms);
3563  memcpy(cp.atoms.begin(),msg->atoms,cp.numAtoms*sizeof(FullAtom));
3565  delete msg;
3566 }
FullAtom * atoms
Definition: PatchMgr.h:89
void sendCheckpointAck(int pid, int dst, int dstpe)
Definition: PatchMgr.C:358
std::map< std::string, checkpoint_t * > checkpoints
Definition: HomePatch.h:435
int berendsenPressure_count
Definition: PatchMgr.h:87
const PatchID patchID
Definition: Patch.h:143
Lattice lattice
Definition: PatchMgr.h:82
static PatchMgr * Object()
Definition: PatchMgr.h:152
void HomePatch::recvExchangeMsg ( ExchangeAtomsMsg msg)

Definition at line 3605 of file HomePatch.C.

References Patch::atomMapper, ExchangeAtomsMsg::atoms, ResizeArray< T >::begin(), ResizeArray< T >::end(), ExchangeAtomsMsg::lattice, Patch::lattice, ExchangeAtomsMsg::numAtoms, rattleListValid, AtomMapper::registerIDsFullAtom(), ResizeArray< T >::resize(), and AtomMapper::unregisterIDsFullAtom().

Referenced by PatchMgr::recvExchangeMsg().

3605  {
3606  // CkPrintf("recvExchangeMsg %d %d\n", CmiMyPartition(), exchange_src);
3607  atomMapper->unregisterIDsFullAtom(atom.begin(),atom.end());
3608  lattice = msg->lattice;
3609  numAtoms = msg->numAtoms;
3610  atom.resize(numAtoms);
3611  memcpy(atom.begin(),msg->atoms,numAtoms*sizeof(FullAtom));
3612  delete msg;
3613  CkpvAccess(_qd)->process();
3614  doAtomUpdate = true;
3615  rattleListValid = false;
3616  if ( ! numNeighbors ) atomMapper->registerIDsFullAtom(atom.begin(),atom.end());
3617 }
Lattice & lattice
Definition: Patch.h:126
void registerIDsFullAtom(const FullAtom *begin, const FullAtom *end)
Definition: AtomMap.C:50
AtomMapper * atomMapper
Definition: Patch.h:152
bool rattleListValid
Definition: HomePatch.h:385
Lattice lattice
Definition: PatchMgr.h:109
iterator end(void)
Definition: ResizeArray.h:37
int numAtoms
Definition: Patch.h:144
void resize(int i)
Definition: ResizeArray.h:84
void unregisterIDsFullAtom(const FullAtom *begin, const FullAtom *end)
Definition: AtomMap.C:100
FullAtom * atoms
Definition: PatchMgr.h:112
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::recvExchangeReq ( int  req)

Definition at line 3594 of file HomePatch.C.

References exchange_dst, exchange_msg, exchange_req, PatchMgr::Object(), and PatchMgr::sendExchangeMsg().

Referenced by exchangeAtoms(), and PatchMgr::recvExchangeReq().

3594  {
3595  exchange_req = req;
3596  if ( exchange_msg ) {
3597  // CkPrintf("recvExchangeReq %d %d\n", CmiMyPartition(), exchange_dst);
3599  exchange_msg = 0;
3600  exchange_req = -1;
3601  CkpvAccess(_qd)->process();
3602  }
3603 }
int exchange_dst
Definition: HomePatch.h:441
ExchangeAtomsMsg * exchange_msg
Definition: HomePatch.h:444
int exchange_req
Definition: HomePatch.h:443
static PatchMgr * Object()
Definition: PatchMgr.h:152
void sendExchangeMsg(ExchangeAtomsMsg *msg, int dst, int dstpe)
Definition: PatchMgr.C:417
void HomePatch::recvNodeAwareSpanningTree ( ProxyNodeAwareSpanningTreeMsg msg)

Definition at line 630 of file HomePatch.C.

Referenced by ProxyMgr::recvNodeAwareSpanningTreeOnHomePatch().

630 {}
void HomePatch::recvSpanningTree ( int *  t,
int  n 
)

Definition at line 636 of file HomePatch.C.

References proxySpanDim, ResizeArray< T >::resize(), sendSpanningTree(), and ResizeArray< T >::size().

Referenced by ProxyMgr::recvSpanningTreeOnHomePatch().

637 {
638  int i;
639  nChild=0;
640  tree.resize(n);
641  for (i=0; i<n; i++) {
642  tree[i] = t[i];
643  }
644 
645  for (i=1; i<=proxySpanDim; i++) {
646  if (tree.size() <= i) break;
647  child[i-1] = tree[i];
648  nChild++;
649  }
650 
651 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
652  isProxyChanged = 1;
653 #endif
654 
655  // send down to children
657 }
void sendSpanningTree()
Definition: HomePatch.C:659
void resize(int i)
Definition: ResizeArray.h:84
int size(void) const
Definition: ResizeArray.h:127
int proxySpanDim
Definition: ProxyMgr.C:48
void HomePatch::registerProxy ( RegisterProxyMsg msg)

Definition at line 402 of file HomePatch.C.

References ResizeArray< T >::add(), ResizeArray< T >::begin(), OwnerBox< Owner, Data >::clientAdd(), DebugM, Patch::forceBox, RegisterProxyMsg::node, Patch::patchID, Random::reorder(), and ResizeArray< T >::size().

Referenced by ProxyMgr::recvRegisterProxy().

402  {
403  DebugM(4, "registerProxy("<<patchID<<") - adding node " <<msg->node<<"\n");
404  proxy.add(msg->node);
406 
407  isNewProxyAdded = 1;
408 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
409  isProxyChanged = 1;
410 #endif
411 
412  Random((patchID + 37) * 137).reorder(proxy.begin(),proxy.size());
413  delete msg;
414 }
OwnerBox< Patch, Results > forceBox
Definition: Patch.h:239
#define DebugM(x, y)
Definition: Debug.h:59
void reorder(Elem *a, int n)
Definition: Random.h:220
Definition: Random.h:37
int add(const Elem &elem)
Definition: ResizeArray.h:97
void clientAdd()
Definition: OwnerBox.h:74
const PatchID patchID
Definition: Patch.h:143
int size(void) const
Definition: ResizeArray.h:127
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::replaceForces ( ExtForce f)

Definition at line 1330 of file HomePatch.C.

References Patch::f.

1331 {
1332  replacementForces = f;
1333 }
ForceList f[Results::maxNumForces]
Definition: Patch.h:207
void HomePatch::revert ( void  )

Definition at line 3459 of file HomePatch.C.

References Patch::atomMapper, ResizeArray< T >::begin(), ResizeArray< T >::copy(), ResizeArray< T >::end(), Patch::lattice, rattleListValid, AtomMapper::registerIDsFullAtom(), ResizeArray< T >::size(), and AtomMapper::unregisterIDsFullAtom().

Referenced by Sequencer::algorithm().

3459  {
3460  atomMapper->unregisterIDsFullAtom(atom.begin(),atom.end());
3461 
3462  atom.copy(checkpoint_atom);
3463  numAtoms = atom.size();
3464  lattice = checkpoint_lattice;
3465 
3466  doAtomUpdate = true;
3467  rattleListValid = false;
3468 
3469  if ( ! numNeighbors ) atomMapper->registerIDsFullAtom(atom.begin(),atom.end());
3470 
3471  // DMK - Atom Separation (water vs. non-water)
3472  #if NAMD_SeparateWaters != 0
3473  numWaterAtoms = checkpoint_numWaterAtoms;
3474  #endif
3475 }
void copy(ResizeArray< Elem > &ra)
Definition: ResizeArray.h:59
Lattice & lattice
Definition: Patch.h:126
void registerIDsFullAtom(const FullAtom *begin, const FullAtom *end)
Definition: AtomMap.C:50
AtomMapper * atomMapper
Definition: Patch.h:152
bool rattleListValid
Definition: HomePatch.h:385
iterator end(void)
Definition: ResizeArray.h:37
int numAtoms
Definition: Patch.h:144
int size(void) const
Definition: ResizeArray.h:127
void unregisterIDsFullAtom(const FullAtom *begin, const FullAtom *end)
Definition: AtomMap.C:100
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::runSequencer ( void  )

Definition at line 269 of file HomePatch.C.

References Sequencer::run().

Referenced by Node::run().

270 { sequencer->run(); }
void run(void)
Definition: Sequencer.C:126
void HomePatch::saveForce ( const int  ftag = Results::normal)

Definition at line 1335 of file HomePatch.C.

References Patch::f, Patch::numAtoms, and ResizeArray< T >::resize().

Referenced by Sequencer::saveForce().

1336 {
1337  f_saved[ftag].resize(numAtoms);
1338  for ( int i = 0; i < numAtoms; ++i )
1339  {
1340  f_saved[ftag][i] = f[ftag][i];
1341  }
1342 }
int numAtoms
Definition: Patch.h:144
void resize(int i)
Definition: ResizeArray.h:84
ForceList f[Results::maxNumForces]
Definition: Patch.h:207
void HomePatch::sendNodeAwareSpanningTree ( )

Definition at line 631 of file HomePatch.C.

631 {}
void HomePatch::sendProxies ( )

Definition at line 468 of file HomePatch.C.

References ResizeArray< T >::begin(), ProxyMgr::Object(), Patch::patchID, ProxyMgr::sendProxies(), NodeProxyMgr::sendProxyList(), and ResizeArray< T >::size().

Referenced by ProxyMgr::buildProxySpanningTree2().

469 {
470 #if USE_NODEPATCHMGR
471  CProxy_NodeProxyMgr pm(CkpvAccess(BOCclass_group).nodeProxyMgr);
472  NodeProxyMgr *npm = pm[CkMyNode()].ckLocalBranch();
473  npm->sendProxyList(patchID, proxy.begin(), proxy.size());
474 #else
475  ProxyMgr::Object()->sendProxies(patchID, proxy.begin(), proxy.size());
476 #endif
477 }
static ProxyMgr * Object()
Definition: ProxyMgr.h:394
void sendProxies(int pid, int *list, int n)
Definition: ProxyMgr.C:600
void sendProxyList(int pid, int *plist, int size)
Definition: ProxyMgr.C:1979
const PatchID patchID
Definition: Patch.h:143
int size(void) const
Definition: ResizeArray.h:127
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::sendSpanningTree ( )

Definition at line 659 of file HomePatch.C.

References ResizeArray< T >::copy(), ProxySpanningTreeMsg::node, ProxyMgr::Object(), ProxySpanningTreeMsg::patch, Patch::patchID, ProxyMgr::sendSpanningTree(), ResizeArray< T >::size(), and ProxySpanningTreeMsg::tree.

Referenced by buildSpanningTree(), and recvSpanningTree().

660 {
661  if (tree.size() == 0) return;
663  msg->patch = patchID;
664  msg->node = CkMyPe();
665  msg->tree.copy(tree); // copy data for thread safety
667 }
void copy(ResizeArray< Elem > &ra)
Definition: ResizeArray.h:59
static ProxyMgr * Object()
Definition: ProxyMgr.h:394
NodeIDList tree
Definition: ProxyMgr.h:265
void sendSpanningTree(ProxySpanningTreeMsg *)
Definition: ProxyMgr.C:1155
const PatchID patchID
Definition: Patch.h:143
int size(void) const
Definition: ResizeArray.h:127
void HomePatch::setGBISIntrinsicRadii ( )

Definition at line 3131 of file HomePatch.C.

References SimParameters::coulomb_radius_offset, Patch::intRad, MassToRadius(), MassToScreen(), Node::molecule, Patch::numAtoms, Node::Object(), ResizeArray< T >::resize(), ResizeArray< T >::setall(), and Node::simParameters.

Referenced by positionsReady().

3131  {
3132  intRad.resize(numAtoms*2);
3133  intRad.setall(0);
3134  Molecule *mol = Node::Object()->molecule;
3136  Real offset = simParams->coulomb_radius_offset;
3137  for (int i = 0; i < numAtoms; i++) {
3138  Real rad = MassToRadius(atom[i].mass);//in ComputeGBIS.inl
3139  Real screen = MassToScreen(atom[i].mass);//same
3140  intRad[2*i+0] = rad - offset;//r0
3141  intRad[2*i+1] = screen*(rad - offset);//s0
3142  }
3143 }
static Node * Object()
Definition: Node.h:86
RealList intRad
Definition: Patch.h:155
SimParameters * simParameters
Definition: Node.h:178
float Real
Definition: common.h:107
BigReal coulomb_radius_offset
int numAtoms
Definition: Patch.h:144
void setall(const Elem &elem)
Definition: ResizeArray.h:90
#define simParams
Definition: Output.C:127
void resize(int i)
Definition: ResizeArray.h:84
static float MassToRadius(Mass mi)
Definition: ComputeGBIS.inl:55
static float MassToScreen(Mass mi)
Molecule * molecule
Definition: Node.h:176
void HomePatch::setLcpoType ( )

Definition at line 3120 of file HomePatch.C.

References Molecule::getLcpoParamType(), Patch::lcpoType, Node::molecule, Patch::numAtoms, Node::Object(), Patch::pExt, and ResizeArray< T >::resize().

Referenced by positionsReady().

3120  {
3121  Molecule *mol = Node::Object()->molecule;
3122  const int *lcpoParamType = mol->getLcpoParamType();
3123 
3125  for (int i = 0; i < numAtoms; i++) {
3126  lcpoType[i] = lcpoParamType[pExt[i].id];
3127  }
3128 }
static Node * Object()
Definition: Node.h:86
int const * getLcpoParamType()
Definition: Molecule.h:478
IntList lcpoType
Definition: Patch.h:164
int numAtoms
Definition: Patch.h:144
void resize(int i)
Definition: ResizeArray.h:84
CompAtomExtList pExt
Definition: Patch.h:174
Molecule * molecule
Definition: Node.h:176
void HomePatch::submitLoadStats ( int  timestep)

Definition at line 3619 of file HomePatch.C.

References LdbCoordinator::Object(), Patch::patchID, and LdbCoordinator::patchLoad().

Referenced by Sequencer::rebalanceLoad().

3620 {
3622 }
void patchLoad(PatchID id, int nAtoms, int timestep)
int numAtoms
Definition: Patch.h:144
static LdbCoordinator * Object()
const PatchID patchID
Definition: Patch.h:143
void HomePatch::unregisterProxy ( UnregisterProxyMsg msg)

Definition at line 416 of file HomePatch.C.

References ResizeArray< T >::begin(), OwnerBox< Owner, Data >::clientRemove(), ResizeArray< T >::del(), Patch::forceBox, and UnregisterProxyMsg::node.

Referenced by ProxyMgr::recvUnregisterProxy().

416  {
417 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
418  isProxyChanged = 1;
419 #endif
420  int n = msg->node;
421  NodeID *pe = proxy.begin();
422  for ( ; *pe != n; ++pe );
424  proxy.del(pe - proxy.begin());
425  delete msg;
426 }
OwnerBox< Patch, Results > forceBox
Definition: Patch.h:239
void del(int index, int num=1)
Definition: ResizeArray.h:104
void clientRemove()
Definition: OwnerBox.h:88
int NodeID
Definition: NamdTypes.h:184
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::useSequencer ( Sequencer sequencerPtr)

Definition at line 265 of file HomePatch.C.

266 { sequencer=sequencerPtr; }

Friends And Related Function Documentation

friend class ComputeGlobal
friend

Definition at line 276 of file HomePatch.h.

friend class PatchMgr
friend

Definition at line 274 of file HomePatch.h.

friend class Sequencer
friend

Definition at line 275 of file HomePatch.h.

Member Data Documentation

int HomePatch::checkpoint_task

Definition at line 428 of file HomePatch.h.

Referenced by exchangeCheckpoint(), and recvCheckpointLoad().

std::map<std::string,checkpoint_t*> HomePatch::checkpoints

Definition at line 435 of file HomePatch.h.

Referenced by recvCheckpointReq(), and recvCheckpointStore().

int HomePatch::exchange_dst

Definition at line 441 of file HomePatch.h.

Referenced by exchangeAtoms(), and recvExchangeReq().

ExchangeAtomsMsg* HomePatch::exchange_msg

Definition at line 444 o