--- trunk/OOPSE/libmdtools/SimInfo.cpp 2004/05/01 18:52:38 1144 +++ trunk/OOPSE/libmdtools/SimInfo.cpp 2004/05/07 21:35:05 1150 @@ -448,41 +448,41 @@ void SimInfo::refreshSim(){ #else n_global = n_atoms; #endif - + isError = 0; - - getFortranGroupArray(this, mfact, ngroup, groupList, groupStart); - + + getFortranGroupArray(this, mfact, ngroup, groupList, groupStart); + setFsimulation( &fInfo, &n_global, &n_atoms, identArray, &n_exclude, excl, - &nGlobalExcludes, globalExcludes, molMembershipArray, - &mfact[0], &ngroup, &groupList[0], &groupStart[0], &isError ); - - if( isError ){ - + &nGlobalExcludes, globalExcludes, molMembershipArray, + &mfact[0], &ngroup, &groupList[0], &groupStart[0], &isError); + + if( isError ){ + sprintf( painCave.errMsg, - "There was an error setting the simulation information in fortran.\n" ); + "There was an error setting the simulation information in fortran.\n" ); painCave.isFatal = 1; simError(); } - + #ifdef IS_MPI sprintf( checkPointMsg, "succesfully sent the simulation information to fortran.\n"); MPIcheckPoint(); #endif // is_mpi - + this->ndf = this->getNDF(); this->ndfRaw = this->getNDFraw(); this->ndfTrans = this->getNDFtranslational(); } void SimInfo::setDefaultRcut( double theRcut ){ - + haveRcut = 1; rCut = theRcut; - + ( rCut > ecr )? rList = rCut + 1.0: rList = ecr + 1.0; - + notifyFortranCutOffs( &rCut, &rList, &ecr, &est ); } @@ -596,53 +596,66 @@ void getFortranGroupArray(SimInfo* info, vector& mfact, int& ngroup, - vector& groupList, vector& groupStart){ + vector& groupList, vector& groupStart){ Molecule* mol; + Atom** myAtoms; int numAtom; int curIndex; + double mtot; mfact.clear(); groupList.clear(); groupStart.clear(); - + //Be careful, fortran array begin at 1 curIndex = 1; - + if(info->useMolecularCutoffs){ - //if using molecular cutoff + +#ifdef IS_MPI + ngroup = mpiSim->getMyNMol(); +#else ngroup = info->n_mol; - +#endif + for(int i = 0; i < ngroup; i ++){ mol = &(info->molecules[i]); numAtom = mol->getNAtoms(); + myAtoms = mol->getMyAtoms(); + mtot = 0.0; + + for(int j=0; j < numAtom; j++) + mtot += myAtoms[j]->getMass(); - for(int j=0; j < numAtom; j++){ -#ifdef IS_MPI - groupList.push_back((info->atoms[i])->getGlobalIndex() + 1); -#else - groupList.push_back((info->atoms[i])->getIndex() + 1); -#endif - }//for(int j=0; j < numAtom; j++) - + 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); + + } + groupStart.push_back(curIndex); curIndex += numAtom; - }//end for(int i =0 ; i < ngroup; i++) + } //end for(int i =0 ; i < ngroup; i++) } else{ //using atomic cutoff, every single atom is just a group - ngroup = info->n_atoms; - for(int i =0 ; i < ngroup; i++){ - groupStart.push_back(curIndex++); - + #ifdef IS_MPI - groupList.push_back((info->atoms[i])->getGlobalIndex() + 1); + ngroup = mpiSim->getMyNlocal(); #else - groupList.push_back((info->atoms[i])->getIndex() + 1); + 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) - + }