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 275 by mmeineke, Tue Feb 18 21:06:36 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 );
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 < #include "mpiForceField.h"
41 <
42 < MPI_Datatype mpiAtomStructType;
37 <
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 54 | Line 59 | extern "C" {
59                                              void (*p3)( double* positionArray,
60                                                          double* forceArray,
61                                                          double* potentialEnergy,
62 <                                                        short int* doPotentialCalc )),
62 >                                                        double* tau,
63 >                                                        short int* doPotentialCalc,
64 >                                                        int* isError)),
65                        int forceNameLength );
66   }
67  
# Line 63 | Line 70 | void LJfunctionWrapper( void (*p1)( int* ident, double
70                                     double* sigma, int* status ),
71                          void (*p2)( int *nLocal, int *identArray, int *isError ),
72                          void (*p3)( double* positionArray,double* forceArray,
73 <                                    double* potentialEnergy,
74 <                                    short int* doPotentialCalc ) );
73 >                                    double* potentialEnergy, double* tau,
74 >                                    short int* doPotentialCalc, int* isError ) );
75  
76   void (*newLJtype)( int* ident, double* mass, double* epslon, double* sigma,
77                     int* status );
# Line 214 | 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,
219 <                                    short int* doPotentialCalc ) ){
224 >                        void (*p3)( double*,double*,double*,double*,
225 >                                    short int*, int* ) ){
226    
227    
228    newLJtype = p1;
# Line 526 | Line 532 | void LJ_FF::initializeTorsions( torsion_set* the_torsi
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 584 | 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 624 | Line 701 | int parseAtomLJ( char *lineBuffer, int lineNum,  atomS
701    }
702    else return 0;
703   }
627
628
629 void LJ_FF::doForces( int calcPot ){
630
631  int i;
632  double* frc;
633  double* pos;
634  short int passedCalcPot = (short int)calcPot;
635
636  // forces are zeroed here, before any are acumulated.
637  // NOTE: do not rezero the forces in Fortran.
638
639  for(i=0; i<entry_plug->n_atoms; i++){
640    entry_plug->atoms[i]->zeroForces();
641  }
642
643  frc = Atom::getFrcArray();
644  pos = Atom::getPosArray();
645
646 //   entry_plug->lrPot = -1;
647  doLJfortran( pos, frc, &(entry_plug->lrPot), &passedCalcPot );
648
649
650  //   fprintf( stderr,
651  //   "lrPot =  %lf\n", entry_plug->lrPot );
652  
653 }
654  
655 void LJ_FF::initFortran( void ){
656  
657  int nLocal = entry_plug->n_atoms;
658  int *ident;
659  int isError;
660  int i;
661
662  ident = new int[nLocal];
663
664  for(i=0; i<nLocal; i++){
665    ident[i] = entry_plug->atoms[i]->getIdent();
666  }
667
668  isError = 0;
669  initLJfortran( &nLocal, ident, &isError );
670  
671  if(isError){
672    sprintf( painCave.errMsg,
673             "LJ_FF error: There was an error initializing the component list in fortran.\n" );
674    painCave.isFatal = 1;
675    simError();
676  }
677
678  
679 #ifdef IS_MPI
680  sprintf( checkPointMsg, "LJ_FF successfully initialized the fortran component list.\n" );
681  MPIcheckPoint();
682 #endif // is_mpi
683  
684  delete[] ident;
685
686 }
687  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines