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 291 by mmeineke, Wed Mar 5 20:35:54 2003 UTC vs.
Revision 299 by mmeineke, Fri Mar 7 19:31:02 2003 UTC

# Line 14 | Line 14 | using namespace std;
14   #include "SRI.hpp"
15   #include "simError.h"
16  
17 + #include <fortranWrappers.hpp>
18 +
19   #ifdef IS_MPI
20   #include "mpiForceField.h"
21   #endif // is_mpi
# Line 43 | Line 45 | namespace {
45   #endif
46   }
47  
46 // declaration of functions needed to wrap the fortran module
48  
48 extern "C" {
49  void forcefactory_( char* forceName,
50                      int* status,
51                      void (*wrapFunction)( void (*p1)( int* ident,
52                                                        double* mass,
53                                                        double* epslon,
54                                                        double* sigma,
55                                                        int* status ),
56                                            void (*p2)( int *nLocal,
57                                                        int *identArray,
58                                                        int *isError ),
59                                            void (*p3)( double* positionArray,
60                                                        double* forceArray,
61                                                        double* potentialEnergy,
62                                                        double* tau,
63                                                        short int* doPotentialCalc,
64                                                        int* isError)),
65                      int forceNameLength );
66 }
67
68
69 void LJfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon,
70                                   double* sigma, int* status ),
71                        void (*p2)( int *nLocal, int *identArray, int *isError ),
72                        void (*p3)( double* positionArray,double* forceArray,
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 );
78
79 void (*initLJfortran) ( int *nLocal, int *identArray, int *isError );
80
81 LJ_FF* currentLJwrap;
82
83
49   //****************************************************************
50   // begins the actual forcefield stuff.  
51   //****************************************************************
# Line 95 | Line 60 | LJ_FF::LJ_FF(){
60    char errMsg[1000];
61  
62    // do the funtion wrapping
63 <  currentLJwrap = this;
99 <  wrapMe();
63 >  wrapMeFF( this );
64  
65   #ifdef IS_MPI
66    int i;
# Line 195 | Line 159 | void LJ_FF::wrapMe( void ){
159   }
160  
161  
198 void LJ_FF::wrapMe( void ){
199  
200  char* currentFF = "LJ";
201  int isError = 0;
202  
203  forcefactory_( currentFF, &isError, LJfunctionWrapper, strlen(currentFF) );
162  
205  if( isError ){
206    
207    sprintf( painCave.errMsg,
208             "LJ_FF error: an error was returned from fortran when the "
209             "the functions were being wrapped.\n" );
210    painCave.isFatal = 1;
211    simError();
212  }
213
214 #ifdef IS_MPI
215  sprintf( checkPointMsg, "LJ_FF functions succesfully wrapped." );
216  MPIcheckPoint();
217 #endif // is_mpi
218 }
219  
220
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*,double*,double*,double*,
225                                    short int*, int* ) ){
226  
227  
228  newLJtype = p1;
229  initLJfortran = p2;
230  currentLJwrap->setLJfortran( p3 );
231 }
232
233
234
163   void LJ_FF::initializeAtoms( void ){
164    
165    class LinkedType {
# Line 408 | Line 336 | void LJ_FF::initializeAtoms( void ){
336    // call new A_types in fortran
337    
338    int isError;
339 +
340 +  // dummy variables
341 +  int isLJ = 1;
342 +  int isDipole = 0;
343 +  int isSSD = 0;
344 +  int isGB = 0;
345 +  double w0 = 0.0;
346 +  double v0 = 0.0;
347 +  double dipole = 0.0;
348 +  
349 +  
350    currentAtomType = headAtomType;
351    while( currentAtomType != NULL ){
352      
353      if( currentAtomType->name[0] != '\0' ){
354        isError = 0;
355 <          newLJtype( &(currentAtomType->ident),
356 <                 &(currentAtomType->mass),
357 <                 &(currentAtomType->epslon),
358 <                 &(currentAtomType->sigma),
359 <                 &isError );
355 >      newAtype( &(currentAtomType->ident),
356 >                &(currentAtomType->mass),
357 >                &(currentAtomType->epslon),
358 >                &(currentAtomType->sigma),
359 >                &isLJ, &isSSD, &isDipole, &isGB, &w0, &v0, &dipole,
360 >                &isError );
361        if( isError ){
362          sprintf( painCave.errMsg,
363                   "Error initializing the \"%s\" atom type in fortran\n",
# Line 486 | Line 426 | void LJ_FF::initializeAtoms( void ){
426    MPIcheckPoint();
427   #endif // is_mpi
428  
429 <  initFortran();
429 >  this->initFortran();
430    entry_plug->refreshSim();
431 <
431 >  
432   }
433  
434   void LJ_FF::initializeBonds( bond_pair* the_bonds ){
# Line 533 | Line 473 | void LJ_FF::doForces( int calcPot ){
473  
474   }
475  
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  
476   void LJ_FF::fastForward( char* stopText, char* searchOwner ){
477  
478    int foundText = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines