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: 1890
Committed: Wed Dec 15 21:07:48 2004 UTC (19 years, 7 months ago) by tim
File size: 7423 byte(s)
Log Message:
add EAM Force Field

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

Properties

Name Value
svn:executable *