ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/dump2Xyz/Dump2XYZ.cpp
Revision: 2008
Committed: Sun Feb 13 19:10:25 2005 UTC (19 years, 4 months ago) by tim
File size: 8894 byte(s)
Log Message:
dynamicProps get built

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

Properties

Name Value
svn:executable *