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 |
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 |
|
//**************************************************************** |
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; |
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 { |
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", |
428 |
|
|
429 |
|
initFortran(); |
430 |
|
entry_plug->refreshSim(); |
431 |
< |
|
431 |
> |
|
432 |
|
} |
433 |
|
|
434 |
|
void LJ_FF::initializeBonds( bond_pair* the_bonds ){ |
478 |
|
int i, isError; |
479 |
|
double* frc; |
480 |
|
double* pos; |
481 |
+ |
double* trq; |
482 |
|
double* tau; |
483 |
|
short int passedCalcPot = (short int)calcPot; |
484 |
|
|
491 |
|
|
492 |
|
frc = Atom::getFrcArray(); |
493 |
|
pos = Atom::getPosArray(); |
494 |
+ |
trq = Atom::getTrqArray(); |
495 |
|
tau = entry_plug->tau; |
496 |
|
|
497 |
+ |
// dummy variables |
498 |
+ |
// NOTE: THIS IS A MAJOR POTENTIAL BUG!!!!!! be careful. |
499 |
+ |
// that said, here we go anyway. |
500 |
+ |
|
501 |
+ |
double* A = NULL; |
502 |
+ |
double* mu = NULL; |
503 |
+ |
double* u_l = NULL; |
504 |
+ |
|
505 |
|
isError = 0; |
506 |
< |
doLJfortran( pos, frc, &(entry_plug->lrPot), tau, &passedCalcPot, &isError ); |
506 |
> |
fortranForceLoop( pos, A, mu, u_l, frc, trq, tau, &(entry_plug->lrPot), |
507 |
> |
&passedCalcPot, &isError ); |
508 |
|
|
509 |
|
|
510 |
|
if( isError ){ |
536 |
|
} |
537 |
|
|
538 |
|
isError = 0; |
539 |
< |
initLJfortran( &nLocal, ident, &isError ); |
539 |
> |
initfortran( &nLocal, ident, &isError ); |
540 |
|
|
541 |
|
if(isError){ |
542 |
|
sprintf( painCave.errMsg, |