ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/applications/dump2Xyz/Dump2XYZ.cpp
Revision: 1957
Committed: Tue Jan 25 17:45:23 2005 UTC (19 years, 5 months ago) by tim
File size: 8104 byte(s)
Log Message:
(1) complete section parser's error message
(2) add GhostTorsion
(3) accumulate inertial tensor from the directional atoms before calculate rigidbody's inertial tensor

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

Properties

Name Value
svn:executable *