53#include "brains/Register.hpp"
56#include "hydrodynamics/AnalyticalModel.hpp"
57#include "hydrodynamics/AtomicBeadModel.hpp"
58#include "hydrodynamics/BoundaryElementModel.hpp"
59#include "hydrodynamics/CompositeShape.hpp"
60#include "hydrodynamics/HydroIO.hpp"
61#include "hydrodynamics/HydrodynamicsModel.hpp"
62#include "hydrodynamics/HydrodynamicsModelCreator.hpp"
64#include "hydrodynamics/Mesh.hpp"
65#include "hydrodynamics/RoughShell.hpp"
66#include "hydrodynamics/ShapeBuilder.hpp"
67#include "hydrodynamics/Sphere.hpp"
68#include "io/MSMSFormat.hpp"
69#include "io/XYZFormat.hpp"
70#include "stl_reader.h"
75#include "utils/Trim.hpp"
76#include "utils/simError.h"
80void registerHydrodynamicsModels();
81void writeHydroProps(std::ostream& os);
83int main(
int argc,
char* argv[]) {
84 registerHydrodynamicsModels();
88 if (cmdline_parser(argc, argv, &args_info) != 0) { exit(1); }
90 std::string inFileName;
91 std::string modelName;
92 std::string modelSpecified;
93 std::string modelRequired;
95 bool hasInput =
false;
96 bool hasModel =
false;
103 case model_arg_RoughShell:
104 modelSpecified =
"RoughShell";
106 case model_arg_BoundaryElement:
107 modelSpecified =
"BoundaryElementModel";
109 case model_arg_AtomicBead:
111 modelSpecified =
"AtomicBeadModel";
121 modelRequired = modelSpecified;
124 inFileName = args_info.
stl_arg;
125 modelRequired =
"BoundaryElementModel";
129 modelRequired =
"BoundaryElementModel";
132 inFileName = args_info.
xyz_arg;
133 modelRequired =
"AtomicBeadModel";
138 strcpy(painCave.errMsg,
"No input file name was specified.\n");
139 painCave.isFatal = 1;
144 if (modelSpecified.compare(modelRequired) != 0) {
145 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
146 "Specified model (%s) does not match model required for input "
148 modelSpecified.c_str(), modelRequired.c_str());
149 painCave.isFatal = 1;
152 modelName = modelSpecified;
155 modelName = modelRequired;
166 std::string outputFilename = prefix +
".hydro";
174 std::map<std::string, Shape*> uniqueShapes;
178 stl_reader::StlMesh<RealType, unsigned int> mesh(inFileName.c_str());
179 for (
size_t isolid = 0; isolid < mesh.num_solids(); ++isolid) {
181 std::cout <<
"solid " << isolid << std::endl;
182 for (
size_t itri = mesh.solid_tris_begin(isolid);
183 itri < mesh.solid_tris_end(isolid); ++itri) {
184 const RealType* c0 = mesh.tri_corner_coords(itri, 0);
185 const RealType* c1 = mesh.tri_corner_coords(itri, 1);
186 const RealType* c2 = mesh.tri_corner_coords(itri, 2);
187 Vector3d vert0(c0[0], c0[1], c0[2]);
188 Vector3d vert1(c1[0], c1[1], c1[2]);
189 Vector3d vert2(c2[0], c2[1], c2[2]);
190 dynamic_cast<Mesh*
>(shape)->add(vert0, vert1, vert2);
192 std::string solidName;
193 if (mesh.num_solids() > 1) {
194 solidName = prefix +
"_" + std::to_string(isolid);
199 shape->setName(solidName);
201 std::map<std::string, Shape*>::value_type(solidName, shape));
203 }
catch (std::exception& e) { std::cout << e.what() << std::endl; }
207 shape = msms->ReadShape();
208 shape->setName(prefix);
210 std::map<std::string, Shape*>::value_type(prefix, shape));
212 ifstream in(inFileName);
214 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
215 "Could not open XYZ file\n");
216 painCave.isFatal = 1;
221 xyz->ReadMolecule(in);
224 shape->setName(xyz->title_);
226 Shape* currShape = NULL;
228 size_t natoms = xyz->mol_.size();
229 for (
size_t iatom = 0; iatom < natoms; ++iatom) {
230 Vector3d pos = xyz->mol_[iatom]->pos;
231 int anum = xyz->mol_[iatom]->atomicNum;
232 std::string atype = xyz->mol_[iatom]->type;
233 currShape =
new Sphere(pos, etab.GetVdwRad(anum));
234 currShape->setName(atype);
235 if (currShape != NULL) {
240 std::map<std::string, Shape*>::value_type(xyz->title_, shape));
246 SimInfo::MoleculeIterator mi;
248 Molecule::IntegrableObjectIterator ii;
251 Globals* simParams = info->getSimParams();
253 if (simParams->haveViscosity()) {
254 viscosity = simParams->getViscosity();
256 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
257 "viscosity must be set\n");
258 painCave.isFatal = 1;
262 if (simParams->haveTargetTemp()) {
263 temperature = simParams->getTargetTemp();
265 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
266 "target temperature must be set\n");
267 painCave.isFatal = 1;
273 for (sd = mol->beginIntegrableObject(ii); sd != NULL;
274 sd = mol->nextIntegrableObject(ii)) {
275 if (uniqueShapes.find(sd->
getType()) == uniqueShapes.end()) {
283 Shape* tmp = ShapeBuilder::createShape(sd);
285 std::map<std::string, Shape*>::value_type(sd->
getType(), tmp));
297 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
298 "Could not create HydrodynamicsModel\n");
299 painCave.isFatal = 1;
304 if (modelName.compare(
"RoughShell") == 0) {
305 dynamic_cast<RoughShell*
>(model)->setSigma(beadSize);
308 std::ofstream outputHydro;
309 outputHydro.open(outputFilename.c_str());
311 hio->openWriter(outputHydro);
313 std::map<std::string, Shape*>::iterator si;
314 for (si = uniqueShapes.begin(); si != uniqueShapes.end(); ++si) {
316 model->setShape(shape);
320 std::stringstream elementFile;
321 elementFile << prefix <<
"_" << shape->getName();
322 if (modelName.compare(
"BoundaryElementModel") == 0) {
323 elementFile <<
".stl";
325 elementFile <<
".xyz";
327 ofs.open(elementFile.str().c_str());
328 model->writeElements(ofs);
333 HydroProp* hp = model->calcHydroProps(viscosity);
334 hio->writeHydroProp(hp, viscosity, temperature, outputHydro);
335 hio->interpretHydroProp(hp, viscosity, temperature);
339 hio->closeWriter(outputHydro);
346void registerHydrodynamicsModels() {
355 "BoundaryElementModel"));
This basic Periodic Table class was originally taken from the data.h file in OpenBabel.
The header file for the command line option parser generated by GNU Gengetopt version 2....
Combine composite pattern and visitor pattern.
Container for information about the hydrodynamic behavior of objects interacting with surroundings.
bool registerHydrodynamicsModel(HydrodynamicsModelCreator *creator)
Registers a creator with a type identifier.
HydrodynamicsModel * createHydrodynamicsModel(const std::string &id)
Looks up the type identifier in the internal map.
static HydrodynamicsModelFactory * getInstance()
Returns an instance of HydrodynamicsModel factory.
void updateAtoms()
update the positions of atoms belong to this rigidbody
The only responsibility of SimCreator is to parse the meta-data file and create a SimInfo instance ba...
SimInfo * createSim(const std::string &mdFileName, bool loadInitCoords=true)
Setup Simulation.
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
Molecule * beginMolecule(MoleculeIterator &i)
Returns the first molecule in this SimInfo and intialize the iterator.
Molecule * nextMolecule(MoleculeIterator &i)
Returns the next avaliable Molecule based on the iterator.
"Don't move, or you're dead! Stand up! Captain, we've got them!"
virtual void setA(const RotMat3x3d &a)
Sets the current rotation matrix of this stuntDouble.
virtual std::string getType()=0
Returns the name of this stuntDouble.
void setPos(const Vector3d &pos)
Sets the current position of this stuntDouble.
bool isRigidBody()
Tests if this stuntDouble is a rigid body.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
std::string getPrefix(const std::string &str)
Where the command line options are stored.
double viscosity_arg
viscosity (in poise) (default='0.01').
unsigned int output_given
Whether output was given.
enum enum_model model_arg
hydrodynamics model.
unsigned int msms_given
Whether msms was given.
unsigned int xyz_given
Whether xyz was given.
double beadSize_arg
bead size (diameter) for RoughShell model (in angstroms) (default='0.2').
char * output_arg
output file name.
char * input_arg
input dump file.
double temperature_arg
temperature (in Kelvin (default='300').
unsigned int stl_given
Whether stl was given.
char * xyz_arg
xyz file for AtomicBead model.
int elements_flag
output the hydrodynamic elements (beads or triangles) only, hydrodynamics calculation will not be per...
unsigned int input_given
Whether input was given.
char * stl_arg
stl file for BoundaryElement model.
unsigned int model_given
Whether model was given.
char * msms_arg
filename root for MSMS .vert and .face files.