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 1535 by gezelter, Fri Dec 31 18:31:56 2010 UTC vs.
Revision 1550 by gezelter, Wed Apr 27 21:49:59 2011 UTC

# Line 54 | Line 54
54   #include "math/Vector3.hpp"
55   #include "primitives/Molecule.hpp"
56   #include "primitives/StuntDouble.hpp"
57 #include "UseTheForce/DarkSide/neighborLists_interface.h"
57   #include "utils/MemoryUtils.hpp"
58   #include "utils/simError.h"
59   #include "selection/SelectionManager.hpp"
# Line 62 | Line 61
61   #include "UseTheForce/ForceField.hpp"
62   #include "nonbonded/SwitchingFunction.hpp"
63  
65 #ifdef IS_MPI
66 #include "UseTheForce/mpiComponentPlan.h"
67 #include "UseTheForce/DarkSide/simParallel_interface.h"
68 #endif
69
64   using namespace std;
65   namespace OpenMD {
66    
# Line 131 | Line 125 | namespace OpenMD {
125      //equal to the total number of atoms minus number of atoms belong to
126      //cutoff group defined in meta-data file plus the number of cutoff
127      //groups defined in meta-data file
128 +    std::cerr << "nGA = " << nGlobalAtoms_ << "\n";
129 +    std::cerr << "nCA = " << nCutoffAtoms << "\n";
130 +    std::cerr << "nG = " << nGroups << "\n";
131 +
132      nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups;
133 +
134 +    std::cerr << "nGCG = " << nGlobalCutoffGroups_ << "\n";
135      
136      //every free atom (atom does not belong to rigid bodies) is an
137      //integrable object therefore the total number of integrable objects
# Line 776 | Line 776 | namespace OpenMD {
776      fInfo_.SIM_requires_SkipCorrection = usesElectrostaticAtoms_;
777      fInfo_.SIM_requires_SelfCorrection = usesElectrostaticAtoms_;
778      fInfo_.SIM_uses_AtomicVirial = usesAtomicVirial_;
779 +  }
780 +
781 +
782 +  vector<int> SimInfo::getGlobalAtomIndices() {
783 +    SimInfo::MoleculeIterator mi;
784 +    Molecule* mol;
785 +    Molecule::AtomIterator ai;
786 +    Atom* atom;
787 +
788 +    vector<int> GlobalAtomIndices(getNAtoms(), 0);
789 +    
790 +    for (mol = beginMolecule(mi); mol != NULL; mol  = nextMolecule(mi)) {
791 +      
792 +      for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
793 +        GlobalAtomIndices[atom->getLocalIndex()] = atom->getGlobalIndex();
794 +      }
795 +    }
796 +    return GlobalAtomIndices;
797    }
798  
799 +
800 +  vector<int> SimInfo::getGlobalGroupIndices() {
801 +    SimInfo::MoleculeIterator mi;
802 +    Molecule* mol;
803 +    Molecule::CutoffGroupIterator ci;
804 +    CutoffGroup* cg;
805 +
806 +    vector<int> GlobalGroupIndices;
807 +    
808 +    for (mol = beginMolecule(mi); mol != NULL; mol  = nextMolecule(mi)) {
809 +      
810 +      //local index of cutoff group is trivial, it only depends on the
811 +      //order of travesing
812 +      for (cg = mol->beginCutoffGroup(ci); cg != NULL;
813 +           cg = mol->nextCutoffGroup(ci)) {
814 +        GlobalGroupIndices.push_back(cg->getGlobalIndex());
815 +      }        
816 +    }
817 +    return GlobalGroupIndices;
818 +  }
819 +
820 +
821    void SimInfo::setupFortran() {
822      int isError;
823      int nExclude, nOneTwo, nOneThree, nOneFour;
# Line 817 | Line 857 | namespace OpenMD {
857        }      
858      }
859  
860 <    //fill ident array of local atoms (it is actually ident of
821 <    //AtomType, it is so confusing !!!)
822 <    vector<int> identArray;
860 >    // Build the identArray_
861  
862 <    //to avoid memory reallocation, reserve enough space identArray
863 <    identArray.reserve(getNAtoms());
826 <    
862 >    identArray_.clear();
863 >    identArray_.reserve(getNAtoms());    
864      for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) {        
865        for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
866 <        identArray.push_back(atom->getIdent());
866 >        identArray_.push_back(atom->getIdent());
867        }
868      }    
869  
# Line 849 | Line 886 | namespace OpenMD {
886      int* oneThreeList = oneThreeInteractions_.getPairList();
887      int* oneFourList = oneFourInteractions_.getPairList();
888  
889 <    setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0],
890 <                   &nExclude, excludeList,
891 <                   &nOneTwo, oneTwoList,
892 <                   &nOneThree, oneThreeList,
893 <                   &nOneFour, oneFourList,
894 <                   &molMembershipArray[0], &mfact[0], &nCutoffGroups_,
895 <                   &fortranGlobalGroupMembership[0], &isError);
889 >    //setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray_[0],
890 >    //               &nExclude, excludeList,
891 >    //               &nOneTwo, oneTwoList,
892 >    //               &nOneThree, oneThreeList,
893 >    //               &nOneFour, oneFourList,
894 >    //               &molMembershipArray[0], &mfact[0], &nCutoffGroups_,
895 >    //               &fortranGlobalGroupMembership[0], &isError);
896      
897 <    if( isError ){
898 <      
899 <      sprintf( painCave.errMsg,
900 <               "There was an error setting the simulation information in fortran.\n" );
901 <      painCave.isFatal = 1;
902 <      painCave.severity = OPENMD_ERROR;
903 <      simError();
904 <    }
897 >    // if( isError ){
898 >    //  
899 >    //  sprintf( painCave.errMsg,
900 >    //         "There was an error setting the simulation information in fortran.\n" );
901 >    //  painCave.isFatal = 1;
902 >    //  painCave.severity = OPENMD_ERROR;
903 >    //  simError();
904 >    //}
905      
906      
907 <    sprintf( checkPointMsg,
908 <             "succesfully sent the simulation information to fortran.\n");
907 >    // sprintf( checkPointMsg,
908 >    //          "succesfully sent the simulation information to fortran.\n");
909      
910 <    errorCheckPoint();
910 >    // errorCheckPoint();
911      
912      // Setup number of neighbors in neighbor list if present
913 <    if (simParams_->haveNeighborListNeighbors()) {
914 <      int nlistNeighbors = simParams_->getNeighborListNeighbors();
915 <      setNeighbors(&nlistNeighbors);
916 <    }
913 >    //if (simParams_->haveNeighborListNeighbors()) {
914 >    //  int nlistNeighbors = simParams_->getNeighborListNeighbors();
915 >    //  setNeighbors(&nlistNeighbors);
916 >    //}
917    
918   #ifdef IS_MPI    
919 <    //SimInfo is responsible for creating localToGlobalAtomIndex and
883 <    //localToGlobalGroupIndex
884 <    vector<int> localToGlobalAtomIndex(getNAtoms(), 0);
885 <    vector<int> localToGlobalCutoffGroupIndex;
886 <    mpiSimData parallelData;
919 >    // mpiSimData parallelData;
920  
888    for (mol = beginMolecule(mi); mol != NULL; mol  = nextMolecule(mi)) {
889
890      //local index(index in DataStorge) of atom is important
891      for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
892        localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1;
893      }
894
895      //local index of cutoff group is trivial, it only depends on the order of travesing
896      for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) {
897        localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1);
898      }        
899        
900    }
901
921      //fill up mpiSimData struct
922 <    parallelData.nMolGlobal = getNGlobalMolecules();
923 <    parallelData.nMolLocal = getNMolecules();
924 <    parallelData.nAtomsGlobal = getNGlobalAtoms();
925 <    parallelData.nAtomsLocal = getNAtoms();
926 <    parallelData.nGroupsGlobal = getNGlobalCutoffGroups();
927 <    parallelData.nGroupsLocal = getNCutoffGroups();
928 <    parallelData.myNode = worldRank;
929 <    MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors));
922 >    // parallelData.nMolGlobal = getNGlobalMolecules();
923 >    // parallelData.nMolLocal = getNMolecules();
924 >    // parallelData.nAtomsGlobal = getNGlobalAtoms();
925 >    // parallelData.nAtomsLocal = getNAtoms();
926 >    // parallelData.nGroupsGlobal = getNGlobalCutoffGroups();
927 >    // parallelData.nGroupsLocal = getNCutoffGroups();
928 >    // parallelData.myNode = worldRank;
929 >    // MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors));
930  
931      //pass mpiSimData struct and index arrays to fortran
932 <    setFsimParallel(&parallelData, &(parallelData.nAtomsLocal),
933 <                    &localToGlobalAtomIndex[0],  &(parallelData.nGroupsLocal),
934 <                    &localToGlobalCutoffGroupIndex[0], &isError);
932 >    //setFsimParallel(&parallelData, &(parallelData.nAtomsLocal),
933 >    //                &localToGlobalAtomIndex[0],  &(parallelData.nGroupsLocal),
934 >    //                &localToGlobalCutoffGroupIndex[0], &isError);
935  
936 <    if (isError) {
937 <      sprintf(painCave.errMsg,
938 <              "mpiRefresh errror: fortran didn't like something we gave it.\n");
939 <      painCave.isFatal = 1;
940 <      simError();
941 <    }
936 >    // if (isError) {
937 >    //   sprintf(painCave.errMsg,
938 >    //           "mpiRefresh errror: fortran didn't like something we gave it.\n");
939 >    //   painCave.isFatal = 1;
940 >    //   simError();
941 >    // }
942  
943 <    sprintf(checkPointMsg, " mpiRefresh successful.\n");
944 <    errorCheckPoint();
943 >    // sprintf(checkPointMsg, " mpiRefresh successful.\n");
944 >    // errorCheckPoint();
945   #endif
946 <    fortranInitialized_ = true;
946 >
947 >    // initFortranFF(&isError);
948 >    // if (isError) {
949 >    //   sprintf(painCave.errMsg,
950 >    //           "initFortranFF errror: fortran didn't like something we gave it.\n");
951 >    //   painCave.isFatal = 1;
952 >    //   simError();
953 >    // }
954 >    // fortranInitialized_ = true;
955    }
956  
957    void SimInfo::addProperty(GenericData* genData) {
# Line 961 | Line 988 | namespace OpenMD {
988      Molecule* mol;
989      RigidBody* rb;
990      Atom* atom;
991 +    CutoffGroup* cg;
992      SimInfo::MoleculeIterator mi;
993      Molecule::RigidBodyIterator rbIter;
994 <    Molecule::AtomIterator atomIter;;
994 >    Molecule::AtomIterator atomIter;
995 >    Molecule::CutoffGroupIterator cgIter;
996  
997      for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) {
998          
# Line 973 | Line 1002 | namespace OpenMD {
1002          
1003        for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
1004          rb->setSnapshotManager(sman_);
1005 +      }
1006 +
1007 +      for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) {
1008 +        cg->setSnapshotManager(sman_);
1009        }
1010      }    
1011      

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines