45#include "hydrodynamics/BoundaryElementModel.hpp"
47#include "hydrodynamics/Mesh.hpp"
51#include "math/integration/StrangFixCowperTriangleQuadrature.hpp"
52#include "math/integration/TriangleQuadrature.hpp"
53#include "utils/Constants.hpp"
54#include "utils/simError.h"
58 BoundaryElementModel::BoundaryElementModel() : ApproximateModel() {}
60 std::size_t BoundaryElementModel::assignElements() {
62 if (shape_->isMesh()) {
63 createTriangles(
dynamic_cast<Mesh*
>(shape_));
65 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
66 "BoundaryElementModel::assignElements Error: No mesh was "
67 "given as the shape\n");
68 painCave.severity = OPENMD_ERROR;
72 return elements_.size();
77 void BoundaryElementModel::createTriangles(Mesh* m) {
79 std::string name = m->getName();
80 std::vector<Triangle> facets = m->getFacets();
81 for (std::vector<Triangle>::iterator i = facets.begin();
82 i != facets.end(); ++i) {
83 HydrodynamicsElement currTri;
85 currTri.pos = (*i).getCentroid();
87 elements_.push_back(currTri);
92 void BoundaryElementModel::checkElement(std::size_t i) {}
94 void BoundaryElementModel::writeElements(std::ostream& os) {
95 std::vector<HydrodynamicsElement>::iterator iter;
96 std::string name = shape_->getName();
98 <<
" " << name << std::endl;
99 for (iter = elements_.begin(); iter != elements_.end(); ++iter) {
100 Triangle t = iter->t;
101 Vector3d n = t.getUnitNormal();
102 Vector3d v1 = t.vertex1();
103 Vector3d v2 = t.vertex2();
104 Vector3d v3 = t.vertex3();
107 <<
" " << n[0] <<
" " << n[1] <<
" " << n[2] << std::endl;
109 <<
"outer loop" << std::endl;
113 <<
" " << v1[0] <<
" " << v1[1] <<
" " << v1[2] << std::endl;
117 <<
" " << v2[0] <<
" " << v2[1] <<
" " << v2[2] << std::endl;
121 <<
" " << v3[0] <<
" " << v3[1] <<
" " << v3[2] << std::endl;
123 <<
"endloop" << std::endl;
125 <<
"endfacet" << std::endl;
128 <<
" " << name << std::endl;
131 Mat3x3d BoundaryElementModel::interactionTensor(
const std::size_t i,
133 const RealType viscosity) {
135 Mat3x3d I = SquareMatrix3<RealType>::identity();
137 StrangFixCowperTriangleQuadratureRule rule(6);
139 Vector3d centroid = elements_[i].pos;
140 Triangle t = elements_[j].t;
142 auto Tij = [&t, ¢roid, &I, &viscosity](
const Vector3d& p) {
144 Vector3d r = t.barycentricToCartesian(p);
145 Vector3d ab = centroid - r;
146 RealType abl = ab.
length();
148 T = (I + outProduct(ab, ab) / (abl * abl));
149 T /= (8.0 * Constants::PI * viscosity * abl);
153 B = TriangleQuadrature<RectMatrix<RealType, 3, 3>, RealType>::Integrate(
156 centroid = elements_[j].pos;
159 auto Tji = [&t, ¢roid, &I, &viscosity](
const Vector3d& p) {
161 Vector3d r = t.barycentricToCartesian(p);
162 Vector3d ab = centroid - r;
163 RealType abl = ab.
length();
165 T = (I + outProduct(ab, ab) / (abl * abl));
166 T /= (8.0 * Constants::PI * viscosity * abl);
170 B += TriangleQuadrature<RectMatrix<RealType, 3, 3>, RealType>::Integrate(
Real length()
Returns the length of this vector.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.