ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/visitors/RigidBodyVisitor.cpp
(Generate patch)

Comparing trunk/src/visitors/RigidBodyVisitor.cpp (file contents):
Revision 2 by gezelter, Fri Sep 24 04:16:43 2004 UTC vs.
Revision 507 by gezelter, Fri Apr 15 22:04:00 2005 UTC

# Line 1 | Line 1
1 < #include "RigidBodyVisitor.hpp"
2 < #include "RigidBody.hpp"
3 < #include "MatVec3.h"
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 < void LipidHeadVisitor::visit(RigidBody* rb){
6 <  double pos[3];
7 <  double u[3] = {0, 0, 1};
8 <  double newVec[3];
9 <  GenericData* data;
10 <  AtomData* atomData;
11 <  AtomInfo* atomInfo;
12 <  bool haveAtomData;
13 <  double rotMatrix[3][3];
44 > #include "primitives/RigidBody.hpp"
45  
15  if(!canVisit(rb->getType()))
16    return;
46  
47 <  rb->getPos(pos);
19 <  rb->getA(rotMatrix);
20 <  matVecMul3(rotMatrix, u, newVec);
47 > namespace oopse {
48  
22  data = rb->getProperty("ATOMDATA");
23  if(data != NULL){
49  
50 <    atomData = dynamic_cast<AtomData*>(data);  
51 <    if(atomData == NULL){
52 <      cerr << "can not get Atom Data from " << rb->getType() << endl;
53 <      atomData = new AtomData;
54 <      haveAtomData = false;      
50 >
51 >  void LipidHeadVisitor::visit(RigidBody* rb){
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;
66 >
67 >    RotMat3x3d rotMatrix;
68 >
69 >
70 >
71 >    if(!canVisit(rb->getType()))
72 >
73 >      return;
74 >
75 >
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 >
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 <    else
111 <      haveAtomData = true;
110 >
111 >    else{
112 >
113 >      atomData = new AtomData;
114 >
115 >      haveAtomData = false;
116 >
117 >    }
118 >
119 >
120 >
121 >    atomInfo = new AtomInfo;
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 <  else{
155 <    atomData = new AtomData;
156 <    haveAtomData = false;
154 >
155 >
156 >
157 >  void LipidHeadVisitor::addLipidHeadName(const std::string& name){
158 >
159 >    lipidHeadName.insert(name);
160 >
161 >
162 >
163    }
164  
39  atomInfo = new AtomInfo;
40  atomInfo->AtomType = "X";
41  atomInfo->pos[0] = pos[0];
42  atomInfo->pos[1] = pos[1];
43  atomInfo->pos[2] = pos[2];
44  atomInfo->dipole[0] = newVec[0];
45  atomInfo->dipole[1] = newVec[1];
46  atomInfo->dipole[2] = newVec[2];
165  
48  atomData->addAtomInfo(atomInfo);
166  
167 <  if(!haveAtomData){
168 <    atomData->setID("ATOMDATA");
169 <    rb->addProperty(atomData);
167 >  bool LipidHeadVisitor::canVisit(const std::string& name){
168 >
169 >    return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
170 >
171 >
172 >
173    }
54    
55 }
174  
57 void LipidHeadVisitor::addLipidHeadName(const string& name){
58  lipidHeadName.insert(name);
175  
60 }
176  
177 < bool LipidHeadVisitor::canVisit(const string& name){
63 <  return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
177 >  const  std::string LipidHeadVisitor::toString(){
178  
179 < }
179 >    char buffer[65535];
180  
181 < const string LipidHeadVisitor::toString(){
182 <  char buffer[65535];
183 <  string result;
184 <  set<string>::iterator i;
181 >    std::string result;
182 >
183 >    std::set<std::string>::iterator i;
184 >
185    
186 <  sprintf(buffer ,"------------------------------------------------------------------\n");
187 <  result += buffer;
186 >
187 >    sprintf(buffer ,"------------------------------------------------------------------\n");
188 >
189 >    result += buffer;
190 >
191    
75  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
76  result += buffer;
192  
193 <  //print the ignore type list
79 <  sprintf(buffer , "lipidHeadName list contains below types:\n");
80 <  result += buffer;
193 >    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
194  
82  for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
83    sprintf(buffer ,"%s\t", i->c_str());
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  
87  sprintf(buffer ,"\n");
88  result += buffer;
235  
90  sprintf(buffer ,"------------------------------------------------------------------\n");
91  result += buffer;
236  
237 <  return result;
237 >  void RBCOMVisitor::visit(RigidBody* rb){
238  
239 < }
239 >    AtomData* atomData;
240  
241 < void RBCOMVisitor::visit(RigidBody* rb){
242 <  AtomData* atomData;
243 <  AtomInfo* atomInfo;
244 <  double pos[3];
241 >    AtomInfo* atomInfo;
242 >
243 >    Vector3d pos;
244 >
245    
102  rb->getPos(pos);
103  atomInfo = new AtomInfo;
104  atomInfo->AtomType = "X";
105  atomInfo->pos[0] = pos[0];
106  atomInfo->pos[1] = pos[1];
107  atomInfo->pos[2] = pos[2];
108  atomInfo->dipole[0] = 0;
109  atomInfo->dipole[1] = 0;
110  atomInfo->dipole[2] = 0;
246  
247 <  atomData = new AtomData;
113 <  atomData->setID("ATOMDATA");
114 <  atomData->addAtomInfo(atomInfo);
247 >    pos = rb->getPos();
248  
249 <  rb->addProperty(atomData);
117 < }
249 >    atomInfo = new AtomInfo;
250  
251 < const string RBCOMVisitor::toString(){
252 <  char buffer[65535];
253 <  string result;
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 >
280 >
281 >  const  std::string RBCOMVisitor::toString(){
282 >
283 >    char buffer[65535];
284 >
285 >    std::string result;
286 >
287    
288 <  sprintf(buffer ,"------------------------------------------------------------------\n");
289 <  result += buffer;
288 >
289 >    sprintf(buffer ,"------------------------------------------------------------------\n");
290 >
291 >    result += buffer;
292 >
293    
126  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
127  result += buffer;
294  
295 <  //print the ignore type list
130 <  sprintf(buffer , "Visitor Description: add a pseudo atom at the center of the mass of the rigidbody\n");
131 <  result += buffer;
295 >    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
296  
297 <  sprintf(buffer ,"------------------------------------------------------------------\n");
134 <  result += buffer;
297 >    result += buffer;
298  
136  return result;
299  
138 }
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 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines