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 202 by mmeineke, Tue Dec 10 21:41:26 2002 UTC vs.
Revision 206 by chuckv, Thu Dec 12 21:21:59 2002 UTC

# Line 240 | Line 240 | void SimSetup::createSim( void ){
240  
241    // set up the local variables
242    
243 <  int localMol;
243 >  int localMol, allMol;
244    int local_atoms, local_bonds, local_bends, local_torsions, local_SRI;
245    
246 +  allMol = 0;
247    localMol = 0;
248    local_atoms = 0;
249    local_bonds = 0;
# Line 252 | Line 253 | void SimSetup::createSim( void ){
253  
254      for( j=0; j<components_nmol[i]; j++ ){
255        
256 <      if( mpiSim->getMyMolStart() <= j &&
257 <          j <= mpiSim->getMyMolEnd() ){
256 >      if( mpiSim->getMyMolStart() <= allMol &&
257 >          allMol <= mpiSim->getMyMolEnd() ){
258          
259          local_atoms +=    comp_stamps[i]->getNAtoms();
260          local_bonds +=    comp_stamps[i]->getNBonds();
# Line 261 | Line 262 | void SimSetup::createSim( void ){
262          local_torsions += comp_stamps[i]->getNTorsions();
263          localMol++;
264        }      
265 +      allMol++;
266      }
267    }
268 <
268 >  local_SRI = local_bonds + local_bends + local_torsions;
269    
270  
271    simnfo->n_atoms = mpiSim->getMyNlocal();  
272    
273 +  if( local_atoms != simnfo->n_atoms ){
274 +    sprintf( painCave.errMsg,
275 +             "SimSetup error: mpiSim's localAtom (%d) and SimSetup's"
276 +             " localAtom (%d) are note equal.\n",
277 +             simnfo->n_atoms,
278 +             local_atoms );
279 +    painCave.isFatal = 1;
280 +    simError();
281 +  }
282  
283 +  simnfo->n_bonds = local_bonds;
284 +  simnfo->n_bends = local_bends;
285 +  simnfo->n_torsions = local_torsions;
286 +  simnfo->n_SRI = local_SRI;
287 +  simnfo->n_mol = localMol;
288 +
289 +  strcpy( checkPointMsg, "Passed nlocal consistency check." );
290 +  MPIcheckPoint();
291 +  
292 +  
293   #endif // is_mpi
294    
295  
# Line 384 | Line 405 | void SimSetup::createSim( void ){
405  
406  
407  
408 < //   if( the_globals->haveInitialConfig() ){
409 < //        InitializeFromFile* fileInit;
410 < //     fileInit = new InitializeFromFile( the_globals->getInitialConfig() );
408 > if( the_globals->haveInitialConfig() ){
409 >
410 >     InitializeFromFile* fileInit;
411 > #ifdef IS_MPI // is_mpi
412 >     if( worldRank == 0 ){
413 > #endif //is_mpi
414 >   fileInit = new InitializeFromFile( the_globals->getInitialConfig() );
415 > #ifdef IS_MPI
416 >     }else fileInit = new InitializeFromFile( NULL );
417 > #endif
418 >   fileInit->read_xyz( simnfo ); // default velocities on
419  
420 < //     fileInit->read_xyz( simnfo ); // default velocities on
420 >   delete fileInit;
421 > }
422 > else{
423  
393 //     delete fileInit;
394 //   }
395 //   else{
396
424   #ifdef IS_MPI
425  
426    // no init from bass
# Line 407 | Line 434 | void SimSetup::createSim( void ){
434  
435    initFromBass();
436  
437 < #endif // is_mpi
438 <
437 >
438 > #endif
439 > }
440 >
441   #ifdef IS_MPI
442    strcpy( checkPointMsg, "Successfully read in the initial configuration" );
443    MPIcheckPoint();
# Line 418 | Line 447 | void SimSetup::createSim( void ){
447    
448  
449    
450 <  //   }
450 >
451    
452   #ifdef IS_MPI
453    if( worldRank == 0 ){
# Line 544 | Line 573 | void SimSetup::makeAtoms( void ){
573    double ux, uy, uz, uSqr, u;
574    AtomStamp* current_atom;
575    DirectionalAtom* dAtom;
576 <  int molIndex, molStart, molEnd, nMemb;
576 >  int molIndex, molStart, molEnd, nMemb, lMolIndex;
577  
578 <
578 >  lMolIndex = 0;
579    molIndex = 0;
580    index = 0;
581    for( i=0; i<n_components; i++ ){
582  
583      for( j=0; j<components_nmol[i]; j++ ){
584  
585 <      molStart = index;
586 <      nMemb = comp_stamps[i]->getNAtoms();
587 <      for( k=0; k<comp_stamps[i]->getNAtoms(); k++ ){
585 > #ifdef IS_MPI
586 >      if( simnfo->mpiSim->getMyMolStart() <= molIndex &&
587 >          molIndex <= simnfo->mpiSim->getMyMolEnd() ){
588 > #endif // is_mpi        
589  
590 <        current_atom = comp_stamps[i]->getAtom( k );
591 <        if( current_atom->haveOrientation() ){
592 <
593 <          dAtom = new DirectionalAtom(index);
594 <          simnfo->n_oriented++;
595 <          the_atoms[index] = dAtom;
596 <
597 <          ux = current_atom->getOrntX();
598 <          uy = current_atom->getOrntY();
599 <          uz = current_atom->getOrntZ();
600 <
601 <          uSqr = (ux * ux) + (uy * uy) + (uz * uz);
602 <
603 <          u = sqrt( uSqr );
604 <          ux = ux / u;
605 <          uy = uy / u;
606 <          uz = uz / u;
607 <
608 <          dAtom->setSUx( ux );
609 <          dAtom->setSUy( uy );
610 <          dAtom->setSUz( uz );
611 <        }
612 <        else{
613 <          the_atoms[index] = new GeneralAtom(index);
614 <        }
615 <        the_atoms[index]->setType( current_atom->getType() );
616 <        the_atoms[index]->setIndex( index );
617 <
618 <        // increment the index and repeat;
619 <        index++;
620 <      }
590 >        molStart = index;
591 >        nMemb = comp_stamps[i]->getNAtoms();
592 >        for( k=0; k<comp_stamps[i]->getNAtoms(); k++ ){
593 >          
594 >          current_atom = comp_stamps[i]->getAtom( k );
595 >          if( current_atom->haveOrientation() ){
596 >            
597 >            dAtom = new DirectionalAtom(index);
598 >            simnfo->n_oriented++;
599 >            the_atoms[index] = dAtom;
600 >            
601 >            ux = current_atom->getOrntX();
602 >            uy = current_atom->getOrntY();
603 >            uz = current_atom->getOrntZ();
604 >            
605 >            uSqr = (ux * ux) + (uy * uy) + (uz * uz);
606 >            
607 >            u = sqrt( uSqr );
608 >            ux = ux / u;
609 >            uy = uy / u;
610 >            uz = uz / u;
611 >            
612 >            dAtom->setSUx( ux );
613 >            dAtom->setSUy( uy );
614 >            dAtom->setSUz( uz );
615 >          }
616 >          else{
617 >            the_atoms[index] = new GeneralAtom(index);
618 >          }
619 >          the_atoms[index]->setType( current_atom->getType() );
620 >          the_atoms[index]->setIndex( index );
621 >          
622 >          // increment the index and repeat;
623 >          index++;
624 >        }
625 >        
626 >        molEnd = index -1;
627 >        the_molecules[lMolIndex].setNMembers( nMemb );
628 >        the_molecules[lMolIndex].setStartAtom( molStart );
629 >        the_molecules[lMolIndex].setEndAtom( molEnd );
630 >        the_molecules[lMolIndex].setStampID( i );
631 >        lMolIndex++;
632  
633 <      molEnd = index -1;
634 <      the_molecules[molIndex].setNMembers( nMemb );
635 <      the_molecules[molIndex].setStartAtom( molStart );
636 <      the_molecules[molIndex].setEndAtom( molEnd );
596 <      the_molecules[molIndex].setStampID( i );
633 > #ifdef IS_MPI
634 >      }
635 > #endif //is_mpi
636 >      
637        molIndex++;
598
638      }
639    }
640  
# Line 604 | Line 643 | void SimSetup::makeBonds( void ){
643  
644   void SimSetup::makeBonds( void ){
645  
646 <  int i, j, k, index, offset;
646 >  int i, j, k, index, offset, molIndex;
647    bond_pair* the_bonds;
648    BondStamp* current_bond;
649  
650    the_bonds = new bond_pair[tot_bonds];
651    index = 0;
652    offset = 0;
653 +  molIndex = 0;
654    for( i=0; i<n_components; i++ ){
655  
656      for( j=0; j<components_nmol[i]; j++ ){
657  
658 <      for( k=0; k<comp_stamps[i]->getNBonds(); k++ ){
659 <
660 <        current_bond = comp_stamps[i]->getBond( k );
661 <        the_bonds[index].a = current_bond->getA() + offset;
662 <        the_bonds[index].b = current_bond->getB() + offset;
663 <
664 <        the_excludes[index].i = the_bonds[index].a;
665 <        the_excludes[index].j = the_bonds[index].b;
666 <
667 <        // increment the index and repeat;
668 <        index++;
658 > #ifdef IS_MPI
659 >      if( simnfo->mpiSim->getMyMolStart() <= molIndex &&
660 >          molIndex <= simnfo->mpiSim->getMyMolEnd() ){
661 > #endif // is_mpi        
662 >        
663 >        for( k=0; k<comp_stamps[i]->getNBonds(); k++ ){
664 >          
665 >          current_bond = comp_stamps[i]->getBond( k );
666 >          the_bonds[index].a = current_bond->getA() + offset;
667 >          the_bonds[index].b = current_bond->getB() + offset;
668 >          
669 >          the_excludes[index].i = the_bonds[index].a;
670 >          the_excludes[index].j = the_bonds[index].b;
671 >          
672 >          // increment the index and repeat;
673 >          index++;
674 >        }
675 >        offset += comp_stamps[i]->getNAtoms();
676 >        
677 > #ifdef IS_MPI
678        }
679 <      offset += comp_stamps[i]->getNAtoms();
680 <    }
679 > #endif is_mpi
680 >      
681 >      molIndex++;
682 >    }      
683    }
684  
685    the_ff->initializeBonds( the_bonds );
# Line 636 | Line 687 | void SimSetup::makeBends( void ){
687  
688   void SimSetup::makeBends( void ){
689  
690 <  int i, j, k, index, offset;
690 >  int i, j, k, index, offset, molIndex;
691    bend_set* the_bends;
692    BendStamp* current_bend;
693  
694    the_bends = new bend_set[tot_bends];
695    index = 0;
696    offset = 0;
697 +  molIndex = 0;
698    for( i=0; i<n_components; i++ ){
699  
700      for( j=0; j<components_nmol[i]; j++ ){
701  
702 <      for( k=0; k<comp_stamps[i]->getNBends(); k++ ){
702 > #ifdef IS_MPI
703 >      if( simnfo->mpiSim->getMyMolStart() <= molIndex &&
704 >          molIndex <= simnfo->mpiSim->getMyMolEnd() ){
705 > #endif // is_mpi        
706  
707 <        current_bend = comp_stamps[i]->getBend( k );
708 <        the_bends[index].a = current_bend->getA() + offset;
709 <        the_bends[index].b = current_bend->getB() + offset;
710 <        the_bends[index].c = current_bend->getC() + offset;
711 <
712 <        the_excludes[index + tot_bonds].i = the_bends[index].a;
713 <        the_excludes[index + tot_bonds].j = the_bends[index].c;
714 <
715 <        // increment the index and repeat;
716 <        index++;
707 >        for( k=0; k<comp_stamps[i]->getNBends(); k++ ){
708 >          
709 >          current_bend = comp_stamps[i]->getBend( k );
710 >          the_bends[index].a = current_bend->getA() + offset;
711 >          the_bends[index].b = current_bend->getB() + offset;
712 >          the_bends[index].c = current_bend->getC() + offset;
713 >          
714 >          the_excludes[index + tot_bonds].i = the_bends[index].a;
715 >          the_excludes[index + tot_bonds].j = the_bends[index].c;
716 >          
717 >          // increment the index and repeat;
718 >          index++;
719 >        }
720 >        offset += comp_stamps[i]->getNAtoms();
721 >        
722 > #ifdef IS_MPI
723        }
724 <      offset += comp_stamps[i]->getNAtoms();
724 > #endif //is_mpi
725 >
726 >      molIndex++;
727      }
728    }
729  
# Line 669 | Line 732 | void SimSetup::makeTorsions( void ){
732  
733   void SimSetup::makeTorsions( void ){
734  
735 <  int i, j, k, index, offset;
735 >  int i, j, k, index, offset, molIndex;
736    torsion_set* the_torsions;
737    TorsionStamp* current_torsion;
738  
739    the_torsions = new torsion_set[tot_torsions];
740    index = 0;
741    offset = 0;
742 +  molIndex = 0;
743    for( i=0; i<n_components; i++ ){
744  
745      for( j=0; j<components_nmol[i]; j++ ){
746  
747 + #ifdef IS_MPI
748 +      if( simnfo->mpiSim->getMyMolStart() <= molIndex &&
749 +          molIndex <= simnfo->mpiSim->getMyMolEnd() ){
750 + #endif // is_mpi        
751 +
752        for( k=0; k<comp_stamps[i]->getNTorsions(); k++ ){
753  
754          current_torsion = comp_stamps[i]->getTorsion( k );
# Line 695 | Line 764 | void SimSetup::makeTorsions( void ){
764          index++;
765        }
766        offset += comp_stamps[i]->getNAtoms();
767 +
768 + #ifdef IS_MPI
769 +      }
770 + #endif //is_mpi      
771 +
772 +      molIndex++;
773      }
774    }
775  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines