1 |
#include <cstdlib> |
2 |
|
3 |
#ifdef IS_MPI |
4 |
#include <mpi.h> |
5 |
#endif // is_mpi |
6 |
|
7 |
|
8 |
#include <simError.h> |
9 |
#include <ForceFields.hpp> |
10 |
#include <Atom.hpp> |
11 |
#include <fortranWrappers.hpp> |
12 |
|
13 |
|
14 |
void ForceFields::doForces( int calcPot ){ |
15 |
|
16 |
int i, isError; |
17 |
double* frc; |
18 |
double* pos; |
19 |
double* trq; |
20 |
double* tau; |
21 |
double* A; |
22 |
double* mu; |
23 |
double* u_l; |
24 |
|
25 |
short int passedCalcPot = (short int)calcPot; |
26 |
|
27 |
// forces are zeroed here, before any are acumulated. |
28 |
// NOTE: do not rezero the forces in Fortran. |
29 |
|
30 |
for(i=0; i<entry_plug->n_atoms; i++){ |
31 |
entry_plug->atoms[i]->zeroForces(); |
32 |
} |
33 |
|
34 |
frc = Atom::getFrcArray(); |
35 |
pos = Atom::getPosArray(); |
36 |
trq = Atom::getTrqArray(); |
37 |
A = Atom::getAmatArray(); |
38 |
mu = Atom::getMuArray(); |
39 |
u_l = Atom::getUlArray(); |
40 |
|
41 |
tau = entry_plug->tau; |
42 |
|
43 |
isError = 0; |
44 |
fortranForceLoop( pos, A, mu, u_l, frc, trq, tau, &(entry_plug->lrPot), |
45 |
&passedCalcPot, &isError ); |
46 |
|
47 |
|
48 |
if( isError ){ |
49 |
sprintf( painCave.errMsg, |
50 |
"Error returned from the fortran force calculation.\n" ); |
51 |
painCave.isFatal = 1; |
52 |
simError(); |
53 |
} |
54 |
|
55 |
#ifdef IS_MPI |
56 |
sprintf( checkPointMsg, |
57 |
"returned from the force calculation.\n" ); |
58 |
MPIcheckPoint(); |
59 |
#endif // is_mpi |
60 |
|
61 |
} |
62 |
|
63 |
|
64 |
void ForceFields::initFortran( void ){ |
65 |
|
66 |
int nLocal = entry_plug->n_atoms; |
67 |
int *ident; |
68 |
int isError; |
69 |
int i; |
70 |
|
71 |
ident = new int[nLocal]; |
72 |
|
73 |
for(i=0; i<nLocal; i++){ |
74 |
ident[i] = entry_plug->atoms[i]->getIdent(); |
75 |
} |
76 |
|
77 |
isError = 0; |
78 |
initfortran( &nLocal, ident, &isError ); |
79 |
|
80 |
if(isError){ |
81 |
sprintf( painCave.errMsg, |
82 |
"ForceField error: There was an error initializing the component list in fortran.\n" ); |
83 |
painCave.isFatal = 1; |
84 |
simError(); |
85 |
} |
86 |
|
87 |
|
88 |
#ifdef IS_MPI |
89 |
sprintf( checkPointMsg, "ForceField successfully initialized the fortran component list.\n" ); |
90 |
MPIcheckPoint(); |
91 |
#endif // is_mpi |
92 |
|
93 |
delete[] ident; |
94 |
|
95 |
} |