56 |
|
#include "brains/SimCreator.hpp" |
57 |
|
#include "brains/SimSnapshotManager.hpp" |
58 |
|
#include "io/DumpReader.hpp" |
59 |
< |
#include "UseTheForce/ForceFieldFactory.hpp" |
59 |
> |
#include "brains/ForceField.hpp" |
60 |
|
#include "utils/simError.h" |
61 |
|
#include "utils/StringUtils.hpp" |
62 |
|
#include "math/SeqRandNumGen.hpp" |
256 |
|
int metaDataBlockStart = -1; |
257 |
|
int metaDataBlockEnd = -1; |
258 |
|
int i; |
259 |
< |
int mdOffset; |
259 |
> |
streamoff mdOffset; |
260 |
|
int mdFileVersion; |
261 |
|
|
262 |
+ |
|
263 |
|
#ifdef IS_MPI |
264 |
|
const int masterNode = 0; |
265 |
|
if (worldRank == masterNode) { |
266 |
|
#endif |
267 |
|
|
268 |
< |
std::ifstream mdFile_(mdFileName.c_str()); |
268 |
> |
std::ifstream mdFile_; |
269 |
> |
mdFile_.open(mdFileName.c_str(), ifstream::in | ifstream::binary); |
270 |
|
|
271 |
|
if (mdFile_.fail()) { |
272 |
|
sprintf(painCave.errMsg, |
373 |
|
metaDataBlockStart + 1); |
374 |
|
|
375 |
|
//create the force field |
376 |
< |
ForceField * ff = ForceFieldFactory::getInstance()->createForceField(simParams->getForceField()); |
376 |
> |
ForceField * ff = new ForceField(simParams->getForceField()); |
377 |
|
|
378 |
|
if (ff == NULL) { |
379 |
|
sprintf(painCave.errMsg, |
427 |
|
//find the storage layout |
428 |
|
|
429 |
|
int storageLayout = computeStorageLayout(info); |
428 |
– |
|
429 |
– |
cerr << "computed Storage Layout = " << storageLayout << "\n"; |
430 |
|
|
431 |
|
//allocate memory for DataStorage(circular reference, need to |
432 |
|
//break it) |
669 |
|
|
670 |
|
int SimCreator::computeStorageLayout(SimInfo* info) { |
671 |
|
|
672 |
+ |
Globals* simParams = info->getSimParams(); |
673 |
|
int nRigidBodies = info->getNGlobalRigidBodies(); |
674 |
|
set<AtomType*> atomTypes = info->getSimulatedAtomTypes(); |
675 |
|
set<AtomType*>::iterator i; |
676 |
|
bool hasDirectionalAtoms = false; |
677 |
|
bool hasFixedCharge = false; |
678 |
< |
bool hasMultipoles = false; |
678 |
> |
bool hasDipoles = false; |
679 |
> |
bool hasQuadrupoles = false; |
680 |
|
bool hasPolarizable = false; |
681 |
|
bool hasFluctuatingCharge = false; |
682 |
|
bool hasMetallic = false; |
698 |
|
if (da.isDirectional()){ |
699 |
|
hasDirectionalAtoms = true; |
700 |
|
} |
701 |
< |
if (ma.isMultipole()){ |
702 |
< |
hasMultipoles = true; |
701 |
> |
if (ma.isDipole()){ |
702 |
> |
hasDipoles = true; |
703 |
|
} |
704 |
+ |
if (ma.isQuadrupole()){ |
705 |
+ |
hasQuadrupoles = true; |
706 |
+ |
} |
707 |
|
if (ea.isEAM() || sca.isSuttonChen()){ |
708 |
|
hasMetallic = true; |
709 |
|
} |
727 |
|
storageLayout |= DataStorage::dslTorque; |
728 |
|
} |
729 |
|
} |
730 |
< |
if (hasMultipoles) { |
731 |
< |
storageLayout |= DataStorage::dslElectroFrame; |
730 |
> |
if (hasDipoles) { |
731 |
> |
storageLayout |= DataStorage::dslDipole; |
732 |
|
} |
733 |
+ |
if (hasQuadrupoles) { |
734 |
+ |
storageLayout |= DataStorage::dslQuadrupole; |
735 |
+ |
} |
736 |
|
if (hasFixedCharge || hasFluctuatingCharge) { |
737 |
|
storageLayout |= DataStorage::dslSkippedCharge; |
738 |
|
} |
753 |
|
storageLayout |= DataStorage::dslFlucQForce; |
754 |
|
} |
755 |
|
} |
756 |
+ |
|
757 |
+ |
// if the user has asked for them, make sure we've got the memory for the |
758 |
+ |
// objects defined. |
759 |
+ |
|
760 |
+ |
if (simParams->getOutputParticlePotential()) { |
761 |
+ |
storageLayout |= DataStorage::dslParticlePot; |
762 |
+ |
} |
763 |
+ |
|
764 |
+ |
if (simParams->havePrintHeatFlux()) { |
765 |
+ |
if (simParams->getPrintHeatFlux()) { |
766 |
+ |
storageLayout |= DataStorage::dslParticlePot; |
767 |
+ |
} |
768 |
+ |
} |
769 |
+ |
|
770 |
+ |
if (simParams->getOutputElectricField()) { |
771 |
+ |
storageLayout |= DataStorage::dslElectricField; |
772 |
+ |
} |
773 |
+ |
|
774 |
+ |
if (simParams->getOutputFluctuatingCharges()) { |
775 |
+ |
storageLayout |= DataStorage::dslFlucQPosition; |
776 |
+ |
storageLayout |= DataStorage::dslFlucQVelocity; |
777 |
+ |
storageLayout |= DataStorage::dslFlucQForce; |
778 |
+ |
} |
779 |
+ |
|
780 |
|
return storageLayout; |
781 |
|
} |
782 |
|
|
796 |
|
int nGlobalAtoms = info->getNGlobalAtoms(); |
797 |
|
|
798 |
|
beginAtomIndex = 0; |
799 |
< |
beginRigidBodyIndex = 0; |
799 |
> |
//rigidbody's index begins right after atom's |
800 |
> |
beginRigidBodyIndex = info->getNGlobalAtoms(); |
801 |
|
beginCutoffGroupIndex = 0; |
802 |
|
|
803 |
|
for(int i = 0; i < info->getNGlobalMolecules(); i++) { |
915 |
|
for (mol = info->beginMolecule(mi); mol != NULL; mol = info->nextMolecule(mi)) { |
916 |
|
int myGlobalIndex = mol->getGlobalIndex(); |
917 |
|
int globalIO = startingIOIndexForMol[myGlobalIndex]; |
918 |
< |
for (StuntDouble* integrableObject = mol->beginIntegrableObject(ioi); integrableObject != NULL; |
919 |
< |
integrableObject = mol->nextIntegrableObject(ioi)) { |
920 |
< |
integrableObject->setGlobalIntegrableObjectIndex(globalIO); |
921 |
< |
IOIndexToIntegrableObject[globalIO] = integrableObject; |
918 |
> |
for (StuntDouble* sd = mol->beginIntegrableObject(ioi); sd != NULL; |
919 |
> |
sd = mol->nextIntegrableObject(ioi)) { |
920 |
> |
sd->setGlobalIntegrableObjectIndex(globalIO); |
921 |
> |
IOIndexToIntegrableObject[globalIO] = sd; |
922 |
|
globalIO++; |
923 |
|
} |
924 |
|
} |