| 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 |
> |
Ring5gbAtomVisitor* ring5Visitor = new Ring5gbAtomVisitor(info); |
| 121 |
> |
compositeVisitor->addVisitor(ring5Visitor, 730); |
| 122 |
> |
|
| 123 |
> |
HeadAtomVisitor* headVisitor = new HeadAtomVisitor(info); |
| 124 |
> |
compositeVisitor->addVisitor(headVisitor, 720); |
| 125 |
> |
|
| 126 |
> |
//create default atom visitor |
| 127 |
|
DefaultAtomVisitor* defaultAtomVisitor = new DefaultAtomVisitor(info); |
| 128 |
|
compositeVisitor->addVisitor(defaultAtomVisitor, 700); |
| 129 |
|
|
| 130 |
< |
//creat waterType visitor |
| 131 |
< |
if(args_info.watertype_flag){ |
| 132 |
< |
WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor; |
| 133 |
< |
compositeVisitor->addVisitor(waterTypeVisitor, 600); |
| 130 |
> |
// if we gave the -w option, we want to skip the waters: |
| 131 |
> |
std::cerr << "-w flag was set to:" << args_info.water_given << "\n"; |
| 132 |
> |
if (!args_info.water_given) { |
| 133 |
> |
//create waterType visitor |
| 134 |
> |
if(args_info.watertype_flag){ |
| 135 |
> |
WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor; |
| 136 |
> |
compositeVisitor->addVisitor(waterTypeVisitor, 600); |
| 137 |
> |
} |
| 138 |
> |
} |
| 139 |
> |
|
| 140 |
> |
if (args_info.basetype_flag) { |
| 141 |
> |
AtomNameVisitor* atomNameVisitor = new AtomNameVisitor(info); |
| 142 |
> |
compositeVisitor->addVisitor(atomNameVisitor, 550); |
| 143 |
> |
|
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
//create ZconsVisitor |
| 155 |
|
} |
| 156 |
|
} |
| 157 |
|
|
| 158 |
< |
//creat wrapping visitor |
| 158 |
> |
//create wrapping visitor |
| 159 |
|
|
| 160 |
< |
if(args_info.periodicBox_flag){ |
| 161 |
< |
WrappingVisitor* wrappingVisitor = new WrappingVisitor(info); |
| 162 |
< |
compositeVisitor->addVisitor(wrappingVisitor, 400); |
| 163 |
< |
} |
| 164 |
< |
|
| 165 |
< |
//creat replicate visitor |
| 160 |
> |
//if(args_info.periodicBox_flag){ |
| 161 |
> |
// WrappingVisitor* wrappingVisitor = new WrappingVisitor(info); |
| 162 |
> |
// compositeVisitor->addVisitor(wrappingVisitor, 400); |
| 163 |
> |
//} |
| 164 |
> |
|
| 165 |
> |
//create replicate visitor |
| 166 |
|
if(args_info.repeatX_given > 0 || args_info.repeatY_given > 0 ||args_info.repeatY_given > 0){ |
| 167 |
|
Vector3i replicateOpt(args_info.repeatX_arg, args_info.repeatY_arg, args_info.repeatZ_arg); |
| 168 |
|
ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, replicateOpt); |
| 169 |
|
compositeVisitor->addVisitor(replicateVisitor, 300); |
| 170 |
|
} |
| 171 |
< |
|
| 172 |
< |
//creat xyzVisitor |
| 173 |
< |
XYZVisitor* xyzVisitor = new XYZVisitor(info); |
| 171 |
> |
|
| 172 |
> |
|
| 173 |
> |
//create rotation visitor |
| 174 |
> |
if (args_info.refsele_given&& args_info.originsele_given) { |
| 175 |
> |
compositeVisitor->addVisitor(new LipidTransVisitor(info, args_info.originsele_arg, args_info.refsele_arg), 250); |
| 176 |
> |
} else if (args_info.refsele_given || args_info.originsele_given) { |
| 177 |
> |
std::cerr << "Both of --refsele and --originsele should appear by pair" << std::endl; |
| 178 |
> |
exit(1); |
| 179 |
> |
} |
| 180 |
> |
|
| 181 |
> |
//create xyzVisitor |
| 182 |
> |
XYZVisitor* xyzVisitor; |
| 183 |
> |
|
| 184 |
> |
if (args_info.selection_given) { |
| 185 |
> |
xyzVisitor = new XYZVisitor(info, args_info.selection_arg); |
| 186 |
> |
} else { |
| 187 |
> |
xyzVisitor = new XYZVisitor(info); |
| 188 |
> |
} |
| 189 |
> |
|
| 190 |
> |
if(args_info.printPosOnly_flag){ |
| 191 |
> |
bool posOnly = true; |
| 192 |
> |
xyzVisitor->setPosOnly(posOnly); |
| 193 |
> |
} |
| 194 |
> |
|
| 195 |
|
compositeVisitor->addVisitor(xyzVisitor, 200); |
| 196 |
|
|
| 197 |
|
std::cout << compositeVisitor->toString(); |
| 198 |
|
|
| 199 |
< |
//creat prepareVisitor |
| 199 |
> |
//create prepareVisitor |
| 200 |
|
PrepareVisitor* prepareVisitor = new PrepareVisitor(); |
| 201 |
|
|
| 202 |
|
//open dump file |
| 204 |
|
int nframes = dumpReader->getNFrames(); |
| 205 |
|
|
| 206 |
|
|
| 207 |
< |
std::ofstream xyzStream; |
| 205 |
< |
xyzStream .open(xyzFileName.c_str()); |
| 207 |
> |
std::ofstream xyzStream(xyzFileName.c_str()); |
| 208 |
|
|
| 207 |
– |
|
| 209 |
|
SimInfo::MoleculeIterator miter; |
| 210 |
|
Molecule::IntegrableObjectIterator iiter; |
| 211 |
|
Molecule::RigidBodyIterator rbIter; |
| 212 |
|
Molecule* mol; |
| 213 |
|
StuntDouble* integrableObject; |
| 214 |
|
RigidBody* rb; |
| 215 |
< |
|
| 216 |
< |
if (evaluator && !evaluator->isDynamic()) { |
| 217 |
< |
info->getSelectionManager()->setSelectionSet(evaluator->evaluate()); |
| 218 |
< |
} |
| 219 |
< |
|
| 215 |
> |
Vector3d molCom; |
| 216 |
> |
Vector3d newMolCom; |
| 217 |
> |
Vector3d displacement; |
| 218 |
> |
Mat3x3d hmat; |
| 219 |
> |
Snapshot* currentSnapshot; |
| 220 |
> |
|
| 221 |
|
for (int i = 0; i < nframes; i += args_info.frame_arg){ |
| 222 |
|
dumpReader->readFrame(i); |
| 223 |
< |
|
| 223 |
> |
|
| 224 |
> |
//wrapping the molecule |
| 225 |
> |
if(args_info.periodicBox_flag) { |
| 226 |
> |
currentSnapshot = info->getSnapshotManager()->getCurrentSnapshot(); |
| 227 |
> |
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
| 228 |
> |
molCom = mol->getCom(); |
| 229 |
> |
newMolCom = molCom; |
| 230 |
> |
currentSnapshot->wrapVector(newMolCom); |
| 231 |
> |
displacement = newMolCom - molCom; |
| 232 |
> |
for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL; |
| 233 |
> |
integrableObject = mol->nextIntegrableObject(iiter)) { |
| 234 |
> |
integrableObject->setPos(integrableObject->getPos() + displacement); |
| 235 |
> |
} |
| 236 |
> |
} |
| 237 |
> |
} |
| 238 |
|
//update atoms of rigidbody |
| 239 |
|
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
| 240 |
|
|
| 255 |
|
//update visitor |
| 256 |
|
compositeVisitor->update(); |
| 257 |
|
|
| 258 |
< |
//if dynamic, we need to re-evaluate the selection |
| 243 |
< |
if (evaluator && evaluator->isDynamic()) { |
| 244 |
< |
info->getSelectionManager()->setSelectionSet(evaluator->evaluate()); |
| 245 |
< |
} |
| 246 |
< |
|
| 258 |
> |
|
| 259 |
|
//visit stuntdouble |
| 260 |
|
for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) { |
| 261 |
|
for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL; |
| 268 |
|
xyzVisitor->clear(); |
| 269 |
|
|
| 270 |
|
}//end for (int i = 0; i < nframes; i += args_info.frame_arg) |
| 271 |
< |
|
| 271 |
> |
|
| 272 |
|
xyzStream.close(); |
| 273 |
< |
|
| 262 |
< |
|
| 273 |
> |
delete prepareVisitor; |
| 274 |
|
delete compositeVisitor; |
| 275 |
|
delete info; |
| 265 |
– |
|
| 276 |
|
} |