45#include "hydrodynamics/ApproximateModel.hpp"
47#include "hydrodynamics/CompositeShape.hpp"
48#include "hydrodynamics/Ellipsoid.hpp"
49#include "hydrodynamics/Sphere.hpp"
53#include "utils/Constants.hpp"
54#include "utils/simError.h"
99 void ApproximateModel::setShape(
Shape* shape) {
102 std::cerr <<
"Assigning Elements...";
104 std::cerr <<
" done.\n";
107 HydroProp* ApproximateModel::calcHydroProps(RealType viscosity) {
108 HydroProp* hp =
new HydroProp();
109 hp->setName(shape_->getName());
110 std::size_t nelements = elements_.size();
111 if (nelements == 0) nelements = assignElements();
113 DynamicRectMatrix<RealType> B(3 * nelements, 3 * nelements);
114 DynamicRectMatrix<RealType> C(3 * nelements, 3 * nelements);
117 std::cerr <<
"Checking " << nelements <<
" elements...";
118 for (std::size_t i = 0; i < nelements; ++i)
120 std::cerr <<
" done.\n";
122 std::cerr <<
"Calculating B matrix...";
123 for (std::size_t i = 0; i < nelements; ++i) {
124 for (std::size_t j = 0; j < nelements; ++j) {
125 Mat3x3d Tij = interactionTensor(i, j, viscosity);
126 B.setSubMatrix(i * 3, j * 3, Tij);
129 std::cerr <<
" done.\n";
132 std::cerr <<
"Inverting B matrix...";
134 std::cerr <<
" done.\n";
139 std::vector<Mat3x3d> U;
140 for (
unsigned int i = 0; i < nelements; ++i) {
142 currU.setupSkewMat(elements_[i].pos);
151 std::cerr <<
"Assembling resistance tensor...";
152 for (std::size_t i = 0; i < nelements; ++i) {
153 for (std::size_t j = 0; j < nelements; ++j) {
155 C.getSubMatrix(i * 3, j * 3, Cij);
161 Xiorr += -U[i] * Cij * U[j];
168 RealType volume = volumeCorrection();
171 Xiorr += (6.0 * viscosity * volume) * I;
173 Xiott *= Constants::viscoConvert;
174 Xiotr *= Constants::viscoConvert;
175 Xiorr *= Constants::viscoConvert;
180 tmp(0, 0) = Xiott(1, 1) + Xiott(2, 2);
181 tmp(0, 1) = -Xiott(0, 1);
182 tmp(0, 2) = -Xiott(0, 2);
183 tmp(1, 0) = -Xiott(0, 1);
184 tmp(1, 1) = Xiott(0, 0) + Xiott(2, 2);
185 tmp(1, 2) = -Xiott(1, 2);
186 tmp(2, 0) = -Xiott(0, 2);
187 tmp(2, 1) = -Xiott(1, 2);
188 tmp(2, 2) = Xiott(1, 1) + Xiott(0, 0);
190 tmpVec[0] = Xiotr(2, 1) - Xiotr(1, 2);
191 tmpVec[1] = Xiotr(0, 2) - Xiotr(2, 0);
192 tmpVec[2] = Xiotr(1, 0) - Xiotr(0, 1);
195 Vector3d ror = tmp.inverse() * tmpVec;
199 Uor.setupSkewMat(ror);
207 Xirtr = (Xiotr - Uor * Xiott);
208 Xirrr = Xiorr - Uor * Xiott * Uor + Xiotr * Uor - Uor * Xiotr.transpose();
214 hp->setCenterOfResistance(ror);
216 Xi.setSubMatrix(0, 0, Xirtt);
217 Xi.setSubMatrix(0, 3, Xirtr.transpose());
218 Xi.setSubMatrix(3, 0, Xirtr);
219 Xi.setSubMatrix(3, 3, Xirrr);
220 std::cerr <<
" done.\n";
222 hp->setResistanceTensor(Xi);
ApproximateModel()
References:
static SquareMatrix< RealType, Dim > identity()
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
bool invertMatrix(MatrixType &A, MatrixType &AI)
Invert input square matrix A into matrix AI.