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 3 by tim, Fri Sep 24 16:27:58 2004 UTC vs.
branches/development/src/visitors/RigidBodyVisitor.cpp (file contents), Revision 1465 by chuckv, Fri Jul 9 23:08:25 2010 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. Redistributions of source code must retain the above copyright
10 + *    notice, this list of conditions and the following disclaimer.
11 + *
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.
16 + *
17 + * This software is provided "AS IS," without a warranty of any
18 + * kind. All express or implied conditions, representations and
19 + * warranties, including any implied warranty of merchantability,
20 + * fitness for a particular purpose or non-infringement, are hereby
21 + * excluded.  The University of Notre Dame and its licensors shall not
22 + * be liable for any damages suffered by licensee as a result of
23 + * using, modifying or distributing the software or its
24 + * derivatives. In no event will the University of Notre Dame or its
25 + * licensors be liable for any lost revenue, profit or data, or for
26 + * direct, indirect, special, consequential, incidental or punitive
27 + * damages, however caused and regardless of the theory of liability,
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   #include "primitives/RigidBody.hpp"
3 #include "math/MatVec3.h"
44  
5 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];
45  
46 <  if(!canVisit(rb->getType()))
16 <    return;
46 > namespace OpenMD {
47  
48 <  rb->getPos(pos);
49 <  rb->getA(rotMatrix);
50 <  matVecMul3(rotMatrix, u, newVec);
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 <  data = rb->getProperty("ATOMDATA");
59 <  if(data != NULL){
58 >    if(!canVisit(rb->getType()))
59 >      return;
60  
61 <    atomData = dynamic_cast<AtomData*>(data);  
62 <    if(atomData == NULL){
63 <      cerr << "can not get Atom Data from " << rb->getType() << endl;
64 <      atomData = new AtomData;
65 <      haveAtomData = false;      
61 >    pos = rb->getPos();
62 >    rotMatrix = rb->getA();
63 >    //matVecMul3(rotMatrix, u, newVec);
64 >    newVec = rotMatrix * u;
65 >
66 >    data = rb->getPropertyByName("ATOMDATA");
67 >
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 <    else
86 <      haveAtomData = true;
85 >
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->vec[0] = newVec[0];
92 >    atomInfo->vec[1] = newVec[1];
93 >    atomInfo->vec[2] = newVec[2];
94 >
95 >    atomData->addAtomInfo(atomInfo);
96 >
97 >    if(!haveAtomData){
98 >      atomData->setID("ATOMDATA");
99 >      rb->addProperty(atomData);
100 >    }
101 >
102    }
34  else{
35    atomData = new AtomData;
36    haveAtomData = false;
37  }
103  
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];
104  
105 <  atomData->addAtomInfo(atomInfo);
105 >  void LipidHeadVisitor::addLipidHeadName(const std::string& name){
106 >    lipidHeadName.insert(name);
107  
50  if(!haveAtomData){
51    atomData->setID("ATOMDATA");
52    rb->addProperty(atomData);
108    }
54    
55 }
109  
110 < void LipidHeadVisitor::addLipidHeadName(const string& name){
111 <  lipidHeadName.insert(name);
110 >  bool LipidHeadVisitor::canVisit(const std::string& name){
111 >    return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
112  
113 < }
113 >  }
114  
62 bool LipidHeadVisitor::canVisit(const string& name){
63  return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
115  
116 < }
116 >  const  std::string LipidHeadVisitor::toString(){
117 >    char buffer[65535];
118 >    std::string result;
119 >    std::set<std::string>::iterator i;
120  
121 < const string LipidHeadVisitor::toString(){
122 <  char buffer[65535];
69 <  string result;
70 <  set<string>::iterator i;
71 <  
72 <  sprintf(buffer ,"------------------------------------------------------------------\n");
73 <  result += buffer;
74 <  
75 <  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
76 <  result += buffer;
121 >    sprintf(buffer ,"------------------------------------------------------------------\n");
122 >    result += buffer;
123  
124 <  //print the ignore type list
125 <  sprintf(buffer , "lipidHeadName list contains below types:\n");
80 <  result += buffer;
124 >    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
125 >    result += buffer;
126  
127 <  for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
128 <    sprintf(buffer ,"%s\t", i->c_str());
127 >    //print the ignore type list
128 >    sprintf(buffer , "lipidHeadName list contains below types:\n");
129      result += buffer;
130 +
131 +    for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
132 +      sprintf(buffer ,"%s\t", i->c_str());
133 +      result += buffer;
134 +    }
135 +
136 +    sprintf(buffer ,"\n");
137 +    result += buffer;
138 +
139 +    sprintf(buffer ,"------------------------------------------------------------------\n");
140 +    result += buffer;
141 +
142 +    return result;
143 +
144    }
145  
87  sprintf(buffer ,"\n");
88  result += buffer;
146  
147 <  sprintf(buffer ,"------------------------------------------------------------------\n");
148 <  result += buffer;
147 >  void RBCOMVisitor::visit(RigidBody* rb){
148 >    AtomData* atomData;
149 >    AtomInfo* atomInfo;
150 >    Vector3d pos;
151  
152 <  return result;
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->vec[0] = 0;
159 >    atomInfo->vec[1] = 0;
160 >    atomInfo->vec[2] = 0;
161  
162 < }
162 >    atomData = new AtomData;
163 >    atomData->setID("ATOMDATA");
164 >    atomData->addAtomInfo(atomInfo);
165  
166 < void RBCOMVisitor::visit(RigidBody* rb){
98 <  AtomData* atomData;
99 <  AtomInfo* atomInfo;
100 <  double pos[3];
101 <  
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;
166 >    rb->addProperty(atomData);
167  
168 <  atomData = new AtomData;
113 <  atomData->setID("ATOMDATA");
114 <  atomData->addAtomInfo(atomInfo);
168 >  }
169  
116  rb->addProperty(atomData);
117 }
170  
171 < const string RBCOMVisitor::toString(){
172 <  char buffer[65535];
173 <  string result;
122 <  
123 <  sprintf(buffer ,"------------------------------------------------------------------\n");
124 <  result += buffer;
125 <  
126 <  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
127 <  result += buffer;
171 >  const  std::string RBCOMVisitor::toString(){
172 >    char buffer[65535];
173 >    std::string result;
174  
175 <  //print the ignore type list
176 <  sprintf(buffer , "Visitor Description: add a pseudo atom at the center of the mass of the rigidbody\n");
131 <  result += buffer;
175 >    sprintf(buffer ,"------------------------------------------------------------------\n");
176 >    result += buffer;
177  
178 <  sprintf(buffer ,"------------------------------------------------------------------\n");
179 <  result += buffer;
178 >    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
179 >    result += buffer;
180  
181 <  return result;
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 < }
185 >    sprintf(buffer ,"------------------------------------------------------------------\n");
186 >    result += buffer;
187  
188 +    return result;
189 +
190 +  }
191 +
192 + }//namespace OpenMD
193 +

Comparing:
trunk/src/visitors/RigidBodyVisitor.cpp (property svn:keywords), Revision 3 by tim, Fri Sep 24 16:27:58 2004 UTC vs.
branches/development/src/visitors/RigidBodyVisitor.cpp (property svn:keywords), Revision 1465 by chuckv, Fri Jul 9 23:08:25 2010 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines