ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/dump2Xyz/Dump2XYZ.cpp
Revision: 2581
Committed: Thu Feb 2 15:49:42 2006 UTC (18 years, 5 months ago) by xsun
File size: 8241 byte(s)
Log Message:
Adding visitor for GBlipid atom type

File Contents

# Content
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. 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 #include <iostream>
43 #include <fstream>
44 #include <string>
45
46 #include "applications/dump2Xyz/Dump2XYZCmd.h"
47 #include "brains/Register.hpp"
48 #include "brains/SimCreator.hpp"
49 #include "brains/SimInfo.hpp"
50 #include "io/DumpReader.hpp"
51 #include "utils/simError.h"
52 #include "visitors/AtomVisitor.hpp"
53 #include "visitors/CompositeVisitor.hpp"
54 #include "visitors/RigidBodyVisitor.hpp"
55 #include "visitors/OtherVisitor.hpp"
56 #include "visitors/ZconsVisitor.hpp"
57 #include "selection/SelectionEvaluator.hpp"
58 #include "selection/SelectionManager.hpp"
59 #include "visitors/LipidTransVisitor.hpp"
60 #include "visitors/AtomNameVisitor.hpp"
61
62 using namespace oopse;
63
64 int main(int argc, char* argv[]){
65
66 //register force fields
67 registerForceFields();
68
69 gengetopt_args_info args_info;
70 std::string dumpFileName;
71 std::string mdFileName;
72 std::string xyzFileName;
73
74 //parse the command line option
75 if (cmdline_parser (argc, argv, &args_info) != 0) {
76 exit(1) ;
77 }
78
79 //get the dumpfile name and meta-data file name
80 if (args_info.input_given){
81 dumpFileName = args_info.input_arg;
82 } else {
83 std::cerr << "Does not have input file name" << std::endl;
84 exit(1);
85 }
86
87 mdFileName = dumpFileName;
88 mdFileName = mdFileName.substr(0, mdFileName.rfind(".")) + ".md";
89
90 if (args_info.output_given){
91 xyzFileName = args_info.output_arg;
92 } else {
93 xyzFileName = dumpFileName;
94 xyzFileName = xyzFileName.substr(0, xyzFileName.rfind(".")) + ".xyz";
95 }
96
97 //parse md file and set up the system
98 SimCreator creator;
99 SimInfo* info = creator.createSim(mdFileName, false);
100
101
102
103 //create visitor list
104 CompositeVisitor* compositeVisitor = new CompositeVisitor();
105
106 //create RigidBody Visitor
107 if(args_info.rigidbody_flag){
108 RBCOMVisitor* rbCOMVisitor = new RBCOMVisitor(info);
109 compositeVisitor->addVisitor(rbCOMVisitor, 900);
110 }
111
112 //create SSD atom visitor
113 SSDAtomVisitor* ssdVisitor = new SSDAtomVisitor(info);
114 compositeVisitor->addVisitor(ssdVisitor, 800);
115
116 LinearAtomVisitor* linearVisitor = new LinearAtomVisitor(info);
117 compositeVisitor->addVisitor(linearVisitor, 750);
118
119 GBLipidAtomVisitor* gbLipidVisitor = new GBLipidAtomVisitor(info);
120 compositeVisitor->addVisitor(gbLipidVisitor, 740);
121
122 //create default atom visitor
123 DefaultAtomVisitor* defaultAtomVisitor = new DefaultAtomVisitor(info);
124 compositeVisitor->addVisitor(defaultAtomVisitor, 700);
125
126 //create waterType visitor
127 if(args_info.watertype_flag){
128 WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor;
129 compositeVisitor->addVisitor(waterTypeVisitor, 600);
130 }
131
132 if (args_info.basetype_flag) {
133 AtomNameVisitor* atomNameVisitor = new AtomNameVisitor(info);
134 compositeVisitor->addVisitor(atomNameVisitor, 550);
135
136 }
137
138 //create ZconsVisitor
139 if(args_info.zconstraint_flag){
140
141 ZConsVisitor* zconsVisitor = new ZConsVisitor(info);
142
143 if(zconsVisitor->haveZconsMol()) {
144 compositeVisitor->addVisitor(zconsVisitor, 500);
145 } else {
146 delete zconsVisitor;
147 }
148 }
149
150 //create wrapping visitor
151
152 if(args_info.periodicBox_flag){
153 WrappingVisitor* wrappingVisitor = new WrappingVisitor(info);
154 compositeVisitor->addVisitor(wrappingVisitor, 400);
155 }
156
157 //create replicate visitor
158 if(args_info.repeatX_given > 0 || args_info.repeatY_given > 0 ||args_info.repeatY_given > 0){
159 Vector3i replicateOpt(args_info.repeatX_arg, args_info.repeatY_arg, args_info.repeatZ_arg);
160 ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, replicateOpt);
161 compositeVisitor->addVisitor(replicateVisitor, 300);
162 }
163
164
165 //create rotation visitor
166 if (args_info.refsele_given&& args_info.originsele_given) {
167 compositeVisitor->addVisitor(new LipidTransVisitor(info, args_info.originsele_arg, args_info.refsele_arg), 250);
168 } else if (args_info.refsele_given || args_info.originsele_given) {
169 std::cerr << "Both of --refsele and --originsele should appear by pair" << std::endl;
170 exit(1);
171 }
172
173 //create xyzVisitor
174 XYZVisitor* xyzVisitor;
175 if (args_info.selection_given) {
176 xyzVisitor = new XYZVisitor(info, args_info.selection_arg);
177 } else {
178 xyzVisitor = new XYZVisitor(info);
179 }
180 compositeVisitor->addVisitor(xyzVisitor, 200);
181
182 std::cout << compositeVisitor->toString();
183
184 //create prepareVisitor
185 PrepareVisitor* prepareVisitor = new PrepareVisitor();
186
187 //open dump file
188 DumpReader* dumpReader = new DumpReader(info, dumpFileName);
189 int nframes = dumpReader->getNFrames();
190
191
192 std::ofstream xyzStream;
193 xyzStream .open(xyzFileName.c_str());
194
195
196 SimInfo::MoleculeIterator miter;
197 Molecule::IntegrableObjectIterator iiter;
198 Molecule::RigidBodyIterator rbIter;
199 Molecule* mol;
200 StuntDouble* integrableObject;
201 RigidBody* rb;
202
203 for (int i = 0; i < nframes; i += args_info.frame_arg){
204 dumpReader->readFrame(i);
205
206 //update atoms of rigidbody
207 for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
208
209 //change the positions of atoms which belong to the rigidbodies
210 for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
211 rb->updateAtoms();
212 }
213 }
214
215 //prepare visit
216 for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
217 for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL;
218 integrableObject = mol->nextIntegrableObject(iiter)) {
219 integrableObject->accept(prepareVisitor);
220 }
221 }
222
223 //update visitor
224 compositeVisitor->update();
225
226
227 //visit stuntdouble
228 for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
229 for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL;
230 integrableObject = mol->nextIntegrableObject(iiter)) {
231 integrableObject->accept(compositeVisitor);
232 }
233 }
234
235 xyzVisitor->writeFrame(xyzStream);
236 xyzVisitor->clear();
237
238 }//end for (int i = 0; i < nframes; i += args_info.frame_arg)
239
240 xyzStream.close();
241
242 delete prepareVisitor;
243 delete compositeVisitor;
244 delete info;
245
246 }

Properties

Name Value
svn:executable *