1 |
|
/* |
2 |
< |
* copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
2 |
> |
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
|
* |
4 |
|
* The University of Notre Dame grants you ("Licensee") a |
5 |
|
* non-exclusive, royalty free, license to use, modify and |
46 |
|
* @date 11/03/2004 |
47 |
|
* @version 1.0 |
48 |
|
*/ |
49 |
+ |
|
50 |
+ |
#ifdef IS_MPI |
51 |
+ |
#include "mpi.h" |
52 |
+ |
#include "math/ParallelRandNumGen.hpp" |
53 |
+ |
#endif |
54 |
+ |
|
55 |
|
#include <exception> |
56 |
|
#include <iostream> |
57 |
|
#include <sstream> |
89 |
|
#include "types/FixedChargeAdapter.hpp" |
90 |
|
#include "types/FluctuatingChargeAdapter.hpp" |
91 |
|
|
86 |
– |
#ifdef IS_MPI |
87 |
– |
#include "mpi.h" |
88 |
– |
#include "math/ParallelRandNumGen.hpp" |
89 |
– |
#endif |
92 |
|
|
93 |
|
namespace OpenMD { |
94 |
|
|
106 |
|
MPI::COMM_WORLD.Bcast(&mdFileVersion, 1, MPI::INT, masterNode); |
107 |
|
#endif |
108 |
|
SimplePreprocessor preprocessor; |
109 |
< |
preprocessor.preprocess(rawMetaDataStream, filename, startOfMetaDataBlock, |
108 |
< |
ppStream); |
109 |
> |
preprocessor.preprocess(rawMetaDataStream, filename, startOfMetaDataBlock, ppStream); |
110 |
|
|
111 |
|
#ifdef IS_MPI |
112 |
|
//brocasting the stream size |
803 |
|
Molecule::AtomIterator ai; |
804 |
|
Molecule::RigidBodyIterator ri; |
805 |
|
Molecule::CutoffGroupIterator ci; |
806 |
+ |
Molecule::BondIterator boi; |
807 |
+ |
Molecule::BendIterator bei; |
808 |
+ |
Molecule::TorsionIterator ti; |
809 |
+ |
Molecule::InversionIterator ii; |
810 |
|
Molecule::IntegrableObjectIterator ioi; |
811 |
< |
Molecule * mol; |
812 |
< |
Atom * atom; |
813 |
< |
RigidBody * rb; |
814 |
< |
CutoffGroup * cg; |
811 |
> |
Molecule* mol; |
812 |
> |
Atom* atom; |
813 |
> |
RigidBody* rb; |
814 |
> |
CutoffGroup* cg; |
815 |
> |
Bond* bond; |
816 |
> |
Bend* bend; |
817 |
> |
Torsion* torsion; |
818 |
> |
Inversion* inversion; |
819 |
|
int beginAtomIndex; |
820 |
|
int beginRigidBodyIndex; |
821 |
|
int beginCutoffGroupIndex; |
822 |
+ |
int beginBondIndex; |
823 |
+ |
int beginBendIndex; |
824 |
+ |
int beginTorsionIndex; |
825 |
+ |
int beginInversionIndex; |
826 |
|
int nGlobalAtoms = info->getNGlobalAtoms(); |
827 |
|
int nGlobalRigidBodies = info->getNGlobalRigidBodies(); |
828 |
|
|
829 |
|
beginAtomIndex = 0; |
830 |
< |
//rigidbody's index begins right after atom's |
830 |
> |
// The rigid body indices begin immediately after the atom indices: |
831 |
|
beginRigidBodyIndex = info->getNGlobalAtoms(); |
832 |
|
beginCutoffGroupIndex = 0; |
833 |
< |
|
833 |
> |
beginBondIndex = 0; |
834 |
> |
beginBendIndex = 0; |
835 |
> |
beginTorsionIndex = 0; |
836 |
> |
beginInversionIndex = 0; |
837 |
> |
|
838 |
|
for(int i = 0; i < info->getNGlobalMolecules(); i++) { |
839 |
|
|
840 |
|
#ifdef IS_MPI |
843 |
|
// stuff to do if I own this molecule |
844 |
|
mol = info->getMoleculeByGlobalIndex(i); |
845 |
|
|
846 |
< |
//local index(index in DataStorge) of atom is important |
847 |
< |
for(atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) { |
846 |
> |
// The local index(index in DataStorge) of the atom is important: |
847 |
> |
for(atom = mol->beginAtom(ai); atom != NULL; |
848 |
> |
atom = mol->nextAtom(ai)) { |
849 |
|
atom->setGlobalIndex(beginAtomIndex++); |
850 |
|
} |
851 |
|
|
854 |
|
rb->setGlobalIndex(beginRigidBodyIndex++); |
855 |
|
} |
856 |
|
|
857 |
< |
//local index of cutoff group is trivial, it only depends on |
858 |
< |
//the order of travesing |
857 |
> |
// The local index of other objects only depends on the order |
858 |
> |
// of traversal: |
859 |
|
for(cg = mol->beginCutoffGroup(ci); cg != NULL; |
860 |
|
cg = mol->nextCutoffGroup(ci)) { |
861 |
|
cg->setGlobalIndex(beginCutoffGroupIndex++); |
862 |
|
} |
863 |
+ |
for(bond = mol->beginBond(boi); bond != NULL; |
864 |
+ |
bond = mol->nextBond(boi)) { |
865 |
+ |
bond->setGlobalIndex(beginBondIndex++); |
866 |
+ |
} |
867 |
+ |
for(bend = mol->beginBend(bei); bend != NULL; |
868 |
+ |
bend = mol->nextBend(bei)) { |
869 |
+ |
bend->setGlobalIndex(beginBendIndex++); |
870 |
+ |
} |
871 |
+ |
for(torsion = mol->beginTorsion(ti); torsion != NULL; |
872 |
+ |
torsion = mol->nextTorsion(ti)) { |
873 |
+ |
torsion->setGlobalIndex(beginTorsionIndex++); |
874 |
+ |
} |
875 |
+ |
for(inversion = mol->beginInversion(ii); inversion != NULL; |
876 |
+ |
inversion = mol->nextInversion(ii)) { |
877 |
+ |
inversion->setGlobalIndex(beginInversionIndex++); |
878 |
+ |
} |
879 |
|
|
880 |
|
#ifdef IS_MPI |
881 |
|
} else { |
888 |
|
beginAtomIndex += stamp->getNAtoms(); |
889 |
|
beginRigidBodyIndex += stamp->getNRigidBodies(); |
890 |
|
beginCutoffGroupIndex += stamp->getNCutoffGroups() + stamp->getNFreeAtoms(); |
891 |
+ |
beginBondIndex += stamp->getNBonds(); |
892 |
+ |
beginBendIndex += stamp->getNBends(); |
893 |
+ |
beginTorsionIndex += stamp->getNTorsions(); |
894 |
+ |
beginInversionIndex += stamp->getNInversions(); |
895 |
|
} |
896 |
|
#endif |
897 |
|
|
899 |
|
|
900 |
|
//fill globalGroupMembership |
901 |
|
std::vector<int> globalGroupMembership(info->getNGlobalAtoms(), 0); |
902 |
< |
for(mol = info->beginMolecule(mi); mol != NULL; mol = info->nextMolecule(mi)) { |
903 |
< |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) { |
904 |
< |
|
902 |
> |
for(mol = info->beginMolecule(mi); mol != NULL; |
903 |
> |
mol = info->nextMolecule(mi)) { |
904 |
> |
for (cg = mol->beginCutoffGroup(ci); cg != NULL; |
905 |
> |
cg = mol->nextCutoffGroup(ci)) { |
906 |
|
for(atom = cg->beginAtom(ai); atom != NULL; atom = cg->nextAtom(ai)) { |
907 |
|
globalGroupMembership[atom->getGlobalIndex()] = cg->getGlobalIndex(); |
908 |
|
} |