| 39 |
|
* [4] Vardeman & Gezelter, in progress (2009). |
| 40 |
|
*/ |
| 41 |
|
#include "parallel/ForceDecomposition.hpp" |
| 42 |
– |
#include "parallel/Communicator.hpp" |
| 42 |
|
#include "math/SquareMatrix3.hpp" |
| 43 |
+ |
#include "nonbonded/NonBondedInteraction.hpp" |
| 44 |
+ |
#include "brains/SnapshotManager.hpp" |
| 45 |
|
|
| 46 |
|
using namespace std; |
| 47 |
|
namespace OpenMD { |
| 48 |
|
|
| 49 |
+ |
/** |
| 50 |
+ |
* distributeInitialData is essentially a copy of the older fortran |
| 51 |
+ |
* SimulationSetup |
| 52 |
+ |
*/ |
| 53 |
+ |
|
| 54 |
|
void ForceDecomposition::distributeInitialData() { |
| 55 |
< |
#ifdef IS_MPI |
| 55 |
> |
#ifdef IS_MPI |
| 56 |
|
Snapshot* snap = sman_->getCurrentSnapshot(); |
| 57 |
< |
int nAtoms = snap->getNumberOfAtoms(); |
| 57 |
> |
int nLocal = snap->getNumberOfAtoms(); |
| 58 |
|
int nGroups = snap->getNumberOfCutoffGroups(); |
| 59 |
|
|
| 60 |
< |
AtomCommRealI = new Communicator<Row,RealType>(nAtoms); |
| 61 |
< |
AtomCommVectorI = new Communicator<Row,Vector3d>(nAtoms); |
| 62 |
< |
AtomCommMatrixI = new Communicator<Row,Mat3x3d>(nAtoms); |
| 60 |
> |
AtomCommIntI = new Communicator<Row,int>(nLocal); |
| 61 |
> |
AtomCommRealI = new Communicator<Row,RealType>(nLocal); |
| 62 |
> |
AtomCommVectorI = new Communicator<Row,Vector3d>(nLocal); |
| 63 |
> |
AtomCommMatrixI = new Communicator<Row,Mat3x3d>(nLocal); |
| 64 |
|
|
| 65 |
< |
AtomCommRealJ = new Communicator<Column,RealType>(nAtoms); |
| 66 |
< |
AtomCommVectorJ = new Communicator<Column,Vector3d>(nAtoms); |
| 67 |
< |
AtomCommMatrixJ = new Communicator<Column,Mat3x3d>(nAtoms); |
| 65 |
> |
AtomCommIntJ = new Communicator<Column,int>(nLocal); |
| 66 |
> |
AtomCommRealJ = new Communicator<Column,RealType>(nLocal); |
| 67 |
> |
AtomCommVectorJ = new Communicator<Column,Vector3d>(nLocal); |
| 68 |
> |
AtomCommMatrixJ = new Communicator<Column,Mat3x3d>(nLocal); |
| 69 |
|
|
| 70 |
+ |
cgCommIntI = new Communicator<Row,int>(nGroups); |
| 71 |
|
cgCommVectorI = new Communicator<Row,Vector3d>(nGroups); |
| 72 |
+ |
cgCommIntJ = new Communicator<Column,int>(nGroups); |
| 73 |
|
cgCommVectorJ = new Communicator<Column,Vector3d>(nGroups); |
| 74 |
|
|
| 75 |
< |
int nInRow = AtomCommRealI.getSize(); |
| 76 |
< |
int nInCol = AtomCommRealJ.getSize(); |
| 75 |
> |
int nAtomsInRow = AtomCommIntI->getSize(); |
| 76 |
> |
int nAtomsInCol = AtomCommIntJ->getSize(); |
| 77 |
> |
int nGroupsInRow = cgCommIntI->getSize(); |
| 78 |
> |
int nGroupsInCol = cgCommIntJ->getSize(); |
| 79 |
|
|
| 80 |
< |
vector<vector<RealType> > pot_row(LR_POT_TYPES, |
| 81 |
< |
vector<RealType> (nInRow, 0.0)); |
| 82 |
< |
vector<vector<RealType> > pot_col(LR_POT_TYPES, |
| 83 |
< |
vector<RealType> (nInCol, 0.0)); |
| 80 |
> |
vector<vector<RealType> > pot_row(N_INTERACTION_FAMILIES, |
| 81 |
> |
vector<RealType> (nAtomsInRow, 0.0)); |
| 82 |
> |
vector<vector<RealType> > pot_col(N_INTERACTION_FAMILIES, |
| 83 |
> |
vector<RealType> (nAtomsInCol, 0.0)); |
| 84 |
> |
|
| 85 |
> |
vector<RealType> pot_local(N_INTERACTION_FAMILIES, 0.0); |
| 86 |
|
|
| 87 |
< |
vector<vector<RealType> > pot_local(LR_POT_TYPES, |
| 88 |
< |
vector<RealType> (nAtoms, 0.0)); |
| 87 |
> |
// gather the information for atomtype IDs (atids): |
| 88 |
> |
vector<int> identsLocal = info_->getIdentArray(); |
| 89 |
> |
identsRow.reserve(nAtomsInRow); |
| 90 |
> |
identsCol.reserve(nAtomsInCol); |
| 91 |
|
|
| 92 |
+ |
AtomCommIntI->gather(identsLocal, identsRow); |
| 93 |
+ |
AtomCommIntJ->gather(identsLocal, identsCol); |
| 94 |
+ |
|
| 95 |
+ |
AtomLocalToGlobal = info_->getLocalToGlobalAtomIndex(); |
| 96 |
+ |
AtomCommIntI->gather(AtomLocalToGlobal, AtomRowToGlobal); |
| 97 |
+ |
AtomCommIntJ->gather(AtomLocalToGlobal, AtomColToGlobal); |
| 98 |
+ |
|
| 99 |
+ |
cgLocalToGlobal = info_->getLocalToGlobalCutoffGroupIndex(); |
| 100 |
+ |
cgCommIntI->gather(cgLocalToGlobal, cgRowToGlobal); |
| 101 |
+ |
cgCommIntJ->gather(cgLocalToGlobal, cgColToGlobal); |
| 102 |
+ |
|
| 103 |
+ |
|
| 104 |
+ |
|
| 105 |
+ |
// still need: |
| 106 |
+ |
// topoDist |
| 107 |
+ |
// exclude |
| 108 |
|
#endif |
| 109 |
|
} |
| 110 |
|
|
| 187 |
|
Snapshot* snap = sman_->getCurrentSnapshot(); |
| 188 |
|
|
| 189 |
|
int n = snap->atomData.force.size(); |
| 190 |
< |
std::vector<Vector3d> frc_tmp(n, 0.0); |
| 190 |
> |
vector<Vector3d> frc_tmp(n, V3Zero); |
| 191 |
|
|
| 192 |
|
AtomCommVectorI->scatter(snap->atomIData.force, frc_tmp); |
| 193 |
|
for (int i = 0; i < n; i++) { |
| 203 |
|
if (snap->atomData.getStorageLayout() & DataStorage::dslTorque) { |
| 204 |
|
|
| 205 |
|
int nt = snap->atomData.force.size(); |
| 206 |
< |
std::vector<Vector3d> trq_tmp(nt, 0.0); |
| 206 |
> |
vector<Vector3d> trq_tmp(nt, V3Zero); |
| 207 |
|
|
| 208 |
|
AtomCommVectorI->scatter(snap->atomIData.torque, trq_tmp); |
| 209 |
|
for (int i = 0; i < n; i++) { |
| 216 |
|
snap->atomData.torque[i] += trq_tmp[i]; |
| 217 |
|
} |
| 218 |
|
|
| 219 |
+ |
int nLocal = snap->getNumberOfAtoms(); |
| 220 |
+ |
|
| 221 |
+ |
vector<vector<RealType> > pot_temp(N_INTERACTION_FAMILIES, |
| 222 |
+ |
vector<RealType> (nLocal, 0.0)); |
| 223 |
|
|
| 224 |
< |
vector<vector<RealType> > pot_temp(LR_POT_TYPES, |
| 189 |
< |
vector<RealType> (nAtoms, 0.0)); |
| 190 |
< |
|
| 191 |
< |
for (int i = 0; i < LR_POT_TYPES; i++) { |
| 224 |
> |
for (int i = 0; i < N_INTERACTION_FAMILIES; i++) { |
| 225 |
|
AtomCommRealI->scatter(pot_row[i], pot_temp[i]); |
| 226 |
|
for (int ii = 0; ii < pot_temp[i].size(); ii++ ) { |
| 227 |
|
pot_local[i] += pot_temp[i][ii]; |
| 228 |
|
} |
| 229 |
|
} |
| 197 |
– |
|
| 198 |
– |
|
| 199 |
– |
|
| 230 |
|
#endif |
| 231 |
|
} |
| 232 |
|
|