--- trunk/OOPSE/libmdtools/SimInfo.cpp 2004/05/11 16:00:22 1154 +++ trunk/OOPSE/libmdtools/SimInfo.cpp 2004/06/04 03:15:31 1234 @@ -14,6 +14,8 @@ using namespace std; #include "MatVec3.h" +#include "ConstraintManager.hpp" + #ifdef IS_MPI #include "mpiSimulation.hpp" #endif @@ -62,7 +64,11 @@ SimInfo::SimInfo(){ useReactionField = 0; useGB = 0; useEAM = 0; + useSolidThermInt = 0; + useLiquidThermInt = 0; + haveCutoffGroups = false; + excludes = Exclude::Instance(); myConfiguration = new SimState(); @@ -72,6 +78,8 @@ SimInfo::SimInfo(){ ngroup = 0; + consMan = NULL; + wrapMeSimInfo( this ); } @@ -84,7 +92,9 @@ SimInfo::~SimInfo(){ for(i = properties.begin(); i != properties.end(); i++) delete (*i).second; - + + if (!consMan) + delete consMan; } void SimInfo::setBox(double newBox[3]) { @@ -187,7 +197,7 @@ void SimInfo::calcHmatInv( void ) { if( oldOrtho != orthoRhombic ){ - if( orthoRhombic ){ + if( orthoRhombic ) { sprintf( painCave.errMsg, "OOPSE is switching from the default Non-Orthorhombic\n" "\tto the faster Orthorhombic periodic boundary computations.\n" @@ -195,6 +205,7 @@ void SimInfo::calcHmatInv( void ) { "\tNon-Orthorhombic computations, make the orthoBoxTolerance\n" "\tvariable ( currently set to %G ) smaller.\n", orthoTolerance); + painCave.severity = OOPSE_INFO; simError(); } else { @@ -206,6 +217,7 @@ void SimInfo::calcHmatInv( void ) { "\tthe Orthorhombic computations, make the orthoBoxTolerance\n" "\tvariable ( currently set to %G ) larger.\n", orthoTolerance); + painCave.severity = OOPSE_WARNING; simError(); } } @@ -442,24 +454,27 @@ void SimInfo::refreshSim(){ excl = excludes->getFortranArray(); #ifdef IS_MPI - n_global = mpiSim->getTotAtoms(); + n_global = mpiSim->getNAtomsGlobal(); #else n_global = n_atoms; #endif isError = 0; - getFortranGroupArray(this, mfact, ngroup, groupList, groupStart); - + getFortranGroupArrays(this, FglobalGroupMembership, mfact); + //it may not be a good idea to pass the address of first element in vector + //since c++ standard does not require vector to be stored continuously in meomory + //Most of the compilers will organize the memory of vector continuously setFsimulation( &fInfo, &n_global, &n_atoms, identArray, &n_exclude, excl, &nGlobalExcludes, globalExcludes, molMembershipArray, - &mfact[0], &ngroup, &groupList[0], &groupStart[0], &isError); - + &mfact[0], &ngroup, &FglobalGroupMembership[0], &isError); + if( isError ){ sprintf( painCave.errMsg, "There was an error setting the simulation information in fortran.\n" ); painCave.isFatal = 1; + painCave.severity = OOPSE_ERROR; simError(); } @@ -510,6 +525,7 @@ void SimInfo::checkCutOffs( void ){ Hmat[0][0], Hmat[0][1], Hmat[0][2], Hmat[1][0], Hmat[1][1], Hmat[1][2], Hmat[2][0], Hmat[2][1], Hmat[2][2]); + painCave.severity = OOPSE_ERROR; painCave.isFatal = 1; simError(); } @@ -518,6 +534,7 @@ void SimInfo::checkCutOffs( void ){ sprintf( painCave.errMsg, "Trying to check cutoffs without a box.\n" "\tOOPSE should have better programmers than that.\n" ); + painCave.severity = OOPSE_ERROR; painCave.isFatal = 1; simError(); } @@ -561,67 +578,53 @@ GenericData* SimInfo::getProperty(const string& propNa } -void getFortranGroupArray(SimInfo* info, vector& mfact, int& ngroup, - vector& groupList, vector& groupStart){ - Molecule* mol; +void SimInfo::getFortranGroupArrays(SimInfo* info, + vector& FglobalGroupMembership, + vector& mfact){ + + Molecule* myMols; Atom** myAtoms; int numAtom; - int curIndex; double mtot; - + int numMol; + int numCutoffGroups; + CutoffGroup* myCutoffGroup; + vector::iterator iterCutoff; + Atom* cutoffAtom; + vector::iterator iterAtom; + int atomIndex; + double totalMass; + mfact.clear(); - groupList.clear(); - groupStart.clear(); + FglobalGroupMembership.clear(); - //Be careful, fortran array begin at 1 - curIndex = 1; - - if(info->useMolecularCutoffs){ - + + // Fix the silly fortran indexing problem #ifdef IS_MPI - ngroup = mpiSim->getMyNMol(); + numAtom = mpiSim->getNAtomsGlobal(); #else - ngroup = info->n_mol; + numAtom = n_atoms; #endif - - for(int i = 0; i < ngroup; i ++){ - mol = &(info->molecules[i]); - numAtom = mol->getNAtoms(); - myAtoms = mol->getMyAtoms(); - mtot = 0.0; + for (int i = 0; i < numAtom; i++) + FglobalGroupMembership.push_back(globalGroupMembership[i] + 1); + - for(int j=0; j < numAtom; j++) - mtot += myAtoms[j]->getMass(); - - for(int j=0; j < numAtom; j++){ - - // We want the local Index: - groupList.push_back(myAtoms[j]->getIndex() + 1); - mfact.push_back(myAtoms[j]->getMass() / mtot); + myMols = info->molecules; + numMol = info->n_mol; + for(int i = 0; i < numMol; i++){ + numCutoffGroups = myMols[i].getNCutoffGroups(); + for(myCutoffGroup =myMols[i].beginCutoffGroup(iterCutoff); + myCutoffGroup != NULL; + myCutoffGroup =myMols[i].nextCutoffGroup(iterCutoff)){ - } + totalMass = myCutoffGroup->getMass(); - groupStart.push_back(curIndex); - curIndex += numAtom; - - } //end for(int i =0 ; i < ngroup; i++) + for(cutoffAtom = myCutoffGroup->beginAtom(iterAtom); + cutoffAtom != NULL; + cutoffAtom = myCutoffGroup->nextAtom(iterAtom)){ + mfact.push_back(cutoffAtom->getMass()/totalMass); + } + } } - else{ - //using atomic cutoff, every single atom is just a group - -#ifdef IS_MPI - ngroup = mpiSim->getMyNlocal(); -#else - ngroup = info->n_atoms; -#endif - - for(int i =0 ; i < ngroup; i++){ - groupStart.push_back(curIndex++); - groupList.push_back((info->atoms[i])->getIndex() + 1); - mfact.push_back(1.0); - - }//end for(int i =0 ; i < ngroup; i++) - - }//end if (info->useMolecularCutoffs) - + }