ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE_old/src/mdtools/libmdCode/LJ_FF.cpp
(Generate patch)

Comparing trunk/OOPSE_old/src/mdtools/libmdCode/LJ_FF.cpp (file contents):
Revision 290 by chuckv, Thu Feb 27 21:25:47 2003 UTC vs.
Revision 291 by mmeineke, Wed Mar 5 20:35:54 2003 UTC

# Line 14 | Line 14 | using namespace std;
14   #include "SRI.hpp"
15   #include "simError.h"
16  
17 + #ifdef IS_MPI
18 + #include "mpiForceField.h"
19 + #endif // is_mpi
20  
21  
19 // Declare the structures that will be passed by the parser and  MPI
22  
23 < typedef struct{
22 <  char name[15];
23 <  double mass;
24 <  double epslon;
25 <  double sigma;
26 <  int ident;
27 <  int last;      //  0  -> default
28 <                 //  1  -> in MPI: tells nodes to stop listening
29 < } atomStruct;
23 > namespace {
24  
25 < int parseAtomLJ( char *lineBuffer, int lineNum, atomStruct &info );
26 <
27 < #ifdef IS_MPI
28 < #include "mpiForceField.h"
29 <
30 < MPI_Datatype mpiAtomStructType;
25 >  // Declare the structures that will be passed by the parser and  MPI
26 >  
27 >  typedef struct{
28 >    char name[15];
29 >    double mass;
30 >    double epslon;
31 >    double sigma;
32 >    int ident;
33 >    int last;      //  0  -> default
34 >                   //  1  -> in MPI: tells nodes to stop listening
35 >  } atomStruct;
36  
37 +  int parseAtom( char *lineBuffer, int lineNum, atomStruct &info );
38 +  
39 + #ifdef IS_MPI
40 +  
41 +  MPI_Datatype mpiAtomStructType;
42 +  
43   #endif
44 + }
45  
40
46   // declaration of functions needed to wrap the fortran module
47  
48   extern "C" {
# Line 216 | Line 221 | void LJfunctionWrapper( void (*p1)( int* ident, double
221   void LJfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon,
222                                     double* sigma, int* status ),
223                          void (*p2)( int*, int*, int* ),
224 <                        void (*p3)( double* positionArray,double* forceArray,
225 <                                    double* potentialEnergy,
221 <                                    short int* doPotentialCalc ) ){
224 >                        void (*p3)( double*,double*,double*,double*,
225 >                                    short int*, int* ) ){
226    
227    
228    newLJtype = p1;
# Line 523 | Line 527 | void LJ_FF::initializeTorsions( torsion_set* the_torsi
527        painCave.isFatal = 1;
528        simError();
529      }
530 + #ifdef IS_MPI
531 +  MPIcheckPoint();
532 + #endif // is_mpi
533 +
534 + }
535 +
536 + void LJ_FF::doForces( int calcPot ){
537 +
538 +  int i, isError;
539 +  double* frc;
540 +  double* pos;
541 +  double* tau;
542 +  short int passedCalcPot = (short int)calcPot;
543 +
544 +  // forces are zeroed here, before any are acumulated.
545 +  // NOTE: do not rezero the forces in Fortran.
546 +
547 +  for(i=0; i<entry_plug->n_atoms; i++){
548 +    entry_plug->atoms[i]->zeroForces();
549 +  }
550 +
551 +  frc = Atom::getFrcArray();
552 +  pos = Atom::getPosArray();
553 +  tau = entry_plug->tau;
554 +
555 +  isError = 0;
556 +  doLJfortran( pos, frc, &(entry_plug->lrPot), tau, &passedCalcPot, &isError );
557 +
558 +
559 +  if( isError ){
560 +    sprintf( painCave.errMsg,
561 +             "Error returned from the fortran force calculation.\n" );
562 +    painCave.isFatal = 1;
563 +    simError();
564 +  }
565 +
566   #ifdef IS_MPI
567 +  sprintf( checkPointMsg,
568 +           "returned from the force calculation.\n" );
569    MPIcheckPoint();
570   #endif // is_mpi
571  
572   }
573 +  
574 + void LJ_FF::initFortran( void ){
575 +  
576 +  int nLocal = entry_plug->n_atoms;
577 +  int *ident;
578 +  int isError;
579 +  int i;
580 +
581 +  ident = new int[nLocal];
582 +
583 +  for(i=0; i<nLocal; i++){
584 +    ident[i] = entry_plug->atoms[i]->getIdent();
585 +  }
586 +
587 +  isError = 0;
588 +  initLJfortran( &nLocal, ident, &isError );
589 +  
590 +  if(isError){
591 +    sprintf( painCave.errMsg,
592 +             "LJ_FF error: There was an error initializing the component list in fortran.\n" );
593 +    painCave.isFatal = 1;
594 +    simError();
595 +  }
596  
597 +  
598 + #ifdef IS_MPI
599 +  sprintf( checkPointMsg, "LJ_FF successfully initialized the fortran component list.\n" );
600 +  MPIcheckPoint();
601 + #endif // is_mpi
602 +  
603 +  delete[] ident;
604  
605 + }
606 +
607 +  
608   void LJ_FF::fastForward( char* stopText, char* searchOwner ){
609  
610    int foundText = 0;
# Line 586 | Line 661 | int parseAtomLJ( char *lineBuffer, int lineNum,  atomS
661  
662  
663  
664 < int parseAtomLJ( char *lineBuffer, int lineNum,  atomStruct &info ){
664 > int parseAtom( char *lineBuffer, int lineNum,  atomStruct &info ){
665  
666    char* the_token;
667    
# Line 626 | Line 701 | int parseAtomLJ( char *lineBuffer, int lineNum,  atomS
701    }
702    else return 0;
703   }
629
630
631 void LJ_FF::doForces( int calcPot ){
632
633  int i, isError;
634  double* frc;
635  double* pos;
636  double* tau;
637  short int passedCalcPot = (short int)calcPot;
638
639  // forces are zeroed here, before any are acumulated.
640  // NOTE: do not rezero the forces in Fortran.
641
642  for(i=0; i<entry_plug->n_atoms; i++){
643    entry_plug->atoms[i]->zeroForces();
644  }
645
646  frc = Atom::getFrcArray();
647  pos = Atom::getPosArray();
648  tau = entry_plug->tau;
649
650  isError = 0;
651  doLJfortran( pos, frc, &(entry_plug->lrPot), tau, &passedCalcPot, &isError );
652
653
654  if( isError ){
655    sprintf( painCave.errMsg,
656             "Error returned from the fortran force calculation.\n" );
657    painCave.isFatal = 1;
658    simError();
659  }
660
661 #ifdef IS_MPI
662  sprintf( checkPointMsg,
663           "returned from the force calculation.\n" );
664  MPIcheckPoint();
665 #endif // is_mpi
666
667 }
668  
669 void LJ_FF::initFortran( void ){
670  
671  int nLocal = entry_plug->n_atoms;
672  int *ident;
673  int isError;
674  int i;
675
676  ident = new int[nLocal];
677
678  for(i=0; i<nLocal; i++){
679    ident[i] = entry_plug->atoms[i]->getIdent();
680  }
681
682  isError = 0;
683  initLJfortran( &nLocal, ident, &isError );
684  
685  if(isError){
686    sprintf( painCave.errMsg,
687             "LJ_FF error: There was an error initializing the component list in fortran.\n" );
688    painCave.isFatal = 1;
689    simError();
690  }
691
692  
693 #ifdef IS_MPI
694  sprintf( checkPointMsg, "LJ_FF successfully initialized the fortran component list.\n" );
695  MPIcheckPoint();
696 #endif // is_mpi
697  
698  delete[] ident;
699
700 }
701  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines