ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/visitors/RigidBodyVisitor.cpp
(Generate patch)

Comparing trunk/OOPSE-2.0/src/visitors/RigidBodyVisitor.cpp (file contents):
Revision 1625 by tim, Thu Oct 21 16:22:01 2004 UTC vs.
Revision 1930 by gezelter, Wed Jan 12 22:41:40 2005 UTC

# Line 1 | Line 1
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"
45 +
46   #include "math/MatVec3.h"
47  
48 +
49 +
50   namespace oopse {
51  
52 +
53 +
54   void LipidHeadVisitor::visit(RigidBody* rb){
55 <  double pos[3];
56 <  double u[3] = {0, 0, 1};
57 <  double newVec[3];
55 >
56 >  Vector3d pos;
57 >
58 >  Vector3d u(0, 0, 1);
59 >
60 >  Vector3d newVec;
61 >
62    GenericData* data;
63 +
64    AtomData* atomData;
65 +
66    AtomInfo* atomInfo;
67 +
68    bool haveAtomData;
15  double rotMatrix[3][3];
69  
70 +  RotMat3x3d rotMatrix;
71 +
72 +
73 +
74    if(!canVisit(rb->getType()))
75 +
76      return;
77  
20  rb->getPos(pos);
21  rb->getA(rotMatrix);
22  matVecMul3(rotMatrix, u, newVec);
78  
79 <  data = rb->getProperty("ATOMDATA");
79 >
80 >  pos = rb->getPos();
81 >
82 >  rotMatrix = rb->getA();
83 >
84 >  //matVecMul3(rotMatrix, u, newVec);
85 >
86 >  newVec = rotMatrix * u;
87 >
88 >  
89 >
90 >  data = rb->getPropertyByName("ATOMDATA");
91 >
92    if(data != NULL){
93  
94 +
95 +
96      atomData = dynamic_cast<AtomData*>(data);  
97 +
98      if(atomData == NULL){
99 <      cerr << "can not get Atom Data from " << rb->getType() << endl;
99 >
100 >      std::cerr << "can not get Atom Data from " << rb->getType() << std::endl;
101 >
102        atomData = new AtomData;
103 +
104        haveAtomData = false;      
105 +
106      }
107 +
108      else
109 +
110        haveAtomData = true;
111 +
112    }
113 +
114    else{
115 +
116      atomData = new AtomData;
117 +
118      haveAtomData = false;
119 +
120    }
121  
122 +
123 +
124    atomInfo = new AtomInfo;
125 +
126    atomInfo->AtomType = "X";
127 +
128    atomInfo->pos[0] = pos[0];
129 +
130    atomInfo->pos[1] = pos[1];
131 +
132    atomInfo->pos[2] = pos[2];
133 +
134    atomInfo->dipole[0] = newVec[0];
135 +
136    atomInfo->dipole[1] = newVec[1];
137 +
138    atomInfo->dipole[2] = newVec[2];
139  
140 +
141 +
142    atomData->addAtomInfo(atomInfo);
143  
144 +
145 +
146    if(!haveAtomData){
147 +
148      atomData->setID("ATOMDATA");
149 +
150      rb->addProperty(atomData);
151 +
152    }
153 +
154      
155 +
156   }
157  
158 < void LipidHeadVisitor::addLipidHeadName(const string& name){
158 >
159 >
160 > void LipidHeadVisitor::addLipidHeadName(const std::string& name){
161 >
162    lipidHeadName.insert(name);
163  
164 +
165 +
166   }
167  
168 < bool LipidHeadVisitor::canVisit(const string& name){
168 >
169 >
170 > bool LipidHeadVisitor::canVisit(const std::string& name){
171 >
172    return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
173  
174 +
175 +
176   }
177  
178 < const string LipidHeadVisitor::toString(){
178 >
179 >
180 > const  std::string LipidHeadVisitor::toString(){
181 >
182    char buffer[65535];
183 <  string result;
184 <  set<string>::iterator i;
183 >
184 >   std::string result;
185 >
186 >   std::set<std::string>::iterator i;
187 >
188    
189 +
190    sprintf(buffer ,"------------------------------------------------------------------\n");
191 +
192    result += buffer;
193 +
194    
195 +
196    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
197 +
198    result += buffer;
199  
200 +
201 +
202    //print the ignore type list
203 +
204    sprintf(buffer , "lipidHeadName list contains below types:\n");
205 +
206    result += buffer;
207  
208 +
209 +
210    for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
211 +
212      sprintf(buffer ,"%s\t", i->c_str());
213 +
214      result += buffer;
215 +
216    }
217  
218 +
219 +
220    sprintf(buffer ,"\n");
221 +
222    result += buffer;
223  
224 +
225 +
226    sprintf(buffer ,"------------------------------------------------------------------\n");
227 +
228    result += buffer;
229  
230 +
231 +
232    return result;
233  
234 +
235 +
236   }
237  
238 +
239 +
240   void RBCOMVisitor::visit(RigidBody* rb){
241 +
242    AtomData* atomData;
243 +
244    AtomInfo* atomInfo;
245 <  double pos[3];
245 >
246 >  Vector3d pos;
247 >
248    
249 <  rb->getPos(pos);
249 >
250 >  pos = rb->getPos();
251 >
252    atomInfo = new AtomInfo;
253 +
254    atomInfo->AtomType = "X";
255 +
256    atomInfo->pos[0] = pos[0];
257 +
258    atomInfo->pos[1] = pos[1];
259 +
260    atomInfo->pos[2] = pos[2];
261 +
262    atomInfo->dipole[0] = 0;
263 +
264    atomInfo->dipole[1] = 0;
265 +
266    atomInfo->dipole[2] = 0;
267  
268 +
269 +
270    atomData = new AtomData;
271 +
272    atomData->setID("ATOMDATA");
273 +
274    atomData->addAtomInfo(atomInfo);
275  
276 +
277 +
278    rb->addProperty(atomData);
279 +
280   }
281  
282 < const string RBCOMVisitor::toString(){
282 >
283 >
284 > const  std::string RBCOMVisitor::toString(){
285 >
286    char buffer[65535];
287 <  string result;
287 >
288 >   std::string result;
289 >
290    
291 +
292    sprintf(buffer ,"------------------------------------------------------------------\n");
293 +
294    result += buffer;
295 +
296    
297 +
298    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
299 +
300    result += buffer;
301  
302 +
303 +
304    //print the ignore type list
305 +
306    sprintf(buffer , "Visitor Description: add a pseudo atom at the center of the mass of the rigidbody\n");
307 +
308    result += buffer;
309  
310 +
311 +
312    sprintf(buffer ,"------------------------------------------------------------------\n");
313 +
314    result += buffer;
315  
316 +
317 +
318    return result;
319  
320 +
321 +
322   }
323  
324  
325 +
326 +
327 +
328   }//namespace oopse
329 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines