--- branches/development/src/brains/SimInfo.cpp 2011/01/17 21:34:36 1540 +++ branches/development/src/brains/SimInfo.cpp 2011/04/27 18:38:15 1549 @@ -783,8 +783,48 @@ namespace OpenMD { 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; @@ -824,16 +864,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()); } } @@ -856,7 +893,7 @@ namespace OpenMD { int* oneThreeList = oneThreeInteractions_.getPairList(); int* oneFourList = oneFourInteractions_.getPairList(); - setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], + setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray_[0], &nExclude, excludeList, &nOneTwo, oneTwoList, &nOneThree, oneThreeList, @@ -886,26 +923,8 @@ namespace OpenMD { } #ifdef IS_MPI - //SimInfo is responsible for creating localToGlobalAtomIndex and - //localToGlobalGroupIndex - vector localToGlobalAtomIndex(getNAtoms(), 0); - vector localToGlobalCutoffGroupIndex; 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(); @@ -917,9 +936,9 @@ namespace OpenMD { 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,