1 |
< |
/* |
1 |
> |
/* |
2 |
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
|
* |
4 |
|
* The University of Notre Dame grants you ("Licensee") a |
54 |
|
#include "visitors/RigidBodyVisitor.hpp" |
55 |
|
#include "visitors/OtherVisitor.hpp" |
56 |
|
#include "visitors/ZconsVisitor.hpp" |
57 |
– |
#include "visitors/SelectionVisitor.hpp" |
57 |
|
#include "selection/SelectionEvaluator.hpp" |
58 |
+ |
#include "selection/SelectionManager.hpp" |
59 |
+ |
#include "visitors/LipidTransVisitor.hpp" |
60 |
+ |
#include "visitors/AtomNameVisitor.hpp" |
61 |
+ |
|
62 |
|
using namespace oopse; |
63 |
|
|
64 |
|
int main(int argc, char* argv[]){ |
68 |
|
|
69 |
|
gengetopt_args_info args_info; |
70 |
|
std::string dumpFileName; |
68 |
– |
std::string mdFileName; |
71 |
|
std::string xyzFileName; |
72 |
|
|
73 |
|
//parse the command line option |
83 |
|
exit(1); |
84 |
|
} |
85 |
|
|
84 |
– |
mdFileName = dumpFileName; |
85 |
– |
mdFileName = mdFileName.substr(0, mdFileName.rfind(".")) + ".md"; |
86 |
– |
|
86 |
|
if (args_info.output_given){ |
87 |
|
xyzFileName = args_info.output_arg; |
88 |
|
} else { |
92 |
|
|
93 |
|
//parse md file and set up the system |
94 |
|
SimCreator creator; |
95 |
< |
SimInfo* info = creator.createSim(mdFileName, false); |
95 |
> |
SimInfo* info = creator.createSim(dumpFileName, false); |
96 |
|
|
97 |
< |
|
98 |
< |
|
100 |
< |
//creat visitor list |
97 |
> |
|
98 |
> |
//create visitor list |
99 |
|
CompositeVisitor* compositeVisitor = new CompositeVisitor(); |
102 |
– |
|
103 |
– |
//creat ignore visitor |
104 |
– |
if(args_info.ignore_given ||args_info.water_flag){ |
100 |
|
|
101 |
< |
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 |
< |
|
111 |
< |
//ignore water |
112 |
< |
if(args_info.water_flag){ |
113 |
< |
ignoreVisitor->addIgnoreType("SSD"); |
114 |
< |
ignoreVisitor->addIgnoreType("SSD1"); |
115 |
< |
ignoreVisitor->addIgnoreType("SSD_E"); |
116 |
< |
ignoreVisitor->addIgnoreType("SSD_RF"); |
117 |
< |
ignoreVisitor->addIgnoreType("TIP3P_RB_0"); |
118 |
< |
ignoreVisitor->addIgnoreType("TIP4P_RB_0"); |
119 |
< |
ignoreVisitor->addIgnoreType("TIP5P_RB_0"); |
120 |
< |
ignoreVisitor->addIgnoreType("SPCE_RB_0"); |
121 |
< |
ignoreVisitor->addIgnoreType("DPD_RB_0"); |
122 |
< |
} |
123 |
< |
|
124 |
< |
compositeVisitor->addVisitor(ignoreVisitor, 1000); |
125 |
< |
} |
126 |
< |
|
127 |
< |
//creat RigidBody Visitor |
101 |
> |
//create RigidBody Visitor |
102 |
|
if(args_info.rigidbody_flag){ |
103 |
|
RBCOMVisitor* rbCOMVisitor = new RBCOMVisitor(info); |
104 |
|
compositeVisitor->addVisitor(rbCOMVisitor, 900); |
105 |
|
} |
106 |
|
|
107 |
< |
//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 |
< |
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 |
107 |
> |
//create SSD atom visitor |
108 |
|
SSDAtomVisitor* ssdVisitor = new SSDAtomVisitor(info); |
109 |
|
compositeVisitor->addVisitor(ssdVisitor, 800); |
110 |
|
|
111 |
|
LinearAtomVisitor* linearVisitor = new LinearAtomVisitor(info); |
112 |
|
compositeVisitor->addVisitor(linearVisitor, 750); |
113 |
+ |
if (args_info.gb_given) { |
114 |
+ |
linearVisitor->addGayBerneAtomType(args_info.gb_arg); |
115 |
+ |
} |
116 |
|
|
117 |
< |
//creat default atom visitor |
117 |
> |
GBLipidAtomVisitor* gbLipidVisitor = new GBLipidAtomVisitor(info); |
118 |
> |
compositeVisitor->addVisitor(gbLipidVisitor, 740); |
119 |
> |
|
120 |
> |
//create default atom visitor |
121 |
|
DefaultAtomVisitor* defaultAtomVisitor = new DefaultAtomVisitor(info); |
122 |
|
compositeVisitor->addVisitor(defaultAtomVisitor, 700); |
123 |
|
|
124 |
< |
//creat waterType visitor |
124 |
> |
//create waterType visitor |
125 |
|
if(args_info.watertype_flag){ |
126 |
|
WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor; |
127 |
|
compositeVisitor->addVisitor(waterTypeVisitor, 600); |
128 |
|
} |
129 |
+ |
|
130 |
+ |
if (args_info.basetype_flag) { |
131 |
+ |
AtomNameVisitor* atomNameVisitor = new AtomNameVisitor(info); |
132 |
+ |
compositeVisitor->addVisitor(atomNameVisitor, 550); |
133 |
+ |
|
134 |
+ |
} |
135 |
|
|
136 |
|
//create ZconsVisitor |
137 |
|
if(args_info.zconstraint_flag){ |
145 |
|
} |
146 |
|
} |
147 |
|
|
148 |
< |
//creat wrapping visitor |
148 |
> |
//create wrapping visitor |
149 |
|
|
150 |
< |
if(args_info.periodicBox_flag){ |
151 |
< |
WrappingVisitor* wrappingVisitor = new WrappingVisitor(info); |
152 |
< |
compositeVisitor->addVisitor(wrappingVisitor, 400); |
153 |
< |
} |
154 |
< |
|
155 |
< |
//creat replicate visitor |
150 |
> |
//if(args_info.periodicBox_flag){ |
151 |
> |
// WrappingVisitor* wrappingVisitor = new WrappingVisitor(info); |
152 |
> |
// compositeVisitor->addVisitor(wrappingVisitor, 400); |
153 |
> |
//} |
154 |
> |
|
155 |
> |
//create replicate visitor |
156 |
|
if(args_info.repeatX_given > 0 || args_info.repeatY_given > 0 ||args_info.repeatY_given > 0){ |
157 |
|
Vector3i replicateOpt(args_info.repeatX_arg, args_info.repeatY_arg, args_info.repeatZ_arg); |
158 |
|
ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, replicateOpt); |
159 |
|
compositeVisitor->addVisitor(replicateVisitor, 300); |
160 |
|
} |
161 |
< |
|
162 |
< |
//creat xyzVisitor |
163 |
< |
XYZVisitor* xyzVisitor = new XYZVisitor(info); |
161 |
> |
|
162 |
> |
|
163 |
> |
//create rotation visitor |
164 |
> |
if (args_info.refsele_given&& args_info.originsele_given) { |
165 |
> |
compositeVisitor->addVisitor(new LipidTransVisitor(info, args_info.originsele_arg, args_info.refsele_arg), 250); |
166 |
> |
} else if (args_info.refsele_given || args_info.originsele_given) { |
167 |
> |
std::cerr << "Both of --refsele and --originsele should appear by pair" << std::endl; |
168 |
> |
exit(1); |
169 |
> |
} |
170 |
> |
|
171 |
> |
//create xyzVisitor |
172 |
> |
XYZVisitor* xyzVisitor; |
173 |
> |
if (args_info.selection_given) { |
174 |
> |
xyzVisitor = new XYZVisitor(info, args_info.selection_arg); |
175 |
> |
} else { |
176 |
> |
xyzVisitor = new XYZVisitor(info); |
177 |
> |
} |
178 |
|
compositeVisitor->addVisitor(xyzVisitor, 200); |
179 |
|
|
180 |
|
std::cout << compositeVisitor->toString(); |
181 |
|
|
182 |
< |
//creat prepareVisitor |
182 |
> |
//create prepareVisitor |
183 |
|
PrepareVisitor* prepareVisitor = new PrepareVisitor(); |
184 |
|
|
185 |
|
//open dump file |
197 |
|
Molecule* mol; |
198 |
|
StuntDouble* integrableObject; |
199 |
|
RigidBody* rb; |
200 |
< |
|
201 |
< |
if (evaluator && !evaluator->isDynamic()) { |
202 |
< |
info->getSelectionManager()->setSelectionSet(evaluator->evaluate()); |
203 |
< |
} |
204 |
< |
|
200 |
> |
Vector3d molCom; |
201 |
> |
Vector3d newMolCom; |
202 |
> |
Vector3d displacement; |
203 |
> |
Mat3x3d hmat; |
204 |
> |
Snapshot* currentSnapshot; |
205 |
> |
|
206 |
|
for (int i = 0; i < nframes; i += args_info.frame_arg){ |
207 |
|
dumpReader->readFrame(i); |
208 |
< |
|
208 |
> |
|
209 |
> |
//wrapping the molecule |
210 |
> |
if(args_info.periodicBox_flag) { |
211 |
> |
currentSnapshot = info->getSnapshotManager()->getCurrentSnapshot(); |
212 |
> |
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
213 |
> |
molCom = mol->getCom(); |
214 |
> |
newMolCom = molCom; |
215 |
> |
currentSnapshot->wrapVector(newMolCom); |
216 |
> |
displacement = newMolCom - molCom; |
217 |
> |
for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL; |
218 |
> |
integrableObject = mol->nextIntegrableObject(iiter)) { |
219 |
> |
integrableObject->setPos(integrableObject->getPos() + displacement); |
220 |
> |
} |
221 |
> |
} |
222 |
> |
} |
223 |
|
//update atoms of rigidbody |
224 |
|
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
225 |
|
|
240 |
|
//update visitor |
241 |
|
compositeVisitor->update(); |
242 |
|
|
243 |
< |
//if dynamic, we need to re-evaluate the selection |
243 |
< |
if (evaluator && evaluator->isDynamic()) { |
244 |
< |
info->getSelectionManager()->setSelectionSet(evaluator->evaluate()); |
245 |
< |
} |
246 |
< |
|
243 |
> |
|
244 |
|
//visit stuntdouble |
245 |
|
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
246 |
|
for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL; |
256 |
|
|
257 |
|
xyzStream.close(); |
258 |
|
|
259 |
< |
|
259 |
> |
delete prepareVisitor; |
260 |
|
delete compositeVisitor; |
261 |
|
delete info; |
262 |
|
|