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 "HomePatchTypes.h"
00023 #include "main.h"
00024 #include "common.h"
00025 #include "Migration.h"
00026
00027 class RegisterProxyMsg;
00028 class UnregisterProxyMsg;
00029 class ProxyResultVarsizeMsg;
00030 class ProxyResultMsg;
00031 class ProxyCombinedResultMsg;
00032 class Sequencer;
00033 class SubmitReduction;
00034
00035 class ProxyNodeAwareSpanningTreeMsg;
00036
00037 class HomePatch : public Patch {
00038 friend class PatchMgr;
00039 friend class Sequencer;
00040 friend class ComputeGlobal;
00041
00042 private:
00043
00044 HomePatch(PatchID, FullAtomList);
00045
00046 HomePatch(PatchID, int atomCnt);
00047
00048 void reinitAtoms(FullAtomList);
00049 ScaledPosition min, max, center;
00050 int aAway, bAway, cAway;
00051
00052 #ifdef MEM_OPT_VERSION
00053
00054
00055
00056
00057
00058
00059
00060 Bool isNewProxyAdded;
00061 #endif
00062
00063 public:
00064 ~HomePatch();
00065
00066
00067 void registerProxy(RegisterProxyMsg *);
00068
00069 void unregisterProxy(UnregisterProxyMsg *);
00070
00071
00072 void receiveResults(ProxyResultVarsizeMsg *msg);
00073 void receiveResults(ProxyResultMsg *msg);
00074
00075 void receiveResults(ProxyCombinedResultMsg *msg);
00076
00077
00078 void depositMigration(MigrateAtomsMsg *);
00079
00080
00081 void useSequencer(Sequencer *sequencerPtr);
00082
00083 void runSequencer(void);
00084
00085
00086
00087
00088
00089
00090 void positionsReady(int doMigration=0);
00091 int marginViolations;
00092
00093
00094 void saveForce(const int ftag = Results::normal);
00095 void addForceToMomentum(const BigReal, const int ftag = Results::normal,
00096 const int useSaved = 0);
00097 void addVelocityToPosition(const BigReal);
00098
00099
00100 int rattle1(const BigReal, Tensor *virial, SubmitReduction *);
00101 void rattle2(const BigReal, Tensor *virial);
00102
00103
00104 void mollyAverage();
00105 void mollyMollify(Tensor *virial);
00106
00107
00108
00109
00110 void checkpoint(void);
00111 void revert(void);
00112
00113
00114 void replaceForces(ExtForce *f);
00115
00116
00117 void submitLoadStats(int timestep);
00118
00119
00120 FullAtomList &getAtomList() { return (atom); }
00121
00122 void setAtomList(FullAtomList *al) {
00123 atom = *al;
00124 }
00125
00126 #ifdef NODEAWARE_PROXY_SPANNINGTREE
00127
00128 void buildNodeAwareSpanningTree(void);
00129 void setupChildrenFromProxySpanningTree();
00130 #else
00131
00132 void buildSpanningTree(void);
00133 #endif
00134
00135 void sendNodeAwareSpanningTree();
00136 void recvNodeAwareSpanningTree(ProxyNodeAwareSpanningTreeMsg *msg);
00137
00138 void sendSpanningTree();
00139 void recvSpanningTree(int *t, int n);
00140
00141
00142 void sendProxies();
00143
00144 #if USE_TOPOMAP
00145 int findSubroots(int dim, int* subroots, int psize, int* pidscopy);
00146 #endif
00147
00148 protected:
00149 virtual void boxClosed(int);
00150
00151
00152 void doPairlistCheck();
00153 void doGroupSizeCheck();
00154 void doMarginCheck();
00155 void doAtomMigration();
00156 int inMigration;
00157 int numMlBuf;
00158 MigrateAtomsMsg *msgbuf[PatchMap::MaxOneAway];
00159
00160 private:
00161
00162 FullAtomList atom;
00163 ForceList f_saved[Results::maxNumForces];
00164 ExtForce *replacementForces;
00165
00166
00167
00168 #if NAMD_SeparateWaters != 0
00169 FullAtomList tempAtom;
00170
00171 void separateAtoms();
00172 void mergeAtomList(FullAtomList &al);
00173
00174 #endif
00175
00176
00177
00178 FullAtomList checkpoint_atom;
00179 Lattice checkpoint_lattice;
00180
00181
00182 #if NAMD_SeparateWaters != 0
00183 int checkpoint_numWaterAtoms;
00184 #endif
00185
00186
00187
00188 CompAtomList doPairlistCheck_positions;
00189 Lattice doPairlistCheck_lattice;
00190 BigReal doPairlistCheck_newTolerance;
00191
00192
00193 ResizeArray<BigReal> molly_lambda;
00194
00195
00196 ProxyList proxy;
00197
00198 Sequencer *sequencer;
00199
00200
00201 int patchMapRead;
00202 void readPatchMap();
00203
00204
00205 int allMigrationIn;
00206 int migrationSuspended;
00207 int patchMigrationCounter;
00208 int numNeighbors;
00209 MigrationInfo realInfo[PatchMap::MaxOneAway];
00210 MigrationInfo *mInfo[3][3][3];
00211
00212 #ifdef NODEAWARE_PROXY_SPANNINGTREE
00213
00214 proxyTreeNodeList ptnTree;
00215
00216
00217
00218
00219
00220
00221 #else
00222 NodeIDList tree;
00223 int *child;
00224 int nChild;
00225 #endif
00226
00227
00228 void redistrib_tip4p_force(Vector&, Vector&, Vector&, Vector&, int, Tensor*);
00229 void redistrib_tip4p_forces(const int, Tensor*);
00230 void tip4_omrepos(Vector*, Vector*, Vector*, BigReal);
00231 void init_tip4();
00232 BigReal r_om, r_ohc;
00233
00234 #if CMK_PERSISTENT_COMM
00235 PersistentHandle *localphs;
00236 int nphs;
00237 public:
00238 int phsReady;
00239 void destoryPersistComm();
00240 #endif
00241 };
00242
00243 #endif
00244