--- trunk/mdtools/interface_implementation/SimSetup.cpp 2002/12/10 21:41:26 202 +++ trunk/mdtools/interface_implementation/SimSetup.cpp 2002/12/11 20:39:41 205 @@ -240,9 +240,10 @@ void SimSetup::createSim( void ){ // set up the local variables - int localMol; + int localMol, allMol; int local_atoms, local_bonds, local_bends, local_torsions, local_SRI; + allMol = 0; localMol = 0; local_atoms = 0; local_bonds = 0; @@ -252,8 +253,8 @@ void SimSetup::createSim( void ){ for( j=0; jgetMyMolStart() <= j && - j <= mpiSim->getMyMolEnd() ){ + if( mpiSim->getMyMolStart() <= allMol && + allMol <= mpiSim->getMyMolEnd() ){ local_atoms += comp_stamps[i]->getNAtoms(); local_bonds += comp_stamps[i]->getNBonds(); @@ -261,14 +262,34 @@ void SimSetup::createSim( void ){ local_torsions += comp_stamps[i]->getNTorsions(); localMol++; } + allMol++; } } - + local_SRI = local_bonds + local_bends + local_torsions; simnfo->n_atoms = mpiSim->getMyNlocal(); + if( local_atoms != simnfo->n_atoms ){ + sprintf( painCave.errMsg, + "SimSetup error: mpiSim's localAtom (%d) and SimSetup's" + " localAtom (%d) are note equal.\n", + simnfo->n_atoms, + local_atoms ); + painCave.isFatal = 1; + simError(); + } + simnfo->n_bonds = local_bonds; + simnfo->n_bends = local_bends; + simnfo->n_torsions = local_torsions; + simnfo->n_SRI = local_SRI; + simnfo->n_mol = localMol; + + strcpy( checkPointMsg, "Passed nlocal consistency check." ); + MPIcheckPoint(); + + #endif // is_mpi @@ -544,58 +565,68 @@ void SimSetup::makeAtoms( void ){ double ux, uy, uz, uSqr, u; AtomStamp* current_atom; DirectionalAtom* dAtom; - int molIndex, molStart, molEnd, nMemb; + int molIndex, molStart, molEnd, nMemb, lMolIndex; - + lMolIndex = 0; molIndex = 0; index = 0; for( i=0; igetNAtoms(); - for( k=0; kgetNAtoms(); k++ ){ - - current_atom = comp_stamps[i]->getAtom( k ); - if( current_atom->haveOrientation() ){ - - dAtom = new DirectionalAtom(index); - simnfo->n_oriented++; - the_atoms[index] = dAtom; - - ux = current_atom->getOrntX(); - uy = current_atom->getOrntY(); - uz = current_atom->getOrntZ(); - - uSqr = (ux * ux) + (uy * uy) + (uz * uz); - - u = sqrt( uSqr ); - ux = ux / u; - uy = uy / u; - uz = uz / u; +#ifdef IS_MPI + if( simnfo->mpiSim->getMyMolStart() <= molIndex && + molIndex <= simnfo->mpiSim->getMyMolEnd() ){ +#endif // is_mpi - dAtom->setSUx( ux ); - dAtom->setSUy( uy ); - dAtom->setSUz( uz ); + molStart = index; + nMemb = comp_stamps[i]->getNAtoms(); + for( k=0; kgetNAtoms(); k++ ){ + + current_atom = comp_stamps[i]->getAtom( k ); + if( current_atom->haveOrientation() ){ + + dAtom = new DirectionalAtom(index); + simnfo->n_oriented++; + the_atoms[index] = dAtom; + + ux = current_atom->getOrntX(); + uy = current_atom->getOrntY(); + uz = current_atom->getOrntZ(); + + uSqr = (ux * ux) + (uy * uy) + (uz * uz); + + u = sqrt( uSqr ); + ux = ux / u; + uy = uy / u; + uz = uz / u; + + dAtom->setSUx( ux ); + dAtom->setSUy( uy ); + dAtom->setSUz( uz ); + } + else{ + the_atoms[index] = new GeneralAtom(index); + } + the_atoms[index]->setType( current_atom->getType() ); + the_atoms[index]->setIndex( index ); + + // increment the index and repeat; + index++; } - else{ - the_atoms[index] = new GeneralAtom(index); - } - the_atoms[index]->setType( current_atom->getType() ); - the_atoms[index]->setIndex( index ); + + molEnd = index -1; + the_molecules[lMolIndex].setNMembers( nMemb ); + the_molecules[lMolIndex].setStartAtom( molStart ); + the_molecules[lMolIndex].setEndAtom( molEnd ); + the_molecules[lMolIndex].setStampID( i ); + lMolIndex++; - // increment the index and repeat; - index++; +#ifdef IS_MPI } - - molEnd = index -1; - the_molecules[molIndex].setNMembers( nMemb ); - the_molecules[molIndex].setStartAtom( molStart ); - the_molecules[molIndex].setEndAtom( molEnd ); - the_molecules[molIndex].setStampID( i ); +#endif //is_mpi + molIndex++; - } } @@ -604,31 +635,43 @@ void SimSetup::makeBonds( void ){ void SimSetup::makeBonds( void ){ - int i, j, k, index, offset; + int i, j, k, index, offset, molIndex; bond_pair* the_bonds; BondStamp* current_bond; the_bonds = new bond_pair[tot_bonds]; index = 0; offset = 0; + molIndex = 0; for( i=0; igetNBonds(); k++ ){ - - current_bond = comp_stamps[i]->getBond( k ); - the_bonds[index].a = current_bond->getA() + offset; - the_bonds[index].b = current_bond->getB() + offset; - - the_excludes[index].i = the_bonds[index].a; - the_excludes[index].j = the_bonds[index].b; - - // increment the index and repeat; - index++; +#ifdef IS_MPI + if( simnfo->mpiSim->getMyMolStart() <= molIndex && + molIndex <= simnfo->mpiSim->getMyMolEnd() ){ +#endif // is_mpi + + for( k=0; kgetNBonds(); k++ ){ + + current_bond = comp_stamps[i]->getBond( k ); + the_bonds[index].a = current_bond->getA() + offset; + the_bonds[index].b = current_bond->getB() + offset; + + the_excludes[index].i = the_bonds[index].a; + the_excludes[index].j = the_bonds[index].b; + + // increment the index and repeat; + index++; + } + offset += comp_stamps[i]->getNAtoms(); + +#ifdef IS_MPI } - offset += comp_stamps[i]->getNAtoms(); - } +#endif is_mpi + + molIndex++; + } } the_ff->initializeBonds( the_bonds ); @@ -636,31 +679,43 @@ void SimSetup::makeBends( void ){ void SimSetup::makeBends( void ){ - int i, j, k, index, offset; + int i, j, k, index, offset, molIndex; bend_set* the_bends; BendStamp* current_bend; the_bends = new bend_set[tot_bends]; index = 0; offset = 0; + molIndex = 0; for( i=0; igetNBends(); k++ ){ +#ifdef IS_MPI + if( simnfo->mpiSim->getMyMolStart() <= molIndex && + molIndex <= simnfo->mpiSim->getMyMolEnd() ){ +#endif // is_mpi - current_bend = comp_stamps[i]->getBend( k ); - the_bends[index].a = current_bend->getA() + offset; - the_bends[index].b = current_bend->getB() + offset; - the_bends[index].c = current_bend->getC() + offset; - - the_excludes[index + tot_bonds].i = the_bends[index].a; - the_excludes[index + tot_bonds].j = the_bends[index].c; - - // increment the index and repeat; - index++; + for( k=0; kgetNBends(); k++ ){ + + current_bend = comp_stamps[i]->getBend( k ); + the_bends[index].a = current_bend->getA() + offset; + the_bends[index].b = current_bend->getB() + offset; + the_bends[index].c = current_bend->getC() + offset; + + the_excludes[index + tot_bonds].i = the_bends[index].a; + the_excludes[index + tot_bonds].j = the_bends[index].c; + + // increment the index and repeat; + index++; + } + offset += comp_stamps[i]->getNAtoms(); + +#ifdef IS_MPI } - offset += comp_stamps[i]->getNAtoms(); +#endif //is_mpi + + molIndex++; } } @@ -669,17 +724,23 @@ void SimSetup::makeTorsions( void ){ void SimSetup::makeTorsions( void ){ - int i, j, k, index, offset; + int i, j, k, index, offset, molIndex; torsion_set* the_torsions; TorsionStamp* current_torsion; the_torsions = new torsion_set[tot_torsions]; index = 0; offset = 0; + molIndex = 0; for( i=0; impiSim->getMyMolStart() <= molIndex && + molIndex <= simnfo->mpiSim->getMyMolEnd() ){ +#endif // is_mpi + for( k=0; kgetNTorsions(); k++ ){ current_torsion = comp_stamps[i]->getTorsion( k ); @@ -695,6 +756,12 @@ void SimSetup::makeTorsions( void ){ index++; } offset += comp_stamps[i]->getNAtoms(); + +#ifdef IS_MPI + } +#endif //is_mpi + + molIndex++; } }