--- trunk/mdtools/interface_implementation/SimSetup.cpp 2002/12/05 18:53:40 195 +++ trunk/mdtools/interface_implementation/SimSetup.cpp 2002/12/10 21:41:26 202 @@ -73,7 +73,7 @@ void SimSetup::createSim( void ){ MakeStamps *the_stamps; Globals* the_globals; - int i; + int i, j; // get the stamps and globals; the_stamps = stamps; @@ -161,15 +161,51 @@ void SimSetup::createSim( void ){ #endif // is_mpi // make an array of molecule stamps that match the components used. + // also extract the used stamps out into a separate linked list + simnfo->nComponents = n_components; + simnfo->componentsNmol = components_nmol; + simnfo->compStamps = comp_stamps; + simnfo->headStamp = new LinkedMolStamp(); + + char* id; + LinkedMolStamp* headStamp = simnfo->headStamp; + LinkedMolStamp* currentStamp = NULL; for( i=0; igetMolecule( the_components[i]->getType() ); + id = the_components[i]->getType(); + comp_stamps[i] = NULL; + + // check to make sure the component isn't already in the list + + comp_stamps[i] = headStamp->match( id ); + if( comp_stamps[i] == NULL ){ + + // extract the component from the list; + + currentStamp = the_stamps->extractMolStamp( id ); + if( currentStamp == NULL ){ + sprintf( painCave.errMsg, + "SimSetup error: Component \"%s\" was not found in the " + "list of declared molecules\n" + id ); + painCave.isFatal = 1; + simError(); + } + + headStamp->add( currentStamp ); + comp_stamps[i] = headStamp->match( id ); + } } +#ifdef IS_MPI + strcpy( checkPointMsg, "Component stamps successfully extracted\n" ); + MPIcheckPoint(); +#endif // is_mpi + + // caclulate the number of atoms, bonds, bends and torsions tot_atoms = 0; @@ -177,10 +213,10 @@ void SimSetup::createSim( void ){ tot_bends = 0; tot_torsions = 0; for( i=0; igetNAtoms(); - tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds(); - tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); + + tot_atoms += components_nmol[i] * comp_stamps[i]->getNAtoms(); + tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds(); + tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions(); } @@ -198,10 +234,41 @@ void SimSetup::createSim( void ){ // divide the molecules among processors here. - new mpiSimulation( simnfo ); + mpiSimulation* mpiSim = new mpiSimulation( simnfo ); - simnfo->mpiSim->divideLabor( n_components, comp_stamps, components_nmol ); + mpiSim->divideLabor(); + + // set up the local variables + + int localMol; + int local_atoms, local_bonds, local_bends, local_torsions, local_SRI; + + localMol = 0; + local_atoms = 0; + local_bonds = 0; + local_bends = 0; + local_torsions = 0; + for( i=0; igetMyMolStart() <= j && + j <= mpiSim->getMyMolEnd() ){ + + local_atoms += comp_stamps[i]->getNAtoms(); + local_bonds += comp_stamps[i]->getNBonds(); + local_bends += comp_stamps[i]->getNBends(); + local_torsions += comp_stamps[i]->getNTorsions(); + localMol++; + } + } + } + + + simnfo->n_atoms = mpiSim->getMyNlocal(); + + #endif // is_mpi @@ -526,6 +593,7 @@ void SimSetup::makeAtoms( void ){ the_molecules[molIndex].setNMembers( nMemb ); the_molecules[molIndex].setStartAtom( molStart ); the_molecules[molIndex].setEndAtom( molEnd ); + the_molecules[molIndex].setStampID( i ); molIndex++; }