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

Comparing trunk/mdtools/interface_implementation/LJ_FF.cpp (file contents):
Revision 238 by mmeineke, Fri Jan 17 21:53:36 2003 UTC vs.
Revision 254 by chuckv, Thu Jan 30 20:03:37 2003 UTC

# Line 9 | Line 9 | using namespace std;
9   #include "SRI.hpp"
10   #include "simError.h"
11  
12
12   // Declare the structures that will be passed by the parser and  MPI
13  
14   typedef struct{
# Line 25 | Line 24 | int parseAtomLJ( char *lineBuffer, int lineNum, atomSt
24   int parseAtomLJ( char *lineBuffer, int lineNum, atomStruct &info );
25  
26   #ifdef IS_MPI
28
27   #include "mpiForceField.h"
28  
29   MPI_Datatype mpiAtomStructType;
# Line 43 | Line 41 | extern "C" {
41                                                          double* epslon,
42                                                          double* sigma,
43                                                          int* status ),
44 <                                            void (*p2)( void ),
44 >                                            void (*p2)( int *nLocal,
45 >                                                        int *identArray,
46 >                                                        int *isError ),
47                                              void (*p3)( double* positionArray,
48                                                          double* forceArray,
49                                                          double* potentialEnergy,
# Line 54 | Line 54 | void LJfunctionWrapper( void (*p1)( int* ident, double
54  
55   void LJfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon,
56                                     double* sigma, int* status ),
57 <                        void (*p2)( void ),
57 >                        void (*p2)( int *nLocal, int *identArray, int *isError ),
58                          void (*p3)( double* positionArray,double* forceArray,
59                                      double* potentialEnergy,
60                                      short int* doPotentialCalc ) );
# Line 62 | Line 62 | void (*newLJtype)( int* ident, double* mass, double* e
62   void (*newLJtype)( int* ident, double* mass, double* epslon, double* sigma,
63                     int* status );
64  
65 < void (*initLJfortran)( void );
65 > void (*initLJfortran) ( int *nLocal, int *identArray, int *isError );
66  
67   LJ_FF* currentLJwrap;
68  
# Line 71 | Line 71 | LJ_FF* currentLJwrap;
71   // begins the actual forcefield stuff.  
72   //****************************************************************
73  
74 +
75   LJ_FF::LJ_FF(){
76  
77    char fileName[200];
# Line 205 | Line 206 | void LJfunctionWrapper( void (*p1)( int* ident, double
206  
207   void LJfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon,
208                                     double* sigma, int* status ),
209 <                        void (*p2)( void ),
209 >                        void (*p2)( int*, int*, int* ),
210                          void (*p3)( double* positionArray,double* forceArray,
211                                      double* potentialEnergy,
212                                      short int* doPotentialCalc ) ){
213    
214    
215 <  p1 = newLJtype;
216 <  p2 = initLJfortran;
217 <  this->setLJfortran( p3 );
215 >  newLJtype = p1;
216 >  initLJfortran = p2;
217 >  currentLJwrap->setLJfortran( p3 );
218   }
219  
220  
# Line 240 | Line 241 | void LJ_FF::initializeAtoms( void ){
241        // check for duplicates
242        
243        if( !strcmp( info.name, name ) ){
244 <        sprintf( simError.painCave,
244 >        sprintf( painCave.errMsg,
245                   "Duplicate LJ atom type \"%s\" found in "
246                   "the LJ_FF param file./n",
247                   name );
# Line 305 | Line 306 | void LJ_FF::initializeAtoms( void ){
306  
307      headAtomType = new LinkedType;
308      
309 <    fastFoward( "AtomTypes", "initializeAtoms" );
309 >    fastForward( "AtomTypes", "initializeAtoms" );
310  
311      // we are now at the AtomTypes section.
312      
# Line 382 | Line 383 | void LJ_FF::initializeAtoms( void ){
383    currentAtomType = headAtomType;
384    while( currentAtomType != NULL ){
385      
386 <    if( currentAtomType->name[0] != NULL ){
386 >    if( currentAtomType->name[0] != '\0' ){
387        isError = 0;
388 <      newLJtype( &(currentAtomType->ident),
388 >          newLJtype( &(currentAtomType->ident),
389                   &(currentAtomType->mass),
390                   &(currentAtomType->epslon),
391                   &(currentAtomType->sigma),
392 <                 isError );
392 >                 &isError );
393        if( isError ){
394          sprintf( painCave.errMsg,
395                   "Error initializing the \"%s\" atom type in fortran\n",
# Line 410 | Line 411 | void LJ_FF::initializeAtoms( void ){
411  
412    // initialize the atoms
413    
414 +  double bigSigma = 0.0;
415    Atom* thisAtom;
416  
417    for( i=0; i<nAtoms; i++ ){
# Line 428 | Line 430 | void LJ_FF::initializeAtoms( void ){
430      the_atoms[i]->setSigma( currentAtomType->sigma );
431      the_atoms[i]->setIdent( currentAtomType->ident );
432      the_atoms[i]->setLJ();
433 +
434 +    if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
435    }
436  
437 +  
438 + #ifdef IS_MPI
439 +  double tempBig = bigSigma;
440 +  MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX );
441 + #endif  //is_mpi
442  
443 +  //calc rCut and rList
444 +
445 +  entry_plug->rCut = 2.5 * bigSigma;
446 +  if(entry_plug->rCut > (entry_plug->box_x / 2.0)) entry_plug->rCut = entry_plug->box_x / 2.0;
447 +  if(entry_plug->rCut > (entry_plug->box_y / 2.0)) entry_plug->rCut = entry_plug->box_y / 2.0;
448 +  if(entry_plug->rCut > (entry_plug->box_z / 2.0)) entry_plug->rCut = entry_plug->box_z / 2.0;
449 +
450 +  entry_plug->rList = entry_plug->rCut + 1.0;
451 +
452    // clean up the memory
453    
454    delete headAtomType;
# Line 440 | Line 458 | void LJ_FF::initializeAtoms( void ){
458    MPIcheckPoint();
459   #endif // is_mpi
460  
461 +  initFortran();
462 +  entry_plug->refreshSim();
463 +
464   }
465  
466   void LJ_FF::initializeBonds( bond_pair* the_bonds ){
# Line 583 | Line 604 | int parseAtomLJ( char *lineBuffer, int lineNum,  atomS
604   }
605  
606  
607 < void LJ_FF::doForces( void ){
607 > void LJ_FF::doForces( int calcPot ){
608  
609    int i;
610    double* frc;
611    double* pos;
612 <  double potE;
592 <  short int calcPot = 0;
612 >  short int passedCalcPot = (short int)calcPot;
613  
614    // forces are zeroed here, before any are acumulated.
615    // NOTE: do not rezero the forces in Fortran.
# Line 601 | Line 621 | void LJ_FF::doForces( void ){
621    frc = Atom::getFrcArray();
622    pos = Atom::getPosArray();
623  
624 <  doLJfortran( pos, frc, potE, calcPot );
624 > //   entry_plug->lrPot = -1;
625 >  doLJfortran( pos, frc, &(entry_plug->lrPot), &passedCalcPot );
626 >
627 >
628 > //  fprintf( stderr,
629 > //         "lrPot =  %lf\n", entry_plug->lrPot );
630 >  
631   }
632    
633 + void LJ_FF::initFortran( void ){
634 +  
635 +  int nLocal = entry_plug->n_atoms;
636 +  int *ident;
637 +  int isError;
638 +  int i;
639 +
640 +  ident = new int[nLocal];
641 +
642 +  for(i=0; i<nLocal; i++){
643 +    ident[i] = entry_plug->atoms[i]->getIdent();
644 +  }
645 +
646 +  isError = 0;
647 +  initLJfortran( &nLocal, ident, &isError );
648 +  
649 +  if(isError){
650 +    sprintf( painCave.errMsg,
651 +             "LJ_FF error: There was an error initializing the component list in fortran.\n" );
652 +    painCave.isFatal = 1;
653 +    simError();
654 +  }
655 +
656 +  
657 + #ifdef IS_MPI
658 +  sprintf( checkPointMsg, "LJ_FF successfully initialized the fortran component list.\n" );
659 +  MPIcheckPoint();
660 + #endif // is_mpi
661 +  
662 +  delete[] ident;
663 +
664 + }
665 +  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines