48#include "hydrodynamics/ApproximateModel.hpp"
50#include "hydrodynamics/CompositeShape.hpp"
51#include "hydrodynamics/Ellipsoid.hpp"
52#include "hydrodynamics/Sphere.hpp"
56#include "utils/Constants.hpp"
57#include "utils/simError.h"
102 void ApproximateModel::setShape(
Shape* shape) {
105 std::cerr <<
"Assigning Elements...";
107 std::cerr <<
" done.\n";
110 HydroProp* ApproximateModel::calcHydroProps(RealType viscosity) {
111 HydroProp* hp =
new HydroProp();
112 hp->setName(shape_->getName());
113 std::size_t nelements = elements_.size();
114 if (nelements == 0) nelements = assignElements();
120 std::cerr <<
"Checking " << nelements <<
" elements...";
121 for (std::size_t i = 0; i < nelements; ++i)
123 std::cerr <<
" done.\n";
125 std::cerr <<
"Calculating B matrix...";
126 for (std::size_t i = 0; i < nelements; ++i) {
127 for (std::size_t j = 0; j < nelements; ++j) {
128 Mat3x3d Tij = interactionTensor(i, j, viscosity);
129 B.setSubMatrix(i * 3, j * 3, Tij);
132 std::cerr <<
" done.\n";
135 std::cerr <<
"Inverting B matrix...";
137 std::cerr <<
" done.\n";
142 std::vector<Mat3x3d> U;
143 for (
unsigned int i = 0; i < nelements; ++i) {
145 currU.setupSkewMat(elements_[i].pos);
154 std::cerr <<
"Assembling resistance tensor...";
155 for (std::size_t i = 0; i < nelements; ++i) {
156 for (std::size_t j = 0; j < nelements; ++j) {
158 C.getSubMatrix(i * 3, j * 3, Cij);
164 Xiorr += -U[i] * Cij * U[j];
171 RealType volume = volumeCorrection();
174 Xiorr += (6.0 * viscosity * volume) * I;
176 Xiott *= Constants::viscoConvert;
177 Xiotr *= Constants::viscoConvert;
178 Xiorr *= Constants::viscoConvert;
183 tmp(0, 0) = Xiott(1, 1) + Xiott(2, 2);
184 tmp(0, 1) = -Xiott(0, 1);
185 tmp(0, 2) = -Xiott(0, 2);
186 tmp(1, 0) = -Xiott(0, 1);
187 tmp(1, 1) = Xiott(0, 0) + Xiott(2, 2);
188 tmp(1, 2) = -Xiott(1, 2);
189 tmp(2, 0) = -Xiott(0, 2);
190 tmp(2, 1) = -Xiott(1, 2);
191 tmp(2, 2) = Xiott(1, 1) + Xiott(0, 0);
193 tmpVec[0] = Xiotr(2, 1) - Xiotr(1, 2);
194 tmpVec[1] = Xiotr(0, 2) - Xiotr(2, 0);
195 tmpVec[2] = Xiotr(1, 0) - Xiotr(0, 1);
198 Vector3d ror = tmp.inverse() * tmpVec;
202 Uor.setupSkewMat(ror);
210 Xirtr = (Xiotr - Uor * Xiott);
211 Xirrr = Xiorr - Uor * Xiott * Uor + Xiotr * Uor - Uor * Xiotr.transpose();
217 hp->setCenterOfResistance(ror);
219 Xi.setSubMatrix(0, 0, Xirtt);
220 Xi.setSubMatrix(0, 3, Xirtr.transpose());
221 Xi.setSubMatrix(3, 0, Xirtr);
222 Xi.setSubMatrix(3, 3, Xirrr);
223 std::cerr <<
" done.\n";
225 hp->setResistanceTensor(Xi);
Rectangular matrix class with contiguous flat storage.
ApproximateModel()
References:
static SquareMatrix< Real, Dim > identity()
Returns an identity matrix.
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.