47#include "hydrodynamics/ShapeBuilder.hpp"
49#include "hydrodynamics/CompositeShape.hpp"
50#include "hydrodynamics/Ellipsoid.hpp"
51#include "hydrodynamics/Sphere.hpp"
52#include "types/GayBerneAdapter.hpp"
53#include "types/LennardJonesAdapter.hpp"
58 Shape* currShape = NULL;
59 if (sd->isDirectionalAtom()) {
60 currShape = internalCreateShape(
static_cast<DirectionalAtom*
>(sd));
61 }
else if (sd->isAtom()) {
62 currShape = internalCreateShape(
static_cast<Atom*
>(sd));
63 }
else if (sd->isRigidBody()) {
64 currShape = internalCreateShape(
static_cast<RigidBody*
>(sd));
70 Molecule::IntegrableObjectIterator j;
73 if (mol->getNAtoms() == 1) {
74 Shape* molShape = createShape(mol->getAtomAt(0));
77 CompositeShape* molShape =
new CompositeShape();
78 for (sd = mol->beginIntegrableObject(j); sd != NULL;
79 sd = mol->nextIntegrableObject(j)) {
80 Shape* currShape = createShape(sd);
81 if (currShape != NULL) { molShape->addShape(currShape); }
83 molShape->setName(mol->getType());
89 Shape* ShapeBuilder::internalCreateShape(
Atom* atom) {
90 AtomType* atomType = atom->getAtomType();
91 Shape* currShape = NULL;
92 LennardJonesAdapter lja = LennardJonesAdapter(atomType);
93 if (lja.isLennardJones()) {
94 currShape =
new Sphere(atom->getPos(), lja.getSigma() / 2.0);
95 currShape->setName(atom->getType());
98 std::vector<AtomType*> atChain = atomType->allYourBase();
99 std::vector<AtomType*>::iterator i;
100 for (i = atChain.begin(); i != atChain.end(); ++i) {
103 currShape =
new Sphere(atom->getPos(), etab.
GetVdwRad(obanum));
104 currShape->setName(atom->getType());
109 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
110 "Could not find atom type in default element.txt\n");
111 painCave.severity = OPENMD_ERROR;
112 painCave.isFatal = 1;
120 AtomType* atomType = datom->getAtomType();
121 Shape* currShape = NULL;
122 LennardJonesAdapter lja = LennardJonesAdapter(atomType);
123 GayBerneAdapter gba = GayBerneAdapter(atomType);
124 if (gba.isGayBerne()) {
125 currShape =
new Ellipsoid(datom->getPos(), gba.getL() / 2.0,
126 gba.getD() / 2.0, datom->getA());
127 }
else if (lja.isLennardJones()) {
128 currShape =
new Sphere(datom->getPos(), lja.getSigma() / 2.0);
130 int obanum = etab.
GetAtomicNum((datom->getType()).c_str());
132 currShape =
new Sphere(datom->getPos(), etab.
GetVdwRad(obanum));
134 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
135 "Could not find atom type in default element.txt\n");
136 painCave.severity = OPENMD_ERROR;
137 painCave.isFatal = 1;
141 currShape->setName(datom->getType());
146 std::vector<Atom*>::iterator ai;
147 CompositeShape* compositeShape =
new CompositeShape;
149 for (atom = rb->beginAtom(ai); atom != NULL; atom = rb->nextAtom(ai)) {
150 Shape* currShape = NULL;
151 if (atom->isDirectionalAtom()) {
152 currShape = internalCreateShape(
static_cast<DirectionalAtom*
>(atom));
153 }
else if (atom->isAtom()) {
154 currShape = internalCreateShape(
static_cast<Atom*
>(atom));
156 if (currShape != NULL) {
157 compositeShape->addShape(currShape);
158 compositeShape->setName(rb->getType());
161 return compositeShape;
RealType GetVdwRad(int atomicnum)
int GetAtomicNum(const char *str)
"Don't move, or you're dead! Stand up! Captain, we've got them!"
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.