ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/visitors/RigidBodyVisitor.cpp
Revision: 1665
Committed: Tue Nov 22 20:38:56 2011 UTC (13 years, 5 months ago) by gezelter
File size: 5682 byte(s)
Log Message:
updated copyright notices

File Contents

# User Rev Content
1 gezelter 507 /*
2 gezelter 246 * 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 gezelter 1390 * 1. Redistributions of source code must retain the above copyright
10 gezelter 246 * notice, this list of conditions and the following disclaimer.
11     *
12 gezelter 1390 * 2. Redistributions in binary form must reproduce the above copyright
13 gezelter 246 * 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 gezelter 1390 *
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 gezelter 1665 * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010).
40     * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41 gezelter 246 */
42    
43 tim 3 #include "visitors/RigidBodyVisitor.hpp"
44     #include "primitives/RigidBody.hpp"
45 gezelter 246
46 gezelter 2
47 gezelter 1390 namespace OpenMD {
48 tim 132
49 gezelter 507 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 gezelter 246
59 gezelter 507 if(!canVisit(rb->getType()))
60     return;
61 gezelter 2
62 gezelter 507 pos = rb->getPos();
63     rotMatrix = rb->getA();
64     //matVecMul3(rotMatrix, u, newVec);
65     newVec = rotMatrix * u;
66 gezelter 246
67 gezelter 507 data = rb->getPropertyByName("ATOMDATA");
68 gezelter 246
69 gezelter 507 if(data != NULL){
70     atomData = dynamic_cast<AtomData*>(data);
71 chrisfen 1008
72 gezelter 507 if(atomData == NULL){
73     std::cerr << "can not get Atom Data from " << rb->getType() << std::endl;
74 chrisfen 1008
75 gezelter 507 atomData = new AtomData;
76     haveAtomData = false;
77 chrisfen 1008
78     } else
79 gezelter 507 haveAtomData = true;
80 chrisfen 1008
81     } else {
82 gezelter 507 atomData = new AtomData;
83     haveAtomData = false;
84 chrisfen 1008
85 gezelter 507 }
86 gezelter 2
87 gezelter 507 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 gezelter 1456 atomInfo->vec[0] = newVec[0];
93     atomInfo->vec[1] = newVec[1];
94     atomInfo->vec[2] = newVec[2];
95 gezelter 2
96 gezelter 507 atomData->addAtomInfo(atomInfo);
97 gezelter 2
98 gezelter 507 if(!haveAtomData){
99     atomData->setID("ATOMDATA");
100     rb->addProperty(atomData);
101     }
102 gezelter 246
103 gezelter 507 }
104 gezelter 2
105 gezelter 246
106 gezelter 507 void LipidHeadVisitor::addLipidHeadName(const std::string& name){
107     lipidHeadName.insert(name);
108 gezelter 2
109 gezelter 507 }
110 gezelter 2
111 gezelter 507 bool LipidHeadVisitor::canVisit(const std::string& name){
112     return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
113 gezelter 2
114 gezelter 507 }
115 gezelter 2
116 gezelter 246
117 gezelter 507 const std::string LipidHeadVisitor::toString(){
118     char buffer[65535];
119     std::string result;
120     std::set<std::string>::iterator i;
121 gezelter 246
122 gezelter 507 sprintf(buffer ,"------------------------------------------------------------------\n");
123     result += buffer;
124 gezelter 246
125 gezelter 507 sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
126     result += buffer;
127 gezelter 2
128 gezelter 507 //print the ignore type list
129     sprintf(buffer , "lipidHeadName list contains below types:\n");
130     result += buffer;
131 gezelter 2
132 gezelter 507 for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
133     sprintf(buffer ,"%s\t", i->c_str());
134     result += buffer;
135     }
136 gezelter 2
137 gezelter 507 sprintf(buffer ,"\n");
138     result += buffer;
139 gezelter 2
140 gezelter 507 sprintf(buffer ,"------------------------------------------------------------------\n");
141     result += buffer;
142 gezelter 2
143 gezelter 507 return result;
144 gezelter 2
145 gezelter 507 }
146 gezelter 2
147 gezelter 246
148 gezelter 507 void RBCOMVisitor::visit(RigidBody* rb){
149     AtomData* atomData;
150     AtomInfo* atomInfo;
151     Vector3d pos;
152 gezelter 246
153 gezelter 507 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 gezelter 1456 atomInfo->vec[0] = 0;
160     atomInfo->vec[1] = 0;
161     atomInfo->vec[2] = 0;
162 gezelter 2
163 gezelter 507 atomData = new AtomData;
164     atomData->setID("ATOMDATA");
165     atomData->addAtomInfo(atomInfo);
166 gezelter 2
167 gezelter 507 rb->addProperty(atomData);
168 gezelter 246
169 gezelter 507 }
170 gezelter 2
171 gezelter 246
172 gezelter 507 const std::string RBCOMVisitor::toString(){
173     char buffer[65535];
174     std::string result;
175 gezelter 246
176 gezelter 507 sprintf(buffer ,"------------------------------------------------------------------\n");
177     result += buffer;
178 gezelter 246
179 gezelter 507 sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
180     result += buffer;
181 gezelter 2
182 gezelter 507 //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 gezelter 2
186 gezelter 507 sprintf(buffer ,"------------------------------------------------------------------\n");
187     result += buffer;
188 gezelter 2
189 gezelter 507 return result;
190 gezelter 2
191 gezelter 507 }
192 gezelter 2
193 gezelter 1390 }//namespace OpenMD
194 gezelter 246

Properties

Name Value
svn:executable *
svn:keywords Author Id Revision Date