OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
ForceDecomposition.hpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the appropriate papers when you publish your
33 * work. Good starting points are:
34 *
35 * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
36 * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
37 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
38 * [4] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
39 * [5] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
40 * [6] Lamichhane, Gezelter & Newman, J. Chem. Phys. 141, 134109 (2014).
41 * [7] Lamichhane, Newman & Gezelter, J. Chem. Phys. 141, 134110 (2014).
42 * [8] Bhattarai, Newman & Gezelter, Phys. Rev. B 99, 094106 (2019).
43 */
44
45#ifndef PARALLEL_FORCEDECOMPOSITION_HPP
46#define PARALLEL_FORCEDECOMPOSITION_HPP
47
48#include "brains/SimInfo.hpp"
50#include "nonbonded/InteractionManager.hpp"
51#include "nonbonded/NonBondedInteraction.hpp"
52
53using namespace std;
54namespace OpenMD {
55
56 /**
57 * @class ForceDecomposition
58 *
59 * ForceDecomposition is an interface for passing out and collecting
60 * information from many processors at various stages of the main
61 * non-bonded ForceLoop.
62 *
63 * The pairwise force calculation has an outer-running loop (the "I"
64 * loop) and an inner-running loop (the "J" loop). In parallel
65 * decompositions, these loop over different groups of atoms on
66 * different processors. Between each set of computations on the
67 * local processor, data must be exchanged among the processors.
68 * This can happen at different times in the calculation:
69 *
70 * distributeInitialData (parallel communication - one time only)
71 * distributeData (parallel communication - every ForceLoop)
72 *
73 * loop iLoop over nLoops (nLoops may be 1, 2, or until self consistent)
74 * | loop over i
75 * | | loop over j
76 * | | | localComputation
77 * | | end
78 * | end
79 * | if (nLoops > 1):
80 * | | collectIntermediateData (parallel communication)
81 * | | distributeIntermediateData (parallel communication)
82 * | endif
83 * end
84 * collectData (parallel communication)
85 * loop over i
86 * | localComputation
87 * end
88 * collectSelfData (parallel communication)
89 *
90 * ForceDecomposition provides the interface for ForceLoop to do the
91 * communication steps and to iterate using the correct set of atoms
92 * and cutoff groups.
93 */
95 public:
97 virtual ~ForceDecomposition() {}
98
99 virtual void setSnapshot(Snapshot* snap) { snap_ = snap; }
100
101 virtual void distributeInitialData() = 0;
102 virtual void distributeData() = 0;
103 virtual void zeroWorkArrays() = 0;
104 virtual void collectIntermediateData() = 0;
105 virtual void distributeIntermediateData() = 0;
106 virtual void collectData() = 0;
107 virtual void collectSelfData() = 0;
108 virtual potVec getSelfPotential() { return selfPot; }
109 virtual potVec getPairwisePotential() { return pairwisePot; }
110 virtual potVec getExcludedPotential() { return excludedPot; }
111 virtual potVec getSelectedPotential() { return selectedPot; }
112 virtual potVec getExcludedSelfPotential() { return excludedSelfPot; }
113 virtual potVec getSelectedSelfPotential() { return selectedSelfPot; }
114
115 // neighbor list routines
116 virtual bool checkNeighborList(vector<Vector3d> savedPositions);
117 virtual void buildNeighborList(vector<int>& neighborList,
118 vector<int>& point,
119 vector<Vector3d>& savedPositions) = 0;
120
121 void setCutoffRadius(RealType rCut);
122
123 // group bookkeeping
124 virtual Vector3d& getGroupVelocityColumn(int atom2) = 0;
125
126 // Group->atom bookkeeping
127 virtual vector<int>& getAtomsInGroupRow(int cg1) = 0;
128 virtual vector<int>& getAtomsInGroupColumn(int cg2) = 0;
129
130 virtual Vector3d getAtomToGroupVectorRow(int atom1, int cg1) = 0;
131 virtual Vector3d getAtomToGroupVectorColumn(int atom2, int cg2) = 0;
132 virtual RealType& getMassFactorRow(int atom1) = 0;
133 virtual RealType& getMassFactorColumn(int atom2) = 0;
134
135 // spatial data
136 virtual Vector3d getIntergroupVector(int cg1, int cg2) = 0;
137 virtual Vector3d getInteratomicVector(int atom1, int atom2) = 0;
138
139 // atom bookkeeping
140 virtual int& getNAtomsInRow() = 0;
141 virtual vector<int>& getExcludesForAtom(int atom1) = 0;
142 virtual bool skipAtomPair(int atom1, int atom2, int cg1, int cg2) = 0;
143 virtual bool excludeAtomPair(int atom1, int atom2) = 0;
144 virtual int getGlobalIDRow(int atom1) = 0;
145 virtual int getGlobalIDCol(int atom2) = 0;
146 virtual int getGlobalID(int atom1) = 0;
147
148 virtual int getTopologicalDistance(int atom1, int atom2) = 0;
149 virtual void addForceToAtomRow(int atom1, Vector3d fg) = 0;
150 virtual void addForceToAtomColumn(int atom2, Vector3d fg) = 0;
151 virtual Vector3d& getAtomVelocityColumn(int atom2) = 0;
152
153 // filling & unpacking interaction data from Snapshot or Row/Col data
154 virtual void fillInteractionData(InteractionData& idat, int atom1,
155 int atom2, bool newAtom1 = true) = 0;
156 virtual void unpackPrePairData(InteractionData& idat, int atom1,
157 int atom2) = 0;
158 virtual void unpackInteractionData(InteractionData& idat, int atom1,
159 int atom2) = 0;
160
161 // filling & unpacking self data from Snapshot data
162 virtual void fillSelfData(SelfData& sdat, int atom);
163 virtual void unpackSelfData(SelfData& sdat, int atom);
164
165 virtual void fillPreForceData(SelfData& sdat, int atom);
166 virtual void unpackPreForceData(SelfData& sdat, int atom);
167
168 virtual void addToHeatFlux(Vector3d hf);
169 virtual void setHeatFlux(Vector3d hf);
170
171 protected:
172 SimInfo* info_ {nullptr};
173 SnapshotManager* sman_;
174 Snapshot* snap_;
175 ForceField* ff_;
176 InteractionManager* interactionMan_;
177
178 int atomStorageLayout_;
179 int rigidBodyStorageLayout_;
180 int cutoffGroupStorageLayout_;
181 bool needVelocities_;
182 bool usePeriodicBoundaryConditions_;
183 RealType skinThickness_; /**< Verlet neighbor list skin thickness */
184 RealType rCut_;
185 RealType rList_;
186 RealType rListSq_;
187
188 vector<int> idents;
189 vector<int> regions;
190 potVec pairwisePot;
191 potVec selfPot;
192 potVec excludedPot;
193 potVec excludedSelfPot;
194 potVec selectedPot;
195 potVec selectedSelfPot;
196
197 /**
198 * The topological distance between two atomic sites is handled
199 * via two vector structures for speed. These structures agnostic
200 * regarding the parallel decomposition. The index for
201 * toposForAtom could be local or row, while the values could be
202 * local or column. It will be up to the specific decomposition
203 * method to fill these.
204 */
205 vector<vector<int>> toposForAtom;
206 vector<vector<int>> topoDist;
207 vector<vector<int>> excludesForAtom;
208 vector<vector<int>> groupList_;
209 vector<RealType> massFactors;
210 vector<AtomType*> atypesLocal;
211
212 vector<Vector3i> cellOffsets_;
213 Vector3i nCells_;
214 vector<vector<int>> cellList_;
215 };
216} // namespace OpenMD
217
218#endif
ForceDecomposition is an interface for passing out and collecting information from many processors at...
RealType skinThickness_
Verlet neighbor list skin thickness.
vector< vector< int > > toposForAtom
The topological distance between two atomic sites is handled via two vector structures for speed.
InteractionManager is responsible for keeping track of the non-bonded interactions (C++)
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
Definition SimInfo.hpp:93
The Snapshot class is a repository storing dynamic data during a Simulation.
Definition Snapshot.hpp:147
SnapshotManager class is an abstract class which maintains a series of snapshots.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
The InteractionData struct.
The SelfData struct.