1 |
+ |
/* |
2 |
+ |
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
+ |
* |
4 |
+ |
* The University of Notre Dame grants you ("Licensee") a |
5 |
+ |
* non-exclusive, royalty free, license to use, modify and |
6 |
+ |
* redistribute this software in source and binary code form, provided |
7 |
+ |
* that the following conditions are met: |
8 |
+ |
* |
9 |
+ |
* 1. Acknowledgement of the program authors must be made in any |
10 |
+ |
* publication of scientific results based in part on use of the |
11 |
+ |
* program. An acceptable form of acknowledgement is citation of |
12 |
+ |
* the article in which the program was described (Matthew |
13 |
+ |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
+ |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
+ |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
+ |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
+ |
* |
18 |
+ |
* 2. Redistributions of source code must retain the above copyright |
19 |
+ |
* notice, this list of conditions and the following disclaimer. |
20 |
+ |
* |
21 |
+ |
* 3. Redistributions in binary form must reproduce the above copyright |
22 |
+ |
* notice, this list of conditions and the following disclaimer in the |
23 |
+ |
* documentation and/or other materials provided with the |
24 |
+ |
* distribution. |
25 |
+ |
* |
26 |
+ |
* This software is provided "AS IS," without a warranty of any |
27 |
+ |
* kind. All express or implied conditions, representations and |
28 |
+ |
* warranties, including any implied warranty of merchantability, |
29 |
+ |
* fitness for a particular purpose or non-infringement, are hereby |
30 |
+ |
* excluded. The University of Notre Dame and its licensors shall not |
31 |
+ |
* be liable for any damages suffered by licensee as a result of |
32 |
+ |
* using, modifying or distributing the software or its |
33 |
+ |
* derivatives. In no event will the University of Notre Dame or its |
34 |
+ |
* licensors be liable for any lost revenue, profit or data, or for |
35 |
+ |
* direct, indirect, special, consequential, incidental or punitive |
36 |
+ |
* damages, however caused and regardless of the theory of liability, |
37 |
+ |
* arising out of the use of or inability to use software, even if the |
38 |
+ |
* University of Notre Dame has been advised of the possibility of |
39 |
+ |
* such damages. |
40 |
+ |
*/ |
41 |
+ |
|
42 |
|
#include "visitors/RigidBodyVisitor.hpp" |
43 |
+ |
|
44 |
|
#include "primitives/RigidBody.hpp" |
3 |
– |
#include "math/MatVec3.h" |
45 |
|
|
46 |
+ |
|
47 |
|
namespace oopse { |
48 |
|
|
49 |
+ |
|
50 |
+ |
|
51 |
|
void LipidHeadVisitor::visit(RigidBody* rb){ |
52 |
< |
double pos[3]; |
53 |
< |
double u[3] = {0, 0, 1}; |
54 |
< |
double newVec[3]; |
52 |
> |
|
53 |
> |
Vector3d pos; |
54 |
> |
|
55 |
> |
Vector3d u(0, 0, 1); |
56 |
> |
|
57 |
> |
Vector3d newVec; |
58 |
> |
|
59 |
|
GenericData* data; |
60 |
+ |
|
61 |
|
AtomData* atomData; |
62 |
+ |
|
63 |
|
AtomInfo* atomInfo; |
64 |
+ |
|
65 |
|
bool haveAtomData; |
15 |
– |
double rotMatrix[3][3]; |
66 |
|
|
67 |
+ |
RotMat3x3d rotMatrix; |
68 |
+ |
|
69 |
+ |
|
70 |
+ |
|
71 |
|
if(!canVisit(rb->getType())) |
72 |
+ |
|
73 |
|
return; |
74 |
|
|
20 |
– |
rb->getPos(pos); |
21 |
– |
rb->getA(rotMatrix); |
22 |
– |
matVecMul3(rotMatrix, u, newVec); |
75 |
|
|
76 |
< |
data = rb->getProperty("ATOMDATA"); |
76 |
> |
|
77 |
> |
pos = rb->getPos(); |
78 |
> |
|
79 |
> |
rotMatrix = rb->getA(); |
80 |
> |
|
81 |
> |
//matVecMul3(rotMatrix, u, newVec); |
82 |
> |
|
83 |
> |
newVec = rotMatrix * u; |
84 |
> |
|
85 |
> |
|
86 |
> |
|
87 |
> |
data = rb->getPropertyByName("ATOMDATA"); |
88 |
> |
|
89 |
|
if(data != NULL){ |
90 |
|
|
91 |
+ |
|
92 |
+ |
|
93 |
|
atomData = dynamic_cast<AtomData*>(data); |
94 |
+ |
|
95 |
|
if(atomData == NULL){ |
96 |
< |
cerr << "can not get Atom Data from " << rb->getType() << endl; |
96 |
> |
|
97 |
> |
std::cerr << "can not get Atom Data from " << rb->getType() << std::endl; |
98 |
> |
|
99 |
|
atomData = new AtomData; |
100 |
+ |
|
101 |
|
haveAtomData = false; |
102 |
+ |
|
103 |
|
} |
104 |
+ |
|
105 |
|
else |
106 |
+ |
|
107 |
|
haveAtomData = true; |
108 |
+ |
|
109 |
|
} |
110 |
+ |
|
111 |
|
else{ |
112 |
+ |
|
113 |
|
atomData = new AtomData; |
114 |
+ |
|
115 |
|
haveAtomData = false; |
116 |
+ |
|
117 |
|
} |
118 |
|
|
119 |
+ |
|
120 |
+ |
|
121 |
|
atomInfo = new AtomInfo; |
122 |
< |
atomInfo->AtomType = "X"; |
122 |
> |
|
123 |
> |
atomInfo->atomTypeName = "X"; |
124 |
> |
|
125 |
|
atomInfo->pos[0] = pos[0]; |
126 |
+ |
|
127 |
|
atomInfo->pos[1] = pos[1]; |
128 |
+ |
|
129 |
|
atomInfo->pos[2] = pos[2]; |
130 |
+ |
|
131 |
|
atomInfo->dipole[0] = newVec[0]; |
132 |
+ |
|
133 |
|
atomInfo->dipole[1] = newVec[1]; |
134 |
+ |
|
135 |
|
atomInfo->dipole[2] = newVec[2]; |
136 |
|
|
137 |
+ |
|
138 |
+ |
|
139 |
|
atomData->addAtomInfo(atomInfo); |
140 |
|
|
141 |
+ |
|
142 |
+ |
|
143 |
|
if(!haveAtomData){ |
144 |
+ |
|
145 |
|
atomData->setID("ATOMDATA"); |
146 |
+ |
|
147 |
|
rb->addProperty(atomData); |
148 |
+ |
|
149 |
|
} |
150 |
+ |
|
151 |
|
|
152 |
+ |
|
153 |
|
} |
154 |
|
|
155 |
< |
void LipidHeadVisitor::addLipidHeadName(const string& name){ |
155 |
> |
|
156 |
> |
|
157 |
> |
void LipidHeadVisitor::addLipidHeadName(const std::string& name){ |
158 |
> |
|
159 |
|
lipidHeadName.insert(name); |
160 |
|
|
161 |
+ |
|
162 |
+ |
|
163 |
|
} |
164 |
|
|
165 |
< |
bool LipidHeadVisitor::canVisit(const string& name){ |
165 |
> |
|
166 |
> |
|
167 |
> |
bool LipidHeadVisitor::canVisit(const std::string& name){ |
168 |
> |
|
169 |
|
return lipidHeadName.find(name) != lipidHeadName.end() ? true : false; |
170 |
|
|
171 |
+ |
|
172 |
+ |
|
173 |
|
} |
174 |
|
|
175 |
< |
const string LipidHeadVisitor::toString(){ |
175 |
> |
|
176 |
> |
|
177 |
> |
const std::string LipidHeadVisitor::toString(){ |
178 |
> |
|
179 |
|
char buffer[65535]; |
180 |
< |
string result; |
181 |
< |
set<string>::iterator i; |
180 |
> |
|
181 |
> |
std::string result; |
182 |
> |
|
183 |
> |
std::set<std::string>::iterator i; |
184 |
> |
|
185 |
|
|
186 |
+ |
|
187 |
|
sprintf(buffer ,"------------------------------------------------------------------\n"); |
188 |
+ |
|
189 |
|
result += buffer; |
190 |
+ |
|
191 |
|
|
192 |
+ |
|
193 |
|
sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); |
194 |
+ |
|
195 |
|
result += buffer; |
196 |
|
|
197 |
+ |
|
198 |
+ |
|
199 |
|
//print the ignore type list |
200 |
+ |
|
201 |
|
sprintf(buffer , "lipidHeadName list contains below types:\n"); |
202 |
+ |
|
203 |
|
result += buffer; |
204 |
|
|
205 |
+ |
|
206 |
+ |
|
207 |
|
for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){ |
208 |
+ |
|
209 |
|
sprintf(buffer ,"%s\t", i->c_str()); |
210 |
+ |
|
211 |
|
result += buffer; |
212 |
+ |
|
213 |
|
} |
214 |
|
|
215 |
+ |
|
216 |
+ |
|
217 |
|
sprintf(buffer ,"\n"); |
218 |
+ |
|
219 |
|
result += buffer; |
220 |
|
|
221 |
+ |
|
222 |
+ |
|
223 |
|
sprintf(buffer ,"------------------------------------------------------------------\n"); |
224 |
+ |
|
225 |
|
result += buffer; |
226 |
|
|
227 |
+ |
|
228 |
+ |
|
229 |
|
return result; |
230 |
|
|
231 |
+ |
|
232 |
+ |
|
233 |
|
} |
234 |
|
|
235 |
+ |
|
236 |
+ |
|
237 |
|
void RBCOMVisitor::visit(RigidBody* rb){ |
238 |
+ |
|
239 |
|
AtomData* atomData; |
240 |
+ |
|
241 |
|
AtomInfo* atomInfo; |
242 |
< |
double pos[3]; |
242 |
> |
|
243 |
> |
Vector3d pos; |
244 |
> |
|
245 |
|
|
246 |
< |
rb->getPos(pos); |
246 |
> |
|
247 |
> |
pos = rb->getPos(); |
248 |
> |
|
249 |
|
atomInfo = new AtomInfo; |
250 |
< |
atomInfo->AtomType = "X"; |
250 |
> |
|
251 |
> |
atomInfo->atomTypeName = "X"; |
252 |
> |
|
253 |
|
atomInfo->pos[0] = pos[0]; |
254 |
+ |
|
255 |
|
atomInfo->pos[1] = pos[1]; |
256 |
+ |
|
257 |
|
atomInfo->pos[2] = pos[2]; |
258 |
+ |
|
259 |
|
atomInfo->dipole[0] = 0; |
260 |
+ |
|
261 |
|
atomInfo->dipole[1] = 0; |
262 |
+ |
|
263 |
|
atomInfo->dipole[2] = 0; |
264 |
|
|
265 |
+ |
|
266 |
+ |
|
267 |
|
atomData = new AtomData; |
268 |
+ |
|
269 |
|
atomData->setID("ATOMDATA"); |
270 |
+ |
|
271 |
|
atomData->addAtomInfo(atomInfo); |
272 |
|
|
273 |
+ |
|
274 |
+ |
|
275 |
|
rb->addProperty(atomData); |
276 |
+ |
|
277 |
|
} |
278 |
|
|
279 |
< |
const string RBCOMVisitor::toString(){ |
279 |
> |
|
280 |
> |
|
281 |
> |
const std::string RBCOMVisitor::toString(){ |
282 |
> |
|
283 |
|
char buffer[65535]; |
284 |
< |
string result; |
284 |
> |
|
285 |
> |
std::string result; |
286 |
> |
|
287 |
|
|
288 |
+ |
|
289 |
|
sprintf(buffer ,"------------------------------------------------------------------\n"); |
290 |
+ |
|
291 |
|
result += buffer; |
292 |
+ |
|
293 |
|
|
294 |
+ |
|
295 |
|
sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str()); |
296 |
+ |
|
297 |
|
result += buffer; |
298 |
|
|
299 |
+ |
|
300 |
+ |
|
301 |
|
//print the ignore type list |
302 |
+ |
|
303 |
|
sprintf(buffer , "Visitor Description: add a pseudo atom at the center of the mass of the rigidbody\n"); |
304 |
+ |
|
305 |
|
result += buffer; |
306 |
|
|
307 |
+ |
|
308 |
+ |
|
309 |
|
sprintf(buffer ,"------------------------------------------------------------------\n"); |
310 |
+ |
|
311 |
|
result += buffer; |
312 |
|
|
313 |
+ |
|
314 |
+ |
|
315 |
|
return result; |
316 |
|
|
317 |
+ |
|
318 |
+ |
|
319 |
|
} |
320 |
|
|
321 |
|
|
322 |
+ |
|
323 |
+ |
|
324 |
+ |
|
325 |
|
}//namespace oopse |
326 |
+ |
|