| 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" | 
| 60 | 
  | 
#include "io/ForceFieldOptions.hpp" | 
| 61 | 
  | 
#include "UseTheForce/ForceField.hpp" | 
| 62 | 
  | 
#include "nonbonded/SwitchingFunction.hpp" | 
| 65 | 
– | 
 | 
| 66 | 
– | 
#ifdef IS_MPI | 
| 67 | 
– | 
#include "UseTheForce/mpiComponentPlan.h" | 
| 68 | 
– | 
#include "UseTheForce/DarkSide/simParallel_interface.h" | 
| 69 | 
– | 
#endif  | 
| 63 | 
  | 
 | 
| 64 | 
  | 
using namespace std; | 
| 65 | 
  | 
namespace OpenMD { | 
| 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; | 
| 857 | 
  | 
      }        | 
| 858 | 
  | 
    } | 
| 859 | 
  | 
 | 
| 860 | 
< | 
    //fill ident array of local atoms (it is actually ident of | 
| 828 | 
< | 
    //AtomType, it is so confusing !!!) | 
| 829 | 
< | 
    vector<int> identArray; | 
| 860 | 
> | 
    // Build the identArray_ | 
| 861 | 
  | 
 | 
| 862 | 
< | 
    //to avoid memory reallocation, reserve enough space identArray | 
| 863 | 
< | 
    identArray.reserve(getNAtoms()); | 
| 833 | 
< | 
     | 
| 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 | 
  | 
 | 
| 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 | 
| 890 | 
< | 
    //localToGlobalGroupIndex | 
| 891 | 
< | 
    vector<int> localToGlobalAtomIndex(getNAtoms(), 0); | 
| 892 | 
< | 
    vector<int> localToGlobalCutoffGroupIndex; | 
| 893 | 
< | 
    mpiSimData parallelData; | 
| 919 | 
> | 
    // mpiSimData parallelData; | 
| 920 | 
  | 
 | 
| 895 | 
– | 
    for (mol = beginMolecule(mi); mol != NULL; mol  = nextMolecule(mi)) { | 
| 896 | 
– | 
 | 
| 897 | 
– | 
      //local index(index in DataStorge) of atom is important | 
| 898 | 
– | 
      for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { | 
| 899 | 
– | 
        localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1; | 
| 900 | 
– | 
      } | 
| 901 | 
– | 
 | 
| 902 | 
– | 
      //local index of cutoff group is trivial, it only depends on the order of travesing | 
| 903 | 
– | 
      for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { | 
| 904 | 
– | 
        localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1); | 
| 905 | 
– | 
      }         | 
| 906 | 
– | 
         | 
| 907 | 
– | 
    } | 
| 908 | 
– | 
 | 
| 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(¶llelData, &(parallelData.nAtomsLocal), | 
| 933 | 
< | 
                    &localToGlobalAtomIndex[0],  &(parallelData.nGroupsLocal), | 
| 934 | 
< | 
                    &localToGlobalCutoffGroupIndex[0], &isError); | 
| 932 | 
> | 
    //setFsimParallel(¶llelData, &(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 | 
  | 
 | 
| 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; | 
| 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) { |