--- branches/development/src/parallel/ForceDecomposition.hpp 2011/03/18 19:31:52 1544 +++ trunk/src/parallel/ForceMatrixDecomposition.hpp 2015/03/03 17:02:20 2064 @@ -35,72 +35,145 @@ * * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). - * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). - * [4] Vardeman & Gezelter, in progress (2009). + * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). + * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). + * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). */ -#ifndef PARALLEL_FORCEDECOMPOSITION_HPP -#define PARALLEL_FORCEDECOMPOSITION_HPP +#ifndef PARALLEL_FORCEMATRIXDECOMPOSITION_HPP +#define PARALLEL_FORCEMATRIXDECOMPOSITION_HPP -#include "Parallel/Decomposition.hpp" +#include "parallel/ForceDecomposition.hpp" #include "math/SquareMatrix3.hpp" +#include "brains/Snapshot.hpp" #ifdef IS_MPI -#include "Parallel/Communicator.hpp" +#include "parallel/Communicator.hpp" #endif using namespace std; namespace OpenMD { - class ForceDecomposition : public Decomposition { + class ForceMatrixDecomposition : public ForceDecomposition { public: - ForceDecomposition(SimInfo* info) : Decomposition(info) {sman_ = info_->getSnapshotManager();} + ForceMatrixDecomposition(SimInfo* info, InteractionManager* iMan); + void distributeInitialData(); + void zeroWorkArrays(); void distributeData(); void collectIntermediateData(); void distributeIntermediateData(); + void collectSelfData(); void collectData(); - unsigned int getNcutoffGroupsI(); - unsigned int getNcutoffGroupsJ(); + // neighbor list routines + void buildNeighborList(vector& neighborList, vector& point); - vector getAtomsInGroupI(int whichCGI); - vector getAtomsInGroupJ(int whichCGJ); + // group bookkeeping + Vector3d& getGroupVelocityColumn(int cg2); - AtomType* getAtomTypeI(int whichAtomI); - AtomType* getAtomTypeJ(int whichAtomJ); + // Group->atom bookkeeping + vector& getAtomsInGroupRow(int cg1); + vector& getAtomsInGroupColumn(int cg2); + Vector3d getAtomToGroupVectorRow(int atom1, int cg1); + Vector3d getAtomToGroupVectorColumn(int atom2, int cg2); + RealType& getMassFactorRow(int atom1); + RealType& getMassFactorColumn(int atom2); - private: - SnapshotManager* sman_; + // spatial data + Vector3d getIntergroupVector(int cg1, int cg2); + Vector3d getInteratomicVector(int atom1, int atom2); + + // atom bookkeeping + int& getNAtomsInRow(); + int getTopologicalDistance(int atom1, int atom2); + vector& getExcludesForAtom(int atom1); + bool skipAtomPair(int atom1, int atom2, int cg1, int cg2); + bool excludeAtomPair(int atom1, int atom2); + void addForceToAtomRow(int atom1, Vector3d fg); + void addForceToAtomColumn(int atom2, Vector3d fg); + Vector3d& getAtomVelocityColumn(int atom2); + + // filling interaction blocks with pointers + void fillInteractionData(InteractionData &idat, int atom1, int atom2, bool newAtom1 = true); + void unpackInteractionData(InteractionData &idat, int atom1, int atom2); + + private: + int nLocal_; + int nGroups_; + vector AtomLocalToGlobal; + vector cgLocalToGlobal; + vector groupCutoff; + vector groupToGtype; + #ifdef IS_MPI - Communicator* AtomCommIntI; - Communicator* AtomCommRealI; - Communicator* AtomCommVectorI; - Communicator* AtomCommMatrixI; + DataStorage atomRowData; + DataStorage atomColData; + DataStorage cgRowData; + DataStorage cgColData; - Communicator* AtomCommIntJ; - Communicator* AtomCommRealJ; - Communicator* AtomCommVectorJ; - Communicator* AtomCommMatrixJ; + int nAtomsInRow_; + int nAtomsInCol_; + int nGroupsInRow_; + int nGroupsInCol_; - Communicator* cgCommIntI; - Communicator* cgCommVectorI; - Communicator* cgCommIntJ; - Communicator* cgCommVectorJ; + Communicator rowComm; + Communicator colComm; - vector > pot_row; - vector > pot_col; - vector identRow; - vector identCol; + Plan* AtomPlanIntRow; + Plan* AtomPlanRealRow; + Plan* AtomPlanVectorRow; + Plan* AtomPlanMatrixRow; + Plan* AtomPlanPotRow; - vector AtomLocalToGlobal; + Plan* AtomPlanIntColumn; + Plan* AtomPlanRealColumn; + Plan* AtomPlanVectorColumn; + Plan* AtomPlanMatrixColumn; + Plan* AtomPlanPotColumn; + + Plan* cgPlanIntRow; + Plan* cgPlanVectorRow; + Plan* cgPlanIntColumn; + Plan* cgPlanVectorColumn; + + // work arrays for assembling potential energy + vector pot_row; + vector pot_col; + + vector expot_row; + vector expot_col; + + vector identsRow; + vector identsCol; + + vector regionsRow; + vector regionsCol; + + vector atypesRow; + vector atypesCol; + vector AtomRowToGlobal; vector AtomColToGlobal; - vector cgLocalToGlobal; + +public: vector cgRowToGlobal; vector cgColToGlobal; + +private: + vector > cellListRow_; + vector > cellListCol_; + + vector > groupListRow_; + vector > groupListCol_; + + vector massFactorsRow; + vector massFactorsCol; + + vector regionRow; + vector regionCol; #endif - vector pot_local; + }; }