ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/applications/dump2Xyz/Dump2XYZ.cpp
Revision: 1903
Committed: Thu Jan 6 00:16:07 2005 UTC (19 years, 7 months ago) by tim
File size: 7867 byte(s)
Log Message:
simpleBuilder in progress

File Contents

# Content
1 /*
2 * Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project
3 *
4 * Contact: oopse@oopse.org
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
10 * All we ask is that proper credit is given for our work, which includes
11 * - but is not limited to - adding the above copyright notice to the beginning
12 * of your source code files, and to any copyright notice that you may distribute
13 * with programs based on this work.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 *
24 */
25
26 #include <iostream>
27 #include <fstream>
28 #include <string>
29
30 #include "applications/dump2Xyz/Dump2XYZCmd.h"
31
32 #include "brains/SimCreator.hpp"
33 #include "brains/SimInfo.hpp"
34 #include "io/DumpReader.hpp"
35 #include "minimizers/MinimizerFactory.hpp"
36 #include "minimizers/MinimizerCreator.hpp"
37 #include "minimizers/PRCG.hpp"
38 #include "minimizers/SDMinimizer.hpp"
39 #include "UseTheForce/DUFF.hpp"
40 #include "UseTheForce/EAM.hpp"
41 #include "UseTheForce/ForceFieldCreator.hpp"
42 #include "utils/simError.h"
43 #include "visitors/AtomVisitor.hpp"
44 #include "visitors/CompositeVisitor.hpp"
45 #include "visitors/RigidBodyVisitor.hpp"
46 #include "visitors/OtherVisitor.hpp"
47 #include "visitors/ZconsVisitor.hpp"
48 using namespace oopse;
49
50 int main(int argc, char* argv[]){
51
52 //DUFF, WATER and LJ are merged into one force field
53 ForceFieldBuilder<DUFF> DUFFCreator("DUFF");
54 ForceFieldBuilder<DUFF> WATERCreator("WATER");
55 ForceFieldBuilder<DUFF> LJCreator("LJ");
56 //in theory, EAM can also be merged
57 ForceFieldBuilder<EAM> EAMCreator("EAM");
58
59 gengetopt_args_info args_info;
60 std::string dumpFileName;
61 std::string mdFileName;
62 std::string xyzFileName;
63
64 //parse the command line option
65 if (cmdline_parser (argc, argv, &args_info) != 0) {
66 exit(1) ;
67 }
68
69 //get the dumpfile name and meta-data file name
70 if (args_info.input_given){
71 dumpFileName = args_info.input_arg;
72 } else {
73 std::cerr << "Does not have input file name" << std::endl;
74 exit(1);
75 }
76
77 mdFileName = dumpFileName;
78 mdFileName = mdFileName.substr(0, mdFileName.rfind(".")) + ".md";
79
80 if (args_info.output_given){
81 xyzFileName = args_info.output_arg;
82 } else {
83 xyzFileName = dumpFileName;
84 xyzFileName = xyzFileName.substr(0, xyzFileName.rfind(".")) + ".xyz";
85 }
86
87 //parse md file and set up the system
88 SimCreator creator;
89 SimInfo* info = creator.createSim(mdFileName);
90
91
92
93 //creat visitor list
94 CompositeVisitor* compositeVisitor = new CompositeVisitor();
95
96 //creat ignore visitor
97 if(args_info.ignore_given ||args_info.water_flag){
98
99 IgnoreVisitor* ignoreVisitor = new IgnoreVisitor();
100
101 for(int i = 0; i < args_info.ignore_given; i++)
102 ignoreVisitor->addIgnoreType(args_info.ignore_arg[i]);
103
104 //ignore water
105 if(args_info.water_flag){
106 ignoreVisitor->addIgnoreType("SSD");
107 ignoreVisitor->addIgnoreType("SSD1");
108 ignoreVisitor->addIgnoreType("SSD_E");
109 ignoreVisitor->addIgnoreType("SSD_RF");
110 ignoreVisitor->addIgnoreType("TIP3P_RB_0");
111 ignoreVisitor->addIgnoreType("TIP4P_RB_0");
112 ignoreVisitor->addIgnoreType("TIP5P_RB_0");
113 ignoreVisitor->addIgnoreType("SPCE_RB_0");
114 ignoreVisitor->addIgnoreType("DPD_RB_0");
115 }
116
117 compositeVisitor->addVisitor(ignoreVisitor, 1000);
118 }
119
120 //creat RigidBody Visitor
121 if(args_info.rigidbody_flag){
122 RBCOMVisitor* rbCOMVisitor = new RBCOMVisitor(info);
123 compositeVisitor->addVisitor(rbCOMVisitor, 900);
124 }
125
126 //compositeVisitor->addVisitor(lipidVisitor, 900);
127
128 //creat SSD atom visitor
129 SSDAtomVisitor* ssdVisitor = new SSDAtomVisitor(info);
130 compositeVisitor->addVisitor(ssdVisitor, 800);
131
132 //creat default atom visitor
133 DefaultAtomVisitor* defaultAtomVisitor = new DefaultAtomVisitor(info);
134 compositeVisitor->addVisitor(defaultAtomVisitor, 700);
135
136 //creat waterType visitor
137 if(args_info.watertype_flag){
138 WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor;
139 compositeVisitor->addVisitor(waterTypeVisitor, 600);
140 }
141
142 //create ZconsVisitor
143 if(args_info.zconstraint_flag){
144
145 ZConsVisitor* zconsVisitor = new ZConsVisitor(info);
146
147 if(zconsVisitor->haveZconsMol()) {
148 compositeVisitor->addVisitor(zconsVisitor, 500);
149 } else {
150 delete zconsVisitor;
151 }
152 }
153
154 //creat wrapping visitor
155
156 if(args_info.periodicBox_flag){
157 WrappingVisitor* wrappingVisitor = new WrappingVisitor(info);
158 compositeVisitor->addVisitor(wrappingVisitor, 400);
159 }
160
161 //creat replicate visitor
162 if(args_info.repeatX_given > 0 || args_info.repeatY_given > 0 ||args_info.repeatY_given > 0){
163 Vector3i replicateOpt(args_info.repeatX_arg, args_info.repeatY_arg, args_info.repeatZ_arg);
164 ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, replicateOpt);
165 compositeVisitor->addVisitor(replicateVisitor, 300);
166 }
167
168 //creat xyzVisitor
169 XYZVisitor* xyzVisitor = new XYZVisitor(info);
170 compositeVisitor->addVisitor(xyzVisitor, 200);
171
172 std::cout << compositeVisitor->toString();
173
174 //creat prepareVisitor
175 PrepareVisitor* prepareVisitor = new PrepareVisitor();
176
177 //open dump file
178 DumpReader* dumpReader = new DumpReader(info, dumpFileName);
179 int nframes = dumpReader->getNFrames();
180
181
182 std::ofstream xyzStream;
183 xyzStream .open(xyzFileName.c_str());
184
185
186 SimInfo::MoleculeIterator miter;
187 Molecule::IntegrableObjectIterator iiter;
188 Molecule::RigidBodyIterator rbIter;
189 Molecule* mol;
190 StuntDouble* integrableObject;
191 RigidBody* rb;
192
193 for (int i = 0; i < nframes; i += args_info.frame_arg){
194 dumpReader->readFrame(i);
195
196 //update atoms of rigidbody
197 for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
198
199 //change the positions of atoms which belong to the rigidbodies
200 for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) {
201 rb->updateAtoms();
202 }
203 }
204
205 //prepare visit
206 for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
207 for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL;
208 integrableObject = mol->nextIntegrableObject(iiter)) {
209 integrableObject->accept(prepareVisitor);
210 }
211 }
212
213 //update visitor
214 compositeVisitor->update();
215
216 //visit stuntdouble
217 for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
218 for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL;
219 integrableObject = mol->nextIntegrableObject(iiter)) {
220 integrableObject->accept(compositeVisitor);
221 }
222 }
223
224 xyzVisitor->writeFrame(xyzStream);
225 xyzVisitor->clear();
226
227 }//end for (int i = 0; i < nframes; i += args_info.frame_arg)
228
229 xyzStream.close();
230
231
232 delete compositeVisitor;
233 delete info;
234
235
236 }

Properties

Name Value
svn:executable *