--- trunk/mdtools/interface_implementation/SimSetup.cpp 2002/12/11 20:39:41 205 +++ trunk/mdtools/interface_implementation/SimSetup.cpp 2003/02/03 21:15:59 261 @@ -10,6 +10,7 @@ #ifdef IS_MPI #include "mpiBASS.h" +#include "mpiSimulation.hpp" #include "bassDiag.hpp" #endif @@ -92,6 +93,7 @@ void SimSetup::createSim( void ){ if( !strcmp( force_field, "TraPPE" ) ) the_ff = new TraPPEFF(); else if( !strcmp( force_field, "DipoleTest" ) ) the_ff = new DipoleTestFF(); else if( !strcmp( force_field, "TraPPE_Ex" ) ) the_ff = new TraPPE_ExFF(); + else if( !strcmp( force_field, "LJ" ) ) the_ff = new LJ_FF(); else{ sprintf( painCave.errMsg, "SimSetup Error. Unrecognized force field -> %s\n", @@ -187,7 +189,7 @@ void SimSetup::createSim( void ){ if( currentStamp == NULL ){ sprintf( painCave.errMsg, "SimSetup error: Component \"%s\" was not found in the " - "list of declared molecules\n" + "list of declared molecules\n", id ); painCave.isFatal = 1; simError(); @@ -234,10 +236,14 @@ void SimSetup::createSim( void ){ // divide the molecules among processors here. - mpiSimulation* mpiSim = new mpiSimulation( simnfo ); + mpiSim = new mpiSimulation( simnfo ); - mpiSim->divideLabor(); + + + globalIndex = mpiSim->divideLabor(); + + // set up the local variables int localMol, allMol; @@ -311,27 +317,8 @@ void SimSetup::createSim( void ){ simnfo->sr_interactions = the_sris; simnfo->n_exclude = tot_SRI; simnfo->excludes = the_excludes; - - - // initialize the arrays - - the_ff->setSimInfo( simnfo ); - makeAtoms(); - if( tot_bonds ){ - makeBonds(); - } - - if( tot_bends ){ - makeBends(); - } - - if( tot_torsions ){ - makeTorsions(); - } - - // get some of the tricky things that may still be in the globals if( simnfo->n_dipoles ){ @@ -404,17 +391,45 @@ void SimSetup::createSim( void ){ #endif // is_mpi + // initialize the arrays -// if( the_globals->haveInitialConfig() ){ -// InitializeFromFile* fileInit; -// fileInit = new InitializeFromFile( the_globals->getInitialConfig() ); + the_ff->setSimInfo( simnfo ); -// fileInit->read_xyz( simnfo ); // default velocities on + makeAtoms(); + // + if( tot_bonds ){ + makeBonds(); + } -// delete fileInit; -// } -// else{ + if( tot_bends ){ + makeBends(); + } + + if( tot_torsions ){ + makeTorsions(); + } + + + + + + + if( the_globals->haveInitialConfig() ){ + + InitializeFromFile* fileInit; +#ifdef IS_MPI // is_mpi + if( worldRank == 0 ){ +#endif //is_mpi + fileInit = new InitializeFromFile( the_globals->getInitialConfig() ); +#ifdef IS_MPI + }else fileInit = new InitializeFromFile( NULL ); +#endif + fileInit->read_xyz( simnfo ); // default velocities on + delete fileInit; + } + else{ + #ifdef IS_MPI // no init from bass @@ -428,8 +443,10 @@ void SimSetup::createSim( void ){ initFromBass(); -#endif // is_mpi - + +#endif + } + #ifdef IS_MPI strcpy( checkPointMsg, "Successfully read in the initial configuration" ); MPIcheckPoint(); @@ -439,7 +456,7 @@ void SimSetup::createSim( void ){ - // } + #ifdef IS_MPI if( worldRank == 0 ){ @@ -550,13 +567,15 @@ void SimSetup::createSim( void ){ if( the_globals->haveTempSet() ) simnfo->setTemp = the_globals->getTempSet(); - // make the longe range forces and the integrator +// // make the longe range forces and the integrator - new AllLong( simnfo ); +// new AllLong( simnfo ); - if( !strcmp( force_field, "TraPPE" ) ) new Verlet( *simnfo ); + if( !strcmp( force_field, "TraPPE" ) ) new Verlet( *simnfo, the_ff ); if( !strcmp( force_field, "DipoleTest" ) ) new Symplectic( simnfo ); if( !strcmp( force_field, "TraPPE_Ex" ) ) new Symplectic( simnfo ); + if( !strcmp( force_field, "LJ" ) ) new Verlet( *simnfo, the_ff ); + } void SimSetup::makeAtoms( void ){ @@ -575,8 +594,8 @@ void SimSetup::makeAtoms( void ){ for( j=0; jmpiSim->getMyMolStart() <= molIndex && - molIndex <= simnfo->mpiSim->getMyMolEnd() ){ + if( mpiSim->getMyMolStart() <= molIndex && + molIndex <= mpiSim->getMyMolEnd() ){ #endif // is_mpi molStart = index; @@ -630,6 +649,14 @@ void SimSetup::makeAtoms( void ){ } } +#ifdef IS_MPI + for( i=0; igetMyNlocal(); i++ ) the_atoms[i]->setGlobalIndex( globalIndex[i] ); + + delete[] globalIndex; + + mpiSim->mpiRefresh(); +#endif //IS_MPI + the_ff->initializeAtoms(); } @@ -643,13 +670,14 @@ void SimSetup::makeBonds( void ){ index = 0; offset = 0; molIndex = 0; + for( i=0; impiSim->getMyMolStart() <= molIndex && - molIndex <= simnfo->mpiSim->getMyMolEnd() ){ + if( mpiSim->getMyMolStart() <= molIndex && + molIndex <= mpiSim->getMyMolEnd() ){ #endif // is_mpi for( k=0; kgetNBonds(); k++ ){ @@ -668,7 +696,7 @@ void SimSetup::makeBonds( void ){ #ifdef IS_MPI } -#endif is_mpi +#endif //is_mpi molIndex++; } @@ -692,8 +720,8 @@ void SimSetup::makeBends( void ){ for( j=0; jmpiSim->getMyMolStart() <= molIndex && - molIndex <= simnfo->mpiSim->getMyMolEnd() ){ + if( mpiSim->getMyMolStart() <= molIndex && + molIndex <= mpiSim->getMyMolEnd() ){ #endif // is_mpi for( k=0; kgetNBends(); k++ ){ @@ -737,8 +765,8 @@ void SimSetup::makeTorsions( void ){ for( j=0; jmpiSim->getMyMolStart() <= molIndex && - molIndex <= simnfo->mpiSim->getMyMolEnd() ){ + if( mpiSim->getMyMolStart() <= molIndex && + molIndex <= mpiSim->getMyMolEnd() ){ #endif // is_mpi for( k=0; kgetNTorsions(); k++ ){