--- trunk/mdtools/interface_implementation/LJ_FF.cpp 2003/01/22 21:45:20 240 +++ trunk/mdtools/interface_implementation/LJ_FF.cpp 2003/02/04 20:15:48 263 @@ -9,7 +9,6 @@ using namespace std; #include "SRI.hpp" #include "simError.h" - // Declare the structures that will be passed by the parser and MPI typedef struct{ @@ -25,7 +24,6 @@ int parseAtomLJ( char *lineBuffer, int lineNum, atomSt int parseAtomLJ( char *lineBuffer, int lineNum, atomStruct &info ); #ifdef IS_MPI - #include "mpiForceField.h" MPI_Datatype mpiAtomStructType; @@ -64,7 +62,7 @@ void (*initLJfortran) ( int *nLocal, int *identArray, void (*newLJtype)( int* ident, double* mass, double* epslon, double* sigma, int* status ); -void (*initLJfortran) ( int *nLocal, int *identArray, int *isError ) +void (*initLJfortran) ( int *nLocal, int *identArray, int *isError ); LJ_FF* currentLJwrap; @@ -73,6 +71,7 @@ LJ_FF::LJ_FF(){ // begins the actual forcefield stuff. //**************************************************************** + LJ_FF::LJ_FF(){ char fileName[200]; @@ -207,15 +206,15 @@ void LJfunctionWrapper( void (*p1)( int* ident, double void LJfunctionWrapper( void (*p1)( int* ident, double* mass, double* epslon, double* sigma, int* status ), - void (*p2)( void ), + void (*p2)( int*, int*, int* ), void (*p3)( double* positionArray,double* forceArray, double* potentialEnergy, short int* doPotentialCalc ) ){ - p1 = newLJtype; - p2 = initLJfortran; - this->setLJfortran( p3 ); + newLJtype = p1; + initLJfortran = p2; + currentLJwrap->setLJfortran( p3 ); } @@ -242,7 +241,7 @@ void LJ_FF::initializeAtoms( void ){ // check for duplicates if( !strcmp( info.name, name ) ){ - sprintf( simError.painCave, + sprintf( painCave.errMsg, "Duplicate LJ atom type \"%s\" found in " "the LJ_FF param file./n", name ); @@ -307,7 +306,7 @@ void LJ_FF::initializeAtoms( void ){ headAtomType = new LinkedType; - fastFoward( "AtomTypes", "initializeAtoms" ); + fastForward( "AtomTypes", "initializeAtoms" ); // we are now at the AtomTypes section. @@ -351,10 +350,19 @@ void LJ_FF::initializeAtoms( void ){ "LJ_FF atom structures read successfully." ); MPIcheckPoint(); - currentAtomType = headAtomType; + currentAtomType = headAtomType->next; //skip the first element who is a place holder. while( currentAtomType != NULL ){ currentAtomType->duplicate( info ); + + + sendFrcStruct( &info, mpiAtomStructType ); + + sprintf( checkPointMsg, + "successfully sent lJ force type: \"%s\"\n", + info.name ); + MPIcheckPoint(); + currentAtomType = currentAtomType->next; } info.last = 1; @@ -370,9 +378,15 @@ void LJ_FF::initializeAtoms( void ){ headAtomType = new LinkedType; recieveFrcStruct( &info, mpiAtomStructType ); + while( !info.last ){ + + headAtomType->add( info ); + + MPIcheckPoint(); + recieveFrcStruct( &info, mpiAtomStructType ); } } @@ -386,7 +400,7 @@ void LJ_FF::initializeAtoms( void ){ if( currentAtomType->name[0] != '\0' ){ isError = 0; - newLJtype( &(currentAtomType->ident), + newLJtype( &(currentAtomType->ident), &(currentAtomType->mass), &(currentAtomType->epslon), &(currentAtomType->sigma), @@ -412,6 +426,7 @@ void LJ_FF::initializeAtoms( void ){ // initialize the atoms + double bigSigma = 0.0; Atom* thisAtom; for( i=0; isetSigma( currentAtomType->sigma ); the_atoms[i]->setIdent( currentAtomType->ident ); the_atoms[i]->setLJ(); + + if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma; } + + +#ifdef IS_MPI + double tempBig = bigSigma; + MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX ); +#endif //is_mpi + + //calc rCut and rList + + entry_plug->rCut = 2.5 * bigSigma; + if(entry_plug->rCut > (entry_plug->box_x / 2.0)) entry_plug->rCut = entry_plug->box_x / 2.0; + if(entry_plug->rCut > (entry_plug->box_y / 2.0)) entry_plug->rCut = entry_plug->box_y / 2.0; + if(entry_plug->rCut > (entry_plug->box_z / 2.0)) entry_plug->rCut = entry_plug->box_z / 2.0; + entry_plug->rList = entry_plug->rCut + 1.0; // clean up the memory @@ -443,6 +474,7 @@ void LJ_FF::initializeAtoms( void ){ #endif // is_mpi initFortran(); + entry_plug->refreshSim(); } @@ -587,13 +619,12 @@ void LJ_FF::doForces( void ){ } -void LJ_FF::doForces( void ){ +void LJ_FF::doForces( int calcPot ){ int i; double* frc; double* pos; - double potE; - short int calcPot = 0; + short int passedCalcPot = (short int)calcPot; // forces are zeroed here, before any are acumulated. // NOTE: do not rezero the forces in Fortran. @@ -605,7 +636,13 @@ void LJ_FF::doForces( void ){ frc = Atom::getFrcArray(); pos = Atom::getPosArray(); - doLJfortran( pos, frc, potE, calcPot ); +// entry_plug->lrPot = -1; + doLJfortran( pos, frc, &(entry_plug->lrPot), &passedCalcPot ); + + + // fprintf( stderr, + // "lrPot = %lf\n", entry_plug->lrPot ); + } void LJ_FF::initFortran( void ){ @@ -618,7 +655,7 @@ void LJ_FF::initFortran( void ){ ident = new int[nLocal]; for(i=0; iatoms[i]->getIdent(); + ident[i] = entry_plug->atoms[i]->getIdent(); } isError = 0;