ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/SimInfo.cpp
(Generate patch)

Comparing branches/development/src/brains/SimInfo.cpp (file contents):
Revision 1536 by gezelter, Wed Jan 5 14:49:05 2011 UTC vs.
Revision 1549 by gezelter, Wed Apr 27 18:38:15 2011 UTC

# Line 132 | Line 132 | namespace OpenMD {
132      //equal to the total number of atoms minus number of atoms belong to
133      //cutoff group defined in meta-data file plus the number of cutoff
134      //groups defined in meta-data file
135 +    std::cerr << "nGA = " << nGlobalAtoms_ << "\n";
136 +    std::cerr << "nCA = " << nCutoffAtoms << "\n";
137 +    std::cerr << "nG = " << nGroups << "\n";
138 +
139      nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups;
140 +
141 +    std::cerr << "nGCG = " << nGlobalCutoffGroups_ << "\n";
142      
143      //every free atom (atom does not belong to rigid bodies) is an
144      //integrable object therefore the total number of integrable objects
# Line 777 | Line 783 | namespace OpenMD {
783      fInfo_.SIM_requires_SkipCorrection = usesElectrostaticAtoms_;
784      fInfo_.SIM_requires_SelfCorrection = usesElectrostaticAtoms_;
785      fInfo_.SIM_uses_AtomicVirial = usesAtomicVirial_;
786 +  }
787 +
788 +
789 +  vector<int> SimInfo::getGlobalAtomIndices() {
790 +    SimInfo::MoleculeIterator mi;
791 +    Molecule* mol;
792 +    Molecule::AtomIterator ai;
793 +    Atom* atom;
794 +
795 +    vector<int> GlobalAtomIndices(getNAtoms(), 0);
796 +    
797 +    for (mol = beginMolecule(mi); mol != NULL; mol  = nextMolecule(mi)) {
798 +      
799 +      for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
800 +        GlobalAtomIndices[atom->getLocalIndex()] = atom->getGlobalIndex();
801 +      }
802 +    }
803 +    return GlobalAtomIndices;
804    }
805  
806 +
807 +  vector<int> SimInfo::getGlobalGroupIndices() {
808 +    SimInfo::MoleculeIterator mi;
809 +    Molecule* mol;
810 +    Molecule::CutoffGroupIterator ci;
811 +    CutoffGroup* cg;
812 +
813 +    vector<int> GlobalGroupIndices;
814 +    
815 +    for (mol = beginMolecule(mi); mol != NULL; mol  = nextMolecule(mi)) {
816 +      
817 +      //local index of cutoff group is trivial, it only depends on the
818 +      //order of travesing
819 +      for (cg = mol->beginCutoffGroup(ci); cg != NULL;
820 +           cg = mol->nextCutoffGroup(ci)) {
821 +        GlobalGroupIndices.push_back(cg->getGlobalIndex());
822 +      }        
823 +    }
824 +    return GlobalGroupIndices;
825 +  }
826 +
827 +
828    void SimInfo::setupFortran() {
829      int isError;
830      int nExclude, nOneTwo, nOneThree, nOneFour;
# Line 818 | Line 864 | namespace OpenMD {
864        }      
865      }
866  
867 <    //fill ident array of local atoms (it is actually ident of
822 <    //AtomType, it is so confusing !!!)
823 <    vector<int> identArray;
867 >    // Build the identArray_
868  
869 <    //to avoid memory reallocation, reserve enough space identArray
870 <    identArray.reserve(getNAtoms());
827 <    
869 >    identArray_.clear();
870 >    identArray_.reserve(getNAtoms());    
871      for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) {        
872        for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
873 <        identArray.push_back(atom->getIdent());
873 >        identArray_.push_back(atom->getIdent());
874        }
875      }    
876  
# Line 850 | Line 893 | namespace OpenMD {
893      int* oneThreeList = oneThreeInteractions_.getPairList();
894      int* oneFourList = oneFourInteractions_.getPairList();
895  
896 <    setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0],
896 >    setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray_[0],
897                     &nExclude, excludeList,
898                     &nOneTwo, oneTwoList,
899                     &nOneThree, oneThreeList,
# Line 880 | Line 923 | namespace OpenMD {
923      }
924    
925   #ifdef IS_MPI    
883    //SimInfo is responsible for creating localToGlobalAtomIndex and
884    //localToGlobalGroupIndex
885    vector<int> localToGlobalAtomIndex(getNAtoms(), 0);
886    vector<int> localToGlobalCutoffGroupIndex;
926      mpiSimData parallelData;
888
889    for (mol = beginMolecule(mi); mol != NULL; mol  = nextMolecule(mi)) {
890
891      //local index(index in DataStorge) of atom is important
892      for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
893        localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1;
894      }
927  
896      //local index of cutoff group is trivial, it only depends on the order of travesing
897      for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) {
898        localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1);
899      }        
900        
901    }
902
928      //fill up mpiSimData struct
929      parallelData.nMolGlobal = getNGlobalMolecules();
930      parallelData.nMolLocal = getNMolecules();
# Line 911 | Line 936 | namespace OpenMD {
936      MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors));
937  
938      //pass mpiSimData struct and index arrays to fortran
939 <    setFsimParallel(&parallelData, &(parallelData.nAtomsLocal),
940 <                    &localToGlobalAtomIndex[0],  &(parallelData.nGroupsLocal),
941 <                    &localToGlobalCutoffGroupIndex[0], &isError);
939 >    //setFsimParallel(&parallelData, &(parallelData.nAtomsLocal),
940 >    //                &localToGlobalAtomIndex[0],  &(parallelData.nGroupsLocal),
941 >    //                &localToGlobalCutoffGroupIndex[0], &isError);
942  
943      if (isError) {
944        sprintf(painCave.errMsg,
# Line 970 | Line 995 | namespace OpenMD {
995      Molecule* mol;
996      RigidBody* rb;
997      Atom* atom;
998 +    CutoffGroup* cg;
999      SimInfo::MoleculeIterator mi;
1000      Molecule::RigidBodyIterator rbIter;
1001 <    Molecule::AtomIterator atomIter;;
1001 >    Molecule::AtomIterator atomIter;
1002 >    Molecule::CutoffGroupIterator cgIter;
1003  
1004      for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) {
1005          
# Line 982 | Line 1009 | namespace OpenMD {
1009          
1010        for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
1011          rb->setSnapshotManager(sman_);
1012 +      }
1013 +
1014 +      for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) {
1015 +        cg->setSnapshotManager(sman_);
1016        }
1017      }    
1018      

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines