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 1933 of file HomePatch.C.

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

Referenced by Sequencer::addForceToMomentum().

1938  {
1940 
1941  if ( simParams->fixedAtomsOn ) {
1942  for ( int i = 0; i < num_atoms; ++i ) {
1943  if ( atom_arr[i].atomFixed ) {
1944  atom_arr[i].velocity = 0;
1945  } else {
1946  BigReal dt_mass = dt * atom_arr[i].recipMass; // dt/mass
1947  atom_arr[i].velocity.x += force_arr[i].x * dt_mass;
1948  atom_arr[i].velocity.y += force_arr[i].y * dt_mass;
1949  atom_arr[i].velocity.z += force_arr[i].z * dt_mass;
1950  }
1951  }
1952  } else {
1953  for ( int i = 0; i < num_atoms; ++i ) {
1954  BigReal dt_mass = dt * atom_arr[i].recipMass; // dt/mass
1955  atom_arr[i].velocity.x += force_arr[i].x * dt_mass;
1956  atom_arr[i].velocity.y += force_arr[i].y * dt_mass;
1957  atom_arr[i].velocity.z += force_arr[i].z * dt_mass;
1958  }
1959  }
1960 }
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:114
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 1962 of file HomePatch.C.

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

Referenced by Sequencer::addForceToMomentum3().

1971  {
1973 
1974  if ( simParams->fixedAtomsOn ) {
1975  for ( int i = 0; i < num_atoms; ++i ) {
1976  if ( atom_arr[i].atomFixed ) {
1977  atom_arr[i].velocity = 0;
1978  } else {
1979  BigReal rmass = atom_arr[i].recipMass; // 1/mass
1980  atom_arr[i].velocity.x += (force_arr1[i].x*dt1
1981  + force_arr2[i].x*dt2 + force_arr3[i].x*dt3) * rmass;
1982  atom_arr[i].velocity.y += (force_arr1[i].y*dt1
1983  + force_arr2[i].y*dt2 + force_arr3[i].y*dt3) * rmass;
1984  atom_arr[i].velocity.z += (force_arr1[i].z*dt1
1985  + force_arr2[i].z*dt2 + force_arr3[i].z*dt3) * rmass;
1986  }
1987  }
1988  } else {
1989  for ( int i = 0; i < num_atoms; ++i ) {
1990  BigReal rmass = atom_arr[i].recipMass; // 1/mass
1991  atom_arr[i].velocity.x += (force_arr1[i].x*dt1
1992  + force_arr2[i].x*dt2 + force_arr3[i].x*dt3) * rmass;
1993  atom_arr[i].velocity.y += (force_arr1[i].y*dt1
1994  + force_arr2[i].y*dt2 + force_arr3[i].y*dt3) * rmass;
1995  atom_arr[i].velocity.z += (force_arr1[i].z*dt1
1996  + force_arr2[i].z*dt2 + force_arr3[i].z*dt3) * rmass;
1997  }
1998  }
1999 }
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:114
void HomePatch::addRattleForce ( const BigReal  invdt,
Tensor wc 
)

Definition at line 2372 of file HomePatch.C.

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

Referenced by rattle1().

2372  {
2373  for (int ig = 0; ig < numAtoms; ++ig ) {
2374  Force df = (velNew[ig] - atom[ig].velocity) * ( atom[ig].mass * invdt );
2375  Tensor vir = outer(df, atom[ig].position);
2376  wc += vir;
2377  f[Results::normal][ig] += df;
2378  atom[ig].velocity = velNew[ig];
2379  }
2380 }
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 2001 of file HomePatch.C.

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

Referenced by Sequencer::addVelocityToPosition().

2005  {
2007  if ( simParams->fixedAtomsOn ) {
2008  for ( int i = 0; i < num_atoms; ++i ) {
2009  if ( ! atom_arr[i].atomFixed ) {
2010  atom_arr[i].position.x += atom_arr[i].velocity.x * dt;
2011  atom_arr[i].position.y += atom_arr[i].velocity.y * dt;
2012  atom_arr[i].position.z += atom_arr[i].velocity.z * dt;
2013  }
2014  }
2015  } else {
2016  for ( int i = 0; i < num_atoms; ++i ) {
2017  atom_arr[i].position.x += atom_arr[i].velocity.x * dt;
2018  atom_arr[i].position.y += atom_arr[i].velocity.y * dt;
2019  atom_arr[i].position.z += atom_arr[i].velocity.z * dt;
2020  }
2021  }
2022 }
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 2230 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().

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

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

Referenced by Sequencer::algorithm().

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

Definition at line 3999 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().

4000 {
4001 
4002  if (!inMigration) { // We have to buffer changes due to migration
4003  // until our patch is in migration mode
4004  msgbuf[numMlBuf++] = msg;
4005  return;
4006  }
4007 
4008 
4009  // DMK - Atom Separation (water vs. non-water)
4010  #if NAMD_SeparateWaters != 0
4011 
4012 
4013  // Merge the incoming list of atoms with the current list of
4014  // atoms. Note that mergeSeparatedAtomList() will apply any
4015  // required transformations to the incoming atoms as it is
4016  // separating them.
4017  mergeAtomList(msg->migrationList);
4018 
4019 
4020  #else
4021 
4022  // Merge the incoming list of atoms with the current list of
4023  // atoms. Apply transformations to the incoming atoms as they are
4024  // added to this patch's list.
4025  {
4026  MigrationList &migrationList = msg->migrationList;
4028  Transform mother_transform;
4029  for (mi = migrationList.begin(); mi != migrationList.end(); mi++) {
4030  DebugM(1,"Migrating atom " << mi->id << " to patch "
4031  << patchID << " with position " << mi->position << "\n");
4032  if ( mi->migrationGroupSize ) {
4033  if ( mi->migrationGroupSize != mi->hydrogenGroupSize ) {
4034  Position pos = mi->position;
4035  int mgs = mi->migrationGroupSize;
4036  int c = 1;
4037  for ( int j=mi->hydrogenGroupSize; j<mgs;
4038  j+=(mi+j)->hydrogenGroupSize ) {
4039  pos += (mi+j)->position;
4040  ++c;
4041  }
4042  pos *= 1./c;
4043  // iout << "mgroup " << mi->id << " at " << pos << "\n" << endi;
4044  mother_transform = mi->transform;
4045  pos = lattice.nearest(pos,center,&mother_transform);
4046  mi->position = lattice.reverse_transform(mi->position,mi->transform);
4047  mi->position = lattice.apply_transform(mi->position,mother_transform);
4048  mi->transform = mother_transform;
4049  } else {
4050  mi->position = lattice.nearest(mi->position,center,&(mi->transform));
4051  mother_transform = mi->transform;
4052  }
4053  } else {
4054  mi->position = lattice.reverse_transform(mi->position,mi->transform);
4055  mi->position = lattice.apply_transform(mi->position,mother_transform);
4056  mi->transform = mother_transform;
4057  }
4058  atom.add(*mi);
4059  }
4060  }
4061 
4062 
4063  #endif // if (NAMD_SeparateWaters != 0)
4064 
4065 
4066  numAtoms = atom.size();
4067  delete msg;
4068 
4069  DebugM(3,"Counter on " << patchID << " = " << patchMigrationCounter << "\n");
4070  if (!--patchMigrationCounter) {
4071  DebugM(3,"All Migrations are in for patch "<<patchID<<"\n");
4072  allMigrationIn = true;
4073  patchMigrationCounter = numNeighbors;
4074  if (migrationSuspended) {
4075  DebugM(3,"patch "<<patchID<<" is being awakened\n");
4076  migrationSuspended = false;
4077  sequencer->awaken();
4078  return;
4079  }
4080  else {
4081  DebugM(3,"patch "<<patchID<<" was not suspended\n");
4082  }
4083  }
4084 }
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 3839 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_START, 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().

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

Definition at line 3718 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().

3719 {
3720  if ( ! flags.doNonbonded ) return;
3721 
3723  BigReal hgcut = 0.5 * simParams->hgroupCutoff; hgcut *= hgcut;
3724  BigReal maxrad2 = 0.;
3725 
3726  FullAtomList::iterator p_i = atom.begin();
3727  FullAtomList::iterator p_e = atom.end();
3728 
3729  while ( p_i != p_e ) {
3730  const int hgs = p_i->hydrogenGroupSize;
3731  if ( ! hgs ) break; // avoid infinite loop on bug
3732  int ngs = hgs;
3733  if ( ngs > 5 ) ngs = 5; // XXX why? limit to at most 5 atoms per group
3734  BigReal x = p_i->position.x;
3735  BigReal y = p_i->position.y;
3736  BigReal z = p_i->position.z;
3737  int i;
3738  for ( i = 1; i < ngs; ++i ) { // limit spatial extent
3739  p_i[i].nonbondedGroupSize = 0;
3740  BigReal dx = p_i[i].position.x - x;
3741  BigReal dy = p_i[i].position.y - y;
3742  BigReal dz = p_i[i].position.z - z;
3743  BigReal r2 = dx * dx + dy * dy + dz * dz;
3744  if ( r2 > hgcut ) break;
3745  else if ( r2 > maxrad2 ) maxrad2 = r2;
3746  }
3747  p_i->nonbondedGroupSize = i;
3748  for ( ; i < hgs; ++i ) {
3749  p_i[i].nonbondedGroupSize = 1;
3750  }
3751  p_i += hgs;
3752  }
3753 
3754  if ( p_i != p_e ) {
3755  NAMD_bug("hydrogenGroupSize is zero in HomePatch::doGroupSizeCheck");
3756  }
3757 
3758  flags.maxGroupRadius = sqrt(maxrad2);
3759 
3760 }
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:129
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:114
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::doMarginCheck ( )
protected

Definition at line 3762 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().

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

Definition at line 3629 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().

3630 {
3631 #if defined(NAMD_NVTX_ENABLED) || defined(NAMD_CMK_TRACE_ENABLED) || defined(NAMD_ROCTX_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 
3638 
3639  if ( numAtoms == 0 || ! flags.usePairlists ) {
3640  flags.pairlistTolerance = 0.;
3641  flags.maxAtomMovement = 99999.;
3642 #if defined(NAMD_NVTX_ENABLED) || defined(NAMD_CMK_TRACE_ENABLED) || defined(NAMD_ROCTX_ENABLED)
3643  NAMD_EVENT_STOP(1, NamdProfileEvent::DO_PAIRLIST_CHECK);
3644 #endif
3645  return;
3646  }
3647 
3648  int i; int n = numAtoms;
3649  CompAtom *p_i = p.begin();
3650 
3651  if ( flags.savePairlists ) {
3652  flags.pairlistTolerance = doPairlistCheck_newTolerance;
3653  flags.maxAtomMovement = 0.;
3654  doPairlistCheck_newTolerance *= (1. - simParams->pairlistShrink);
3655  doPairlistCheck_lattice = lattice;
3656  doPairlistCheck_positions.resize(numAtoms);
3657  CompAtom *psave_i = doPairlistCheck_positions.begin();
3658  for ( i=0; i<n; ++i ) { psave_i[i] = p_i[i]; }
3659 #if defined(NAMD_NVTX_ENABLED) || defined(NAMD_CMK_TRACE_ENABLED) || defined(NAMD_ROCTX_ENABLED)
3660  NAMD_EVENT_STOP(1, NamdProfileEvent::DO_PAIRLIST_CHECK);
3661 #endif
3662  return;
3663  }
3664 
3665  Lattice &lattice_old = doPairlistCheck_lattice;
3666  Position center_cur = lattice.unscale(center);
3667  Position center_old = lattice_old.unscale(center);
3668  Vector center_delta = center_cur - center_old;
3669 
3670  // find max deviation to corner (any neighbor shares a corner)
3671  BigReal max_cd = 0.;
3672  for ( i=0; i<2; ++i ) {
3673  for ( int j=0; j<2; ++j ) {
3674  for ( int k=0; k<2; ++k ) {
3675  ScaledPosition corner( i ? min.x : max.x ,
3676  j ? min.y : max.y ,
3677  k ? min.z : max.z );
3678  Vector corner_delta =
3679  lattice.unscale(corner) - lattice_old.unscale(corner);
3680  corner_delta -= center_delta;
3681  BigReal cd = corner_delta.length2();
3682  if ( cd > max_cd ) max_cd = cd;
3683  }
3684  }
3685  }
3686  max_cd = sqrt(max_cd);
3687 
3688  // find max deviation of atoms relative to center
3689  BigReal max_pd = 0.;
3690  CompAtom *p_old_i = doPairlistCheck_positions.begin();
3691  for ( i=0; i<n; ++i ) {
3692  Vector p_delta = p_i[i].position - p_old_i[i].position;
3693  p_delta -= center_delta;
3694  BigReal pd = p_delta.length2();
3695  if ( pd > max_pd ) max_pd = pd;
3696  }
3697  max_pd = sqrt(max_pd);
3698 
3699  BigReal max_tol = max_pd + max_cd;
3700 
3701  flags.maxAtomMovement = max_tol;
3702 
3703  // if ( max_tol > flags.pairlistTolerance ) iout << "tolerance " << max_tol << " > " << flags.pairlistTolerance << "\n" << endi;
3704 
3705  if ( max_tol > ( (1. - simParams->pairlistTrigger) *
3706  doPairlistCheck_newTolerance ) ) {
3707  doPairlistCheck_newTolerance *= (1. + simParams->pairlistGrow);
3708  }
3709 
3710  if ( max_tol > doPairlistCheck_newTolerance ) {
3711  doPairlistCheck_newTolerance = max_tol / (1. - simParams->pairlistTrigger);
3712  }
3713 #if defined(NAMD_NVTX_ENABLED) || defined(NAMD_CMK_TRACE_ENABLED) || defined(NAMD_ROCTX_ENABLED)
3714  NAMD_EVENT_STOP(1, NamdProfileEvent::DO_PAIRLIST_CHECK);
3715 #endif
3716 }
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:114
iterator begin(void)
Definition: ResizeArray.h:36
void HomePatch::exchangeAtoms ( int  scriptTask)

Definition at line 3574 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().

3574  {
3576  // CkPrintf("exchangeAtoms %d %d %d %d\n", CmiMyPartition(), scriptTask, (int)(simParams->scriptArg1), (int)(simParams->scriptArg2));
3577  if ( scriptTask == SCRIPT_ATOMSEND || scriptTask == SCRIPT_ATOMSENDRECV ) {
3578  exchange_dst = (int) simParams->scriptArg1;
3579  // create and save outgoing message
3584  memcpy(exchange_msg->atoms,atom.begin(),numAtoms*sizeof(FullAtom));
3585  if ( exchange_req >= 0 ) {
3587  }
3588  }
3589  if ( scriptTask == SCRIPT_ATOMRECV || scriptTask == SCRIPT_ATOMSENDRECV ) {
3590  exchange_src = (int) simParams->scriptArg2;
3592  }
3593 }
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:3595
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 3478 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().

3478  { // initiating replica
3480  checkpoint_task = scriptTask;
3481  const int remote = simParams->scriptIntArg1;
3482  const char *key = simParams->scriptStringArg1;
3483  PatchMgr::Object()->sendCheckpointReq(patchID, remote, key, scriptTask);
3484 }
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 3147 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.

3147  {
3148 
3150  BigReal alphaMax = simParams->alpha_max;
3151  BigReal delta = simParams->gbis_delta;
3152  BigReal beta = simParams->gbis_beta;
3153  BigReal gamma = simParams->gbis_gamma;
3154  BigReal coulomb_radius_offset = simParams->coulomb_radius_offset;
3155 
3156  BigReal rhoi;
3157  BigReal rhoi0;
3158  //calculate bornRad from psiSum
3159  for (int i = 0; i < numAtoms; i++) {
3160  rhoi0 = intRad[2*i];
3161  rhoi = rhoi0+coulomb_radius_offset;
3162  psiFin[i] += psiSum[i];
3163  psiFin[i] *= rhoi0;
3164  bornRad[i]=1/(1/rhoi0-1/rhoi*tanh(psiFin[i]*(delta+psiFin[i]*(-beta+gamma*psiFin[i]))));
3165  bornRad[i] = (bornRad[i] > alphaMax) ? alphaMax : bornRad[i];
3166 #ifdef PRINT_COMP
3167  CkPrintf("BORNRAD(%04i)[%04i] = % .4e\n",flags.sequence,pExt[i].id,bornRad[i]);
3168 #endif
3169  }
3170 
3171  gbisP2Ready();
3172 }
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:3219
#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:114
void HomePatch::gbisComputeAfterP2 ( )

Definition at line 3175 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.

3175  {
3176 
3178  BigReal delta = simParams->gbis_delta;
3179  BigReal beta = simParams->gbis_beta;
3180  BigReal gamma = simParams->gbis_gamma;
3181  BigReal epsilon_s = simParams->solvent_dielectric;
3182  BigReal epsilon_p = simParams->dielectric;
3183  BigReal epsilon_s_i = 1/simParams->solvent_dielectric;
3184  BigReal epsilon_p_i = 1/simParams->dielectric;
3185  BigReal coulomb_radius_offset = simParams->coulomb_radius_offset;
3186  BigReal kappa = simParams->kappa;
3187  BigReal fij, expkappa, Dij, dEdai, dedasum;
3188  BigReal rhoi, rhoi0, psii, nbetapsi;
3189  BigReal gammapsi2, tanhi, daidr;
3190  for (int i = 0; i < numAtoms; i++) {
3191  //add diagonal dEda term
3192  dHdrPrefix[i] += dEdaSum[i];//accumulated from proxies
3193  fij = bornRad[i];//inf
3194  expkappa = exp(-kappa*fij);//0
3195  Dij = epsilon_p_i - expkappa*epsilon_s_i;//dielectric term
3196  //calculate dHij prefix
3197  dEdai = -0.5*COULOMB*atom[i].charge*atom[i].charge
3198  *(kappa*epsilon_s_i*expkappa-Dij/fij)/bornRad[i];
3199  dHdrPrefix[i] += dEdai;
3200  dedasum = dHdrPrefix[i];
3201 
3202  rhoi0 = intRad[2*i];
3203  rhoi = rhoi0+coulomb_radius_offset;
3204  psii = psiFin[i];
3205  nbetapsi = -beta*psii;
3206  gammapsi2 = gamma*psii*psii;
3207  tanhi = tanh(psii*(delta+nbetapsi+gammapsi2));
3208  daidr = bornRad[i]*bornRad[i]*rhoi0/rhoi*(1-tanhi*tanhi)
3209  * (delta+nbetapsi+nbetapsi+gammapsi2+gammapsi2+gammapsi2);
3210  dHdrPrefix[i] *= daidr;//dHdrPrefix previously equaled dEda
3211 #ifdef PRINT_COMP
3212  CkPrintf("DHDR(%04i)[%04i] = % .4e\n",flags.sequence,pExt[i].id,dHdrPrefix[i]);
3213 #endif
3214  }
3215  gbisP3Ready();
3216 }
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:46
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:3239
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:114
void HomePatch::gbisP2Ready ( )

Definition at line 3219 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().

3219  {
3220  if (proxy.size() > 0) {
3221  CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
3222  for (int i = 0; i < proxy.size(); i++) {
3223  int node = proxy[i];
3225  msg->patch = patchID;
3226  msg->origPe = CkMyPe();
3227  memcpy(msg->bornRad,bornRad.begin(),numAtoms*sizeof(Real));
3228  msg->destPe = node;
3229  int seq = flags.sequence;
3231  SET_PRIORITY(msg,seq,priority);
3232  cp[node].recvData(msg);
3233  }
3234  }
3236 }
float Real
Definition: common.h:109
Flags flags
Definition: Patch.h:127
#define PRIORITY_SIZE
Definition: Priorities.h:13
void gbisP2Ready()
Definition: Patch.C:570
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 3239 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().

3239  {
3240  if (proxy.size() > 0) {
3241  CProxy_ProxyMgr cp(CkpvAccess(BOCclass_group).proxyMgr);
3242  //only nonzero message should be sent for doFullElec
3243  int msgAtoms = (flags.doFullElectrostatics) ? numAtoms : 0;
3244  for (int i = 0; i < proxy.size(); i++) {
3245  int node = proxy[i];
3247  msg->patch = patchID;
3248  msg->dHdrPrefixLen = msgAtoms;
3249  msg->origPe = CkMyPe();
3250  memcpy(msg->dHdrPrefix, dHdrPrefix.begin(), msgAtoms*sizeof(Real));
3251  msg->destPe = node;
3252  int seq = flags.sequence;
3254  SET_PRIORITY(msg,seq,priority);
3255  cp[node].recvData(msg);
3256  }
3257  }
3259 }
float Real
Definition: common.h:109
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:587
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 2024 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().

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

Definition at line 3113 of file HomePatch.C.

References DebugM.

3114 {
3115  DebugM(2, "loweAndersenFinish\n");
3116  v.resize(0);
3117 }
#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 3098 of file HomePatch.C.

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

Referenced by positionsReady().

3099 {
3100  DebugM(2, "loweAndersenVelocities\n");
3101  Molecule *mol = Node::Object()->molecule;
3103  v.resize(numAtoms);
3104  for (int i = 0; i < numAtoms; ++i) {
3105  //v[i] = p[i];
3106  // co-opt CompAtom structure to pass velocity and mass information
3107  v[i].position = atom[i].velocity;
3108  v[i].charge = atom[i].mass;
3109  }
3110  DebugM(2, "loweAndersenVelocities\n");
3111 }
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 2963 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().

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

Definition at line 3313 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().

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

Definition at line 3387 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.

3388 {
3389  Molecule *mol = Node::Object()->molecule;
3391  Tensor wc; // constraint virial
3392  int i;
3393  HGArrayInt ial, ibl;
3394  HGArrayVector ref; // reference position
3395  CompAtom *avg; // averaged position
3396  HGArrayVector refab; // reference vector
3397  HGArrayVector force; // new force
3398  HGArrayBigReal rmass; // 1 / mass
3399  BigReal *lambda; // Lagrange multipliers
3400  int numLambdas = 0;
3401  HGArrayInt fixed; // is atom fixed?
3402 
3403  for ( int ig = 0; ig < numAtoms; ig += atom[ig].hydrogenGroupSize ) {
3404  int hgs = atom[ig].hydrogenGroupSize;
3405  if (hgs == 1 ) continue; // only one atom in group
3406  for ( i = 0; i < hgs; ++i ) {
3407  ref[i] = atom[ig+i].position;
3408  force[i] = f[Results::slow][ig+i];
3409  rmass[i] = 1. / atom[ig+i].mass;
3410  fixed[i] = ( simParams->fixedAtomsOn && atom[ig+i].atomFixed );
3411  if ( fixed[i] ) rmass[i] = 0.;
3412  }
3413  int icnt = 0;
3414  // c-ji I'm only going to mollify water for now
3415  if ( atom[ig].rigidBondLength > 0 ) { // for water
3416  if ( hgs != 3 ) {
3417  NAMD_die("Hydrogen group error caught in mollyMollify(). It's a bug!\n");
3418  }
3419  if ( !(fixed[1] && fixed[2]) ) {
3420  ial[icnt] = 1; ibl[icnt] = 2; ++icnt;
3421  }
3422  }
3423  for ( i = 1; i < hgs; ++i ) { // normal bonds to mother atom
3424  if ( atom[ig+i].rigidBondLength > 0 ) {
3425  if ( !(fixed[0] && fixed[i]) ) {
3426  ial[icnt] = 0; ibl[icnt] = i; ++icnt;
3427  }
3428  }
3429  }
3430 
3431  if ( icnt == 0 ) continue; // no constraints
3432  lambda = &(molly_lambda[numLambdas]);
3433  numLambdas += icnt;
3434  for ( i = 0; i < icnt; ++i ) {
3435  refab[i] = ref[ial[i]] - ref[ibl[i]];
3436  }
3437  avg = &(p_avg[ig]);
3438  mollify(avg,ref,lambda,force,hgs,icnt,rmass,ial,ibl,refab);
3439  // store data back to patch
3440  for ( i = 0; i < hgs; ++i ) {
3441  wc += outer(force[i]-f[Results::slow][ig+i],ref[i]);
3442  f[Results::slow][ig+i] = force[i];
3443  }
3444  }
3445  // check that there isn't a constant needed here!
3446  *virial += wc;
3447  p_avg.resize(0);
3448 }
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:4675
CompAtomList p_avg
Definition: Patch.h:147
int numAtoms
Definition: Patch.h:144
void NAMD_die(const char *err_msg)
Definition: common.C:85
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:114
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) || defined(NAMD_ROCTX_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_HIP) || 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_HIP) || 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 
1067 #if ! (defined(NAMD_CUDA) || defined(NAMD_HIP))
1068 #if defined(NAMD_AVXTILES)
1069  if (!simParams->useAVXTiles)
1070 #endif
1071  doGroupSizeCheck();
1072 #endif
1073 
1074  // Copy information needed by computes and proxys to Patch::p.
1075  // Resize only if atoms were migrated
1076  if (doMigration) {
1077  p.resize(numAtoms);
1078  pExt.resize(numAtoms);
1079  }
1080  CompAtom *p_i = p.begin();
1081  CompAtomExt *pExt_i = pExt.begin();
1082  FullAtom *a_i = atom.begin();
1083  int i; int n = numAtoms;
1084  for ( i=0; i<n; ++i ) {
1085  p_i[i] = a_i[i];
1086  pExt_i[i] = a_i[i];
1087  }
1088 
1089  // Measure atom movement to test pairlist validity
1090  doPairlistCheck();
1091 
1092  if (flags.doMolly) mollyAverage();
1093  // BEGIN LA
1095  // END LA
1096 
1097  if (flags.doGBIS) {
1098  //reset for next time step
1099  numGBISP1Arrived = 0;
1100  phase1BoxClosedCalled = false;
1101  numGBISP2Arrived = 0;
1102  phase2BoxClosedCalled = false;
1103  numGBISP3Arrived = 0;
1104  phase3BoxClosedCalled = false;
1105  if (doMigration || isNewProxyAdded)
1107  }
1108 
1109  if (flags.doLCPO) {
1110  if (doMigration || isNewProxyAdded) {
1111  setLcpoType();
1112  }
1113  }
1114 
1115  // Must Add Proxy Changes when migration completed!
1117  int *pids = NULL;
1118  int pidsPreAllocated = 1;
1119  int npid;
1120  if (proxySendSpanning == 0) {
1121  npid = proxy.size();
1122  pids = new int[npid];
1123  pidsPreAllocated = 0;
1124  int *pidi = pids;
1125  int *pide = pids + proxy.size();
1126  int patchNodesLast =
1127  ( PatchMap::Object()->numNodesWithPatches() < ( 0.7 * CkNumPes() ) );
1128  for ( pli = proxy.begin(); pli != proxy.end(); ++pli )
1129  {
1130  if ( patchNodesLast && PatchMap::Object()->numPatchesOnNode(*pli) ) {
1131  *(--pide) = *pli;
1132  } else {
1133  *(pidi++) = *pli;
1134  }
1135  }
1136  }
1137  else {
1138 #ifdef NODEAWARE_PROXY_SPANNINGTREE
1139  #ifdef USE_NODEPATCHMGR
1140  npid = numNodeChild;
1141  pids = nodeChildren;
1142  #else
1143  npid = nChild;
1144  pids = child;
1145  #endif
1146 #else
1147  npid = nChild;
1148  pidsPreAllocated = 0;
1149  pids = new int[proxySpanDim];
1150  for (int i=0; i<nChild; i++) pids[i] = child[i];
1151 #endif
1152  }
1153  if (npid) { //have proxies
1154  int seq = flags.sequence;
1155  int priority = PROXY_DATA_PRIORITY + PATCH_PRIORITY(patchID);
1156  //begin to prepare proxy msg and send it
1157  int pdMsgPLLen = p.size();
1158  int pdMsgAvgPLLen = 0;
1159  if(flags.doMolly) {
1160  pdMsgAvgPLLen = p_avg.size();
1161  }
1162  // BEGIN LA
1163  int pdMsgVLLen = 0;
1164  if (flags.doLoweAndersen) {
1165  pdMsgVLLen = v.size();
1166  }
1167  // END LA
1168 
1169  int intRadLen = 0;
1170  if (flags.doGBIS && (doMigration || isNewProxyAdded)) {
1171  intRadLen = numAtoms * 2;
1172  }
1173 
1174  //LCPO
1175  int lcpoTypeLen = 0;
1176  if (flags.doLCPO && (doMigration || isNewProxyAdded)) {
1177  lcpoTypeLen = numAtoms;
1178  }
1179 
1180  int pdMsgPLExtLen = 0;
1181  if(doMigration || isNewProxyAdded) {
1182  pdMsgPLExtLen = pExt.size();
1183  }
1184 
1185  int cudaAtomLen = 0;
1186 #if defined(NAMD_CUDA) || defined(NAMD_HIP)
1187  cudaAtomLen = numAtoms;
1188 #elif defined(NAMD_AVXTILES)
1189  if (simParams->useAVXTiles)
1190  cudaAtomLen = (numAtoms + 15) & (~15);
1191 #elif defined(NAMD_MIC)
1192  #if MIC_HANDCODE_FORCE_SOA_VS_AOS != 0
1193  cudaAtomLen = numAtoms;
1194  #else
1195  cudaAtomLen = (numAtoms + 15) & (~15);
1196  #endif
1197 #endif
1198 
1199  ProxyDataMsg *nmsg = new (pdMsgPLLen, pdMsgAvgPLLen, pdMsgVLLen, intRadLen,
1200  lcpoTypeLen, pdMsgPLExtLen, cudaAtomLen, PRIORITY_SIZE) ProxyDataMsg; // BEGIN LA, END LA
1201 
1202  SET_PRIORITY(nmsg,seq,priority);
1203  nmsg->patch = patchID;
1204  nmsg->flags = flags;
1205  nmsg->plLen = pdMsgPLLen;
1206  //copying data to the newly created msg
1207  memcpy(nmsg->positionList, p.begin(), sizeof(CompAtom)*pdMsgPLLen);
1208  nmsg->avgPlLen = pdMsgAvgPLLen;
1209  if(flags.doMolly) {
1210  memcpy(nmsg->avgPositionList, p_avg.begin(), sizeof(CompAtom)*pdMsgAvgPLLen);
1211  }
1212  // BEGIN LA
1213  nmsg->vlLen = pdMsgVLLen;
1214  if (flags.doLoweAndersen) {
1215  memcpy(nmsg->velocityList, v.begin(), sizeof(CompAtom)*pdMsgVLLen);
1216  }
1217  // END LA
1218 
1219  if (flags.doGBIS && (doMigration || isNewProxyAdded)) {
1220  for (int i = 0; i < numAtoms * 2; i++) {
1221  nmsg->intRadList[i] = intRad[i];
1222  }
1223  }
1224 
1225  if (flags.doLCPO && (doMigration || isNewProxyAdded)) {
1226  for (int i = 0; i < numAtoms; i++) {
1227  nmsg->lcpoTypeList[i] = lcpoType[i];
1228  }
1229  }
1230 
1231  nmsg->plExtLen = pdMsgPLExtLen;
1232  if(doMigration || isNewProxyAdded){
1233  memcpy(nmsg->positionExtList, pExt.begin(), sizeof(CompAtomExt)*pdMsgPLExtLen);
1234  }
1235 
1236 // DMK
1237 #if defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_MIC) || defined(NAMD_AVXTILES)
1238  #ifdef NAMD_AVXTILES
1239  if (simParams->useAVXTiles)
1240  #endif
1241  memcpy(nmsg->cudaAtomList, cudaAtomPtr, sizeof(CudaAtom)*cudaAtomLen);
1242 #endif
1243 
1244 #if NAMD_SeparateWaters != 0
1245  //DMK - Atom Separation (water vs. non-water)
1246  nmsg->numWaterAtoms = numWaterAtoms;
1247 #endif
1248 
1249 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR) && (CMK_SMP) && defined(NAMDSRC_IMMQD_HACK)
1250  nmsg->isFromImmMsgCall = 0;
1251 #endif
1252 
1253  #if defined(PROCTRACE_DEBUG) && defined(NAST_DEBUG)
1254  DebugFileTrace *dft = DebugFileTrace::Object();
1255  dft->openTrace();
1256  dft->writeTrace("HP::posReady: for HomePatch[%d], sending proxy msg to: ", patchID);
1257  for(int i=0; i<npid; i++) {
1258  dft->writeTrace("%d ", pids[i]);
1259  }
1260  dft->writeTrace("\n");
1261  dft->closeTrace();
1262  #endif
1263 
1264 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
1265  if (isProxyChanged || localphs == NULL)
1266  {
1267 //CmiPrintf("[%d] Build persistent: isProxyChanged: %d %p\n", CkMyPe(), isProxyChanged, localphs);
1268  //CmiAssert(isProxyChanged);
1269  if (nphs) {
1270  for (int i=0; i<nphs; i++) {
1271  CmiDestoryPersistent(localphs[i]);
1272  }
1273  delete [] localphs;
1274  }
1275  localphs = new PersistentHandle[npid];
1276  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;
1277  for (int i=0; i<npid; i++) {
1278 #if defined(NODEAWARE_PROXY_SPANNINGTREE) && defined(USE_NODEPATCHMGR)
1279  if (proxySendSpanning)
1280  localphs[i] = CmiCreateNodePersistent(pids[i], persist_size, sizeof(envelope)+sizeof(ProxyDataMsg));
1281  else
1282 #endif
1283  localphs[i] = CmiCreatePersistent(pids[i], persist_size, sizeof(envelope)+sizeof(ProxyDataMsg));
1284  }
1285  nphs = npid;
1286  }
1287  CmiAssert(nphs == npid && localphs != NULL);
1288  CmiUsePersistentHandle(localphs, nphs);
1289 #endif
1290  if(doMigration || isNewProxyAdded) {
1291  ProxyMgr::Object()->sendProxyAll(nmsg,npid,pids);
1292  }else{
1293  ProxyMgr::Object()->sendProxyData(nmsg,npid,pids);
1294  }
1295 #if CMK_PERSISTENT_COMM && USE_PERSISTENT_TREE
1296  CmiUsePersistentHandle(NULL, 0);
1297 #endif
1298  isNewProxyAdded = 0;
1299  }
1300  isProxyChanged = 0;
1301  if(!pidsPreAllocated) delete [] pids;
1302  DebugM(4, "patchID("<<patchID<<") doing positions Ready\n");
1303 
1304 #ifdef REMOVE_PROXYDATAMSG_EXTRACOPY
1305  positionPtrBegin = p.begin();
1306  positionPtrEnd = p.end();
1307 #endif
1308 
1309  if(flags.doMolly) {
1312  }
1313  // BEGIN LA
1314  if (flags.doLoweAndersen) {
1315  velocityPtrBegin = v.begin();
1316  velocityPtrEnd = v.end();
1317  }
1318  // END LA
1319 
1320  Patch::positionsReady(doMigration);
1321 
1322  patchMapRead = 1;
1323 
1324  // gzheng
1325  Sync::Object()->PatchReady();
1326 
1327  NAMD_EVENT_STOP(1, NamdProfileEvent::POSITIONS_READY);
1328 
1329 }
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:109
#define COULOMB
Definition: common.h:46
#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:403
#define PROXY_DATA_PRIORITY
Definition: Priorities.h:40
CompAtomList v
Definition: Patch.h:149
void doGroupSizeCheck()
Definition: HomePatch.C:3718
CompAtom * avgPositionList
Definition: ProxyMgr.h:104
void loweAndersenVelocities()
Definition: HomePatch.C:3098
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:116
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:3121
CompAtom * avgPositionPtrBegin
Definition: Patch.h:197
void doPairlistCheck()
Definition: HomePatch.C:3629
void doAtomMigration()
Definition: HomePatch.C:3839
void PatchReady(void)
Definition: Sync.C:150
void setGBISIntrinsicRadii()
Definition: HomePatch.C:3132
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:3313
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:3762
int doMolly
Definition: PatchTypes.h:24
double BigReal
Definition: common.h:114
#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:824
SimParameters * simParameters
Definition: Node.h:178
int get_numQMAtoms()
Definition: Molecule.h:826
float Real
Definition: common.h:109
Charge charge
Definition: NamdTypes.h:54
int newVdWType
Definition: ComputeQM.h:33
const Real * get_qmAtomGroup() const
Definition: Molecule.h:820
Real * get_qmAtmChrg()
Definition: Molecule.h:823
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 2382 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().

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

Definition at line 2559 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().

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

Definition at line 2829 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.

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

Definition at line 3262 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().

3262  {
3263  ++numGBISP1Arrived;
3264  for ( int i = 0; i < msg->psiSumLen; ++i ) {
3265  psiFin[i] += msg->psiSum[i];
3266  }
3267  delete msg;
3268 
3269  if (flags.doNonbonded) {
3270  //awaken if phase 1 done
3271  if (phase1BoxClosedCalled == true &&
3272  numGBISP1Arrived==proxy.size() ) {
3273  sequencer->awaken();
3274  }
3275  } else {
3276  //awaken if all phases done on noWork step
3277  if (boxesOpen == 0 &&
3278  numGBISP1Arrived == proxy.size() &&
3279  numGBISP2Arrived == proxy.size() &&
3280  numGBISP3Arrived == proxy.size()) {
3281  sequencer->awaken();
3282  }
3283  }
3284 }
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 3287 of file HomePatch.C.

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

3287  {
3288  ++numGBISP2Arrived;
3289  //accumulate dEda
3290  for ( int i = 0; i < msg->dEdaSumLen; ++i ) {
3291  dHdrPrefix[i] += msg->dEdaSum[i];
3292  }
3293  delete msg;
3294 
3295  if (flags.doNonbonded) {
3296  //awaken if phase 2 done
3297  if (phase2BoxClosedCalled == true &&
3298  numGBISP2Arrived==proxy.size() ) {
3299  sequencer->awaken();
3300  }
3301  } else {
3302  //awaken if all phases done on noWork step
3303  if (boxesOpen == 0 &&
3304  numGBISP1Arrived == proxy.size() &&
3305  numGBISP2Arrived == proxy.size() &&
3306  numGBISP3Arrived == proxy.size()) {
3307  sequencer->awaken();
3308  }
3309  }
3310 }
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 3569 of file HomePatch.C.

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

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

Definition at line 3516 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().

3516  { // initiating replica
3518  const int remote = simParams->scriptIntArg1;
3519  const char *key = simParams->scriptStringArg1;
3521  NAMD_bug("HomePatch::recvCheckpointLoad called during checkpointFree.");
3522  }
3523  if ( msg->replica != remote ) {
3524  NAMD_bug("HomePatch::recvCheckpointLoad message from wrong replica.");
3525  }
3527  CheckpointAtomsMsg *newmsg = new (numAtoms,1+strlen(key),0) CheckpointAtomsMsg;
3528  strcpy(newmsg->key,key);
3529  newmsg->lattice = lattice;
3530  newmsg->berendsenPressure_count = sequencer->berendsenPressure_count;
3531  newmsg->pid = patchID;
3532  newmsg->pe = CkMyPe();
3533  newmsg->replica = CmiMyPartition();
3534  newmsg->numAtoms = numAtoms;
3535  memcpy(newmsg->atoms,atom.begin(),numAtoms*sizeof(FullAtom));
3536  PatchMgr::Object()->sendCheckpointStore(newmsg, remote, msg->pe);
3537  }
3539  atomMapper->unregisterIDsFullAtom(atom.begin(),atom.end());
3540  lattice = msg->lattice;
3542  numAtoms = msg->numAtoms;
3543  atom.resize(numAtoms);
3544  memcpy(atom.begin(),msg->atoms,numAtoms*sizeof(FullAtom));
3545  doAtomUpdate = true;
3546  rattleListValid = false;
3547  if ( ! numNeighbors ) atomMapper->registerIDsFullAtom(atom.begin(),atom.end());
3548  }
3551  }
3552  delete msg;
3553 }
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:3569
void NAMD_bug(const char *err_msg)
Definition: common.C:129
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 3486 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().

3486  { // responding replica
3487  if ( task == SCRIPT_CHECKPOINT_FREE ) {
3488  if ( ! checkpoints.count(key) ) {
3489  NAMD_die("Unable to free checkpoint, requested key was never stored.");
3490  }
3491  delete checkpoints[key];
3492  checkpoints.erase(key);
3493  PatchMgr::Object()->sendCheckpointAck(patchID, replica, pe);
3494  return;
3495  }
3496  CheckpointAtomsMsg *msg;
3497  if ( task == SCRIPT_CHECKPOINT_LOAD || task == SCRIPT_CHECKPOINT_SWAP ) {
3498  if ( ! checkpoints.count(key) ) {
3499  NAMD_die("Unable to load checkpoint, requested key was never stored.");
3500  }
3501  checkpoint_t &cp = *checkpoints[key];
3502  msg = new (cp.numAtoms,1,0) CheckpointAtomsMsg;
3503  msg->lattice = cp.lattice;
3504  msg->berendsenPressure_count = cp.berendsenPressure_count;
3505  msg->numAtoms = cp.numAtoms;
3506  memcpy(msg->atoms,cp.atoms.begin(),cp.numAtoms*sizeof(FullAtom));
3507  } else {
3508  msg = new (0,1,0) CheckpointAtomsMsg;
3509  }
3510  msg->pid = patchID;
3511  msg->replica = CmiMyPartition();
3512  msg->pe = CkMyPe();
3513  PatchMgr::Object()->sendCheckpointLoad(msg, replica, pe);
3514 }
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:85
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 3555 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().

3555  { // responding replica
3556  if ( ! checkpoints.count(msg->key) ) {
3557  checkpoints[msg->key] = new checkpoint_t;
3558  }
3559  checkpoint_t &cp = *checkpoints[msg->key];
3560  cp.lattice = msg->lattice;
3561  cp.berendsenPressure_count = msg->berendsenPressure_count;
3562  cp.numAtoms = msg->numAtoms;
3563  cp.atoms.resize(cp.numAtoms);
3564  memcpy(cp.atoms.begin(),msg->atoms,cp.numAtoms*sizeof(FullAtom));
3566  delete msg;
3567 }
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 3606 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().

3606  {
3607  // CkPrintf("recvExchangeMsg %d %d\n", CmiMyPartition(), exchange_src);
3608  atomMapper->unregisterIDsFullAtom(atom.begin(),atom.end());
3609  lattice = msg->lattice;
3610  numAtoms = msg->numAtoms;
3611  atom.resize(numAtoms);
3612  memcpy(atom.begin(),msg->atoms,numAtoms*sizeof(FullAtom));
3613  delete msg;
3614  CkpvAccess(_qd)->process();
3615  doAtomUpdate = true;
3616  rattleListValid = false;
3617  if ( ! numNeighbors ) atomMapper->registerIDsFullAtom(atom.begin(),atom.end());
3618 }
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 3595 of file HomePatch.C.

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

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

3595  {
3596  exchange_req = req;
3597  if ( exchange_msg ) {
3598  // CkPrintf("recvExchangeReq %d %d\n", CmiMyPartition(), exchange_dst);
3600  exchange_msg = 0;
3601  exchange_req = -1;
3602  CkpvAccess(_qd)->process();
3603  }
3604 }
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 1331 of file HomePatch.C.

References Patch::f.

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

Definition at line 3460 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().

3460  {
3461  atomMapper->unregisterIDsFullAtom(atom.begin(),atom.end());
3462 
3463  atom.copy(checkpoint_atom);
3464  numAtoms = atom.size();
3465  lattice = checkpoint_lattice;
3466 
3467  doAtomUpdate = true;
3468  rattleListValid = false;
3469 
3470  if ( ! numNeighbors ) atomMapper->registerIDsFullAtom(atom.begin(),atom.end());
3471 
3472  // DMK - Atom Separation (water vs. non-water)
3473  #if NAMD_SeparateWaters != 0
3474  numWaterAtoms = checkpoint_numWaterAtoms;
3475  #endif
3476 }
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 1336 of file HomePatch.C.

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

Referenced by Sequencer::saveForce().

1337 {
1338  f_saved[ftag].resize(numAtoms);
1339  for ( int i = 0; i < numAtoms; ++i )
1340  {
1341  f_saved[ftag][i] = f[ftag][i];
1342  }
1343 }
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 3132 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().

3132  {
3133  intRad.resize(numAtoms*2);
3134  intRad.setall(0);
3135  Molecule *mol = Node::Object()->molecule;
3137  Real offset = simParams->coulomb_radius_offset;
3138  for (int i = 0; i < numAtoms; i++) {
3139  Real rad = MassToRadius(atom[i].mass);//in ComputeGBIS.inl
3140  Real screen = MassToScreen(atom[i].mass);//same
3141  intRad[2*i+0] = rad - offset;//r0
3142  intRad[2*i+1] = screen*(rad - offset);//s0
3143  }
3144 }
static Node * Object()
Definition: Node.h:86
RealList intRad
Definition: Patch.h:155
SimParameters * simParameters
Definition: Node.h:178
float Real
Definition: common.h:109
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 3121 of file HomePatch.C.

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

Referenced by positionsReady().

3121  {
3122  Molecule *mol = Node::Object()->molecule;
3123  const int *lcpoParamType = mol->getLcpoParamType();
3124 
3126  for (int i = 0; i < numAtoms; i++) {
3127  lcpoType[i] = lcpoParamType[pExt[i].id];
3128  }
3129 }
static Node * Object()
Definition: Node.h:86
int const * getLcpoParamType()
Definition: Molecule.h:479
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 3620 of file HomePatch.C.

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

Referenced by Sequencer::rebalanceLoad().

3621 {
3623 }
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 of file HomePatch.h.

Referenced by exchangeAtoms(), and recvExchangeReq().

int HomePatch::exchange_req

Definition at line 443 of file HomePatch.h.

Referenced by exchangeAtoms(), and recvExchangeReq().

int HomePatch::exchange_src

Definition at line 442 of file HomePatch.h.

Referenced by exchangeAtoms().

int HomePatch::inMigration
protected

Definition at line 492 of file HomePatch.h.

Referenced by depositMigration(), and doAtomMigration().

LDObjHandle HomePatch::ldObjHandle
int HomePatch::marginViolations
MigrateAtomsMsg* HomePatch::msgbuf[PatchMap::MaxOneAway]
protected

Definition at line 494 of file HomePatch.h.

Referenced by depositMigration(), and doAtomMigration().

std::vector<int> HomePatch::noconstList

Definition at line 383 of file HomePatch.h.

Referenced by buildRattleList(), and rattle1().

int HomePatch::numMlBuf
protected

Definition at line 493 of file HomePatch.h.

Referenced by depositMigration(), and doAtomMigration().

std::vector<Vector> HomePatch::posNew

Definition at line 389 of file HomePatch.h.

Referenced by buildRattleList(), and rattle1().

std::vector<RattleList> HomePatch::rattleList

Definition at line 381 of file HomePatch.h.

Referenced by buildRattleList(), and rattle1().

bool HomePatch::rattleListValid

Definition at line 385 of file HomePatch.h.

Referenced by positionsReady(), rattle1(), recvCheckpointLoad(), recvExchangeMsg(), and revert().

std::vector<RattleParam> HomePatch::rattleParam

Definition at line 382 of file HomePatch.h.

Referenced by buildRattleList(), and rattle1().

std::vector<int> HomePatch::settleList

Definition at line 380 of file HomePatch.h.

Referenced by buildRattleList(), and rattle1().

std::vector<Vector> HomePatch::velNew

Definition at line 388 of file HomePatch.h.

Referenced by addRattleForce(), buildRattleList(), and rattle1().


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