--- branches/development/src/parallel/ForceDecomposition.cpp 2011/02/04 20:04:56 1541 +++ branches/development/src/parallel/ForceDecomposition.cpp 2011/03/18 19:31:52 1544 @@ -39,40 +39,71 @@ * [4] Vardeman & Gezelter, in progress (2009). */ #include "parallel/ForceDecomposition.hpp" -#include "parallel/Communicator.hpp" #include "math/SquareMatrix3.hpp" +#include "nonbonded/NonBondedInteraction.hpp" +#include "brains/SnapshotManager.hpp" using namespace std; namespace OpenMD { + /** + * distributeInitialData is essentially a copy of the older fortran + * SimulationSetup + */ + void ForceDecomposition::distributeInitialData() { -#ifdef IS_MPI +#ifdef IS_MPI Snapshot* snap = sman_->getCurrentSnapshot(); - int nAtoms = snap->getNumberOfAtoms(); + int nLocal = snap->getNumberOfAtoms(); int nGroups = snap->getNumberOfCutoffGroups(); - AtomCommRealI = new Communicator(nAtoms); - AtomCommVectorI = new Communicator(nAtoms); - AtomCommMatrixI = new Communicator(nAtoms); + AtomCommIntI = new Communicator(nLocal); + AtomCommRealI = new Communicator(nLocal); + AtomCommVectorI = new Communicator(nLocal); + AtomCommMatrixI = new Communicator(nLocal); - AtomCommRealJ = new Communicator(nAtoms); - AtomCommVectorJ = new Communicator(nAtoms); - AtomCommMatrixJ = new Communicator(nAtoms); + AtomCommIntJ = new Communicator(nLocal); + AtomCommRealJ = new Communicator(nLocal); + AtomCommVectorJ = new Communicator(nLocal); + AtomCommMatrixJ = new Communicator(nLocal); + cgCommIntI = new Communicator(nGroups); cgCommVectorI = new Communicator(nGroups); + cgCommIntJ = new Communicator(nGroups); cgCommVectorJ = new Communicator(nGroups); - int nInRow = AtomCommRealI.getSize(); - int nInCol = AtomCommRealJ.getSize(); + int nAtomsInRow = AtomCommIntI->getSize(); + int nAtomsInCol = AtomCommIntJ->getSize(); + int nGroupsInRow = cgCommIntI->getSize(); + int nGroupsInCol = cgCommIntJ->getSize(); - vector > pot_row(LR_POT_TYPES, - vector (nInRow, 0.0)); - vector > pot_col(LR_POT_TYPES, - vector (nInCol, 0.0)); + vector > pot_row(N_INTERACTION_FAMILIES, + vector (nAtomsInRow, 0.0)); + vector > pot_col(N_INTERACTION_FAMILIES, + vector (nAtomsInCol, 0.0)); + + vector pot_local(N_INTERACTION_FAMILIES, 0.0); - vector > pot_local(LR_POT_TYPES, - vector (nAtoms, 0.0)); + // gather the information for atomtype IDs (atids): + AtomCommIntI->gather(info_->getIdentArray(), identsRow); + AtomCommIntJ->gather(info_->getIdentArray(), identsCol); + AtomLocalToGlobal = info_->getLocalToGlobalAtomIndex(); + AtomCommIntI->gather(AtomLocalToGlobal, AtomRowToGlobal); + AtomCommIntJ->gather(AtomLocalToGlobal, AtomColToGlobal); + + cgLocalToGlobal = info_->getLocalToGlobalCutoffGroupIndex(); + cgCommIntI->gather(cgLocalToGlobal, cgRowToGlobal); + cgCommIntJ->gather(cgLocalToGlobal, cgColToGlobal); + + + + + + + // still need: + // topoDist + // exclude #endif } @@ -155,7 +186,7 @@ namespace OpenMD { Snapshot* snap = sman_->getCurrentSnapshot(); int n = snap->atomData.force.size(); - std::vector frc_tmp(n, 0.0); + vector frc_tmp(n, V3Zero); AtomCommVectorI->scatter(snap->atomIData.force, frc_tmp); for (int i = 0; i < n; i++) { @@ -171,7 +202,7 @@ namespace OpenMD { if (snap->atomData.getStorageLayout() & DataStorage::dslTorque) { int nt = snap->atomData.force.size(); - std::vector trq_tmp(nt, 0.0); + vector trq_tmp(nt, V3Zero); AtomCommVectorI->scatter(snap->atomIData.torque, trq_tmp); for (int i = 0; i < n; i++) { @@ -184,19 +215,17 @@ namespace OpenMD { snap->atomData.torque[i] += trq_tmp[i]; } + int nLocal = snap->getNumberOfAtoms(); + + vector > pot_temp(N_INTERACTION_FAMILIES, + vector (nLocal, 0.0)); - vector > pot_temp(LR_POT_TYPES, - vector (nAtoms, 0.0)); - - for (int i = 0; i < LR_POT_TYPES; i++) { + for (int i = 0; i < N_INTERACTION_FAMILIES; i++) { AtomCommRealI->scatter(pot_row[i], pot_temp[i]); for (int ii = 0; ii < pot_temp[i].size(); ii++ ) { pot_local[i] += pot_temp[i][ii]; } } - - - #endif }