--- branches/development/src/parallel/Decomposition.hpp 2011/01/14 22:31:31 1539 +++ branches/development/src/parallel/ForceDecomposition.hpp 2011/05/26 13:55:04 1569 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. + * Copyright (c) 2011 The University of Notre Dame. All Rights Reserved. * * The University of Notre Dame grants you ("Licensee") a * non-exclusive, royalty free, license to use, modify and @@ -39,20 +39,23 @@ * [4] Vardeman & Gezelter, in progress (2009). */ -#ifndef PARALLEL_DECOMPOSITION_HPP -#define PARALLEL_DECOMPOSITION_HPP +#ifndef PARALLEL_FORCEDECOMPOSITION_HPP +#define PARALLEL_FORCEDECOMPOSITION_HPP +#include "brains/SimInfo.hpp" #include "brains/SnapshotManager.hpp" -#include "types/AtomType.hpp" +#include "nonbonded/NonBondedInteraction.hpp" using namespace std; namespace OpenMD { /** - * @class Decomposition - * Decomposition is an interface for passing out and collecting information - * from many processors at various stages of the main non-bonded ForceLoop. + * @class ForceDecomposition * + * ForceDecomposition is an interface for passing out and collecting + * information from many processors at various stages of the main + * non-bonded ForceLoop. + * * The pairwise force calculation has an outer-running loop (the "I" * loop) and an inner-running loop (the "J" loop). In parallel * decompositions, these loop over different groups of atoms on @@ -62,29 +65,29 @@ namespace OpenMD { * * distributeInitialData (parallel communication - one time only) * distributeData (parallel communication - every ForceLoop) - * loop over i - * | loop over j - * | | localComputation + * + * loop iLoop over nLoops (nLoops may be 1, 2, or until self consistent) + * | loop over i + * | | loop over j + * | | | localComputation + * | | end * | end + * | if (nLoops > 1): + * | | collectIntermediateData (parallel communication) + * | | distributeIntermediateData (parallel communication) + * | endif * end - * collectIntermediateData (parallel communication) - * distributeIntermediateData (parallel communication) - * loop over i - * | loop over j - * | | localComputation - * | end - * end - * collectData (parallel communication) + * collectData (parallel communication) * - * Decomposition provides the interface for ForceLoop to do the + * ForceDecomposition provides the interface for ForceLoop to do the * communication steps and to iterate using the correct set of atoms * and cutoff groups. */ - class Decomposition { + class ForceDecomposition { public: - Decomposition(SnapshotManager* sman) : sman_(sman) {} - virtual ~Decomposition() {} + ForceDecomposition(SimInfo* info); + virtual ~ForceDecomposition() {} virtual void distributeInitialData() = 0; virtual void distributeData() = 0; @@ -92,17 +95,72 @@ namespace OpenMD { virtual void distributeIntermediateData() = 0; virtual void collectData() = 0; - virtual unsigned int getNcutoffGroupsI() = 0; - virtual unsigned int getNcutoffGroupsJ() = 0; + // neighbor list routines + virtual bool checkNeighborList(); + virtual vector > buildNeighborList() = 0; - virtual vector getAtomsInGroupI(int whichCGI) = 0; - virtual vector getAtomsInGroupJ(int whichCGJ) = 0; + // group bookkeeping + virtual pair getGroupTypes(int cg1, int cg2) = 0; - virtual AtomType* getAtomTypeI(int whichAtomI) = 0; - virtual AtomType* getAtomTypeJ(int whichAtomJ) = 0; + // Group->atom bookkeeping + virtual vector getAtomsInGroupRow(int cg1) = 0; + virtual vector getAtomsInGroupColumn(int cg2) = 0; + + virtual Vector3d getAtomToGroupVectorRow(int atom1, int cg1) = 0; + virtual Vector3d getAtomToGroupVectorColumn(int atom2, int cg2) = 0; + virtual RealType getMassFactorRow(int atom1) = 0; + virtual RealType getMassFactorColumn(int atom2) = 0; + + // spatial data + virtual Vector3d getIntergroupVector(int cg1, int cg2) = 0; + virtual Vector3d getInteratomicVector(int atom1, int atom2) = 0; + + // atom bookkeeping + virtual vector getAtomList() = 0; + virtual vector getSkipsForAtom(int atom1) = 0; + virtual bool skipAtomPair(int atom1, int atom2) = 0; + virtual void addForceToAtomRow(int atom1, Vector3d fg) = 0; + virtual void addForceToAtomColumn(int atom2, Vector3d fg) = 0; + + // filling interaction blocks with pointers + virtual InteractionData fillInteractionData(int atom1, int atom2) = 0; + virtual InteractionData fillSkipData(int atom1, int atom2) = 0; + virtual SelfData fillSelfData(int atom1); protected: - SnapshotManager* sman_; + SimInfo* info_; + SnapshotManager* sman_; + Snapshot* snap_; + int storageLayout_; + RealType skinThickness_; /**< Verlet neighbor list skin thickness */ + + map, int> topoDist; //< topoDist gives the + //topological distance between + //two atomic sites. This + //declaration is agnostic + //regarding the parallel + //decomposition. The two + //indices could be local or row + //& column. It will be up to + //the specific decomposition + //method to fill this. + map, bool> exclude; //< exclude is the set of pairs + //to leave out of non-bonded + //force evaluations. This + //declaration is agnostic + //regarding the parallel + //decomposition. The two + //indices could be local or row + //& column. It will be up to + //the specific decomposition + //method to fill this. + + vector > groupList_; + vector cellOffsets_; + Vector3i nCells_; + vector > cellList_; + vector saved_CG_positions_; + }; } #endif