ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/applications/dump2Xyz/Dump2XYZ.cpp
Revision: 1978
Committed: Fri Feb 4 22:46:10 2005 UTC (19 years, 5 months ago) by tim
File size: 8852 byte(s)
Log Message:
remove SelectionVisitor

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 using namespace oopse;
59
60 int main(int argc, char* argv[]){
61
62 //register force fields
63 registerForceFields();
64
65 gengetopt_args_info args_info;
66 std::string dumpFileName;
67 std::string mdFileName;
68 std::string xyzFileName;
69
70 //parse the command line option
71 if (cmdline_parser (argc, argv, &args_info) != 0) {
72 exit(1) ;
73 }
74
75 //get the dumpfile name and meta-data file name
76 if (args_info.input_given){
77 dumpFileName = args_info.input_arg;
78 } else {
79 std::cerr << "Does not have input file name" << std::endl;
80 exit(1);
81 }
82
83 mdFileName = dumpFileName;
84 mdFileName = mdFileName.substr(0, mdFileName.rfind(".")) + ".md";
85
86 if (args_info.output_given){
87 xyzFileName = args_info.output_arg;
88 } else {
89 xyzFileName = dumpFileName;
90 xyzFileName = xyzFileName.substr(0, xyzFileName.rfind(".")) + ".xyz";
91 }
92
93 //parse md file and set up the system
94 SimCreator creator;
95 SimInfo* info = creator.createSim(mdFileName, false);
96
97
98
99 //creat visitor list
100 CompositeVisitor* compositeVisitor = new CompositeVisitor();
101
102 //creat ignore visitor
103 if(args_info.ignore_given ||args_info.water_flag){
104
105 IgnoreVisitor* ignoreVisitor = new IgnoreVisitor(info);
106
107 for(int i = 0; i < args_info.ignore_given; i++)
108 ignoreVisitor->addIgnoreType(args_info.ignore_arg[i]);
109
110 //ignore water
111 if(args_info.water_flag){
112 ignoreVisitor->addIgnoreType("SSD");
113 ignoreVisitor->addIgnoreType("SSD1");
114 ignoreVisitor->addIgnoreType("SSD_E");
115 ignoreVisitor->addIgnoreType("SSD_RF");
116 ignoreVisitor->addIgnoreType("TIP3P_RB_0");
117 ignoreVisitor->addIgnoreType("TIP4P_RB_0");
118 ignoreVisitor->addIgnoreType("TIP5P_RB_0");
119 ignoreVisitor->addIgnoreType("SPCE_RB_0");
120 ignoreVisitor->addIgnoreType("DPD_RB_0");
121 }
122
123 compositeVisitor->addVisitor(ignoreVisitor, 1000);
124 }
125
126 //creat RigidBody Visitor
127 if(args_info.rigidbody_flag){
128 RBCOMVisitor* rbCOMVisitor = new RBCOMVisitor(info);
129 compositeVisitor->addVisitor(rbCOMVisitor, 900);
130 }
131
132 //create selection visitor
133 //if (args_info.selection_given){
134 // SelectionVisitor* selectionVisitor = new SelectionVisitor(info, args_info.selection_arg);
135 // compositeVisitor->addVisitor(selectionVisitor, 850);
136 //}
137
138 SelectionEvaluator* evaluator = NULL;
139 if (args_info.selection_given) {
140 evaluator = new SelectionEvaluator(info);
141 assert(evaluator);
142 evaluator->loadScriptString( args_info.selection_arg);
143
144 }
145
146 //creat SSD atom visitor
147 SSDAtomVisitor* ssdVisitor = new SSDAtomVisitor(info);
148 compositeVisitor->addVisitor(ssdVisitor, 800);
149
150 LinearAtomVisitor* linearVisitor = new LinearAtomVisitor(info);
151 compositeVisitor->addVisitor(linearVisitor, 750);
152
153 //creat default atom visitor
154 DefaultAtomVisitor* defaultAtomVisitor = new DefaultAtomVisitor(info);
155 compositeVisitor->addVisitor(defaultAtomVisitor, 700);
156
157 //creat waterType visitor
158 if(args_info.watertype_flag){
159 WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor;
160 compositeVisitor->addVisitor(waterTypeVisitor, 600);
161 }
162
163 //create ZconsVisitor
164 if(args_info.zconstraint_flag){
165
166 ZConsVisitor* zconsVisitor = new ZConsVisitor(info);
167
168 if(zconsVisitor->haveZconsMol()) {
169 compositeVisitor->addVisitor(zconsVisitor, 500);
170 } else {
171 delete zconsVisitor;
172 }
173 }
174
175 //creat wrapping visitor
176
177 if(args_info.periodicBox_flag){
178 WrappingVisitor* wrappingVisitor = new WrappingVisitor(info);
179 compositeVisitor->addVisitor(wrappingVisitor, 400);
180 }
181
182 //creat replicate visitor
183 if(args_info.repeatX_given > 0 || args_info.repeatY_given > 0 ||args_info.repeatY_given > 0){
184 Vector3i replicateOpt(args_info.repeatX_arg, args_info.repeatY_arg, args_info.repeatZ_arg);
185 ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, replicateOpt);
186 compositeVisitor->addVisitor(replicateVisitor, 300);
187 }
188
189 //creat xyzVisitor
190 XYZVisitor* xyzVisitor = new XYZVisitor(info);
191 compositeVisitor->addVisitor(xyzVisitor, 200);
192
193 std::cout << compositeVisitor->toString();
194
195 //creat prepareVisitor
196 PrepareVisitor* prepareVisitor = new PrepareVisitor();
197
198 //open dump file
199 DumpReader* dumpReader = new DumpReader(info, dumpFileName);
200 int nframes = dumpReader->getNFrames();
201
202
203 std::ofstream xyzStream;
204 xyzStream .open(xyzFileName.c_str());
205
206
207 SimInfo::MoleculeIterator miter;
208 Molecule::IntegrableObjectIterator iiter;
209 Molecule::RigidBodyIterator rbIter;
210 Molecule* mol;
211 StuntDouble* integrableObject;
212 RigidBody* rb;
213
214 if (evaluator && !evaluator->isDynamic()) {
215 info->getSelectionManager()->setSelectionSet(evaluator->evaluate());
216 }
217
218 for (int i = 0; i < nframes; i += args_info.frame_arg){
219 dumpReader->readFrame(i);
220
221 //update atoms of rigidbody
222 for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
223
224 //change the positions of atoms which belong to the rigidbodies
225 for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
226 rb->updateAtoms();
227 }
228 }
229
230 //prepare visit
231 for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
232 for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL;
233 integrableObject = mol->nextIntegrableObject(iiter)) {
234 integrableObject->accept(prepareVisitor);
235 }
236 }
237
238 //update visitor
239 compositeVisitor->update();
240
241 //if dynamic, we need to re-evaluate the selection
242 if (evaluator && evaluator->isDynamic()) {
243 info->getSelectionManager()->setSelectionSet(evaluator->evaluate());
244 }
245
246 //visit stuntdouble
247 for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
248 for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL;
249 integrableObject = mol->nextIntegrableObject(iiter)) {
250 integrableObject->accept(compositeVisitor);
251 }
252 }
253
254 xyzVisitor->writeFrame(xyzStream);
255 xyzVisitor->clear();
256
257 }//end for (int i = 0; i < nframes; i += args_info.frame_arg)
258
259 xyzStream.close();
260
261
262 delete compositeVisitor;
263 delete info;
264
265 }

Properties

Name Value
svn:executable *