OpenLB 1.7
Loading...
Searching...
No Matches
frameChangeF3D.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2013, 2015 Gilles Zahnd, Mathias J. Krause
4 * Marie-Luise Maier
5 * E-mail contact: info@openlb.net
6 * The most recent release of OpenLB can be downloaded at
7 * <http://www.openlb.net/>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23*/
24
25#ifndef FRAME_CHANGE_F_3D_H
26#define FRAME_CHANGE_F_3D_H
27
28#include<vector>
29#include<string>
30#include <random>
31
32#include "analyticalF.h"
33
48/* To enable simulations in a rotating frame, the axis is set in the
49 * constructor with axisPoint and axisDirection. The axisPoint can be the
50 * coordinate of any point on the axis. The axisDirection has to be a normed to
51 * 1. The pulse w is in rad/s. It determines the pulse speed by its norm while
52 * the trigonometric or clockwise direction is determined by its sign: When the
53 * axisDirection is pointing "towards you", a positive pulse makes it turn in
54 * the trigonometric way. It has to be noticed that putting both axisDirection
55 * into -axisDirection and w into -w yields an exactly identical situation.
56 */
57
58namespace olb {
59
60
61template<typename T, unsigned D> class SuperGeometry;
62
63// PART 1: /////////////////////////////////////////////////////////////////////
64// Functors for rotating the coordinate system (velocity, pressure, force,...)
65
74template <typename T>
75class RotatingLinear3D final : public AnalyticalF3D<T,T> {
76protected:
77 std::vector<T> axisPoint;
78 std::vector<T> axisDirection;
79 T w;
81public:
82 RotatingLinear3D(std::vector<T> axisPoint_, std::vector<T> axisDirection_, T w_, T scale_=1);
83 bool operator()(T output[], const T x[]) override;
84};
85
94template <typename T>
95class RotatingLinearAnnulus3D final : public AnalyticalF3D<T,T> {
96protected:
97 std::vector<T> axisPoint;
98 std::vector<T> axisDirection;
99 T w;
100 T ri;
101 T ro;
103public:
104 RotatingLinearAnnulus3D(std::vector<T> axisPoint_, std::vector<T> axisDirection_, T w_, T ri_, T ro_, T scale_=1);
105 bool operator()(T output[], const T x[]);
106};
107
108
117template <typename T>
118class RotatingQuadratic1D final : public AnalyticalF3D<T,T> {
119protected:
120 std::vector<T> axisPoint;
121 std::vector<T> axisDirection;
122 T w;
125public:
126 RotatingQuadratic1D(std::vector<T> axisPoint_, std::vector<T> axisDirection_,
127 T w_, T scale_=1, T additive_=0);
128 bool operator()(T output[], const T x[]) override;
129};
130
131
132// PART 2: /////////////////////////////////////////////////////////////////////
133// Functors for setting velocities on a velocity boundary of a pipe
134
153template <typename T>
154class CirclePowerLaw3D : public AnalyticalF3D<T,T> {
155protected:
157 std::vector<T> _normal;
160 T _n;
162
163public:
164 CirclePowerLaw3D(olb::Vector<T, 3> axisPoint, std::vector<T> axisDirection, T maxVelocity, T radius, T n, T scale = T(1));
165 CirclePowerLaw3D(T center0, T center1, T center2, T normal0, T normal1, T normal2, T radius, T maxVelocity, T n, T scale = T(1));
166 CirclePowerLaw3D(const SuperGeometry<T,3>& superGeometry, int material, T maxVelocity, T n, T distance2Wall, T scale = T(1));
167
168 CirclePowerLaw3D(bool useMeanVelocity, std::vector<T> axisPoint, std::vector<T> axisDirection, T Velocity, T radius, T n, T scale = T(1));
169 CirclePowerLaw3D(bool useMeanVelocity, T center0, T center1, T center2, T normal0, T normal1, T normal2, T radius, T Velocity, T n, T scale = T(1));
170 CirclePowerLaw3D(bool useMeanVelocity, SuperGeometry<T,3>& superGeometry, int material, T Velocity, T n, T distance2Wall, T scale = T(1));
171
174 {
175 return _center;
176 };
178 std::vector<T> getNormal()
179 {
180 return _normal;
181 };
184 {
185 return _radius;
186 };
187
188 bool operator()(T output[], const T x[]) override;
189};
190
193template <typename T>
195private:
196 T _turbulenceIntensity;
197 std::random_device _rd;
198 std::mt19937 _generator;
199 std::normal_distribution<T> _dist;
200
201public:
202 CirclePowerLawTurbulent3D(std::vector<T> axisPoint_, std::vector<T> axisDirection, T maxVelocity, T radius, T n = 7, T turbulenceIntensity = 0.05, T scale = T(1));
203 CirclePowerLawTurbulent3D(T center0, T center1, T center2, T normal0, T normal1, T normal2, T radius, T maxVelocity, T n = 7, T turbulenceIntensity = 0.05, T scale = T(1));
204 CirclePowerLawTurbulent3D(SuperGeometry<T,3>& superGeometry, int material, T maxVelocity, T distance2Wall, T n = 7, T turbulenceIntensity = 0.05, T scale = T(1));
205
206 CirclePowerLawTurbulent3D(bool useMeanVelocity, std::vector<T> axisPoint, std::vector<T> axisDirection, T Velocity, T radius, T n = 7, T turbulenceIntensity = 0.05, T scale = T(1));
207 CirclePowerLawTurbulent3D(bool useMeanVelocity, T center0, T center1, T center2, T normal0, T normal1, T normal2, T radius, T Velocity, T n = 7, T turbulenceIntensity = 0.05, T scale = T(1));
208 CirclePowerLawTurbulent3D(bool useMeanVelocity, SuperGeometry<T,3>& superGeometry, int material, T Velocity, T distance2Wall, T n = 7, T turbulenceIntensity = 0.05, T scale = T(1));
209
210 bool operator()(T output[], const T x[]) override;
211};
212
214template <typename T>
215class CirclePoiseuille3D final : public CirclePowerLaw3D<T> {
216
217public:
218 CirclePoiseuille3D(std::vector<T> axisPoint, std::vector<T> axisDirection, T maxVelocity, T radius, T scale = T(1));
219 CirclePoiseuille3D(T center0, T center1, T center2, T normal0, T normal1, T normal2, T radius, T maxVelocity, T scale = T(1));
220 CirclePoiseuille3D(SuperGeometry<T,3>& superGeometry, int material, T maxVelocity, T distance2Wall, T scale = T(1));
221
222 CirclePoiseuille3D(bool useMeanVelocity, std::vector<T> axisPoint, std::vector<T> axisDirection, T Velocity, T radius, T scale = T(1));
223 CirclePoiseuille3D(bool useMeanVelocity, T center0, T center1, T center2, T normal0, T normal1, T normal2, T radius, T Velocity, T scale = T(1));
224 CirclePoiseuille3D(bool useMeanVelocity, SuperGeometry<T,3>& superGeometry, int material, T Velocity, T distance2Wall, T scale = T(1));
225};
226
228template < typename T,typename DESCRIPTOR>
230protected:
234
235public:
237 bool operator()(T output[], const T input[]) override;
238};
239
244template <typename T>
245class RectanglePoiseuille3D final : public AnalyticalF3D<T,T> {
246protected:
251 std::vector<T> maxVelocity;
252
253public:
254 RectanglePoiseuille3D(olb::Vector<T, 3>& x0_, olb::Vector<T, 3>& x1_, olb::Vector<T, 3>& x2_, std::vector<T>& maxVelocity_);
256
258 RectanglePoiseuille3D(SuperGeometry<T,3>& superGeometry_, int material_, std::vector<T>& maxVelocity_, T offsetX, T offsetY, T offsetZ);
259 bool operator()(T output[], const T x[]) override;
260};
261
262//More accurate Version using a trigonometric formulation
263template <typename T>
265protected:
267 std::vector<T> x0;
268 std::vector<T> x1;
269 std::vector<T> x2;
270 std::vector<T> maxVelocity;
274 void calcPeakAndAvg();
275
276public:
277 RectangleTrigonometricPoiseuille3D(std::vector<T>& x0_, std::vector<T>& x1_, std::vector<T>& x2_, std::vector<T>& maxVelocity, int numOfPolynoms_ = 1);
279
281 RectangleTrigonometricPoiseuille3D(SuperGeometry<T,3>& superGeometry_, int material_, std::vector<T>& maxVelocity_, T offsetX, T offsetY, T offsetZ, int numOfPolynoms_ = 1);
282 T getProfilePeak();
284 bool operator()(T output[], const T x[]) override;
285};
286
297template <typename T>
298class EllipticPoiseuille3D final : public AnalyticalF3D<T,T> {
299protected:
301 std::vector<T> _center;
304
305public:
306 EllipticPoiseuille3D(std::vector<T> center, T a, T b, T maxVel);
307 bool operator()(T output[], const T x[]) override;
308};
309
310
313template <typename T>
315protected:
320public:
321 AnalyticalPorousVelocity3D(SuperGeometry<T,3>& superGeometry, int material, T K_, T mu_, T gradP_, T radius_, T eps_=T(1));
322 T getPeakVelocity();
323 bool operator()(T output[], const T input[]) override;
324};
325
326
328
329
334template <typename T, typename S>
335class AngleBetweenVectors3D final : public AnalyticalF3D<T,S> {
336protected:
338 std::vector<T> _referenceVector;
341 std::vector<T> _orientation;
342public:
344 AngleBetweenVectors3D(std::vector<T> referenceVector,
345 std::vector<T> orientation);
347 bool operator()(T output[], const S x[]) override;
348};
349
350
355template <typename T, typename S>
356class RotationRoundAxis3D final : public AnalyticalF3D<T,S> {
357protected:
364public:
367 T alpha);
371 bool operator()(T output[], const S x[]) override;
372};
373
374
376
377
383template <typename T, typename S>
384class CylinderToCartesian3D final : public AnalyticalF3D<T,S> {
385protected:
386 std::vector<T> _cylinderOrigin;
387public:
389 CylinderToCartesian3D(std::vector<T> cylinderOrigin);
392 bool operator()(T output[], const S x[]) override;
393};
394
395
403template <typename T, typename S>
404class CartesianToCylinder3D final : public AnalyticalF3D<T,S> {
405protected:
413public:
414 CartesianToCylinder3D(olb::Vector<T, 3> cartesianOrigin, T& angle,
415 olb::Vector<T, 3> orientation = {T(1),T(),T()});
417 olb::Vector<T, 3> axisDirection,
418 olb::Vector<T, 3> orientation = {T(1),T(),T()});
419 CartesianToCylinder3D(T cartesianOriginX, T cartesianOriginY,
420 T cartesianOriginZ,
421 T axisDirectionX, T axisDirectionY,
422 T axisDirectionZ,
423 T orientationX = T(1), T orientationY = T(),
424 T orientationZ = T());
428 bool operator()(T output[], const S x[]) override;
430 olb::Vector<T, 3> const& getAxisDirection() const;
438 void setAngle(T angle);
439};
440
441
443
444
453template <typename T, typename S>
454class SphericalToCartesian3D final : public AnalyticalF3D<T,S> {
455 //protected:
456public:
461 bool operator()(T output[], const S x[]) override;
462};
463
464
471template <typename T, typename S>
472class CartesianToSpherical3D final : public AnalyticalF3D<T,S> {
473protected:
475 std::vector<T> _cartesianOrigin;
477 std::vector<T> _axisDirection;
478public:
479 CartesianToSpherical3D(std::vector<T> cartesianOrigin,
480 std::vector<T> axisDirection);//, std::vector<T> orientation);
485 bool operator()(T output[], const S x[]) override;
486};
487
488
490
491
497template <typename T, typename S>
499protected:
517public:
519 T radWire, T cutoff, T Mw, T Mp = T(1),
520 T radParticle = T(1), T mu0 = 4*3.14159265e-7);
522 bool operator()(T output[], const S x[]) override;
523};
524
525template <typename T, typename S>
526class MagneticFieldFromCylinder3D final : public AnalyticalF3D<T, S> {
527protected:
539public:
541 T length,
542 T radWire,
543 T cutoff,
544 T Mw
545 );
547 bool operator()(T output[], const S x[]) override;
548};
549
550} // end namespace olb
551
552#endif
AnalyticalF are applications from DD to XD, where X is set by the constructor.
Analytical solution of porous media channel flow with low Reynolds number See Spaid and Phelan (doi:1...
AnalyticalPorousVelocity3D(SuperGeometry< T, 3 > &superGeometry, int material, T K_, T mu_, T gradP_, T radius_, T eps_=T(1))
bool operator()(T output[], const T input[]) override
This class calculates the angle alpha between vector _referenceVector and any other vector x.
std::vector< T > _orientation
direction around which x has to be turned with angle is in math pos sense to lie over _referenceVecto...
std::vector< T > _referenceVector
between _referenceVector and vector x, angle is calculated
AngleBetweenVectors3D(std::vector< T > referenceVector, std::vector< T > orientation)
constructor defines _referenceVector and _orientation
bool operator()(T output[], const S x[]) override
operator writes angle between x and _referenceVector inro output field
This class converts Cartesian coordinates of point x to cylindrical coordinates wrote into output fie...
olb::Vector< T, 3 > const & getAxisDirection() const
Read only access to _axisDirection.
olb::Vector< T, 3 > _cartesianOrigin
origin of the Cartesian coordinate system
olb::Vector< T, 3 > const & getCartesianOrigin() const
Read only access to _catesianOrigin.
bool operator()(T output[], const S x[]) override
operator writes cylindrical coordinates of Cartesian point x into output field, output[0] = radius ( ...
CartesianToCylinder3D(olb::Vector< T, 3 > cartesianOrigin, T &angle, olb::Vector< T, 3 > orientation={T(1), T(), T()})
olb::Vector< T, 3 > _axisDirection
direction of the axis along which the cylindrical coordinates are calculated
void setAngle(T angle)
Read and write access to _axisDirection using angle.
olb::Vector< T, 3 > _orientation
direction to know orientation for math positive to obtain angle phi of Cartesian point x
This class converts Cartesian coordinates of point x to spherical coordinates wrote into output field...
std::vector< T > _axisDirection
direction of the axis along which the spherical coordinates are calculated
bool operator()(T output[], const S x[]) override
operator writes shperical coordinates of Cartesian point x into output field, output[0] = radius ( >=...
CartesianToSpherical3D(std::vector< T > cartesianOrigin, std::vector< T > axisDirection)
std::vector< T > _cartesianOrigin
origin of the Cartesian coordinate system
Velocity profile for util::round pipes and a laminar flow of a Newtonian fluid: u(r)=u_max*(1-(r/R)^2...
CirclePoiseuille3D(std::vector< T > axisPoint, std::vector< T > axisDirection, T maxVelocity, T radius, T scale=T(1))
Strain rate for util::round pipes and laminar flow of a Newtonian fluid.
bool operator()(T output[], const T input[]) override
CirclePoiseuilleStrainRate3D(UnitConverter< T, DESCRIPTOR > const &converter, T ly)
This functor returns a quadratic Poiseuille profile for use with a pipe with util::round cross-sectio...
std::vector< T > _normal
bool operator()(T output[], const T x[]) override
olb::Vector< T, 3 > getCenter()
Returns centerpoint vector.
olb::Vector< T, 3 > _center
std::vector< T > getNormal()
Returns normal vector.
T getRadius()
Returns radi.
CirclePowerLaw3D(olb::Vector< T, 3 > axisPoint, std::vector< T > axisDirection, T maxVelocity, T radius, T n, T scale=T(1))
Velocity profile for util::round pipes and turbulent flows: u(r)=u_max*(1-r/R)^(1/n) The exponent n c...
CirclePowerLawTurbulent3D(std::vector< T > axisPoint_, std::vector< T > axisDirection, T maxVelocity, T radius, T n=7, T turbulenceIntensity=0.05, T scale=T(1))
bool operator()(T output[], const T x[]) override
This class converts cylindrical of point x (x[0] = radius, x[1] = phi, x[2] = z) to Cartesian coordin...
bool operator()(T output[], const S x[]) override
operator writes Cartesian coordinates of cylinder coordinates x[0] = radius >= 0, x[1] = phi in [0,...
std::vector< T > _cylinderOrigin
CylinderToCartesian3D(std::vector< T > cylinderOrigin)
constructor defines _cylinderOrigin
This functor returns a quadratic Poiseuille profile for use with a pipe with elliptic cross-section.
EllipticPoiseuille3D(std::vector< T > center, T a, T b, T maxVel)
bool operator()(T output[], const T x[]) override
T _factor
factor = mu0*4/3.*PI*radParticle^3*_Mp*radWire^2/r^3
T _cutoff
maximal distance from wire cutoff/threshold
CartesianToCylinder3D< T, S > & _car2cyl
MagneticFieldFromCylinder3D(CartesianToCylinder3D< T, S > &car2cyl, T length, T radWire, T cutoff, T Mw)
T _length
length of the wire, from origin to _car2cyl.axisDirection
bool operator()(T output[], const S x[]) override
operator writes the magnetic force in a point x util::round a cylindrical wire into output field
T _Mw
saturation magnetization wire, linear scaling factor
Magnetic field that creates magnetization in wire has to be orthogonal to the wire.
T _factor
factor = mu0*4/3.*PI*radParticle^3*_Mp*radWire^2/r^3
CartesianToCylinder3D< T, S > & _car2cyl
T _radParticle
particle radius, cubic scaling factor
T _Mw
saturation magnetization wire, linear scaling factor
T _cutoff
maximal distance from wire cutoff/threshold
MagneticForceFromCylinder3D(CartesianToCylinder3D< T, S > &car2cyl, T length, T radWire, T cutoff, T Mw, T Mp=T(1), T radParticle=T(1), T mu0=4 *3.14159265e-7)
Magnetic field that creates magnetization in wire has to be orthogonal to the wire.
bool operator()(T output[], const S x[]) override
operator writes the magnetic force in a point x util::round a cylindrical wire into output field
T _length
length of the wire, from origin to _car2cyl.axisDirection
T _Mp
magnetization particle, linear scaling factor
T _mu0
permeability constant, linear scaling factor
class for marking output with some text
This functor returns a Poiseuille profile for use with a pipe with square shaped cross-section.
RectanglePoiseuille3D(olb::Vector< T, 3 > &x0_, olb::Vector< T, 3 > &x1_, olb::Vector< T, 3 > &x2_, std::vector< T > &maxVelocity_)
bool operator()(T output[], const T x[]) override
RectangleTrigonometricPoiseuille3D(std::vector< T > &x0_, std::vector< T > &x1_, std::vector< T > &x2_, std::vector< T > &maxVelocity, int numOfPolynoms_=1)
bool operator()(T output[], const T x[]) override
This functor gives a linar profile for a given point x as it computes the distance between x and the ...
std::vector< T > axisPoint
RotatingLinear3D(std::vector< T > axisPoint_, std::vector< T > axisDirection_, T w_, T scale_=1)
std::vector< T > axisDirection
bool operator()(T output[], const T x[]) override
This functor gives a linar profile in an annulus for a given point x between the inner and outer radi...
RotatingLinearAnnulus3D(std::vector< T > axisPoint_, std::vector< T > axisDirection_, T w_, T ri_, T ro_, T scale_=1)
bool operator()(T output[], const T x[])
This functor gives a parabolic profile for a given point x as it computes the distance between x and ...
RotatingQuadratic1D(std::vector< T > axisPoint_, std::vector< T > axisDirection_, T w_, T scale_=1, T additive_=0)
std::vector< T > axisPoint
std::vector< T > axisDirection
bool operator()(T output[], const T x[]) override
This class saves coordinates of the resulting point after rotation in the output field.
olb::Vector< T, 3 > _rotAxisDirection
direction, around which x is turned
T _alpha
angle, by which vector x is rotated around _rotAxisDirection
olb::Vector< T, 3 > _origin
origin, around which x is turned
RotationRoundAxis3D(olb::Vector< T, 3 > origin, olb::Vector< T, 3 > rotAxisDirection, T alpha)
constructor defines _rotAxisDirection, _alpha and _origin
bool operator()(T output[], const S x[]) override
operator writes coordinates of the resulting point after rotation of x by angle _alpha in math positi...
This class converts spherical coordinates of point x (x[0] = radius, x[1] = phi, x[2] = theta) to Car...
bool operator()(T output[], const S x[]) override
operator writes spherical coordinates of Cartesian coordinates of x (x[0] = radius,...
Representation of a statistic for a parallel 2D geometry.
Conversion between physical and lattice units, as well as discretization.
Plain old scalar vector.
Definition vector.h:47
Top level namespace for all of OpenLB.