1 |
#include <stdlib.h> |
2 |
#include <vector> |
3 |
|
4 |
#include "AllCorr.hpp" |
5 |
|
6 |
|
7 |
AllCorr::AllCorr(){ |
8 |
|
9 |
pairCorrs = NULL; |
10 |
haveFrames = false; |
11 |
haveLength = false; |
12 |
} |
13 |
|
14 |
AllCorr::~AllCorr(){ |
15 |
int i; |
16 |
|
17 |
if( pairCorrs != NULL ){ |
18 |
for(i=0; i<nPairs; i++) |
19 |
delete pairCorrs[i]; |
20 |
delete[] pairCorrs; |
21 |
} |
22 |
} |
23 |
|
24 |
void AllCorr::setMaxLength( double theLength ){ |
25 |
maxLength = theLength; |
26 |
haveLength = true; |
27 |
} |
28 |
|
29 |
void AllCorr::setFrames( SimInfo* theInfoArray, int theNframes, |
30 |
DumpReader* theReader ){ |
31 |
int i; |
32 |
|
33 |
|
34 |
infoArray = theInfoArray; |
35 |
nFrames = theNframes; |
36 |
reader = theReader; |
37 |
|
38 |
nAtoms = infoArray[0].n_atoms; |
39 |
|
40 |
|
41 |
// allocate the first frame's atom arrays |
42 |
|
43 |
(infoArray[0].getConfiguration())->createArrays(infoArray[0].n_atoms); |
44 |
for (i = 0; i < infoArray[0].n_atoms; i++) |
45 |
infoArray[0].atoms[i]->setCoords(); |
46 |
|
47 |
// read in the first frame's positions |
48 |
|
49 |
reader->readFrame( &(infoArray[0]), 0 ); |
50 |
|
51 |
if( !haveLength ){ |
52 |
maxLength = infoArray[0].getMaxCutoff(); |
53 |
haveLength = true; |
54 |
} |
55 |
|
56 |
haveFrames = true; |
57 |
} |
58 |
|
59 |
void AllCorr::setPairCorrList( vector <PairCorrList> &theList ){ |
60 |
|
61 |
int i; |
62 |
char pair1[PCL_NAME_LENGTH]; |
63 |
char pair2[PCL_NAME_LENGTH]; |
64 |
|
65 |
if( !haveFrames ){ |
66 |
sprintf( painCave.errMsg, |
67 |
"\n" |
68 |
"AllCorr Error: attempt to create the pair correlations without" |
69 |
" first setting the Frames\n" ); |
70 |
painCave.isFatal = 1; |
71 |
simError(); |
72 |
} |
73 |
|
74 |
|
75 |
theList.sort(); |
76 |
|
77 |
nPairs = (int)theList.size(); |
78 |
pairCorrs = new PairCorrType*[nPairs]; |
79 |
|
80 |
for(i=0;i<nPairs;i++){ |
81 |
|
82 |
theList[i].getAtom1( pair1 ); |
83 |
theList[i].getAtom2( pair2 ); |
84 |
|
85 |
switch( theList[i].getType() ){ |
86 |
|
87 |
case gofr: |
88 |
pairCorrs[i] = new GofR(pair1, pair2, nAtoms); |
89 |
break; |
90 |
|
91 |
default: |
92 |
|
93 |
sprintf( painCave.errMsg, |
94 |
"AllCorr Error: Unrecognized pair corr type in " |
95 |
" setPairCorrList()->theList[%d]\n", |
96 |
i ); |
97 |
painCave.isFatal = 1; |
98 |
simError(); |
99 |
break; |
100 |
} |
101 |
} |
102 |
} |
103 |
|