50#include "brains/Register.hpp" 
   53#include "hydrodynamics/AnalyticalModel.hpp" 
   54#include "hydrodynamics/AtomicBeadModel.hpp" 
   55#include "hydrodynamics/BoundaryElementModel.hpp" 
   56#include "hydrodynamics/CompositeShape.hpp" 
   57#include "hydrodynamics/HydroIO.hpp" 
   58#include "hydrodynamics/HydrodynamicsModel.hpp" 
   59#include "hydrodynamics/HydrodynamicsModelCreator.hpp" 
   61#include "hydrodynamics/Mesh.hpp" 
   62#include "hydrodynamics/RoughShell.hpp" 
   63#include "hydrodynamics/ShapeBuilder.hpp" 
   64#include "hydrodynamics/Sphere.hpp" 
   65#include "io/MSMSFormat.hpp" 
   66#include "io/XYZFormat.hpp" 
   67#include "stl_reader.h" 
   72#include "utils/Trim.hpp" 
   73#include "utils/simError.h" 
   77void registerHydrodynamicsModels();
 
   78void writeHydroProps(std::ostream& os);
 
   80int main(
int argc, 
char* argv[]) {
 
   81  registerHydrodynamicsModels();
 
   85  if (cmdline_parser(argc, argv, &args_info) != 0) { exit(1); }
 
   87  std::string inFileName;
 
   88  std::string modelName;
 
   89  std::string modelSpecified;
 
   90  std::string modelRequired;
 
   92  bool hasInput = 
false;
 
   93  bool hasModel = 
false;
 
  100    case model_arg_RoughShell:
 
  101      modelSpecified = 
"RoughShell";
 
  103    case model_arg_BoundaryElement:
 
  104      modelSpecified = 
"BoundaryElementModel";
 
  106    case model_arg_AtomicBead:
 
  108      modelSpecified = 
"AtomicBeadModel";
 
  118    modelRequired = modelSpecified;
 
  121    inFileName    = args_info.
stl_arg;
 
  122    modelRequired = 
"BoundaryElementModel";
 
  126    modelRequired = 
"BoundaryElementModel";
 
  129    inFileName    = args_info.
xyz_arg;
 
  130    modelRequired = 
"AtomicBeadModel";
 
  135    strcpy(painCave.errMsg, 
"No input file name was specified.\n");
 
  136    painCave.isFatal = 1;
 
  141    if (modelSpecified.compare(modelRequired) != 0) {
 
  142      snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
 
  143               "Specified model (%s) does not match model required for input " 
  145               modelSpecified.c_str(), modelRequired.c_str());
 
  146      painCave.isFatal = 1;
 
  149      modelName = modelSpecified;
 
  152    modelName = modelRequired;
 
  163  std::string outputFilename = prefix + 
".hydro";
 
  171  std::map<std::string, Shape*> uniqueShapes;
 
  175      stl_reader::StlMesh<RealType, unsigned int> mesh(inFileName.c_str());
 
  176      for (
size_t isolid = 0; isolid < mesh.num_solids(); ++isolid) {
 
  178        std::cout << 
"solid " << isolid << std::endl;
 
  179        for (
size_t itri = mesh.solid_tris_begin(isolid);
 
  180             itri < mesh.solid_tris_end(isolid); ++itri) {
 
  181          const RealType* c0 = mesh.tri_corner_coords(itri, 0);
 
  182          const RealType* c1 = mesh.tri_corner_coords(itri, 1);
 
  183          const RealType* c2 = mesh.tri_corner_coords(itri, 2);
 
  184          Vector3d vert0(c0[0], c0[1], c0[2]);
 
  185          Vector3d vert1(c1[0], c1[1], c1[2]);
 
  186          Vector3d vert2(c2[0], c2[1], c2[2]);
 
  187          dynamic_cast<Mesh*
>(shape)->add(vert0, vert1, vert2);
 
  189        std::string solidName;
 
  190        if (mesh.num_solids() > 1) {
 
  191          solidName = prefix + 
"_" + std::to_string(isolid);
 
  196        shape->setName(solidName);
 
  198            std::map<std::string, Shape*>::value_type(solidName, shape));
 
  200    } 
catch (std::exception& e) { std::cout << e.what() << std::endl; }
 
  204    shape            = msms->ReadShape();
 
  205    shape->setName(prefix);
 
  207        std::map<std::string, Shape*>::value_type(prefix, shape));
 
  209    ifstream in(inFileName);
 
  211      snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
 
  212               "Could not open XYZ file\n");
 
  213      painCave.isFatal = 1;
 
  218    xyz->ReadMolecule(in);
 
  221    shape->setName(xyz->title_);
 
  223    Shape* currShape = NULL;
 
  225    size_t natoms = xyz->mol_.size();
 
  226    for (
size_t iatom = 0; iatom < natoms; ++iatom) {
 
  227      Vector3d pos      = xyz->mol_[iatom]->pos;
 
  228      int anum          = xyz->mol_[iatom]->atomicNum;
 
  229      std::string atype = xyz->mol_[iatom]->type;
 
  231      currShape->setName(atype);
 
  232      if (currShape != NULL) {
 
  237        std::map<std::string, Shape*>::value_type(xyz->title_, shape));
 
  243    SimInfo::MoleculeIterator mi;
 
  245    Molecule::IntegrableObjectIterator ii;
 
  248    Globals* simParams = info->getSimParams();
 
  250    if (simParams->haveViscosity()) {
 
  251      viscosity = simParams->getViscosity();
 
  253      snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
 
  254               "viscosity must be set\n");
 
  255      painCave.isFatal = 1;
 
  259    if (simParams->haveTargetTemp()) {
 
  260      temperature = simParams->getTargetTemp();
 
  262      snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
 
  263               "target temperature must be set\n");
 
  264      painCave.isFatal = 1;
 
  270      for (sd = mol->beginIntegrableObject(ii); sd != NULL;
 
  271           sd = mol->nextIntegrableObject(ii)) {
 
  272        if (uniqueShapes.find(sd->
getType()) == uniqueShapes.end()) {
 
  280          Shape* tmp = ShapeBuilder::createShape(sd);
 
  282              std::map<std::string, Shape*>::value_type(sd->
getType(), tmp));
 
  294    snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
 
  295             "Could not create HydrodynamicsModel\n");
 
  296    painCave.isFatal = 1;
 
  301    if (modelName.compare(
"RoughShell") == 0) {
 
  302      dynamic_cast<RoughShell*
>(model)->setSigma(beadSize);
 
  305    std::ofstream outputHydro;
 
  306    outputHydro.open(outputFilename.c_str());
 
  308    hio->openWriter(outputHydro);
 
  310    std::map<std::string, Shape*>::iterator si;
 
  311    for (si = uniqueShapes.begin(); si != uniqueShapes.end(); ++si) {
 
  313      model->setShape(shape);
 
  317      std::stringstream elementFile;
 
  318      elementFile << prefix << 
"_" << shape->getName();
 
  319      if (modelName.compare(
"BoundaryElementModel") == 0) {
 
  320        elementFile << 
".stl";
 
  322        elementFile << 
".xyz";
 
  324      ofs.open(elementFile.str().c_str());
 
  325      model->writeElements(ofs);
 
  330        HydroProp* hp = model->calcHydroProps(viscosity);
 
  331        hio->writeHydroProp(hp, viscosity, temperature, outputHydro);
 
  332        hio->interpretHydroProp(hp, viscosity, temperature);
 
  336    hio->closeWriter(outputHydro);
 
  343void registerHydrodynamicsModels() {
 
  352          "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.
 
RealType GetVdwRad(int atomicnum)
 
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.