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 |
|
|
5 |
– |
#include "brains/SimSetup.hpp" |
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 "visitors/SelectionVisitor.hpp" |
58 |
+ |
#include "selection/SelectionEvaluator.hpp" |
59 |
+ |
using namespace oopse; |
60 |
|
|
13 |
– |
using namespace std; |
14 |
– |
|
61 |
|
int main(int argc, char* argv[]){ |
16 |
– |
gengetopt_args_info args_info; |
17 |
– |
string dumpFileName; |
18 |
– |
string mdFileName; |
19 |
– |
char inFileName[2002]; |
20 |
– |
string xyzFileName; |
21 |
– |
SimInfo* info; |
22 |
– |
SimSetup startMe; |
23 |
– |
DumpReader* dumpReader; |
24 |
– |
ofstream xyzStream; |
25 |
– |
int nframes; |
26 |
– |
Molecule* mol; |
27 |
– |
vector<StuntDouble*> integrableObjects; |
28 |
– |
vector<StuntDouble*>::iterator iter; |
29 |
– |
vector<RigidBody*> myRigidBodies; |
30 |
– |
vector<RigidBody*>::iterator rbIter; |
62 |
|
|
63 |
< |
CompositeVisitor* compositeVisitor; |
64 |
< |
SSDAtomVisitor* ssdVisitor; |
34 |
< |
LinearAtomVisitor* linearVisitor; |
35 |
< |
DefaultAtomVisitor* defaultAtomVisitor; |
36 |
< |
LipidHeadVisitor* lipidVisitor; |
37 |
< |
RBCOMVisitor* rbCOMVisitor; |
38 |
< |
ReplicateVisitor* replicateVisitor; |
39 |
< |
WrappingVisitor* wrappingVisitor; |
40 |
< |
IgnoreVisitor* ignoreVisitor; |
41 |
< |
XYZVisitor* xyzVisitor; |
42 |
< |
ZConsVisitor* zconsVisitor; |
43 |
< |
PrepareVisitor* prepareVisitor; |
44 |
< |
WaterTypeVisitor* waterTypeVisitor; |
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 |
< |
|
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 |
< |
} |
80 |
< |
else{ |
56 |
< |
cerr << "Does not have input file name" << endl; |
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 |
< |
} |
65 |
< |
else{ |
89 |
> |
} else { |
90 |
|
xyzFileName = dumpFileName; |
91 |
|
xyzFileName = xyzFileName.substr(0, xyzFileName.rfind(".")) + ".xyz"; |
92 |
|
} |
93 |
< |
|
93 |
> |
|
94 |
|
//parse md file and set up the system |
95 |
< |
info = new SimInfo(); |
96 |
< |
startMe.setSimInfo(info ); |
73 |
< |
|
74 |
< |
strcpy(inFileName, mdFileName.c_str() ); |
75 |
< |
startMe.parseFile( inFileName ); |
76 |
< |
|
77 |
< |
startMe.createSim(); |
78 |
< |
|
95 |
> |
SimCreator creator; |
96 |
> |
SimInfo* info = creator.createSim(mdFileName, false); |
97 |
|
|
98 |
+ |
|
99 |
+ |
|
100 |
|
//creat visitor list |
101 |
< |
compositeVisitor = new CompositeVisitor(); |
102 |
< |
|
101 |
> |
CompositeVisitor* compositeVisitor = new CompositeVisitor(); |
102 |
> |
|
103 |
|
//creat ignore visitor |
104 |
|
if(args_info.ignore_given ||args_info.water_flag){ |
105 |
|
|
106 |
< |
ignoreVisitor = new IgnoreVisitor(); |
107 |
< |
|
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 |
< |
|
110 |
> |
|
111 |
|
//ignore water |
112 |
|
if(args_info.water_flag){ |
113 |
|
ignoreVisitor->addIgnoreType("SSD"); |
120 |
|
ignoreVisitor->addIgnoreType("SPCE_RB_0"); |
121 |
|
ignoreVisitor->addIgnoreType("DPD_RB_0"); |
122 |
|
} |
123 |
< |
|
124 |
< |
compositeVisitor->addVisitor(ignoreVisitor, 1000); |
123 |
> |
|
124 |
> |
compositeVisitor->addVisitor(ignoreVisitor, 1000); |
125 |
|
} |
126 |
< |
|
126 |
> |
|
127 |
|
//creat RigidBody Visitor |
128 |
|
if(args_info.rigidbody_flag){ |
129 |
< |
rbCOMVisitor = new RBCOMVisitor(info); |
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 |
< |
//compositeVisitor->addVisitor(lipidVisitor, 900); |
140 |
< |
|
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 |
< |
ssdVisitor = new SSDAtomVisitor(info); |
148 |
> |
SSDAtomVisitor* ssdVisitor = new SSDAtomVisitor(info); |
149 |
|
compositeVisitor->addVisitor(ssdVisitor, 800); |
150 |
< |
linearVisitor = new LinearAtomVisitor(info); |
150 |
> |
|
151 |
> |
LinearAtomVisitor* linearVisitor = new LinearAtomVisitor(info); |
152 |
|
compositeVisitor->addVisitor(linearVisitor, 750); |
153 |
< |
|
153 |
> |
|
154 |
|
//creat default atom visitor |
155 |
< |
defaultAtomVisitor = new DefaultAtomVisitor(info); |
155 |
> |
DefaultAtomVisitor* defaultAtomVisitor = new DefaultAtomVisitor(info); |
156 |
|
compositeVisitor->addVisitor(defaultAtomVisitor, 700); |
157 |
< |
|
157 |
> |
|
158 |
|
//creat waterType visitor |
159 |
|
if(args_info.watertype_flag){ |
160 |
< |
waterTypeVisitor = new WaterTypeVisitor; |
160 |
> |
WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor; |
161 |
|
compositeVisitor->addVisitor(waterTypeVisitor, 600); |
162 |
|
} |
163 |
< |
|
163 |
> |
|
164 |
|
//create ZconsVisitor |
165 |
|
if(args_info.zconstraint_flag){ |
133 |
– |
|
134 |
– |
zconsVisitor = new ZConsVisitor(info); |
166 |
|
|
167 |
< |
if(zconsVisitor->haveZconsMol()) |
167 |
> |
ZConsVisitor* zconsVisitor = new ZConsVisitor(info); |
168 |
> |
|
169 |
> |
if(zconsVisitor->haveZconsMol()) { |
170 |
|
compositeVisitor->addVisitor(zconsVisitor, 500); |
171 |
< |
else |
171 |
> |
} else { |
172 |
|
delete zconsVisitor; |
173 |
+ |
} |
174 |
|
} |
175 |
< |
|
175 |
> |
|
176 |
|
//creat wrapping visitor |
177 |
< |
|
177 |
> |
|
178 |
|
if(args_info.periodicBox_flag){ |
179 |
< |
wrappingVisitor = new WrappingVisitor(info); |
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 |
< |
IntVec3 replicateOpt(args_info.repeatX_arg, args_info.repeatY_arg, args_info.repeatZ_arg); |
186 |
< |
replicateVisitor = new ReplicateVisitor(info, replicateOpt); |
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 |
< |
|
189 |
> |
|
190 |
|
//creat xyzVisitor |
191 |
< |
xyzVisitor = new XYZVisitor(info); |
191 |
> |
XYZVisitor* xyzVisitor = new XYZVisitor(info); |
192 |
|
compositeVisitor->addVisitor(xyzVisitor, 200); |
193 |
< |
|
194 |
< |
cout << compositeVisitor->toString(); |
195 |
< |
|
193 |
> |
|
194 |
> |
std::cout << compositeVisitor->toString(); |
195 |
> |
|
196 |
|
//creat prepareVisitor |
197 |
< |
prepareVisitor = new PrepareVisitor(); |
198 |
< |
|
197 |
> |
PrepareVisitor* prepareVisitor = new PrepareVisitor(); |
198 |
> |
|
199 |
|
//open dump file |
200 |
< |
dumpReader = new DumpReader(dumpFileName.c_str()); |
201 |
< |
nframes = dumpReader->getNframes(); |
202 |
< |
|
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 |
< |
for (int i = 0; i < nframes; i += args_info.frame_arg){ |
208 |
< |
dumpReader->readFrame(info, i); |
207 |
> |
|
208 |
> |
SimInfo::MoleculeIterator miter; |
209 |
> |
Molecule::IntegrableObjectIterator iiter; |
210 |
> |
Molecule::RigidBodyIterator rbIter; |
211 |
> |
Molecule* mol; |
212 |
> |
StuntDouble* integrableObject; |
213 |
> |
RigidBody* rb; |
214 |
|
|
215 |
< |
mol = info->molecules; |
216 |
< |
|
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(int j = 0; j < info->n_mol; j++){ |
224 |
< |
myRigidBodies = mol[j].getMyRigidBodies(); |
225 |
< |
|
226 |
< |
for(rbIter = myRigidBodies.begin(); rbIter != myRigidBodies.end(); ++rbIter) |
227 |
< |
(*rbIter)->updateAtoms(); |
228 |
< |
} |
229 |
< |
|
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(int j = 0; j < info->n_mol; j++){ |
233 |
< |
integrableObjects = mol[j].getIntegrableObjects(); |
234 |
< |
|
235 |
< |
for(iter = integrableObjects.begin(); iter != integrableObjects.end(); ++iter) |
236 |
< |
(*iter)->accept(prepareVisitor); |
237 |
< |
} |
238 |
< |
|
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(int j = 0; j < info->n_mol; j++){ |
249 |
< |
integrableObjects = mol[j].getIntegrableObjects(); |
250 |
< |
|
251 |
< |
for(iter = integrableObjects.begin(); iter != integrableObjects.end(); ++iter) |
252 |
< |
(*iter)->accept(compositeVisitor); |
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 |
< |
|
254 |
> |
|
255 |
|
xyzVisitor->writeFrame(xyzStream); |
256 |
|
xyzVisitor->clear(); |
257 |
|
|
258 |
|
}//end for (int i = 0; i < nframes; i += args_info.frame_arg) |
259 |
< |
|
259 |
> |
|
260 |
|
xyzStream.close(); |
261 |
< |
|
262 |
< |
|
261 |
> |
|
262 |
> |
|
263 |
|
delete compositeVisitor; |
264 |
|
delete info; |
265 |
< |
|
215 |
< |
|
265 |
> |
|
266 |
|
} |