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