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.
branches/development/src/visitors/RigidBodyVisitor.cpp (file contents), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 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]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 + * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   #include "visitors/RigidBodyVisitor.hpp"
43
44   #include "primitives/RigidBody.hpp"
45  
46  
47 < namespace oopse {
47 > namespace OpenMD {
48  
49 +  void LipidHeadVisitor::visit(RigidBody* rb){
50 +    Vector3d pos;
51 +    Vector3d u(0, 0, 1);
52 +    Vector3d newVec;
53 +    GenericData* data;
54 +    AtomData* atomData;
55 +    AtomInfo* atomInfo;
56 +    bool haveAtomData;
57 +    RotMat3x3d rotMatrix;
58  
59 +    if(!canVisit(rb->getType()))
60 +      return;
61  
62 < void LipidHeadVisitor::visit(RigidBody* rb){
62 >    pos = rb->getPos();
63 >    rotMatrix = rb->getA();
64 >    //matVecMul3(rotMatrix, u, newVec);
65 >    newVec = rotMatrix * u;
66  
67 <  Vector3d pos;
67 >    data = rb->getPropertyByName("ATOMDATA");
68  
69 <  Vector3d u(0, 0, 1);
69 >    if(data != NULL){
70 >      atomData = dynamic_cast<AtomData*>(data);  
71 >      
72 >      if(atomData == NULL){
73 >        std::cerr << "can not get Atom Data from " << rb->getType() << std::endl;
74 >        
75 >        atomData = new AtomData;
76 >        haveAtomData = false;      
77 >        
78 >      } else
79 >        haveAtomData = true;
80 >      
81 >    } else {
82 >      atomData = new AtomData;
83 >      haveAtomData = false;
84 >      
85 >    }
86  
87 <  Vector3d newVec;
87 >    atomInfo = new AtomInfo;
88 >    atomInfo->atomTypeName = "X";
89 >    atomInfo->pos[0] = pos[0];
90 >    atomInfo->pos[1] = pos[1];
91 >    atomInfo->pos[2] = pos[2];
92 >    atomInfo->vec[0] = newVec[0];
93 >    atomInfo->vec[1] = newVec[1];
94 >    atomInfo->vec[2] = newVec[2];
95  
96 <  GenericData* data;
96 >    atomData->addAtomInfo(atomInfo);
97  
98 <  AtomData* atomData;
99 <
100 <  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 <
98 >    if(!haveAtomData){
99 >      atomData->setID("ATOMDATA");
100 >      rb->addProperty(atomData);
101      }
102  
105    else
106
107      haveAtomData = true;
108
103    }
104  
111  else{
105  
106 <    atomData = new AtomData;
106 >  void LipidHeadVisitor::addLipidHeadName(const std::string& name){
107 >    lipidHeadName.insert(name);
108  
115    haveAtomData = false;
116
109    }
110  
111 +  bool LipidHeadVisitor::canVisit(const std::string& name){
112 +    return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
113  
114 +  }
115  
121  atomInfo = new AtomInfo;
116  
117 <  atomInfo->AtomType = "X";
117 >  const  std::string LipidHeadVisitor::toString(){
118 >    char buffer[65535];
119 >    std::string result;
120 >    std::set<std::string>::iterator i;
121  
122 <  atomInfo->pos[0] = pos[0];
122 >    sprintf(buffer ,"------------------------------------------------------------------\n");
123 >    result += buffer;
124  
125 <  atomInfo->pos[1] = pos[1];
125 >    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
126 >    result += buffer;
127  
128 <  atomInfo->pos[2] = pos[2];
128 >    //print the ignore type list
129 >    sprintf(buffer , "lipidHeadName list contains below types:\n");
130 >    result += buffer;
131  
132 <  atomInfo->dipole[0] = newVec[0];
132 >    for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
133 >      sprintf(buffer ,"%s\t", i->c_str());
134 >      result += buffer;
135 >    }
136  
137 <  atomInfo->dipole[1] = newVec[1];
137 >    sprintf(buffer ,"\n");
138 >    result += buffer;
139  
140 <  atomInfo->dipole[2] = newVec[2];
140 >    sprintf(buffer ,"------------------------------------------------------------------\n");
141 >    result += buffer;
142  
143 +    return result;
144  
145 +  }
146  
139  atomData->addAtomInfo(atomInfo);
147  
148 +  void RBCOMVisitor::visit(RigidBody* rb){
149 +    AtomData* atomData;
150 +    AtomInfo* atomInfo;
151 +    Vector3d pos;
152  
153 +    pos = rb->getPos();
154 +    atomInfo = new AtomInfo;
155 +    atomInfo->atomTypeName = "X";
156 +    atomInfo->pos[0] = pos[0];
157 +    atomInfo->pos[1] = pos[1];
158 +    atomInfo->pos[2] = pos[2];
159 +    atomInfo->vec[0] = 0;
160 +    atomInfo->vec[1] = 0;
161 +    atomInfo->vec[2] = 0;
162  
163 <  if(!haveAtomData){
144 <
163 >    atomData = new AtomData;
164      atomData->setID("ATOMDATA");
165 +    atomData->addAtomInfo(atomInfo);
166  
167      rb->addProperty(atomData);
168  
169    }
170  
151    
171  
172 < }
172 >  const  std::string RBCOMVisitor::toString(){
173 >    char buffer[65535];
174 >    std::string result;
175  
176 +    sprintf(buffer ,"------------------------------------------------------------------\n");
177 +    result += buffer;
178  
179 +    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
180 +    result += buffer;
181  
182 < void LipidHeadVisitor::addLipidHeadName(const std::string& name){
182 >    //print the ignore type list
183 >    sprintf(buffer , "Visitor Description: add a pseudo atom at the center of the mass of the rigidbody\n");
184 >    result += buffer;
185  
186 <  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 <
186 >    sprintf(buffer ,"------------------------------------------------------------------\n");
187      result += buffer;
188  
189 +    return result;
190 +
191    }
192  
193 + }//namespace OpenMD
194  
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

Comparing:
trunk/src/visitors/RigidBodyVisitor.cpp (property svn:keywords), Revision 385 by tim, Tue Mar 1 20:10:14 2005 UTC vs.
branches/development/src/visitors/RigidBodyVisitor.cpp (property svn:keywords), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines