--- trunk/OOPSE/libmdtools/SimInfo.cpp 2004/05/11 16:00:22 1154 +++ trunk/OOPSE/libmdtools/SimInfo.cpp 2004/06/01 18:42:58 1214 @@ -62,7 +62,11 @@ SimInfo::SimInfo(){ useReactionField = 0; useGB = 0; useEAM = 0; + useSolidThermInt = 0; + useLiquidThermInt = 0; + haveCutoffGroups = false; + excludes = Exclude::Instance(); myConfiguration = new SimState(); @@ -442,18 +446,20 @@ 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 ){ @@ -561,67 +567,52 @@ 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; - - mfact.clear(); - groupList.clear(); - groupStart.clear(); + int numMol; + int numCutoffGroups; + CutoffGroup* myCutoffGroup; + vector::iterator iterCutoff; + Atom* cutoffAtom; + vector::iterator iterAtom; + int atomIndex; + double totalMass; - //Be careful, fortran array begin at 1 - curIndex = 1; + mfact.clear(); + FglobalGroupMembership.clear(); - 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) - + }