54 |
|
#include "math/Vector3.hpp" |
55 |
|
#include "primitives/Molecule.hpp" |
56 |
|
#include "primitives/StuntDouble.hpp" |
57 |
– |
#include "UseTheForce/fCutoffPolicy.h" |
58 |
– |
#include "UseTheForce/DarkSide/fSwitchingFunctionType.h" |
59 |
– |
#include "UseTheForce/doForces_interface.h" |
60 |
– |
#include "UseTheForce/DarkSide/neighborLists_interface.h" |
61 |
– |
#include "UseTheForce/DarkSide/switcheroo_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/InteractionManager.hpp" |
68 |
< |
|
69 |
< |
|
62 |
> |
#include "nonbonded/SwitchingFunction.hpp" |
63 |
|
#ifdef IS_MPI |
64 |
< |
#include "UseTheForce/mpiComponentPlan.h" |
65 |
< |
#include "UseTheForce/DarkSide/simParallel_interface.h" |
73 |
< |
#endif |
64 |
> |
#include <mpi.h> |
65 |
> |
#endif |
66 |
|
|
67 |
|
using namespace std; |
68 |
|
namespace OpenMD { |
74 |
|
nGlobalIntegrableObjects_(0), nGlobalRigidBodies_(0), |
75 |
|
nAtoms_(0), nBonds_(0), nBends_(0), nTorsions_(0), nInversions_(0), |
76 |
|
nRigidBodies_(0), nIntegrableObjects_(0), nCutoffGroups_(0), |
77 |
< |
nConstraints_(0), sman_(NULL), fortranInitialized_(false), |
77 |
> |
nConstraints_(0), sman_(NULL), topologyDone_(false), |
78 |
|
calcBoxDipole_(false), useAtomicVirial_(true) { |
79 |
|
|
80 |
|
MoleculeStamp* molStamp; |
128 |
|
//equal to the total number of atoms minus number of atoms belong to |
129 |
|
//cutoff group defined in meta-data file plus the number of cutoff |
130 |
|
//groups defined in meta-data file |
131 |
+ |
|
132 |
|
nGlobalCutoffGroups_ = nGlobalAtoms_ - nCutoffAtoms + nGroups; |
133 |
|
|
134 |
|
//every free atom (atom does not belong to rigid bodies) is an |
272 |
|
#endif |
273 |
|
return fdf_; |
274 |
|
} |
275 |
+ |
|
276 |
+ |
unsigned int SimInfo::getNLocalCutoffGroups(){ |
277 |
+ |
int nLocalCutoffAtoms = 0; |
278 |
+ |
Molecule* mol; |
279 |
+ |
MoleculeIterator mi; |
280 |
+ |
CutoffGroup* cg; |
281 |
+ |
Molecule::CutoffGroupIterator ci; |
282 |
|
|
283 |
+ |
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
284 |
+ |
|
285 |
+ |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; |
286 |
+ |
cg = mol->nextCutoffGroup(ci)) { |
287 |
+ |
nLocalCutoffAtoms += cg->getNumAtom(); |
288 |
+ |
|
289 |
+ |
} |
290 |
+ |
} |
291 |
+ |
|
292 |
+ |
return nAtoms_ - nLocalCutoffAtoms + nCutoffGroups_; |
293 |
+ |
} |
294 |
+ |
|
295 |
|
void SimInfo::calcNdfRaw() { |
296 |
|
int ndfRaw_local; |
297 |
|
|
667 |
|
moleculeStamps_.push_back(molStamp); |
668 |
|
molStampIds_.insert(molStampIds_.end(), nmol, curStampId); |
669 |
|
} |
658 |
– |
|
659 |
– |
void SimInfo::update() { |
660 |
– |
|
661 |
– |
setupSimType(); |
662 |
– |
setupCutoffRadius(); |
663 |
– |
setupSwitchingRadius(); |
664 |
– |
setupCutoffMethod(); |
665 |
– |
setupSkinThickness(); |
666 |
– |
setupSwitchingFunction(); |
667 |
– |
setupAccumulateBoxDipole(); |
670 |
|
|
669 |
– |
#ifdef IS_MPI |
670 |
– |
setupFortranParallel(); |
671 |
– |
#endif |
672 |
– |
setupFortranSim(); |
673 |
– |
fortranInitialized_ = true; |
671 |
|
|
672 |
+ |
/** |
673 |
+ |
* update |
674 |
+ |
* |
675 |
+ |
* Performs the global checks and variable settings after the |
676 |
+ |
* objects have been created. |
677 |
+ |
* |
678 |
+ |
*/ |
679 |
+ |
void SimInfo::update() { |
680 |
+ |
setupSimVariables(); |
681 |
|
calcNdf(); |
682 |
|
calcNdfRaw(); |
683 |
|
calcNdfTrans(); |
684 |
|
} |
685 |
|
|
686 |
+ |
/** |
687 |
+ |
* getSimulatedAtomTypes |
688 |
+ |
* |
689 |
+ |
* Returns an STL set of AtomType* that are actually present in this |
690 |
+ |
* simulation. Must query all processors to assemble this information. |
691 |
+ |
* |
692 |
+ |
*/ |
693 |
|
set<AtomType*> SimInfo::getSimulatedAtomTypes() { |
694 |
|
SimInfo::MoleculeIterator mi; |
695 |
|
Molecule* mol; |
698 |
|
set<AtomType*> atomTypes; |
699 |
|
|
700 |
|
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
701 |
< |
|
702 |
< |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
701 |
> |
for(atom = mol->beginAtom(ai); atom != NULL; |
702 |
> |
atom = mol->nextAtom(ai)) { |
703 |
|
atomTypes.insert(atom->getAtomType()); |
704 |
< |
} |
705 |
< |
|
693 |
< |
} |
704 |
> |
} |
705 |
> |
} |
706 |
|
|
707 |
< |
return atomTypes; |
696 |
< |
} |
707 |
> |
#ifdef IS_MPI |
708 |
|
|
709 |
< |
/** |
710 |
< |
* setupCutoffRadius |
700 |
< |
* |
701 |
< |
* If the cutoffRadius was explicitly set, use that value. |
702 |
< |
* If the cutoffRadius was not explicitly set: |
703 |
< |
* Are there electrostatic atoms? Use 12.0 Angstroms. |
704 |
< |
* No electrostatic atoms? Poll the atom types present in the |
705 |
< |
* simulation for suggested cutoff values (e.g. 2.5 * sigma). |
706 |
< |
* Use the maximum suggested value that was found. |
707 |
< |
*/ |
708 |
< |
void SimInfo::setupCutoffRadius() { |
709 |
> |
// loop over the found atom types on this processor, and add their |
710 |
> |
// numerical idents to a vector: |
711 |
|
|
712 |
< |
if (simParams_->haveCutoffRadius()) { |
713 |
< |
cutoffRadius_ = simParams_->getCutoffRadius(); |
714 |
< |
} else { |
715 |
< |
if (usesElectrostaticAtoms_) { |
714 |
< |
sprintf(painCave.errMsg, |
715 |
< |
"SimInfo Warning: No value was set for the cutoffRadius.\n" |
716 |
< |
"\tOpenMD will use a default value of 12.0 angstroms" |
717 |
< |
"\tfor the cutoffRadius.\n"); |
718 |
< |
painCave.isFatal = 0; |
719 |
< |
simError(); |
720 |
< |
cutoffRadius_ = 12.0; |
721 |
< |
} else { |
722 |
< |
RealType thisCut; |
723 |
< |
set<AtomType*>::iterator i; |
724 |
< |
set<AtomType*> atomTypes; |
725 |
< |
atomTypes = getSimulatedAtomTypes(); |
726 |
< |
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) { |
727 |
< |
thisCut = InteractionManager::Instance()->getSuggestedCutoffRadius((*i)); |
728 |
< |
cutoffRadius_ = max(thisCut, cutoffRadius_); |
729 |
< |
} |
730 |
< |
sprintf(painCave.errMsg, |
731 |
< |
"SimInfo Warning: No value was set for the cutoffRadius.\n" |
732 |
< |
"\tOpenMD will use %lf angstroms.\n", |
733 |
< |
cutoffRadius_); |
734 |
< |
painCave.isFatal = 0; |
735 |
< |
simError(); |
736 |
< |
} |
737 |
< |
} |
712 |
> |
vector<int> foundTypes; |
713 |
> |
set<AtomType*>::iterator i; |
714 |
> |
for (i = atomTypes.begin(); i != atomTypes.end(); ++i) |
715 |
> |
foundTypes.push_back( (*i)->getIdent() ); |
716 |
|
|
717 |
< |
InteractionManager::Instance()->setCutoffRadius(cutoffRadius_); |
718 |
< |
} |
717 |
> |
// count_local holds the number of found types on this processor |
718 |
> |
int count_local = foundTypes.size(); |
719 |
> |
|
720 |
> |
int nproc = MPI::COMM_WORLD.Get_size(); |
721 |
> |
|
722 |
> |
// we need arrays to hold the counts and displacement vectors for |
723 |
> |
// all processors |
724 |
> |
vector<int> counts(nproc, 0); |
725 |
> |
vector<int> disps(nproc, 0); |
726 |
> |
|
727 |
> |
// fill the counts array |
728 |
> |
MPI::COMM_WORLD.Allgather(&count_local, 1, MPI::INT, &counts[0], |
729 |
> |
1, MPI::INT); |
730 |
|
|
731 |
< |
/** |
732 |
< |
* setupSwitchingRadius |
733 |
< |
* |
734 |
< |
* If the switchingRadius was explicitly set, use that value (but check it) |
735 |
< |
* If the switchingRadius was not explicitly set: use 0.85 * cutoffRadius_ |
736 |
< |
*/ |
737 |
< |
void SimInfo::setupSwitchingRadius() { |
731 |
> |
// use the processor counts to compute the displacement array |
732 |
> |
disps[0] = 0; |
733 |
> |
int totalCount = counts[0]; |
734 |
> |
for (int iproc = 1; iproc < nproc; iproc++) { |
735 |
> |
disps[iproc] = disps[iproc-1] + counts[iproc-1]; |
736 |
> |
totalCount += counts[iproc]; |
737 |
> |
} |
738 |
> |
|
739 |
> |
// we need a (possibly redundant) set of all found types: |
740 |
> |
vector<int> ftGlobal(totalCount); |
741 |
|
|
742 |
< |
if (simParams_->haveSwitchingRadius()) { |
743 |
< |
switchingRadius_ = simParams_->getSwitchingRadius(); |
744 |
< |
if (switchingRadius_ > cutoffRadius_) { |
745 |
< |
sprintf(painCave.errMsg, |
754 |
< |
"SimInfo Error: switchingRadius (%f) is larger than cutoffRadius(%f)\n", |
755 |
< |
switchingRadius_, cutoffRadius_); |
756 |
< |
painCave.isFatal = 1; |
757 |
< |
simError(); |
742 |
> |
// now spray out the foundTypes to all the other processors: |
743 |
> |
MPI::COMM_WORLD.Allgatherv(&foundTypes[0], count_local, MPI::INT, |
744 |
> |
&ftGlobal[0], &counts[0], &disps[0], |
745 |
> |
MPI::INT); |
746 |
|
|
747 |
< |
} |
760 |
< |
} else { |
761 |
< |
switchingRadius_ = 0.85 * cutoffRadius_; |
762 |
< |
sprintf(painCave.errMsg, |
763 |
< |
"SimInfo Warning: No value was set for the switchingRadius.\n" |
764 |
< |
"\tOpenMD will use a default value of 85 percent of the cutoffRadius.\n" |
765 |
< |
"\tswitchingRadius = %f. for this simulation\n", switchingRadius_); |
766 |
< |
painCave.isFatal = 0; |
767 |
< |
simError(); |
768 |
< |
} |
769 |
< |
InteractionManager::Instance()->setSwitchingRadius(switchingRadius_); |
770 |
< |
} |
747 |
> |
vector<int>::iterator j; |
748 |
|
|
749 |
< |
/** |
750 |
< |
* setupSkinThickness |
751 |
< |
* |
752 |
< |
* If the skinThickness was explicitly set, use that value (but check it) |
753 |
< |
* If the skinThickness was not explicitly set: use 1.0 angstroms |
754 |
< |
*/ |
755 |
< |
void SimInfo::setupSkinThickness() { |
756 |
< |
if (simParams_->haveSkinThickness()) { |
757 |
< |
skinThickness_ = simParams_->getSkinThickness(); |
758 |
< |
} else { |
759 |
< |
skinThickness_ = 1.0; |
760 |
< |
sprintf(painCave.errMsg, |
761 |
< |
"SimInfo Warning: No value was set for the skinThickness.\n" |
762 |
< |
"\tOpenMD will use a default value of %f Angstroms\n" |
763 |
< |
"\tfor this simulation\n", skinThickness_); |
764 |
< |
painCave.isFatal = 0; |
788 |
< |
simError(); |
789 |
< |
} |
749 |
> |
// foundIdents is a stl set, so inserting an already found ident |
750 |
> |
// will have no effect. |
751 |
> |
set<int> foundIdents; |
752 |
> |
|
753 |
> |
for (j = ftGlobal.begin(); j != ftGlobal.end(); ++j) |
754 |
> |
foundIdents.insert((*j)); |
755 |
> |
|
756 |
> |
// now iterate over the foundIdents and get the actual atom types |
757 |
> |
// that correspond to these: |
758 |
> |
set<int>::iterator it; |
759 |
> |
for (it = foundIdents.begin(); it != foundIdents.end(); ++it) |
760 |
> |
atomTypes.insert( forceField_->getAtomType((*it)) ); |
761 |
> |
|
762 |
> |
#endif |
763 |
> |
|
764 |
> |
return atomTypes; |
765 |
|
} |
766 |
|
|
767 |
< |
void SimInfo::setupSimType() { |
767 |
> |
void SimInfo::setupSimVariables() { |
768 |
> |
useAtomicVirial_ = simParams_->getUseAtomicVirial(); |
769 |
> |
// we only call setAccumulateBoxDipole if the accumulateBoxDipole parameter is true |
770 |
> |
calcBoxDipole_ = false; |
771 |
> |
if ( simParams_->haveAccumulateBoxDipole() ) |
772 |
> |
if ( simParams_->getAccumulateBoxDipole() ) { |
773 |
> |
calcBoxDipole_ = true; |
774 |
> |
} |
775 |
> |
|
776 |
|
set<AtomType*>::iterator i; |
777 |
|
set<AtomType*> atomTypes; |
778 |
< |
atomTypes = getSimulatedAtomTypes(); |
796 |
< |
|
797 |
< |
useAtomicVirial_ = simParams_->getUseAtomicVirial(); |
798 |
< |
|
778 |
> |
atomTypes = getSimulatedAtomTypes(); |
779 |
|
int usesElectrostatic = 0; |
780 |
|
int usesMetallic = 0; |
781 |
|
int usesDirectional = 0; |
785 |
|
usesMetallic |= (*i)->isMetal(); |
786 |
|
usesDirectional |= (*i)->isDirectional(); |
787 |
|
} |
788 |
< |
|
788 |
> |
|
789 |
|
#ifdef IS_MPI |
790 |
|
int temp; |
791 |
|
temp = usesDirectional; |
792 |
|
MPI_Allreduce(&temp, &usesDirectionalAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
793 |
< |
|
793 |
> |
|
794 |
|
temp = usesMetallic; |
795 |
|
MPI_Allreduce(&temp, &usesMetallicAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
796 |
< |
|
796 |
> |
|
797 |
|
temp = usesElectrostatic; |
798 |
|
MPI_Allreduce(&temp, &usesElectrostaticAtoms_, 1, MPI_INT, MPI_LOR, MPI_COMM_WORLD); |
799 |
+ |
#else |
800 |
+ |
|
801 |
+ |
usesDirectionalAtoms_ = usesDirectional; |
802 |
+ |
usesMetallicAtoms_ = usesMetallic; |
803 |
+ |
usesElectrostaticAtoms_ = usesElectrostatic; |
804 |
+ |
|
805 |
|
#endif |
806 |
< |
fInfo_.SIM_uses_PBC = usesPeriodicBoundaries_; |
807 |
< |
fInfo_.SIM_uses_DirectionalAtoms = usesDirectionalAtoms_; |
808 |
< |
fInfo_.SIM_uses_MetallicAtoms = usesMetallicAtoms_; |
809 |
< |
fInfo_.SIM_requires_SkipCorrection = usesElectrostaticAtoms_; |
824 |
< |
fInfo_.SIM_requires_SelfCorrection = usesElectrostaticAtoms_; |
825 |
< |
fInfo_.SIM_uses_AtomicVirial = usesAtomicVirial_; |
806 |
> |
|
807 |
> |
requiresPrepair_ = usesMetallicAtoms_ ? true : false; |
808 |
> |
requiresSkipCorrection_ = usesElectrostaticAtoms_ ? true : false; |
809 |
> |
requiresSelfCorrection_ = usesElectrostaticAtoms_ ? true : false; |
810 |
|
} |
811 |
|
|
812 |
< |
void SimInfo::setupFortranSim() { |
813 |
< |
int isError; |
814 |
< |
int nExclude, nOneTwo, nOneThree, nOneFour; |
815 |
< |
vector<int> fortranGlobalGroupMembership; |
812 |
> |
|
813 |
> |
vector<int> SimInfo::getGlobalAtomIndices() { |
814 |
> |
SimInfo::MoleculeIterator mi; |
815 |
> |
Molecule* mol; |
816 |
> |
Molecule::AtomIterator ai; |
817 |
> |
Atom* atom; |
818 |
> |
|
819 |
> |
vector<int> GlobalAtomIndices(getNAtoms(), 0); |
820 |
|
|
821 |
< |
notifyFortranSkinThickness(&skinThickness_); |
821 |
> |
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
822 |
> |
|
823 |
> |
for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
824 |
> |
GlobalAtomIndices[atom->getLocalIndex()] = atom->getGlobalIndex(); |
825 |
> |
} |
826 |
> |
} |
827 |
> |
return GlobalAtomIndices; |
828 |
> |
} |
829 |
|
|
835 |
– |
int ljsp = cutoffMethod_ == SHIFTED_POTENTIAL ? 1 : 0; |
836 |
– |
int ljsf = cutoffMethod_ == SHIFTED_FORCE ? 1 : 0; |
837 |
– |
notifyFortranCutoffs(&cutoffRadius_, &switchingRadius_, &ljsp, &ljsf); |
830 |
|
|
831 |
< |
isError = 0; |
831 |
> |
vector<int> SimInfo::getGlobalGroupIndices() { |
832 |
> |
SimInfo::MoleculeIterator mi; |
833 |
> |
Molecule* mol; |
834 |
> |
Molecule::CutoffGroupIterator ci; |
835 |
> |
CutoffGroup* cg; |
836 |
|
|
837 |
< |
//globalGroupMembership_ is filled by SimCreator |
838 |
< |
for (int i = 0; i < nGlobalAtoms_; i++) { |
839 |
< |
fortranGlobalGroupMembership.push_back(globalGroupMembership_[i] + 1); |
837 |
> |
vector<int> GlobalGroupIndices; |
838 |
> |
|
839 |
> |
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
840 |
> |
|
841 |
> |
//local index of cutoff group is trivial, it only depends on the |
842 |
> |
//order of travesing |
843 |
> |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; |
844 |
> |
cg = mol->nextCutoffGroup(ci)) { |
845 |
> |
GlobalGroupIndices.push_back(cg->getGlobalIndex()); |
846 |
> |
} |
847 |
|
} |
848 |
+ |
return GlobalGroupIndices; |
849 |
+ |
} |
850 |
|
|
851 |
+ |
|
852 |
+ |
void SimInfo::prepareTopology() { |
853 |
+ |
int nExclude, nOneTwo, nOneThree, nOneFour; |
854 |
+ |
|
855 |
|
//calculate mass ratio of cutoff group |
847 |
– |
vector<RealType> mfact; |
856 |
|
SimInfo::MoleculeIterator mi; |
857 |
|
Molecule* mol; |
858 |
|
Molecule::CutoffGroupIterator ci; |
861 |
|
Atom* atom; |
862 |
|
RealType totalMass; |
863 |
|
|
864 |
< |
//to avoid memory reallocation, reserve enough space for mfact |
865 |
< |
mfact.reserve(getNCutoffGroups()); |
864 |
> |
/** |
865 |
> |
* The mass factor is the relative mass of an atom to the total |
866 |
> |
* mass of the cutoff group it belongs to. By default, all atoms |
867 |
> |
* are their own cutoff groups, and therefore have mass factors of |
868 |
> |
* 1. We need some special handling for massless atoms, which |
869 |
> |
* will be treated as carrying the entire mass of the cutoff |
870 |
> |
* group. |
871 |
> |
*/ |
872 |
> |
massFactors_.clear(); |
873 |
> |
massFactors_.resize(getNAtoms(), 1.0); |
874 |
|
|
875 |
|
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
876 |
< |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
876 |
> |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; |
877 |
> |
cg = mol->nextCutoffGroup(ci)) { |
878 |
|
|
879 |
|
totalMass = cg->getMass(); |
880 |
|
for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
881 |
|
// Check for massless groups - set mfact to 1 if true |
882 |
< |
if (totalMass != 0) |
883 |
< |
mfact.push_back(atom->getMass()/totalMass); |
882 |
> |
if (totalMass != 0) |
883 |
> |
massFactors_[atom->getLocalIndex()] = atom->getMass()/totalMass; |
884 |
|
else |
885 |
< |
mfact.push_back( 1.0 ); |
885 |
> |
massFactors_[atom->getLocalIndex()] = 1.0; |
886 |
|
} |
887 |
|
} |
888 |
|
} |
889 |
|
|
890 |
< |
//fill ident array of local atoms (it is actually ident of AtomType, it is so confusing !!!) |
874 |
< |
vector<int> identArray; |
890 |
> |
// Build the identArray_ |
891 |
|
|
892 |
< |
//to avoid memory reallocation, reserve enough space identArray |
893 |
< |
identArray.reserve(getNAtoms()); |
878 |
< |
|
892 |
> |
identArray_.clear(); |
893 |
> |
identArray_.reserve(getNAtoms()); |
894 |
|
for(mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
895 |
|
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
896 |
< |
identArray.push_back(atom->getIdent()); |
896 |
> |
identArray_.push_back(atom->getIdent()); |
897 |
|
} |
898 |
|
} |
884 |
– |
|
885 |
– |
//fill molMembershipArray |
886 |
– |
//molMembershipArray is filled by SimCreator |
887 |
– |
vector<int> molMembershipArray(nGlobalAtoms_); |
888 |
– |
for (int i = 0; i < nGlobalAtoms_; i++) { |
889 |
– |
molMembershipArray[i] = globalMolMembership_[i] + 1; |
890 |
– |
} |
899 |
|
|
900 |
< |
//setup fortran simulation |
900 |
> |
//scan topology |
901 |
|
|
902 |
|
nExclude = excludedInteractions_.getSize(); |
903 |
|
nOneTwo = oneTwoInteractions_.getSize(); |
909 |
|
int* oneThreeList = oneThreeInteractions_.getPairList(); |
910 |
|
int* oneFourList = oneFourInteractions_.getPairList(); |
911 |
|
|
912 |
< |
setFortranSim( &fInfo_, &nGlobalAtoms_, &nAtoms_, &identArray[0], |
905 |
< |
&nExclude, excludeList, |
906 |
< |
&nOneTwo, oneTwoList, |
907 |
< |
&nOneThree, oneThreeList, |
908 |
< |
&nOneFour, oneFourList, |
909 |
< |
&molMembershipArray[0], &mfact[0], &nCutoffGroups_, |
910 |
< |
&fortranGlobalGroupMembership[0], &isError); |
911 |
< |
|
912 |
< |
if( isError ){ |
913 |
< |
|
914 |
< |
sprintf( painCave.errMsg, |
915 |
< |
"There was an error setting the simulation information in fortran.\n" ); |
916 |
< |
painCave.isFatal = 1; |
917 |
< |
painCave.severity = OPENMD_ERROR; |
918 |
< |
simError(); |
919 |
< |
} |
920 |
< |
|
921 |
< |
|
922 |
< |
sprintf( checkPointMsg, |
923 |
< |
"succesfully sent the simulation information to fortran.\n"); |
924 |
< |
|
925 |
< |
errorCheckPoint(); |
926 |
< |
|
927 |
< |
// Setup number of neighbors in neighbor list if present |
928 |
< |
if (simParams_->haveNeighborListNeighbors()) { |
929 |
< |
int nlistNeighbors = simParams_->getNeighborListNeighbors(); |
930 |
< |
setNeighbors(&nlistNeighbors); |
931 |
< |
} |
932 |
< |
|
933 |
< |
|
934 |
< |
} |
935 |
< |
|
936 |
< |
|
937 |
< |
void SimInfo::setupFortranParallel() { |
938 |
< |
#ifdef IS_MPI |
939 |
< |
//SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex |
940 |
< |
vector<int> localToGlobalAtomIndex(getNAtoms(), 0); |
941 |
< |
vector<int> localToGlobalCutoffGroupIndex; |
942 |
< |
SimInfo::MoleculeIterator mi; |
943 |
< |
Molecule::AtomIterator ai; |
944 |
< |
Molecule::CutoffGroupIterator ci; |
945 |
< |
Molecule* mol; |
946 |
< |
Atom* atom; |
947 |
< |
CutoffGroup* cg; |
948 |
< |
mpiSimData parallelData; |
949 |
< |
int isError; |
950 |
< |
|
951 |
< |
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
952 |
< |
|
953 |
< |
//local index(index in DataStorge) of atom is important |
954 |
< |
for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
955 |
< |
localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1; |
956 |
< |
} |
957 |
< |
|
958 |
< |
//local index of cutoff group is trivial, it only depends on the order of travesing |
959 |
< |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
960 |
< |
localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1); |
961 |
< |
} |
962 |
< |
|
963 |
< |
} |
964 |
< |
|
965 |
< |
//fill up mpiSimData struct |
966 |
< |
parallelData.nMolGlobal = getNGlobalMolecules(); |
967 |
< |
parallelData.nMolLocal = getNMolecules(); |
968 |
< |
parallelData.nAtomsGlobal = getNGlobalAtoms(); |
969 |
< |
parallelData.nAtomsLocal = getNAtoms(); |
970 |
< |
parallelData.nGroupsGlobal = getNGlobalCutoffGroups(); |
971 |
< |
parallelData.nGroupsLocal = getNCutoffGroups(); |
972 |
< |
parallelData.myNode = worldRank; |
973 |
< |
MPI_Comm_size(MPI_COMM_WORLD, &(parallelData.nProcessors)); |
974 |
< |
|
975 |
< |
//pass mpiSimData struct and index arrays to fortran |
976 |
< |
setFsimParallel(¶llelData, &(parallelData.nAtomsLocal), |
977 |
< |
&localToGlobalAtomIndex[0], &(parallelData.nGroupsLocal), |
978 |
< |
&localToGlobalCutoffGroupIndex[0], &isError); |
979 |
< |
|
980 |
< |
if (isError) { |
981 |
< |
sprintf(painCave.errMsg, |
982 |
< |
"mpiRefresh errror: fortran didn't like something we gave it.\n"); |
983 |
< |
painCave.isFatal = 1; |
984 |
< |
simError(); |
985 |
< |
} |
986 |
< |
|
987 |
< |
sprintf(checkPointMsg, " mpiRefresh successful.\n"); |
988 |
< |
errorCheckPoint(); |
989 |
< |
|
990 |
< |
#endif |
991 |
< |
} |
992 |
< |
|
993 |
< |
|
994 |
< |
void SimInfo::setupSwitchingFunction() { |
995 |
< |
int ft = CUBIC; |
996 |
< |
|
997 |
< |
if (simParams_->haveSwitchingFunctionType()) { |
998 |
< |
string funcType = simParams_->getSwitchingFunctionType(); |
999 |
< |
toUpper(funcType); |
1000 |
< |
if (funcType == "CUBIC") { |
1001 |
< |
ft = CUBIC; |
1002 |
< |
} else { |
1003 |
< |
if (funcType == "FIFTH_ORDER_POLYNOMIAL") { |
1004 |
< |
ft = FIFTH_ORDER_POLY; |
1005 |
< |
} else { |
1006 |
< |
// throw error |
1007 |
< |
sprintf( painCave.errMsg, |
1008 |
< |
"SimInfo error: Unknown switchingFunctionType. (Input file specified %s .)\n\tswitchingFunctionType must be one of: \"cubic\" or \"fifth_order_polynomial\".", funcType.c_str() ); |
1009 |
< |
painCave.isFatal = 1; |
1010 |
< |
simError(); |
1011 |
< |
} |
1012 |
< |
} |
1013 |
< |
} |
1014 |
< |
|
1015 |
< |
// send switching function notification to switcheroo |
1016 |
< |
setFunctionType(&ft); |
1017 |
< |
|
912 |
> |
topologyDone_ = true; |
913 |
|
} |
914 |
|
|
1020 |
– |
void SimInfo::setupAccumulateBoxDipole() { |
1021 |
– |
|
1022 |
– |
// we only call setAccumulateBoxDipole if the accumulateBoxDipole parameter is true |
1023 |
– |
if ( simParams_->haveAccumulateBoxDipole() ) |
1024 |
– |
if ( simParams_->getAccumulateBoxDipole() ) { |
1025 |
– |
calcBoxDipole_ = true; |
1026 |
– |
} |
1027 |
– |
|
1028 |
– |
} |
1029 |
– |
|
915 |
|
void SimInfo::addProperty(GenericData* genData) { |
916 |
|
properties_.addProperty(genData); |
917 |
|
} |
946 |
|
Molecule* mol; |
947 |
|
RigidBody* rb; |
948 |
|
Atom* atom; |
949 |
+ |
CutoffGroup* cg; |
950 |
|
SimInfo::MoleculeIterator mi; |
951 |
|
Molecule::RigidBodyIterator rbIter; |
952 |
< |
Molecule::AtomIterator atomIter;; |
952 |
> |
Molecule::AtomIterator atomIter; |
953 |
> |
Molecule::CutoffGroupIterator cgIter; |
954 |
|
|
955 |
|
for (mol = beginMolecule(mi); mol != NULL; mol = nextMolecule(mi)) { |
956 |
|
|
960 |
|
|
961 |
|
for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { |
962 |
|
rb->setSnapshotManager(sman_); |
963 |
+ |
} |
964 |
+ |
|
965 |
+ |
for (cg = mol->beginCutoffGroup(cgIter); cg != NULL; cg = mol->nextCutoffGroup(cgIter)) { |
966 |
+ |
cg->setSnapshotManager(sman_); |
967 |
|
} |
968 |
|
} |
969 |
|
|