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 385 by tim, Tue Mar 1 20:10:14 2005 UTC vs.
Revision 1390 by gezelter, Wed Nov 25 20:02:06 2009 UTC

# Line 1 | Line 1
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
# Line 6 | Line 6
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
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
35 + *                                                                      
36 + * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37 + * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 + * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 + * [4]  Vardeman & Gezelter, in progress (2009).                        
40   */
41  
42   #include "visitors/RigidBodyVisitor.hpp"
43
43   #include "primitives/RigidBody.hpp"
44  
45  
46 < namespace oopse {
46 > namespace OpenMD {
47  
48 +  void LipidHeadVisitor::visit(RigidBody* rb){
49 +    Vector3d pos;
50 +    Vector3d u(0, 0, 1);
51 +    Vector3d newVec;
52 +    GenericData* data;
53 +    AtomData* atomData;
54 +    AtomInfo* atomInfo;
55 +    bool haveAtomData;
56 +    RotMat3x3d rotMatrix;
57  
58 +    if(!canVisit(rb->getType()))
59 +      return;
60  
61 < void LipidHeadVisitor::visit(RigidBody* rb){
61 >    pos = rb->getPos();
62 >    rotMatrix = rb->getA();
63 >    //matVecMul3(rotMatrix, u, newVec);
64 >    newVec = rotMatrix * u;
65  
66 <  Vector3d pos;
66 >    data = rb->getPropertyByName("ATOMDATA");
67  
68 <  Vector3d u(0, 0, 1);
68 >    if(data != NULL){
69 >      atomData = dynamic_cast<AtomData*>(data);  
70 >      
71 >      if(atomData == NULL){
72 >        std::cerr << "can not get Atom Data from " << rb->getType() << std::endl;
73 >        
74 >        atomData = new AtomData;
75 >        haveAtomData = false;      
76 >        
77 >      } else
78 >        haveAtomData = true;
79 >      
80 >    } else {
81 >      atomData = new AtomData;
82 >      haveAtomData = false;
83 >      
84 >    }
85  
86 <  Vector3d newVec;
86 >    atomInfo = new AtomInfo;
87 >    atomInfo->atomTypeName = "X";
88 >    atomInfo->pos[0] = pos[0];
89 >    atomInfo->pos[1] = pos[1];
90 >    atomInfo->pos[2] = pos[2];
91 >    atomInfo->dipole[0] = newVec[0];
92 >    atomInfo->dipole[1] = newVec[1];
93 >    atomInfo->dipole[2] = newVec[2];
94  
95 <  GenericData* data;
95 >    atomData->addAtomInfo(atomInfo);
96  
97 <  AtomData* atomData;
98 <
99 <  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 <
97 >    if(!haveAtomData){
98 >      atomData->setID("ATOMDATA");
99 >      rb->addProperty(atomData);
100      }
101  
105    else
106
107      haveAtomData = true;
108
102    }
103  
111  else{
104  
105 <    atomData = new AtomData;
105 >  void LipidHeadVisitor::addLipidHeadName(const std::string& name){
106 >    lipidHeadName.insert(name);
107  
115    haveAtomData = false;
116
108    }
109  
110 +  bool LipidHeadVisitor::canVisit(const std::string& name){
111 +    return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
112  
113 +  }
114  
121  atomInfo = new AtomInfo;
115  
116 <  atomInfo->AtomType = "X";
116 >  const  std::string LipidHeadVisitor::toString(){
117 >    char buffer[65535];
118 >    std::string result;
119 >    std::set<std::string>::iterator i;
120  
121 <  atomInfo->pos[0] = pos[0];
121 >    sprintf(buffer ,"------------------------------------------------------------------\n");
122 >    result += buffer;
123  
124 <  atomInfo->pos[1] = pos[1];
124 >    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
125 >    result += buffer;
126  
127 <  atomInfo->pos[2] = pos[2];
127 >    //print the ignore type list
128 >    sprintf(buffer , "lipidHeadName list contains below types:\n");
129 >    result += buffer;
130  
131 <  atomInfo->dipole[0] = newVec[0];
131 >    for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
132 >      sprintf(buffer ,"%s\t", i->c_str());
133 >      result += buffer;
134 >    }
135  
136 <  atomInfo->dipole[1] = newVec[1];
136 >    sprintf(buffer ,"\n");
137 >    result += buffer;
138  
139 <  atomInfo->dipole[2] = newVec[2];
139 >    sprintf(buffer ,"------------------------------------------------------------------\n");
140 >    result += buffer;
141  
142 +    return result;
143  
144 +  }
145  
139  atomData->addAtomInfo(atomInfo);
146  
147 +  void RBCOMVisitor::visit(RigidBody* rb){
148 +    AtomData* atomData;
149 +    AtomInfo* atomInfo;
150 +    Vector3d pos;
151  
152 +    pos = rb->getPos();
153 +    atomInfo = new AtomInfo;
154 +    atomInfo->atomTypeName = "X";
155 +    atomInfo->pos[0] = pos[0];
156 +    atomInfo->pos[1] = pos[1];
157 +    atomInfo->pos[2] = pos[2];
158 +    atomInfo->dipole[0] = 0;
159 +    atomInfo->dipole[1] = 0;
160 +    atomInfo->dipole[2] = 0;
161  
162 <  if(!haveAtomData){
144 <
162 >    atomData = new AtomData;
163      atomData->setID("ATOMDATA");
164 +    atomData->addAtomInfo(atomInfo);
165  
166      rb->addProperty(atomData);
167  
168    }
169  
151    
170  
171 < }
171 >  const  std::string RBCOMVisitor::toString(){
172 >    char buffer[65535];
173 >    std::string result;
174  
175 +    sprintf(buffer ,"------------------------------------------------------------------\n");
176 +    result += buffer;
177  
178 +    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
179 +    result += buffer;
180  
181 < void LipidHeadVisitor::addLipidHeadName(const std::string& name){
181 >    //print the ignore type list
182 >    sprintf(buffer , "Visitor Description: add a pseudo atom at the center of the mass of the rigidbody\n");
183 >    result += buffer;
184  
185 <  lipidHeadName.insert(name);
160 <
161 <
162 <
163 < }
164 <
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 <
176 <
177 < const  std::string LipidHeadVisitor::toString(){
178 <
179 <  char buffer[65535];
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 <
185 >    sprintf(buffer ,"------------------------------------------------------------------\n");
186      result += buffer;
187  
188 +    return result;
189 +
190    }
191  
192 + }//namespace OpenMD
193  
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
243  Vector3d pos;
244
245  
246
247  pos = rb->getPos();
248
249  atomInfo = new AtomInfo;
250
251  atomInfo->AtomType = "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
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines