# | 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 770 | Line 770 | namespace OpenMD { | |
770 | temp = usesElectrostatic; | |
771 | MPI_Allreduce(&temp, &usesElectrostaticAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); | |
772 | #endif | |
773 | < | fInfo_.SIM_uses_PBC = usesPeriodicBoundaries_; |
774 | < | fInfo_.SIM_uses_DirectionalAtoms = usesDirectionalAtoms_; |
775 | < | fInfo_.SIM_uses_MetallicAtoms = usesMetallicAtoms_; |
776 | < | fInfo_.SIM_requires_SkipCorrection = usesElectrostaticAtoms_; |
777 | < | fInfo_.SIM_requires_SelfCorrection = usesElectrostaticAtoms_; |
778 | < | fInfo_.SIM_uses_AtomicVirial = usesAtomicVirial_; |
773 | > | } |
774 | > | |
775 | > | |
776 | > | vector<int> SimInfo::getGlobalAtomIndices() { |
777 | > | SimInfo::MoleculeIterator mi; |
778 | > | Molecule* mol; |
779 | > | Molecule::AtomIterator ai; |
780 | > | Atom* atom; |
781 | > | |
782 | > | vector<int> GlobalAtomIndices(getNAtoms(), 0); |
783 | > | |
784 | > | for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
785 | > | |
786 | > | for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
787 | > | GlobalAtomIndices[atom->getLocalIndex()] = atom->getGlobalIndex(); |
788 | > | } |
789 | > | } |
790 | > | return GlobalAtomIndices; |
791 | } | |
792 | ||
793 | + | |
794 | + | vector<int> SimInfo::getGlobalGroupIndices() { |
795 | + | SimInfo::MoleculeIterator mi; |
796 | + | Molecule* mol; |
797 | + | Molecule::CutoffGroupIterator ci; |
798 | + | CutoffGroup* cg; |
799 | + | |
800 | + | vector<int> GlobalGroupIndices; |
801 | + | |
802 | + | for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
803 | + | |
804 | + | //local index of cutoff group is trivial, it only depends on the |
805 | + | //order of travesing |
806 | + | for (cg = mol->beginCutoffGroup(ci); cg != NULL; |
807 | + | cg = mol->nextCutoffGroup(ci)) { |
808 | + | GlobalGroupIndices.push_back(cg->getGlobalIndex()); |
809 | + | } |
810 | + | } |
811 | + | return GlobalGroupIndices; |
812 | + | } |
813 | + | |
814 | + | |
815 | void SimInfo::setupFortran() { | |
816 | int isError; | |
817 | int nExclude, nOneTwo, nOneThree, nOneFour; | |
# | Line 817 | Line 851 | namespace OpenMD { | |
851 | } | |
852 | } | |
853 | ||
854 | < | //fill ident array of local atoms (it is actually ident of |
821 | < | //AtomType, it is so confusing !!!) |
822 | < | vector<int> identArray; |
854 | > | // Build the identArray_ |
855 | ||
856 | < | //to avoid memory reallocation, reserve enough space identArray |
857 | < | identArray.reserve(getNAtoms()); |
826 | < | |
856 | > | identArray_.clear(); |
857 | > | identArray_.reserve(getNAtoms()); |
858 | for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { | |
859 | for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { | |
860 | < | identArray.push_back(atom->getIdent()); |
860 | > | identArray_.push_back(atom->getIdent()); |
861 | } | |
862 | } | |
863 | ||
# | Line 849 | Line 880 | namespace OpenMD { | |
880 | int* oneThreeList = oneThreeInteractions_.getPairList(); | |
881 | int* oneFourList = oneFourInteractions_.getPairList(); | |
882 | ||
883 | < | setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], |
884 | < | &nExclude, excludeList, |
885 | < | &nOneTwo, oneTwoList, |
886 | < | &nOneThree, oneThreeList, |
887 | < | &nOneFour, oneFourList, |
888 | < | &molMembershipArray[0], &mfact[0], &nCutoffGroups_, |
889 | < | &fortranGlobalGroupMembership[0], &isError); |
883 | > | //setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray_[0], |
884 | > | // &nExclude, excludeList, |
885 | > | // &nOneTwo, oneTwoList, |
886 | > | // &nOneThree, oneThreeList, |
887 | > | // &nOneFour, oneFourList, |
888 | > | // &molMembershipArray[0], &mfact[0], &nCutoffGroups_, |
889 | > | // &fortranGlobalGroupMembership[0], &isError); |
890 | ||
891 | < | if( isError ){ |
892 | < | |
893 | < | sprintf( painCave.errMsg, |
894 | < | "There was an error setting the simulation information in fortran.\n" ); |
895 | < | painCave.isFatal = 1; |
896 | < | painCave.severity = OPENMD_ERROR; |
897 | < | simError(); |
898 | < | } |
891 | > | // if( isError ){ |
892 | > | // |
893 | > | // sprintf( painCave.errMsg, |
894 | > | // "There was an error setting the simulation information in fortran.\n" ); |
895 | > | // painCave.isFatal = 1; |
896 | > | // painCave.severity = OPENMD_ERROR; |
897 | > | // simError(); |
898 | > | //} |
899 | ||
900 | ||
901 | < | sprintf( checkPointMsg, |
902 | < | "succesfully sent the simulation information to fortran.\n"); |
901 | > | // sprintf( checkPointMsg, |
902 | > | // "succesfully sent the simulation information to fortran.\n"); |
903 | ||
904 | < | errorCheckPoint(); |
904 | > | // errorCheckPoint(); |
905 | ||
906 | // Setup number of neighbors in neighbor list if present | |
907 | < | if (simParams_->haveNeighborListNeighbors()) { |
908 | < | int nlistNeighbors = simParams_->getNeighborListNeighbors(); |
909 | < | setNeighbors(&nlistNeighbors); |
910 | < | } |
907 | > | //if (simParams_->haveNeighborListNeighbors()) { |
908 | > | // int nlistNeighbors = simParams_->getNeighborListNeighbors(); |
909 | > | // setNeighbors(&nlistNeighbors); |
910 | > | //} |
911 | ||
912 | #ifdef IS_MPI | |
913 | < | //SimInfo is responsible for creating localToGlobalAtomIndex and |
883 | < | //localToGlobalGroupIndex |
884 | < | vector<int> localToGlobalAtomIndex(getNAtoms(), 0); |
885 | < | vector<int> localToGlobalCutoffGroupIndex; |
886 | < | mpiSimData parallelData; |
913 | > | // mpiSimData parallelData; |
914 | ||
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 | – | |
915 | //fill up mpiSimData struct | |
916 | < | parallelData.nMolGlobal = getNGlobalMolecules(); |
917 | < | parallelData.nMolLocal = getNMolecules(); |
918 | < | parallelData.nAtomsGlobal = getNGlobalAtoms(); |
919 | < | parallelData.nAtomsLocal = getNAtoms(); |
920 | < | parallelData.nGroupsGlobal = getNGlobalCutoffGroups(); |
921 | < | parallelData.nGroupsLocal = getNCutoffGroups(); |
922 | < | parallelData.myNode = worldRank; |
923 | < | MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors)); |
916 | > | // parallelData.nMolGlobal = getNGlobalMolecules(); |
917 | > | // parallelData.nMolLocal = getNMolecules(); |
918 | > | // parallelData.nAtomsGlobal = getNGlobalAtoms(); |
919 | > | // parallelData.nAtomsLocal = getNAtoms(); |
920 | > | // parallelData.nGroupsGlobal = getNGlobalCutoffGroups(); |
921 | > | // parallelData.nGroupsLocal = getNCutoffGroups(); |
922 | > | // parallelData.myNode = worldRank; |
923 | > | // MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors)); |
924 | ||
925 | //pass mpiSimData struct and index arrays to fortran | |
926 | < | setFsimParallel(¶llelData, &(parallelData.nAtomsLocal), |
927 | < | &localToGlobalAtomIndex[0], &(parallelData.nGroupsLocal), |
928 | < | &localToGlobalCutoffGroupIndex[0], &isError); |
926 | > | //setFsimParallel(¶llelData, &(parallelData.nAtomsLocal), |
927 | > | // &localToGlobalAtomIndex[0], &(parallelData.nGroupsLocal), |
928 | > | // &localToGlobalCutoffGroupIndex[0], &isError); |
929 | ||
930 | < | if (isError) { |
931 | < | sprintf(painCave.errMsg, |
932 | < | "mpiRefresh errror: fortran didn't like something we gave it.\n"); |
933 | < | painCave.isFatal = 1; |
934 | < | simError(); |
935 | < | } |
930 | > | // if (isError) { |
931 | > | // sprintf(painCave.errMsg, |
932 | > | // "mpiRefresh errror: fortran didn't like something we gave it.\n"); |
933 | > | // painCave.isFatal = 1; |
934 | > | // simError(); |
935 | > | // } |
936 | ||
937 | < | sprintf(checkPointMsg, " mpiRefresh successful.\n"); |
938 | < | errorCheckPoint(); |
937 | > | // sprintf(checkPointMsg, " mpiRefresh successful.\n"); |
938 | > | // errorCheckPoint(); |
939 | #endif | |
940 | < | fortranInitialized_ = true; |
940 | > | |
941 | > | // initFortranFF(&isError); |
942 | > | // if (isError) { |
943 | > | // sprintf(painCave.errMsg, |
944 | > | // "initFortranFF errror: fortran didn't like something we gave it.\n"); |
945 | > | // painCave.isFatal = 1; |
946 | > | // simError(); |
947 | > | // } |
948 | > | // fortranInitialized_ = true; |
949 | } | |
950 | ||
951 | void SimInfo::addProperty(GenericData* genData) { | |
# | Line 961 | Line 982 | namespace OpenMD { | |
982 | Molecule* mol; | |
983 | RigidBody* rb; | |
984 | Atom* atom; | |
985 | + | CutoffGroup* cg; |
986 | SimInfo::MoleculeIterator mi; | |
987 | Molecule::RigidBodyIterator rbIter; | |
988 | < | Molecule::AtomIterator atomIter;; |
988 | > | Molecule::AtomIterator atomIter; |
989 | > | Molecule::CutoffGroupIterator cgIter; |
990 | ||
991 | for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { | |
992 | ||
# | Line 974 | Line 997 | namespace OpenMD { | |
997 | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { | |
998 | rb->setSnapshotManager(sman_); | |
999 | } | |
1000 | + | |
1001 | + | for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) { |
1002 | + | cg->setSnapshotManager(sman_); |
1003 | + | } |
1004 | } | |
1005 | ||
1006 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |