ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/visitors/RigidBodyVisitor.cpp
Revision: 2954
Committed: Wed Jul 19 12:35:31 2006 UTC (18 years, 2 months ago) by chrisfen
File size: 5591 byte(s)
Log Message:
Added TRED water visitor for Dump2XYZ visualization

File Contents

# User Rev Content
1 gezelter 2204 /*
2 gezelter 1930 * 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. 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
19     * notice, this list of conditions and the following disclaimer.
20     *
21     * 3. Redistributions in binary form must reproduce the above copyright
22     * notice, this list of conditions and the following disclaimer in the
23     * documentation and/or other materials provided with the
24     * distribution.
25     *
26     * This software is provided "AS IS," without a warranty of any
27     * kind. All express or implied conditions, representations and
28     * warranties, including any implied warranty of merchantability,
29     * fitness for a particular purpose or non-infringement, are hereby
30     * excluded. The University of Notre Dame and its licensors shall not
31     * be liable for any damages suffered by licensee as a result of
32     * using, modifying or distributing the software or its
33     * derivatives. In no event will the University of Notre Dame or its
34     * licensors be liable for any lost revenue, profit or data, or for
35     * direct, indirect, special, consequential, incidental or punitive
36     * damages, however caused and regardless of the theory of liability,
37     * arising out of the use of or inability to use software, even if the
38     * University of Notre Dame has been advised of the possibility of
39     * such damages.
40     */
41    
42 tim 1492 #include "visitors/RigidBodyVisitor.hpp"
43     #include "primitives/RigidBody.hpp"
44 gezelter 1930
45 gezelter 1490
46 tim 1625 namespace oopse {
47    
48 gezelter 2204 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 gezelter 1930
58 gezelter 2204 if(!canVisit(rb->getType()))
59     return;
60 gezelter 1490
61 gezelter 2204 pos = rb->getPos();
62     rotMatrix = rb->getA();
63     //matVecMul3(rotMatrix, u, newVec);
64     newVec = rotMatrix * u;
65 gezelter 1930
66 gezelter 2204 data = rb->getPropertyByName("ATOMDATA");
67 gezelter 1930
68 gezelter 2204 if(data != NULL){
69     atomData = dynamic_cast<AtomData*>(data);
70 chrisfen 2954
71 gezelter 2204 if(atomData == NULL){
72     std::cerr << "can not get Atom Data from " << rb->getType() << std::endl;
73 chrisfen 2954
74 gezelter 2204 atomData = new AtomData;
75     haveAtomData = false;
76 chrisfen 2954
77     } else
78 gezelter 2204 haveAtomData = true;
79 chrisfen 2954
80     } else {
81 gezelter 2204 atomData = new AtomData;
82     haveAtomData = false;
83 chrisfen 2954
84 gezelter 2204 }
85 gezelter 1490
86 gezelter 2204 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 gezelter 1490
95 gezelter 2204 atomData->addAtomInfo(atomInfo);
96 gezelter 1490
97 gezelter 2204 if(!haveAtomData){
98     atomData->setID("ATOMDATA");
99     rb->addProperty(atomData);
100     }
101 gezelter 1930
102 gezelter 2204 }
103 gezelter 1490
104 gezelter 1930
105 gezelter 2204 void LipidHeadVisitor::addLipidHeadName(const std::string& name){
106     lipidHeadName.insert(name);
107 gezelter 1490
108 gezelter 2204 }
109 gezelter 1490
110 gezelter 2204 bool LipidHeadVisitor::canVisit(const std::string& name){
111     return lipidHeadName.find(name) != lipidHeadName.end() ? true : false;
112 gezelter 1490
113 gezelter 2204 }
114 gezelter 1490
115 gezelter 1930
116 gezelter 2204 const std::string LipidHeadVisitor::toString(){
117     char buffer[65535];
118     std::string result;
119     std::set<std::string>::iterator i;
120 gezelter 1930
121 gezelter 2204 sprintf(buffer ,"------------------------------------------------------------------\n");
122     result += buffer;
123 gezelter 1930
124 gezelter 2204 sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
125     result += buffer;
126 gezelter 1490
127 gezelter 2204 //print the ignore type list
128     sprintf(buffer , "lipidHeadName list contains below types:\n");
129     result += buffer;
130 gezelter 1490
131 gezelter 2204 for(i = lipidHeadName.begin(); i != lipidHeadName.end(); ++i){
132     sprintf(buffer ,"%s\t", i->c_str());
133     result += buffer;
134     }
135 gezelter 1490
136 gezelter 2204 sprintf(buffer ,"\n");
137     result += buffer;
138 gezelter 1490
139 gezelter 2204 sprintf(buffer ,"------------------------------------------------------------------\n");
140     result += buffer;
141 gezelter 1490
142 gezelter 2204 return result;
143 gezelter 1490
144 gezelter 2204 }
145 gezelter 1490
146 gezelter 1930
147 gezelter 2204 void RBCOMVisitor::visit(RigidBody* rb){
148     AtomData* atomData;
149     AtomInfo* atomInfo;
150     Vector3d pos;
151 gezelter 1930
152 gezelter 2204 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 gezelter 1490
162 gezelter 2204 atomData = new AtomData;
163     atomData->setID("ATOMDATA");
164     atomData->addAtomInfo(atomInfo);
165 gezelter 1490
166 gezelter 2204 rb->addProperty(atomData);
167 gezelter 1930
168 gezelter 2204 }
169 gezelter 1490
170 gezelter 1930
171 gezelter 2204 const std::string RBCOMVisitor::toString(){
172     char buffer[65535];
173     std::string result;
174 gezelter 1930
175 gezelter 2204 sprintf(buffer ,"------------------------------------------------------------------\n");
176     result += buffer;
177 gezelter 1930
178 gezelter 2204 sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
179     result += buffer;
180 gezelter 1490
181 gezelter 2204 //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 gezelter 1490
185 gezelter 2204 sprintf(buffer ,"------------------------------------------------------------------\n");
186     result += buffer;
187 gezelter 1490
188 gezelter 2204 return result;
189 gezelter 1490
190 gezelter 2204 }
191 gezelter 1490
192 tim 1625 }//namespace oopse
193 gezelter 1930

Properties

Name Value
svn:executable *