--- branches/development/src/brains/SimInfo.cpp 2011/01/05 14:49:05 1536 +++ branches/development/src/brains/SimInfo.cpp 2011/04/29 17:25:12 1553 @@ -54,8 +54,6 @@ #include "math/Vector3.hpp" #include "primitives/Molecule.hpp" #include "primitives/StuntDouble.hpp" -#include "UseTheForce/DarkSide/neighborLists_interface.h" -#include "UseTheForce/doForces_interface.h" #include "utils/MemoryUtils.hpp" #include "utils/simError.h" #include "selection/SelectionManager.hpp" @@ -63,11 +61,6 @@ #include "UseTheForce/ForceField.hpp" #include "nonbonded/SwitchingFunction.hpp" -#ifdef IS_MPI -#include "UseTheForce/mpiComponentPlan.h" -#include "UseTheForce/DarkSide/simParallel_interface.h" -#endif - using namespace std; namespace OpenMD { @@ -132,7 +125,13 @@ namespace OpenMD { //equal to the total number of atoms minus number of atoms belong to //cutoff group defined in meta-data file plus the number of cutoff //groups defined in meta-data file + std::cerr << "nGA = " << nGlobalAtoms_ << "\n"; + std::cerr << "nCA = " << nCutoffAtoms << "\n"; + std::cerr << "nG = " << nGroups << "\n"; + nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; + + std::cerr << "nGCG = " << nGlobalCutoffGroups_ << "\n"; //every free atom (atom does not belong to rigid bodies) is an //integrable object therefore the total number of integrable objects @@ -771,14 +770,48 @@ namespace OpenMD { temp = usesElectrostatic; MPI_Allreduce(&temp, &usesElectrostaticAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); #endif - fInfo_.SIM_uses_PBC = usesPeriodicBoundaries_; - fInfo_.SIM_uses_DirectionalAtoms = usesDirectionalAtoms_; - fInfo_.SIM_uses_MetallicAtoms = usesMetallicAtoms_; - fInfo_.SIM_requires_SkipCorrection = usesElectrostaticAtoms_; - fInfo_.SIM_requires_SelfCorrection = usesElectrostaticAtoms_; - fInfo_.SIM_uses_AtomicVirial = usesAtomicVirial_; + } + + + vector SimInfo::getGlobalAtomIndices() { + SimInfo::MoleculeIterator mi; + Molecule* mol; + Molecule::AtomIterator ai; + Atom* atom; + + vector GlobalAtomIndices(getNAtoms(), 0); + + for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { + + for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { + GlobalAtomIndices[atom->getLocalIndex()] = atom->getGlobalIndex(); + } + } + return GlobalAtomIndices; + } + + + vector SimInfo::getGlobalGroupIndices() { + SimInfo::MoleculeIterator mi; + Molecule* mol; + Molecule::CutoffGroupIterator ci; + CutoffGroup* cg; + + vector GlobalGroupIndices; + + for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { + + //local index of cutoff group is trivial, it only depends on the + //order of travesing + for (cg = mol->beginCutoffGroup(ci); cg != NULL; + cg = mol->nextCutoffGroup(ci)) { + GlobalGroupIndices.push_back(cg->getGlobalIndex()); + } + } + return GlobalGroupIndices; } + void SimInfo::setupFortran() { int isError; int nExclude, nOneTwo, nOneThree, nOneFour; @@ -818,16 +851,13 @@ namespace OpenMD { } } - //fill ident array of local atoms (it is actually ident of - //AtomType, it is so confusing !!!) - vector identArray; + // Build the identArray_ - //to avoid memory reallocation, reserve enough space identArray - identArray.reserve(getNAtoms()); - + identArray_.clear(); + identArray_.reserve(getNAtoms()); for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { - identArray.push_back(atom->getIdent()); + identArray_.push_back(atom->getIdent()); } } @@ -850,90 +880,72 @@ namespace OpenMD { int* oneThreeList = oneThreeInteractions_.getPairList(); int* oneFourList = oneFourInteractions_.getPairList(); - setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], - &nExclude, excludeList, - &nOneTwo, oneTwoList, - &nOneThree, oneThreeList, - &nOneFour, oneFourList, - &molMembershipArray[0], &mfact[0], &nCutoffGroups_, - &fortranGlobalGroupMembership[0], &isError); + //setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray_[0], + // &nExclude, excludeList, + // &nOneTwo, oneTwoList, + // &nOneThree, oneThreeList, + // &nOneFour, oneFourList, + // &molMembershipArray[0], &mfact[0], &nCutoffGroups_, + // &fortranGlobalGroupMembership[0], &isError); - if( isError ){ - - sprintf( painCave.errMsg, - "There was an error setting the simulation information in fortran.\n" ); - painCave.isFatal = 1; - painCave.severity = OPENMD_ERROR; - simError(); - } + // if( isError ){ + // + // sprintf( painCave.errMsg, + // "There was an error setting the simulation information in fortran.\n" ); + // painCave.isFatal = 1; + // painCave.severity = OPENMD_ERROR; + // simError(); + //} - sprintf( checkPointMsg, - "succesfully sent the simulation information to fortran.\n"); + // sprintf( checkPointMsg, + // "succesfully sent the simulation information to fortran.\n"); - errorCheckPoint(); + // errorCheckPoint(); // Setup number of neighbors in neighbor list if present - if (simParams_->haveNeighborListNeighbors()) { - int nlistNeighbors = simParams_->getNeighborListNeighbors(); - setNeighbors(&nlistNeighbors); - } + //if (simParams_->haveNeighborListNeighbors()) { + // int nlistNeighbors = simParams_->getNeighborListNeighbors(); + // setNeighbors(&nlistNeighbors); + //} #ifdef IS_MPI - //SimInfo is responsible for creating localToGlobalAtomIndex and - //localToGlobalGroupIndex - vector localToGlobalAtomIndex(getNAtoms(), 0); - vector localToGlobalCutoffGroupIndex; - mpiSimData parallelData; + // mpiSimData parallelData; - for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { - - //local index(index in DataStorge) of atom is important - for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { - localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1; - } - - //local index of cutoff group is trivial, it only depends on the order of travesing - for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { - localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1); - } - - } - //fill up mpiSimData struct - parallelData.nMolGlobal = getNGlobalMolecules(); - parallelData.nMolLocal = getNMolecules(); - parallelData.nAtomsGlobal = getNGlobalAtoms(); - parallelData.nAtomsLocal = getNAtoms(); - parallelData.nGroupsGlobal = getNGlobalCutoffGroups(); - parallelData.nGroupsLocal = getNCutoffGroups(); - parallelData.myNode = worldRank; - MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors)); + // parallelData.nMolGlobal = getNGlobalMolecules(); + // parallelData.nMolLocal = getNMolecules(); + // parallelData.nAtomsGlobal = getNGlobalAtoms(); + // parallelData.nAtomsLocal = getNAtoms(); + // parallelData.nGroupsGlobal = getNGlobalCutoffGroups(); + // parallelData.nGroupsLocal = getNCutoffGroups(); + // parallelData.myNode = worldRank; + // MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors)); //pass mpiSimData struct and index arrays to fortran - setFsimParallel(¶llelData, &(parallelData.nAtomsLocal), - &localToGlobalAtomIndex[0], &(parallelData.nGroupsLocal), - &localToGlobalCutoffGroupIndex[0], &isError); + //setFsimParallel(¶llelData, &(parallelData.nAtomsLocal), + // &localToGlobalAtomIndex[0], &(parallelData.nGroupsLocal), + // &localToGlobalCutoffGroupIndex[0], &isError); - if (isError) { - sprintf(painCave.errMsg, - "mpiRefresh errror: fortran didn't like something we gave it.\n"); - painCave.isFatal = 1; - simError(); - } + // if (isError) { + // sprintf(painCave.errMsg, + // "mpiRefresh errror: fortran didn't like something we gave it.\n"); + // painCave.isFatal = 1; + // simError(); + // } - sprintf(checkPointMsg, " mpiRefresh successful.\n"); - errorCheckPoint(); + // sprintf(checkPointMsg, " mpiRefresh successful.\n"); + // errorCheckPoint(); #endif - initFortranFF(&isError); - if (isError) { - sprintf(painCave.errMsg, - "initFortranFF errror: fortran didn't like something we gave it.\n"); - painCave.isFatal = 1; - simError(); - } - fortranInitialized_ = true; + // initFortranFF(&isError); + // if (isError) { + // sprintf(painCave.errMsg, + // "initFortranFF errror: fortran didn't like something we gave it.\n"); + // painCave.isFatal = 1; + // simError(); + // } + // fortranInitialized_ = true; } void SimInfo::addProperty(GenericData* genData) { @@ -970,9 +982,11 @@ namespace OpenMD { Molecule* mol; RigidBody* rb; Atom* atom; + CutoffGroup* cg; SimInfo::MoleculeIterator mi; Molecule::RigidBodyIterator rbIter; - Molecule::AtomIterator atomIter;; + Molecule::AtomIterator atomIter; + Molecule::CutoffGroupIterator cgIter; for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { @@ -982,6 +996,10 @@ namespace OpenMD { for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { rb->setSnapshotManager(sman_); + } + + for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) { + cg->setSnapshotManager(sman_); } }