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

Comparing trunk/src/visitors/RigidBodyVisitor.cpp (file contents):
Revision 132 by tim, Thu Oct 21 16:22:01 2004 UTC vs.
Revision 1879 by gezelter, Sun Jun 16 15:15:42 2013 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, 234107 (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"
44   #include "primitives/RigidBody.hpp"
3 #include "math/MatVec3.h"
45  
5 namespace oopse {
46  
47 < void LipidHeadVisitor::visit(RigidBody* rb){
8 <  double pos[3];
9 <  double u[3] = {0, 0, 1};
10 <  double newVec[3];
11 <  GenericData* data;
12 <  AtomData* atomData;
13 <  AtomInfo* atomInfo;
14 <  bool haveAtomData;
15 <  double rotMatrix[3][3];
47 > namespace OpenMD {
48  
49 <  if(!canVisit(rb->getType()))
50 <    return;
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 <  rb->getPos(pos);
60 <  rb->getA(rotMatrix);
22 <  matVecMul3(rotMatrix, u, newVec);
59 >    if(!canVisit(rb->getType()))
60 >      return;
61  
62 <  data = rb->getProperty("ATOMDATA");
63 <  if(data != NULL){
62 >    pos = rb->getPos();
63 >    rotMatrix = rb->getA();
64 >    //matVecMul3(rotMatrix, u, newVec);
65 >    newVec = rotMatrix * u;
66  
67 <    atomData = dynamic_cast<AtomData*>(data);  
68 <    if(atomData == NULL){
69 <      cerr << "can not get Atom Data from " << rb->getType() << endl;
70 <      atomData = new AtomData;
71 <      haveAtomData = false;      
67 >    data = rb->getPropertyByName("ATOMDATA");
68 >
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 <    else
87 <      haveAtomData = true;
86 >
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 >    atomData->addAtomInfo(atomInfo);
97 >
98 >    if(!haveAtomData){
99 >      atomData->setID("ATOMDATA");
100 >      rb->addProperty(atomData);
101 >    }
102 >
103    }
36  else{
37    atomData = new AtomData;
38    haveAtomData = false;
39  }
104  
41  atomInfo = new AtomInfo;
42  atomInfo->AtomType = "X";
43  atomInfo->pos[0] = pos[0];
44  atomInfo->pos[1] = pos[1];
45  atomInfo->pos[2] = pos[2];
46  atomInfo->dipole[0] = newVec[0];
47  atomInfo->dipole[1] = newVec[1];
48  atomInfo->dipole[2] = newVec[2];
105  
106 <  atomData->addAtomInfo(atomInfo);
106 >  void LipidHeadVisitor::addLipidHeadName(const std::string& name){
107 >    lipidHeadName.insert(name);
108  
52  if(!haveAtomData){
53    atomData->setID("ATOMDATA");
54    rb->addProperty(atomData);
109    }
56    
57 }
110  
111 < void LipidHeadVisitor::addLipidHeadName(const string& name){
112 <  lipidHeadName.insert(name);
111 >  bool LipidHeadVisitor::canVisit(const std::string& name){
112 >    return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
113  
114 < }
114 >  }
115  
64 bool LipidHeadVisitor::canVisit(const string& name){
65  return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
116  
117 < }
117 >  const  std::string LipidHeadVisitor::toString(){
118 >    char buffer[65535];
119 >    std::string result;
120 >    std::set<std::string>::iterator i;
121  
122 < const string LipidHeadVisitor::toString(){
123 <  char buffer[65535];
71 <  string result;
72 <  set<string>::iterator i;
73 <  
74 <  sprintf(buffer ,"------------------------------------------------------------------\n");
75 <  result += buffer;
76 <  
77 <  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
78 <  result += buffer;
122 >    sprintf(buffer ,"------------------------------------------------------------------\n");
123 >    result += buffer;
124  
125 <  //print the ignore type list
126 <  sprintf(buffer , "lipidHeadName list contains below types:\n");
82 <  result += buffer;
125 >    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
126 >    result += buffer;
127  
128 <  for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
129 <    sprintf(buffer ,"%s\t", i->c_str());
128 >    //print the ignore type list
129 >    sprintf(buffer , "lipidHeadName list contains below types:\n");
130      result += buffer;
131 +
132 +    for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
133 +      sprintf(buffer ,"%s\t", i->c_str());
134 +      result += buffer;
135 +    }
136 +
137 +    sprintf(buffer ,"\n");
138 +    result += buffer;
139 +
140 +    sprintf(buffer ,"------------------------------------------------------------------\n");
141 +    result += buffer;
142 +
143 +    return result;
144 +
145    }
146  
89  sprintf(buffer ,"\n");
90  result += buffer;
147  
148 <  sprintf(buffer ,"------------------------------------------------------------------\n");
149 <  result += buffer;
148 >  void RBCOMVisitor::visit(RigidBody* rb){
149 >    AtomData* atomData;
150 >    AtomInfo* atomInfo;
151 >    Vector3d pos;
152  
153 <  return result;
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 < }
163 >    atomData = new AtomData;
164 >    atomData->setID("ATOMDATA");
165 >    atomData->addAtomInfo(atomInfo);
166  
167 < void RBCOMVisitor::visit(RigidBody* rb){
100 <  AtomData* atomData;
101 <  AtomInfo* atomInfo;
102 <  double pos[3];
103 <  
104 <  rb->getPos(pos);
105 <  atomInfo = new AtomInfo;
106 <  atomInfo->AtomType = "X";
107 <  atomInfo->pos[0] = pos[0];
108 <  atomInfo->pos[1] = pos[1];
109 <  atomInfo->pos[2] = pos[2];
110 <  atomInfo->dipole[0] = 0;
111 <  atomInfo->dipole[1] = 0;
112 <  atomInfo->dipole[2] = 0;
167 >    rb->addProperty(atomData);
168  
169 <  atomData = new AtomData;
115 <  atomData->setID("ATOMDATA");
116 <  atomData->addAtomInfo(atomInfo);
169 >  }
170  
118  rb->addProperty(atomData);
119 }
171  
172 < const string RBCOMVisitor::toString(){
173 <  char buffer[65535];
174 <  string result;
124 <  
125 <  sprintf(buffer ,"------------------------------------------------------------------\n");
126 <  result += buffer;
127 <  
128 <  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
129 <  result += buffer;
172 >  const  std::string RBCOMVisitor::toString(){
173 >    char buffer[65535];
174 >    std::string result;
175  
176 <  //print the ignore type list
177 <  sprintf(buffer , "Visitor Description: add a pseudo atom at the center of the mass of the rigidbody\n");
133 <  result += buffer;
176 >    sprintf(buffer ,"------------------------------------------------------------------\n");
177 >    result += buffer;
178  
179 <  sprintf(buffer ,"------------------------------------------------------------------\n");
180 <  result += buffer;
179 >    sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
180 >    result += buffer;
181  
182 <  return result;
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 < }
186 >    sprintf(buffer ,"------------------------------------------------------------------\n");
187 >    result += buffer;
188  
189 +    return result;
190  
191 < }//namespace oopse
191 >  }
192 >
193 > }//namespace OpenMD
194 >

Comparing trunk/src/visitors/RigidBodyVisitor.cpp (property svn:keywords):
Revision 132 by tim, Thu Oct 21 16:22:01 2004 UTC vs.
Revision 1879 by gezelter, Sun Jun 16 15:15:42 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines