2 |
|
#include "AtomVisitor.hpp" |
3 |
|
#include "DirectionalAtom.hpp" |
4 |
|
#include "MatVec3.h" |
5 |
+ |
#include "RigidBody.hpp" |
6 |
|
|
7 |
+ |
void BaseAtomVisitor::visit(RigidBody* rb){ |
8 |
+ |
//vector<Atom*> myAtoms; |
9 |
+ |
//vector<Atom*>::iterator atomIter; |
10 |
+ |
|
11 |
+ |
//myAtoms = rb->getAtoms(); |
12 |
+ |
|
13 |
+ |
//for(atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter) |
14 |
+ |
// (*atomIter)->accept(this); |
15 |
+ |
} |
16 |
+ |
|
17 |
|
void BaseAtomVisitor::setVisited(Atom* atom){ |
18 |
|
GenericData* data; |
19 |
|
data = atom->getProperty("VISITED"); |
44 |
|
double ox[3] = {0.0, 0.0, -0.0654}; |
45 |
|
double u[3] = {0, 0, 1}; |
46 |
|
double rotMatrix[3][3]; |
47 |
+ |
double rotTrans[3][3]; |
48 |
|
AtomInfo* atomInfo; |
49 |
|
double pos[3]; |
50 |
|
double vel[3]; |
55 |
|
bool haveAtomData; |
56 |
|
|
57 |
|
//if atom is not SSD atom, just skip it |
58 |
< |
if(!strcmp(datom->getType(), "SSD")) |
58 |
> |
if(strcmp(datom->getType(), "SSD")) |
59 |
|
return; |
60 |
|
|
61 |
|
data = datom->getProperty("ATOMDATA"); |
79 |
|
datom->getPos(pos); |
80 |
|
datom->getQ(q); |
81 |
|
datom->getA(rotMatrix); |
82 |
+ |
|
83 |
+ |
// We need A^T to convert from body-fixed to space-fixed: |
84 |
+ |
transposeMat3(rotMatrix, rotTrans); |
85 |
|
|
86 |
|
//center of mass of the water molecule |
87 |
< |
matVecMul3(rotMatrix, u, newVec); |
87 |
> |
matVecMul3(rotTrans, u, newVec); |
88 |
|
atomInfo = new AtomInfo; |
89 |
|
atomInfo->AtomType = "X"; |
90 |
|
atomInfo->pos[0] = pos[0]; |
97 |
|
atomData->addAtomInfo(atomInfo); |
98 |
|
|
99 |
|
//oxygen |
100 |
< |
matVecMul3(rotMatrix, ox, newVec); |
100 |
> |
matVecMul3(rotTrans, ox, newVec); |
101 |
|
atomInfo = new AtomInfo; |
102 |
|
atomInfo->AtomType = "O"; |
103 |
|
atomInfo->pos[0] = pos[0] + newVec[0]; |
110 |
|
|
111 |
|
|
112 |
|
//hydrogen1 |
113 |
< |
matVecMul3(rotMatrix, h1, newVec); |
113 |
> |
matVecMul3(rotTrans, h1, newVec); |
114 |
|
atomInfo = new AtomInfo; |
115 |
|
atomInfo->AtomType = "H"; |
116 |
|
atomInfo->pos[0] = pos[0] + newVec[0]; |
122 |
|
atomData->addAtomInfo(atomInfo); |
123 |
|
|
124 |
|
//hydrogen2 |
125 |
< |
matVecMul3(rotMatrix, h2, newVec); |
125 |
> |
matVecMul3(rotTrans, h2, newVec); |
126 |
|
atomInfo = new AtomInfo; |
127 |
|
atomInfo->AtomType = "H"; |
128 |
|
atomInfo->pos[0] = pos[0] + newVec[0]; |
144 |
|
|
145 |
|
} |
146 |
|
|
147 |
+ |
const string SSDAtomVisitor::toString(){ |
148 |
+ |
char buffer[65535]; |
149 |
+ |
string result; |
150 |
+ |
|
151 |
+ |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
152 |
+ |
result += buffer; |
153 |
+ |
|
154 |
+ |
sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); |
155 |
+ |
result += buffer; |
156 |
+ |
|
157 |
+ |
sprintf(buffer , "Visitor Description: Convert SSD into 4 different atoms\n"); |
158 |
+ |
result += buffer; |
159 |
+ |
|
160 |
+ |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
161 |
+ |
result += buffer; |
162 |
+ |
|
163 |
+ |
return result; |
164 |
+ |
} |
165 |
+ |
|
166 |
+ |
//----------------------------------------------------------------------------// |
167 |
+ |
|
168 |
|
void DefaultAtomVisitor::visit(Atom* atom){ |
169 |
|
AtomData* atomData; |
170 |
|
AtomInfo* atomInfo; |
174 |
|
return; |
175 |
|
|
176 |
|
atomInfo =new AtomInfo; |
177 |
+ |
|
178 |
+ |
atomData = new AtomData; |
179 |
+ |
atomData->setID("ATOMDATA"); |
180 |
|
|
181 |
|
atom->getPos(pos); |
182 |
|
atomInfo->AtomType = atom->getType(); |
187 |
|
atomInfo->dipole[1] = 0.0; |
188 |
|
atomInfo->dipole[2] = 0.0; |
189 |
|
|
190 |
< |
atomData = new AtomData; |
191 |
< |
atomData->setID("ATOMDATA"); |
190 |
> |
|
191 |
> |
atomData->addAtomInfo(atomInfo); |
192 |
> |
|
193 |
|
atom->addProperty(atomData); |
194 |
|
|
195 |
|
setVisited(atom); |
206 |
|
datom->getPos(pos); |
207 |
|
datom->getU(u); |
208 |
|
|
209 |
+ |
atomData = new AtomData; |
210 |
+ |
atomData->setID("ATOMDATA"); |
211 |
|
atomInfo =new AtomInfo; |
212 |
|
|
213 |
|
atomInfo->AtomType = datom->getType(); |
218 |
|
atomInfo->dipole[1] = u[1]; |
219 |
|
atomInfo->dipole[2] = u[2]; |
220 |
|
|
221 |
< |
atomData = new AtomData; |
222 |
< |
atomData->setID("ATOMDATA"); |
221 |
> |
atomData->addAtomInfo(atomInfo); |
222 |
> |
|
223 |
|
datom->addProperty(atomData); |
224 |
|
|
225 |
|
setVisited(datom); |
226 |
|
} |
227 |
< |
|
227 |
> |
|
228 |
> |
|
229 |
> |
const string DefaultAtomVisitor::toString(){ |
230 |
> |
char buffer[65535]; |
231 |
> |
string result; |
232 |
> |
|
233 |
> |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
234 |
> |
result += buffer; |
235 |
> |
|
236 |
> |
sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); |
237 |
> |
result += buffer; |
238 |
> |
|
239 |
> |
sprintf(buffer , "Visitor Description: copy atom infomation into atom data\n"); |
240 |
> |
result += buffer; |
241 |
> |
|
242 |
> |
sprintf(buffer ,"------------------------------------------------------------------\n"); |
243 |
> |
result += buffer; |
244 |
> |
|
245 |
> |
return result; |
246 |
> |
} |