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 257 by chuckv, Thu Jan 30 22:29:24 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 (*initLJfortran)( void );
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::LJ_FF(){
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 349 | Line 350 | void LJ_FF::initializeAtoms( void ){
350               "LJ_FF atom structures read successfully." );
351      MPIcheckPoint();
352  
353 <    currentAtomType = headAtomType;
353 >    currentAtomType = headAtomType->next; //skip the first element who is a place holder.
354      while( currentAtomType != NULL ){
355        currentAtomType->duplicate( info );
356 +
357 +
358 +
359        sendFrcStruct( &info, mpiAtomStructType );
360 +
361 +      sprintf( checkPointMsg,
362 +               "successfully sent lJ force type: \"%s\"\n",
363 +               info.name );
364 +      MPIcheckPoint();
365 +
366        currentAtomType = currentAtomType->next;
367      }
368      info.last = 1;
# Line 368 | Line 378 | void LJ_FF::initializeAtoms( void ){
378  
379      headAtomType = new LinkedType;
380      recieveFrcStruct( &info, mpiAtomStructType );
381 +    
382      while( !info.last ){
383  
384 +
385 +
386        headAtomType->add( info );
387 +      
388 +      MPIcheckPoint();
389 +
390        recieveFrcStruct( &info, mpiAtomStructType );
391      }
392    }
# Line 382 | Line 398 | void LJ_FF::initializeAtoms( void ){
398    currentAtomType = headAtomType;
399    while( currentAtomType != NULL ){
400      
401 <    if( currentAtomType->name[0] != NULL ){
401 >    if( currentAtomType->name[0] != '\0' ){
402        isError = 0;
403 <      newLJtype( &(currentAtomType->ident),
403 >          newLJtype( &(currentAtomType->ident),
404                   &(currentAtomType->mass),
405                   &(currentAtomType->epslon),
406                   &(currentAtomType->sigma),
407 <                 isError );
407 >                 &isError );
408        if( isError ){
409          sprintf( painCave.errMsg,
410                   "Error initializing the \"%s\" atom type in fortran\n",
# Line 410 | Line 426 | void LJ_FF::initializeAtoms( void ){
426  
427    // initialize the atoms
428    
429 +  double bigSigma = 0.0;
430    Atom* thisAtom;
431  
432    for( i=0; i<nAtoms; i++ ){
# Line 428 | Line 445 | void LJ_FF::initializeAtoms( void ){
445      the_atoms[i]->setSigma( currentAtomType->sigma );
446      the_atoms[i]->setIdent( currentAtomType->ident );
447      the_atoms[i]->setLJ();
448 +
449 +    if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
450    }
451 +
452 +  
453 + #ifdef IS_MPI
454 +  double tempBig = bigSigma;
455 +  MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX );
456 + #endif  //is_mpi
457 +
458 +  //calc rCut and rList
459  
460 +  entry_plug->rCut = 2.5 * bigSigma;
461 +  if(entry_plug->rCut > (entry_plug->box_x / 2.0)) entry_plug->rCut = entry_plug->box_x / 2.0;
462 +  if(entry_plug->rCut > (entry_plug->box_y / 2.0)) entry_plug->rCut = entry_plug->box_y / 2.0;
463 +  if(entry_plug->rCut > (entry_plug->box_z / 2.0)) entry_plug->rCut = entry_plug->box_z / 2.0;
464  
465 +  entry_plug->rList = entry_plug->rCut + 1.0;
466 +
467    // clean up the memory
468    
469    delete headAtomType;
# Line 440 | Line 473 | void LJ_FF::initializeAtoms( void ){
473    MPIcheckPoint();
474   #endif // is_mpi
475  
476 +  initFortran();
477 +  entry_plug->refreshSim();
478 +
479   }
480  
481   void LJ_FF::initializeBonds( bond_pair* the_bonds ){
# Line 583 | Line 619 | void LJ_FF::doForces( void ){
619   }
620  
621  
622 < void LJ_FF::doForces( void ){
622 > void LJ_FF::doForces( int calcPot ){
623  
624    int i;
625    double* frc;
626    double* pos;
627 <  double potE;
592 <  short int calcPot = 0;
627 >  short int passedCalcPot = (short int)calcPot;
628  
629    // forces are zeroed here, before any are acumulated.
630    // NOTE: do not rezero the forces in Fortran.
# Line 601 | Line 636 | void LJ_FF::doForces( void ){
636    frc = Atom::getFrcArray();
637    pos = Atom::getPosArray();
638  
639 <  doLJfortran( pos, frc, potE, calcPot );
639 > //   entry_plug->lrPot = -1;
640 >  doLJfortran( pos, frc, &(entry_plug->lrPot), &passedCalcPot );
641 >
642 >
643 > //  fprintf( stderr,
644 > //         "lrPot =  %lf\n", entry_plug->lrPot );
645 >  
646   }
647    
648 + void LJ_FF::initFortran( void ){
649 +  
650 +  int nLocal = entry_plug->n_atoms;
651 +  int *ident;
652 +  int isError;
653 +  int i;
654 +
655 +  ident = new int[nLocal];
656 +
657 +  for(i=0; i<nLocal; i++){
658 +    ident[i] = entry_plug->atoms[i]->getIdent();
659 +  }
660 +
661 +  isError = 0;
662 +  initLJfortran( &nLocal, ident, &isError );
663 +  
664 +  if(isError){
665 +    sprintf( painCave.errMsg,
666 +             "LJ_FF error: There was an error initializing the component list in fortran.\n" );
667 +    painCave.isFatal = 1;
668 +    simError();
669 +  }
670 +
671 +  
672 + #ifdef IS_MPI
673 +  sprintf( checkPointMsg, "LJ_FF successfully initialized the fortran component list.\n" );
674 +  MPIcheckPoint();
675 + #endif // is_mpi
676 +  
677 +  delete[] ident;
678 +
679 + }
680 +  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines