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