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

Comparing trunk/src/brains/SimCreator.cpp (file contents):
Revision 1938 by gezelter, Thu Oct 31 15:32:17 2013 UTC vs.
Revision 1993 by gezelter, Tue Apr 29 17:32:31 2014 UTC

# Line 64 | Line 64
64   #include "brains/ForceField.hpp"
65   #include "utils/simError.h"
66   #include "utils/StringUtils.hpp"
67 + #include "utils/Revision.hpp"
68   #include "math/SeqRandNumGen.hpp"
69   #include "mdParser/MDLexer.hpp"
70   #include "mdParser/MDParser.hpp"
# Line 103 | Line 104 | namespace OpenMD {
104        const int masterNode = 0;
105  
106        if (worldRank == masterNode) {
107 <        MPI::COMM_WORLD.Bcast(&mdFileVersion, 1, MPI::INT, masterNode);
107 >        MPI_Bcast(&mdFileVersion, 1, MPI_INT, masterNode, MPI_COMM_WORLD);
108   #endif                
109          SimplePreprocessor preprocessor;
110 <        preprocessor.preprocess(rawMetaDataStream, filename, startOfMetaDataBlock, ppStream);
110 >        preprocessor.preprocess(rawMetaDataStream, filename,
111 >                                startOfMetaDataBlock, ppStream);
112                  
113   #ifdef IS_MPI            
114 <        //brocasting the stream size
114 >        //broadcasting the stream size
115          streamSize = ppStream.str().size() +1;
116 <        MPI::COMM_WORLD.Bcast(&streamSize, 1, MPI::LONG, masterNode);
117 <        MPI::COMM_WORLD.Bcast(static_cast<void*>(const_cast<char*>(ppStream.str().c_str())), streamSize, MPI::CHAR, masterNode);
118 <                          
116 >        MPI_Bcast(&streamSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD);
117 >        MPI_Bcast(static_cast<void*>(const_cast<char*>(ppStream.str().c_str())),
118 >                  streamSize, MPI_CHAR, masterNode, MPI_COMM_WORLD);
119        } else {
120 <        MPI::COMM_WORLD.Bcast(&mdFileVersion, 1, MPI::INT, masterNode);
120 >
121 >        MPI_Bcast(&mdFileVersion, 1, MPI_INT, masterNode, MPI_COMM_WORLD);
122  
123          //get stream size
124 <        MPI::COMM_WORLD.Bcast(&streamSize, 1, MPI::LONG, masterNode);
122 <
124 >        MPI_Bcast(&streamSize, 1, MPI_INT, masterNode, MPI_COMM_WORLD);
125          char* buf = new char[streamSize];
126          assert(buf);
127                  
128          //receive file content
129 <        MPI::COMM_WORLD.Bcast(buf, streamSize, MPI::CHAR, masterNode);
130 <                
129 >        MPI_Bcast(buf, streamSize, MPI_CHAR, masterNode, MPI_COMM_WORLD);
130 >
131          ppStream.str(buf);
132          delete [] buf;
133        }
# Line 149 | Line 151 | namespace OpenMD {
151        parser.initializeASTFactory(factory);
152        parser.setASTFactory(&factory);
153        parser.mdfile();
152
154        // Create a tree parser that reads information into Globals
155        MDTreeParser treeParser;
156        treeParser.initializeASTFactory(factory);
# Line 263 | Line 264 | namespace OpenMD {
264      version.append(".");
265      version.append(OPENMD_VERSION_MINOR);
266  
267 <    std::string svnrev;
267 >    std::string svnrev(g_REVISION, strnlen(g_REVISION, 20));
268      //convert a macro from compiler to a string in c++
269 <    STR_DEFINE(svnrev, SVN_REV );
269 >    // STR_DEFINE(svnrev, SVN_REV );
270      version.append(" Revision: ");
271      // If there's no SVN revision, just call this the RELEASE revision.
272      if (!svnrev.empty()) {
# Line 520 | Line 521 | namespace OpenMD {
521                                                      // error
522                                                      // condition:
523      
524 <    nProcessors = MPI::COMM_WORLD.Get_size();
524 >    MPI_Comm_size( MPI_COMM_WORLD, &nProcessors);    
525      
526      if (nProcessors > nGlobalMols) {
527        sprintf(painCave.errMsg,
# Line 639 | Line 640 | namespace OpenMD {
640        delete myRandom;
641  
642        // Spray out this nonsense to all other processors:
643 <      MPI::COMM_WORLD.Bcast(&molToProcMap[0], nGlobalMols, MPI::INT, 0);
643 >      MPI_Bcast(&molToProcMap[0], nGlobalMols, MPI_INT, 0, MPI_COMM_WORLD);
644 >
645      } else {
646        
647        // Listen to your marching orders from processor 0:
648 <      MPI::COMM_WORLD.Bcast(&molToProcMap[0], nGlobalMols, MPI::INT, 0);
648 >      MPI_Bcast(&molToProcMap[0], nGlobalMols, MPI_INT, 0, MPI_COMM_WORLD);
649  
650      }
651      
# Line 785 | Line 787 | namespace OpenMD {
787  
788      if (simParams->getOutputElectricField() | simParams->haveElectricField()) {
789        storageLayout |= DataStorage::dslElectricField;
790 +    }
791 +
792 +    if (simParams->getOutputSitePotential() ) {
793 +      storageLayout |= DataStorage::dslSitePotential;
794      }
795  
796      if (simParams->getOutputFluctuatingCharges()) {
# Line 803 | Line 809 | namespace OpenMD {
809      Molecule::AtomIterator ai;
810      Molecule::RigidBodyIterator ri;
811      Molecule::CutoffGroupIterator ci;
812 +    Molecule::BondIterator boi;
813 +    Molecule::BendIterator bei;
814 +    Molecule::TorsionIterator ti;
815 +    Molecule::InversionIterator ii;
816      Molecule::IntegrableObjectIterator  ioi;
817 <    Molecule * mol;
818 <    Atom * atom;
819 <    RigidBody * rb;
820 <    CutoffGroup * cg;
817 >    Molecule* mol;
818 >    Atom* atom;
819 >    RigidBody* rb;
820 >    CutoffGroup* cg;
821 >    Bond* bond;
822 >    Bend* bend;
823 >    Torsion* torsion;
824 >    Inversion* inversion;
825      int beginAtomIndex;
826      int beginRigidBodyIndex;
827      int beginCutoffGroupIndex;
828 +    int beginBondIndex;
829 +    int beginBendIndex;
830 +    int beginTorsionIndex;
831 +    int beginInversionIndex;
832      int nGlobalAtoms = info->getNGlobalAtoms();
833      int nGlobalRigidBodies = info->getNGlobalRigidBodies();
834      
835      beginAtomIndex = 0;
836 <    //rigidbody's index begins right after atom's
836 >    // The rigid body indices begin immediately after the atom indices:
837      beginRigidBodyIndex = info->getNGlobalAtoms();
838      beginCutoffGroupIndex = 0;
839 <
839 >    beginBondIndex = 0;
840 >    beginBendIndex = 0;
841 >    beginTorsionIndex = 0;
842 >    beginInversionIndex = 0;
843 >  
844      for(int i = 0; i < info->getNGlobalMolecules(); i++) {
845        
846   #ifdef IS_MPI      
# Line 827 | Line 849 | namespace OpenMD {
849          // stuff to do if I own this molecule
850          mol = info->getMoleculeByGlobalIndex(i);
851  
852 <        //local index(index in DataStorge) of atom is important
853 <        for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
852 >        // The local index(index in DataStorge) of the atom is important:
853 >        for(atom = mol->beginAtom(ai); atom != NULL;
854 >            atom = mol->nextAtom(ai)) {
855            atom->setGlobalIndex(beginAtomIndex++);
856          }
857          
# Line 837 | Line 860 | namespace OpenMD {
860            rb->setGlobalIndex(beginRigidBodyIndex++);
861          }
862          
863 <        //local index of cutoff group is trivial, it only depends on
864 <        //the order of travesing
863 >        // The local index of other objects only depends on the order
864 >        // of traversal:
865          for(cg = mol->beginCutoffGroup(ci); cg != NULL;
866              cg = mol->nextCutoffGroup(ci)) {
867            cg->setGlobalIndex(beginCutoffGroupIndex++);
868          }        
869 +        for(bond = mol->beginBond(boi); bond != NULL;
870 +            bond = mol->nextBond(boi)) {
871 +          bond->setGlobalIndex(beginBondIndex++);
872 +        }        
873 +        for(bend = mol->beginBend(bei); bend != NULL;
874 +            bend = mol->nextBend(bei)) {
875 +          bend->setGlobalIndex(beginBendIndex++);
876 +        }        
877 +        for(torsion = mol->beginTorsion(ti); torsion != NULL;
878 +            torsion = mol->nextTorsion(ti)) {
879 +          torsion->setGlobalIndex(beginTorsionIndex++);
880 +        }        
881 +        for(inversion = mol->beginInversion(ii); inversion != NULL;
882 +            inversion = mol->nextInversion(ii)) {
883 +          inversion->setGlobalIndex(beginInversionIndex++);
884 +        }        
885          
886   #ifdef IS_MPI        
887        }  else {
# Line 855 | Line 894 | namespace OpenMD {
894          beginAtomIndex += stamp->getNAtoms();
895          beginRigidBodyIndex += stamp->getNRigidBodies();
896          beginCutoffGroupIndex += stamp->getNCutoffGroups() + stamp->getNFreeAtoms();
897 +        beginBondIndex += stamp->getNBonds();
898 +        beginBendIndex += stamp->getNBends();
899 +        beginTorsionIndex += stamp->getNTorsions();
900 +        beginInversionIndex += stamp->getNInversions();
901        }
902   #endif          
903  
# Line 862 | Line 905 | namespace OpenMD {
905  
906      //fill globalGroupMembership
907      std::vector<int> globalGroupMembership(info->getNGlobalAtoms(), 0);
908 <    for(mol = info->beginMolecule(mi); mol != NULL; mol = info->nextMolecule(mi)) {        
909 <      for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) {
910 <        
908 >    for(mol = info->beginMolecule(mi); mol != NULL;
909 >        mol = info->nextMolecule(mi)) {        
910 >      for (cg = mol->beginCutoffGroup(ci); cg != NULL;
911 >           cg = mol->nextCutoffGroup(ci)) {        
912          for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) {
913            globalGroupMembership[atom->getGlobalIndex()] = cg->getGlobalIndex();
914          }
# Line 879 | Line 923 | namespace OpenMD {
923      // This would be prettier if we could use MPI_IN_PLACE like the MPI-2
924      // docs said we could.
925      std::vector<int> tmpGroupMembership(info->getNGlobalAtoms(), 0);
926 <    MPI::COMM_WORLD.Allreduce(&globalGroupMembership[0],
927 <                              &tmpGroupMembership[0], nGlobalAtoms,
928 <                              MPI::INT, MPI::SUM);
926 >    MPI_Allreduce(&globalGroupMembership[0],
927 >                  &tmpGroupMembership[0], nGlobalAtoms,
928 >                  MPI_INT, MPI_SUM, MPI_COMM_WORLD);
929 >
930      info->setGlobalGroupMembership(tmpGroupMembership);
931   #else
932      info->setGlobalGroupMembership(globalGroupMembership);
# Line 905 | Line 950 | namespace OpenMD {
950   #ifdef IS_MPI
951      std::vector<int> tmpMolMembership(info->getNGlobalAtoms() +
952                                        info->getNGlobalRigidBodies(), 0);
953 <    MPI::COMM_WORLD.Allreduce(&globalMolMembership[0], &tmpMolMembership[0],
954 <                              nGlobalAtoms + nGlobalRigidBodies,
955 <                              MPI::INT, MPI::SUM);
953 >    MPI_Allreduce(&globalMolMembership[0], &tmpMolMembership[0],
954 >                  nGlobalAtoms + nGlobalRigidBodies,
955 >                  MPI_INT, MPI_SUM, MPI_COMM_WORLD);
956      
957      info->setGlobalMolMembership(tmpMolMembership);
958   #else
# Line 925 | Line 970 | namespace OpenMD {
970      
971   #ifdef IS_MPI
972      std::vector<int> numIntegrableObjectsPerMol(info->getNGlobalMolecules(), 0);
973 <    MPI::COMM_WORLD.Allreduce(&nIOPerMol[0], &numIntegrableObjectsPerMol[0],
974 <                              info->getNGlobalMolecules(), MPI::INT, MPI::SUM);
973 >    MPI_Allreduce(&nIOPerMol[0], &numIntegrableObjectsPerMol[0],
974 >      info->getNGlobalMolecules(), MPI_INT, MPI_SUM, MPI_COMM_WORLD);
975   #else
976      std::vector<int> numIntegrableObjectsPerMol = nIOPerMol;
977   #endif    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines