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 1549 by gezelter, Wed Apr 27 18:38:15 2011 UTC vs.
Revision 1569 by gezelter, Thu May 26 13:55:04 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"
58 #include "UseTheForce/doForces_interface.h"
57   #include "utils/MemoryUtils.hpp"
58   #include "utils/simError.h"
59   #include "selection/SelectionManager.hpp"
# Line 63 | Line 61
61   #include "UseTheForce/ForceField.hpp"
62   #include "nonbonded/SwitchingFunction.hpp"
63  
66 #ifdef IS_MPI
67 #include "UseTheForce/mpiComponentPlan.h"
68 #include "UseTheForce/DarkSide/simParallel_interface.h"
69 #endif
70
64   using namespace std;
65   namespace OpenMD {
66    
# Line 78 | Line 71 | namespace OpenMD {
71      nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0),
72      nAtoms_(0), nBonds_(0),  nBends_(0), nTorsions_(0), nInversions_(0),
73      nRigidBodies_(0), nIntegrableObjects_(0), nCutoffGroups_(0),
74 <    nConstraints_(0), sman_(NULL), fortranInitialized_(false),
74 >    nConstraints_(0), sman_(NULL), topologyDone_(false),
75      calcBoxDipole_(false), useAtomicVirial_(true) {    
76      
77      MoleculeStamp* molStamp;
# Line 777 | Line 770 | namespace OpenMD {
770      temp = usesElectrostatic;
771      MPI_Allreduce(&temp, &usesElectrostaticAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD);
772   #endif
780    fInfo_.SIM_uses_PBC = usesPeriodicBoundaries_;    
781    fInfo_.SIM_uses_DirectionalAtoms = usesDirectionalAtoms_;
782    fInfo_.SIM_uses_MetallicAtoms = usesMetallicAtoms_;
783    fInfo_.SIM_requires_SkipCorrection = usesElectrostaticAtoms_;
784    fInfo_.SIM_requires_SelfCorrection = usesElectrostaticAtoms_;
785    fInfo_.SIM_uses_AtomicVirial = usesAtomicVirial_;
773    }
774  
775  
# Line 825 | Line 812 | namespace OpenMD {
812    }
813  
814  
815 <  void SimInfo::setupFortran() {
829 <    int isError;
815 >  void SimInfo::prepareTopology() {
816      int nExclude, nOneTwo, nOneThree, nOneFour;
831    vector<int> fortranGlobalGroupMembership;
832    
833    isError = 0;
817  
835    //globalGroupMembership_ is filled by SimCreator    
836    for (int i = 0; i < nGlobalAtoms_; i++) {
837      fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1);
838    }
839
818      //calculate mass ratio of cutoff group
841    vector<RealType> mfact;
819      SimInfo::MoleculeIterator mi;
820      Molecule* mol;
821      Molecule::CutoffGroupIterator ci;
# Line 847 | Line 824 | namespace OpenMD {
824      Atom* atom;
825      RealType totalMass;
826  
827 <    //to avoid memory reallocation, reserve enough space for mfact
828 <    mfact.reserve(getNCutoffGroups());
827 >    //to avoid memory reallocation, reserve enough space for massFactors_
828 >    massFactors_.clear();
829 >    massFactors_.reserve(getNCutoffGroups());
830      
831      for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) {        
832 <      for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) {
832 >      for (cg = mol->beginCutoffGroup(ci); cg != NULL;
833 >           cg = mol->nextCutoffGroup(ci)) {
834  
835          totalMass = cg->getMass();
836          for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) {
837            // Check for massless groups - set mfact to 1 if true
838            if (totalMass != 0)
839 <            mfact.push_back(atom->getMass()/totalMass);
839 >            massFactors_.push_back(atom->getMass()/totalMass);
840            else
841 <            mfact.push_back( 1.0 );
841 >            massFactors_.push_back( 1.0 );
842          }
843        }      
844      }
# Line 873 | Line 852 | namespace OpenMD {
852          identArray_.push_back(atom->getIdent());
853        }
854      }    
876
877    //fill molMembershipArray
878    //molMembershipArray is filled by SimCreator    
879    vector<int> molMembershipArray(nGlobalAtoms_);
880    for (int i = 0; i < nGlobalAtoms_; i++) {
881      molMembershipArray[i] = globalMolMembership_[i] + 1;
882    }
855      
856 <    //setup fortran simulation
856 >    //scan topology
857  
858      nExclude = excludedInteractions_.getSize();
859      nOneTwo = oneTwoInteractions_.getSize();
# Line 893 | Line 865 | namespace OpenMD {
865      int* oneThreeList = oneThreeInteractions_.getPairList();
866      int* oneFourList = oneFourInteractions_.getPairList();
867  
868 <    setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray_[0],
869 <                   &nExclude, excludeList,
870 <                   &nOneTwo, oneTwoList,
871 <                   &nOneThree, oneThreeList,
872 <                   &nOneFour, oneFourList,
873 <                   &molMembershipArray[0], &mfact[0], &nCutoffGroups_,
874 <                   &fortranGlobalGroupMembership[0], &isError);
868 >    //setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray_[0],
869 >    //               &nExclude, excludeList,
870 >    //               &nOneTwo, oneTwoList,
871 >    //               &nOneThree, oneThreeList,
872 >    //               &nOneFour, oneFourList,
873 >    //               &molMembershipArray[0], &mfact[0], &nCutoffGroups_,
874 >    //               &fortranGlobalGroupMembership[0], &isError);
875      
876 <    if( isError ){
905 <      
906 <      sprintf( painCave.errMsg,
907 <               "There was an error setting the simulation information in fortran.\n" );
908 <      painCave.isFatal = 1;
909 <      painCave.severity = OPENMD_ERROR;
910 <      simError();
911 <    }
912 <    
913 <    
914 <    sprintf( checkPointMsg,
915 <             "succesfully sent the simulation information to fortran.\n");
916 <    
917 <    errorCheckPoint();
918 <    
919 <    // Setup number of neighbors in neighbor list if present
920 <    if (simParams_->haveNeighborListNeighbors()) {
921 <      int nlistNeighbors = simParams_->getNeighborListNeighbors();
922 <      setNeighbors(&nlistNeighbors);
923 <    }
924 <  
925 < #ifdef IS_MPI    
926 <    mpiSimData parallelData;
927 <
928 <    //fill up mpiSimData struct
929 <    parallelData.nMolGlobal = getNGlobalMolecules();
930 <    parallelData.nMolLocal = getNMolecules();
931 <    parallelData.nAtomsGlobal = getNGlobalAtoms();
932 <    parallelData.nAtomsLocal = getNAtoms();
933 <    parallelData.nGroupsGlobal = getNGlobalCutoffGroups();
934 <    parallelData.nGroupsLocal = getNCutoffGroups();
935 <    parallelData.myNode = worldRank;
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);
942 <
943 <    if (isError) {
944 <      sprintf(painCave.errMsg,
945 <              "mpiRefresh errror: fortran didn't like something we gave it.\n");
946 <      painCave.isFatal = 1;
947 <      simError();
948 <    }
949 <
950 <    sprintf(checkPointMsg, " mpiRefresh successful.\n");
951 <    errorCheckPoint();
952 < #endif
953 <
954 <    initFortranFF(&isError);
955 <    if (isError) {
956 <      sprintf(painCave.errMsg,
957 <              "initFortranFF errror: fortran didn't like something we gave it.\n");
958 <      painCave.isFatal = 1;
959 <      simError();
960 <    }
961 <    fortranInitialized_ = true;
876 >    topologyDone_ = true;
877    }
878  
879    void SimInfo::addProperty(GenericData* genData) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines