00001
00007
00008
00009
00010
00011
00012 #ifndef HOMEPATCH_H
00013 #define HOMEPATCH_H
00014
00015 #include "charm++.h"
00016
00017 #include "NamdTypes.h"
00018 #include "Patch.h"
00019 #include "PatchMap.h"
00020
00021 #include "MigrateAtomsMsg.h"
00022 #include "main.h"
00023 #include "common.h"
00024 #include "Migration.h"
00025
00026 class RegisterProxyMsg;
00027 class UnregisterProxyMsg;
00028 class ProxyResultVarsizeMsg;
00029 class ProxyResultMsg;
00030 class ProxyCombinedResultRawMsg;
00031 class Sequencer;
00032 class SubmitReduction;
00033 class ProxyGBISP1ResultMsg;
00034 class ProxyGBISP2ResultMsg;
00035
00036 class ProxyNodeAwareSpanningTreeMsg;
00037
00038 class HomePatch : public Patch {
00039 friend class PatchMgr;
00040 friend class Sequencer;
00041 friend class ComputeGlobal;
00042
00043 private:
00044
00045 HomePatch(PatchID, int atomCnt);
00046
00047 HomePatch(PatchID, FullAtomList&);
00048
00049
00050
00051 void reinitAtoms(FullAtomList&);
00052 ScaledPosition min, max, center;
00053 BigReal aAwayDist, bAwayDist, cAwayDist;
00054
00055
00056
00057
00058
00059
00060
00061
00062 Bool isNewProxyAdded;
00063 int numGBISP1Arrived, numGBISP2Arrived, numGBISP3Arrived;
00064 bool phase1BoxClosedCalled;
00065 bool phase2BoxClosedCalled;
00066 bool phase3BoxClosedCalled;
00067
00068 public:
00069 ~HomePatch();
00070
00071
00072 void registerProxy(RegisterProxyMsg *);
00073
00074 void unregisterProxy(UnregisterProxyMsg *);
00075
00076
00077 void receiveResults(ProxyResultVarsizeMsg *msg);
00078 void receiveResults(ProxyResultMsg *msg);
00079
00080 void receiveResult(ProxyGBISP1ResultMsg *msg);
00081 void receiveResult(ProxyGBISP2ResultMsg *msg);
00082
00083
00084 void receiveResults(ProxyCombinedResultRawMsg *msg);
00085
00086
00087 void depositMigration(MigrateAtomsMsg *);
00088
00089
00090 void useSequencer(Sequencer *sequencerPtr);
00091
00092 void runSequencer(void);
00093
00094
00095
00096
00097
00098
00099 void positionsReady(int doMigration=0);
00100 int marginViolations;
00101
00102
00103 void saveForce(const int ftag = Results::normal);
00104 void addForceToMomentum(const BigReal, const int ftag = Results::normal,
00105 const int useSaved = 0);
00106 void addVelocityToPosition(const BigReal);
00107
00108
00109 int hardWallDrude(const BigReal, Tensor *virial, SubmitReduction *);
00110
00111
00112 int rattle1(const BigReal, Tensor *virial, SubmitReduction *);
00113 void rattle2(const BigReal, Tensor *virial);
00114
00115
00116 void mollyAverage();
00117 void mollyMollify(Tensor *virial);
00118
00119
00120
00121
00122 void loweAndersenVelocities();
00123 void loweAndersenFinish();
00124
00125
00126 void setGBISIntrinsicRadii();
00127 void gbisComputeAfterP1();
00128 void gbisComputeAfterP2();
00129 void gbisP2Ready();
00130 void gbisP3Ready();
00131
00132
00133 void setLcpoType();
00134
00135
00136 void checkpoint(void);
00137 void revert(void);
00138
00139
00140 void replaceForces(ExtForce *f);
00141
00142
00143 void submitLoadStats(int timestep);
00144
00145
00146 FullAtomList &getAtomList() { return (atom); }
00147
00148 #ifdef NODEAWARE_PROXY_SPANNINGTREE
00149
00150 void buildNodeAwareSpanningTree(void);
00151 void setupChildrenFromProxySpanningTree();
00152 #else
00153
00154 void buildSpanningTree(void);
00155 #endif
00156
00157 void sendNodeAwareSpanningTree();
00158 void recvNodeAwareSpanningTree(ProxyNodeAwareSpanningTreeMsg *msg);
00159
00160 void sendSpanningTree();
00161 void recvSpanningTree(int *t, int n);
00162
00163
00164 void sendProxies();
00165
00166 #if USE_TOPOMAP
00167 int findSubroots(int dim, int* subroots, int psize, int* pidscopy);
00168 #endif
00169
00170 LDObjHandle ldObjHandle;
00171 protected:
00172 virtual void boxClosed(int);
00173
00174
00175 void doPairlistCheck();
00176 void doGroupSizeCheck();
00177 void doMarginCheck();
00178 void doAtomMigration();
00179 int inMigration;
00180 int numMlBuf;
00181 MigrateAtomsMsg *msgbuf[PatchMap::MaxOneAway];
00182
00183 private:
00184
00185 FullAtomList atom;
00186 ForceList f_saved[Results::maxNumForces];
00187 ExtForce *replacementForces;
00188
00189 CudaAtomList cudaAtomList;
00190
00191
00192 #if NAMD_SeparateWaters != 0
00193 FullAtomList tempAtom;
00194
00195 void separateAtoms();
00196 void mergeAtomList(FullAtomList &al);
00197
00198 #endif
00199
00200
00201
00202 FullAtomList checkpoint_atom;
00203 Lattice checkpoint_lattice;
00204
00205
00206 #if NAMD_SeparateWaters != 0
00207 int checkpoint_numWaterAtoms;
00208 #endif
00209
00210
00211
00212 CompAtomList doPairlistCheck_positions;
00213 Lattice doPairlistCheck_lattice;
00214 BigReal doPairlistCheck_newTolerance;
00215
00216
00217 ResizeArray<BigReal> molly_lambda;
00218
00219
00220 NodeIDList proxy;
00221
00222 Sequencer *sequencer;
00223
00224
00225 int patchMapRead;
00226 void readPatchMap();
00227
00228
00229 int allMigrationIn;
00230 int migrationSuspended;
00231 int patchMigrationCounter;
00232 int numNeighbors;
00233 MigrationInfo realInfo[PatchMap::MaxOneAway];
00234 MigrationInfo *mInfo[3][3][3];
00235
00236 #ifdef NODEAWARE_PROXY_SPANNINGTREE
00237
00238 proxyTreeNodeList ptnTree;
00239
00240
00241
00242
00243
00244
00245 #else
00246 NodeIDList tree;
00247 int *child;
00248 int nChild;
00249 #endif
00250
00251
00252 int settle_initialized;
00253 BigReal settle_mOrmT; BigReal settle_mHrmT; BigReal settle_ra;
00254 BigReal settle_rb; BigReal settle_rc; BigReal settle_rra;
00255
00256
00257 void redistrib_lonepair_forces(const int, Tensor *);
00258
00259
00260
00261 void redistrib_tip4p_forces(const int, Tensor*);
00262 void tip4_omrepos(Vector*, Vector*, Vector*, BigReal);
00263 void init_tip4();
00264
00265
00266 void redistrib_swm4_forces(const int, Tensor*);
00267 void swm4_omrepos(Vector*, Vector*, Vector*, BigReal);
00268 void init_swm4();
00269
00270
00271 void reposition_lonepair(
00272 Vector& ri, const Vector& rj, const Vector& rk, const Vector& rl,
00273 Real distance, Real angle, Real dihedral);
00274
00275 void reposition_all_lonepairs(void);
00276
00277
00278 void redistrib_lp_force(
00279 Vector& fi, Vector& fj, Vector& fk, Vector& fl,
00280 const Vector& ri, const Vector& rj, const Vector& rk, const Vector& rl,
00281 Tensor *virial, int midpt);
00282
00283
00284 void redistrib_lp_water_force(
00285 Vector& f_ox, Vector& f_h1, Vector& f_h2, Vector& f_lp,
00286 const Vector& p_ox, const Vector& p_h1, const Vector& p_h2,
00287 const Vector& p_lp, Tensor *virial);
00288
00289 BigReal r_om, r_ohc;
00290 void write_tip4_props(void);
00291
00292 int isProxyChanged;
00293
00294 #if CMK_PERSISTENT_COMM
00295 PersistentHandle *localphs;
00296 int nphs;
00297 #endif
00298 };
00299
00300 #endif
00301