ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/interface_implementation/SimSetup.cpp
(Generate patch)

Comparing trunk/mdtools/interface_implementation/SimSetup.cpp (file contents):
Revision 205 by mmeineke, Wed Dec 11 20:39:41 2002 UTC vs.
Revision 254 by chuckv, Thu Jan 30 20:03:37 2003 UTC

# Line 10 | Line 10
10  
11   #ifdef IS_MPI
12   #include "mpiBASS.h"
13 + #include "mpiSimulation.hpp"
14   #include "bassDiag.hpp"
15   #endif
16  
# Line 92 | Line 93 | void SimSetup::createSim( void ){
93    if( !strcmp( force_field, "TraPPE" ) ) the_ff = new TraPPEFF();
94    else if( !strcmp( force_field, "DipoleTest" ) ) the_ff = new DipoleTestFF();
95    else if( !strcmp( force_field, "TraPPE_Ex" ) ) the_ff = new TraPPE_ExFF();
96 +  else if( !strcmp( force_field, "LJ" ) ) the_ff = new LJ_FF();
97    else{
98      sprintf( painCave.errMsg,
99               "SimSetup Error. Unrecognized force field -> %s\n",
# Line 187 | Line 189 | void SimSetup::createSim( void ){
189        if( currentStamp == NULL ){
190          sprintf( painCave.errMsg,
191                   "SimSetup error: Component \"%s\" was not found in the "
192 <                 "list of declared molecules\n"
192 >                 "list of declared molecules\n",
193                   id );
194          painCave.isFatal = 1;
195          simError();
# Line 234 | Line 236 | void SimSetup::createSim( void ){
236  
237    // divide the molecules among processors here.
238    
239 <  mpiSimulation* mpiSim = new mpiSimulation( simnfo );
239 >  mpiSim = new mpiSimulation( simnfo );
240    
241 <  mpiSim->divideLabor();
241 >  fprintf( stderr, "about to call divideLabour.\n" );
242 >
243 >  globalIndex = mpiSim->divideLabor();
244  
245 +  fprintf(stderr, "we're back from divideLabour\n" );
246 +
247    // set up the local variables
248    
249    int localMol, allMol;
# Line 311 | Line 317 | void SimSetup::createSim( void ){
317    simnfo->sr_interactions = the_sris;
318    simnfo->n_exclude = tot_SRI;
319    simnfo->excludes = the_excludes;
314
315
316  // initialize the arrays
317
318  the_ff->setSimInfo( simnfo );
320  
320  makeAtoms();
321  
322  if( tot_bonds ){
323    makeBonds();
324  }
325
326  if( tot_bends ){
327    makeBends();
328  }
329
330  if( tot_torsions ){
331    makeTorsions();
332  }
333
334
322    // get some of the tricky things that may still be in the globals
323  
324    if( simnfo->n_dipoles ){
# Line 404 | Line 391 | void SimSetup::createSim( void ){
391   #endif // is_mpi
392  
393  
394 +  // initialize the arrays
395  
396 < //   if( the_globals->haveInitialConfig() ){
409 < //        InitializeFromFile* fileInit;
410 < //     fileInit = new InitializeFromFile( the_globals->getInitialConfig() );
396 >  the_ff->setSimInfo( simnfo );
397  
398 < //     fileInit->read_xyz( simnfo ); // default velocities on
398 >  makeAtoms();
399  
400 < //     delete fileInit;
401 < //   }
402 < //   else{
400 >  if( tot_bonds ){
401 >    makeBonds();
402 >  }
403 >
404 >  if( tot_bends ){
405 >    makeBends();
406 >  }
407 >
408 >  if( tot_torsions ){
409 >    makeTorsions();
410 >  }
411 >
412 >
413 >
414 >
415 >
416 >
417 > if( the_globals->haveInitialConfig() ){
418 >
419 >     InitializeFromFile* fileInit;
420 > #ifdef IS_MPI // is_mpi
421 >     if( worldRank == 0 ){
422 > #endif //is_mpi
423 >   fileInit = new InitializeFromFile( the_globals->getInitialConfig() );
424 > #ifdef IS_MPI
425 >     }else fileInit = new InitializeFromFile( NULL );
426 > #endif
427 >   fileInit->read_xyz( simnfo ); // default velocities on
428  
429 +   delete fileInit;
430 + }
431 + else{
432 +
433   #ifdef IS_MPI
434  
435    // no init from bass
# Line 428 | Line 443 | void SimSetup::createSim( void ){
443  
444    initFromBass();
445  
446 < #endif // is_mpi
447 <
446 >
447 > #endif
448 > }
449 >
450   #ifdef IS_MPI
451    strcpy( checkPointMsg, "Successfully read in the initial configuration" );
452    MPIcheckPoint();
# Line 439 | Line 456 | void SimSetup::createSim( void ){
456    
457  
458    
459 <  //   }
459 >
460    
461   #ifdef IS_MPI
462    if( worldRank == 0 ){
# Line 550 | Line 567 | void SimSetup::createSim( void ){
567    if( the_globals->haveTempSet() ) simnfo->setTemp = the_globals->getTempSet();
568  
569  
570 <  // make the longe range forces and the integrator
570 > //   // make the longe range forces and the integrator
571  
572 <  new AllLong( simnfo );
572 > //   new AllLong( simnfo );
573  
574 <  if( !strcmp( force_field, "TraPPE" ) ) new Verlet( *simnfo );
574 >  if( !strcmp( force_field, "TraPPE" ) ) new Verlet( *simnfo, the_ff );
575    if( !strcmp( force_field, "DipoleTest" ) ) new Symplectic( simnfo );
576    if( !strcmp( force_field, "TraPPE_Ex" ) ) new Symplectic( simnfo );
577 +  if( !strcmp( force_field, "LJ" ) ) new Verlet( *simnfo, the_ff );
578 +
579   }
580  
581   void SimSetup::makeAtoms( void ){
# Line 575 | Line 594 | void SimSetup::makeAtoms( void ){
594      for( j=0; j<components_nmol[i]; j++ ){
595  
596   #ifdef IS_MPI
597 <      if( simnfo->mpiSim->getMyMolStart() <= molIndex &&
598 <          molIndex <= simnfo->mpiSim->getMyMolEnd() ){
597 >      if( mpiSim->getMyMolStart() <= molIndex &&
598 >          molIndex <= mpiSim->getMyMolEnd() ){
599   #endif // is_mpi        
600  
601          molStart = index;
# Line 630 | Line 649 | void SimSetup::makeAtoms( void ){
649      }
650    }
651  
652 + #ifdef IS_MPI
653 +    for( i=0; i<mpiSim->getMyNlocal(); i++ ) the_atoms[i]->setGlobalIndex( globalIndex[i] );
654 +    
655 +    delete[] globalIndex;
656 +
657 +    mpiSim->mpiRefresh();
658 + #endif //IS_MPI
659 +          
660    the_ff->initializeAtoms();
661   }
662  
# Line 643 | Line 670 | void SimSetup::makeBonds( void ){
670    index = 0;
671    offset = 0;
672    molIndex = 0;
673 +
674    for( i=0; i<n_components; i++ ){
675  
676      for( j=0; j<components_nmol[i]; j++ ){
677  
678   #ifdef IS_MPI
679 <      if( simnfo->mpiSim->getMyMolStart() <= molIndex &&
680 <          molIndex <= simnfo->mpiSim->getMyMolEnd() ){
679 >      if( mpiSim->getMyMolStart() <= molIndex &&
680 >          molIndex <= mpiSim->getMyMolEnd() ){
681   #endif // is_mpi        
682          
683          for( k=0; k<comp_stamps[i]->getNBonds(); k++ ){
# Line 668 | Line 696 | void SimSetup::makeBonds( void ){
696          
697   #ifdef IS_MPI
698        }
699 < #endif is_mpi
699 > #endif //is_mpi
700        
701        molIndex++;
702      }      
# Line 692 | Line 720 | void SimSetup::makeBends( void ){
720      for( j=0; j<components_nmol[i]; j++ ){
721  
722   #ifdef IS_MPI
723 <      if( simnfo->mpiSim->getMyMolStart() <= molIndex &&
724 <          molIndex <= simnfo->mpiSim->getMyMolEnd() ){
723 >      if( mpiSim->getMyMolStart() <= molIndex &&
724 >          molIndex <= mpiSim->getMyMolEnd() ){
725   #endif // is_mpi        
726  
727          for( k=0; k<comp_stamps[i]->getNBends(); k++ ){
# Line 737 | Line 765 | void SimSetup::makeTorsions( void ){
765      for( j=0; j<components_nmol[i]; j++ ){
766  
767   #ifdef IS_MPI
768 <      if( simnfo->mpiSim->getMyMolStart() <= molIndex &&
769 <          molIndex <= simnfo->mpiSim->getMyMolEnd() ){
768 >      if( mpiSim->getMyMolStart() <= molIndex &&
769 >          molIndex <= mpiSim->getMyMolEnd() ){
770   #endif // is_mpi        
771  
772        for( k=0; k<comp_stamps[i]->getNTorsions(); k++ ){

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines