OpenLB 1.7
Loading...
Searching...
No Matches
smoothIndicatorF3D.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2014-2016 Cyril Masquelier, Mathias J. Krause, Albert Mink
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef SMOOTH_INDICATOR_F_3D_H
25#define SMOOTH_INDICATOR_F_3D_H
26
27#include <vector>
28
30#include "io/xmlReader.h"
32
33#include "core/blockData.h"
34#include "core/unitConverter.h"
38
39namespace olb {
40
42template <typename T, typename S, bool PARTICLE=false>
43class SmoothIndicatorCuboid3D final: public SmoothIndicatorF3D<T, S, PARTICLE> {
44private:
46
47public:
48 SmoothIndicatorCuboid3D(IndicatorCuboid3D<S>& ind, S epsilon, Vector<S,3> theta = Vector<S,3> (0.,0.,0.));
49 SmoothIndicatorCuboid3D(S xLength, S yLength, S zLength, Vector<S,3> center, S epsilon, Vector<S,3> theta = Vector<S,3> (0.,0.,0.));
51 Vector<S,3> surfaceNormal(const Vector<S,3>& pos, const S meshSize) override;
52 const S signedDistance( const PhysR<S,3> input ) override;
53 S getVolume( ) override;
54 Vector<S,4> calcMofiAndMass(const S density) override;
55};
56
58template <typename T, typename S, bool PARTICLE=false>
59class SmoothIndicatorEllipsoid3D final: public SmoothIndicatorF3D<T, S, PARTICLE> {
60private:
62
63public:
65 SmoothIndicatorEllipsoid3D(Vector<S,3> center, Vector<S,3> radius, S epsilon, Vector<S,3> theta = Vector<S,3> (0.,0.,0.));
67 Vector<S,3> surfaceNormal(const Vector<S,3>& pos, const S meshSize) override;
68 const S signedDistance( const PhysR<S,3> input ) override;
69 S getVolume( ) override;
70 Vector<S,4> calcMofiAndMass(const S density) override;
71 bool operator()(T output[],const S input[]) override;
72};
73
75template <typename T, typename S, bool PARTICLE=false>
76class SmoothIndicatorSuperEllipsoid3D final: public SmoothIndicatorF3D<T, S, PARTICLE> {
77private:
79public:
81 SmoothIndicatorSuperEllipsoid3D(Vector<S,3> center, S xHalfAxis, S yHalfAxis, S zHalfAxis, S exponent1, S exponent2,
82 S epsilon, Vector<S,3> theta = Vector<S,3> (0.,0.,0.));
84 // this implements the beta function from the gamma function and will be deprecated when switching to c++17
85 S beta(S arg1, S arg2);
86 // calculates cartesian moments
87 S moments(S p, S q, S r);
88 Vector<S,3> surfaceNormal(const Vector<S,3>& pos, const S meshSize) override;
89 const S signedDistance( const PhysR<S,3> input ) override;
90 S getVolume( ) override;
91 Vector<S,4> calcMofiAndMass(const S density) override;
92 bool operator()(T output[],const S input[]) override;
93};
94
96template <typename T, typename S, bool PARTICLE=false>
97class SmoothIndicatorSphere3D final: public SmoothIndicatorF3D<T, S, PARTICLE> {
98private:
100public:
102 SmoothIndicatorSphere3D(Vector<S,3> center, S radius, S epsilon);
104 Vector<S,3> surfaceNormal(const Vector<S,3>& pos, const S meshSize) override;
105 const S signedDistance( const PhysR<S,3> input ) override;
106 S getVolume( ) override;
107 Vector<S,4> calcMofiAndMass(const S density) override;
108};
109
111template <typename T, typename S, bool PARTICLE=false>
112class SmoothIndicatorCylinder3D final: public SmoothIndicatorF3D<T, S, PARTICLE> {
113private:
115 void initIndicatorCylinder3D(Vector<S,3> theta, S length);
116
117public:
118 SmoothIndicatorCylinder3D(IndicatorCylinder3D<S>& ind, S epsilon, Vector<S,3> theta = Vector<S,3> (0.,0.,0.));
119 SmoothIndicatorCylinder3D(Vector<S,3> center1, Vector<S,3> center2, S radius, S epsilon, Vector<S,3> theta = Vector<S,3> (0.,0.,0.));
120 SmoothIndicatorCylinder3D(Vector<S,3> center, Vector<S,3> normal, S radius, S height, S epsilon, Vector<S,3> theta = Vector<S,3> (0.,0.,0.));
122 Vector<S,3> surfaceNormal(const Vector<S,3>& pos, const S meshSize) override;
123 const S signedDistance( const PhysR<S,3> input ) override;
124 S getVolume( ) override;
125 Vector<S,4> calcMofiAndMass(const S density) override;
126};
127
129template <typename T, typename S, bool PARTICLE=false>
130class SmoothIndicatorCone3D : public SmoothIndicatorF3D<T, S, PARTICLE> {
131private:
132 Vector<S,3> _startPos;
133 void initIndicatorCone3D(Vector<S,3> theta, S length);
135public:
136 SmoothIndicatorCone3D(IndicatorCone3D<S>& indPtr, S epsilon, Vector<S,3> theta = Vector<S,3> (0.,0.,0.));
137 SmoothIndicatorCone3D(Vector<S,3> center1, Vector<S,3> center2, S radius1, S radius2, S epsilon, Vector<S,3> theta = Vector<S,3> (0.,0.,0.));
139 Vector<S,3> surfaceNormal(const Vector<S,3>& pos, const S meshSize) override;
140 const S signedDistance( const PhysR<S,3> input ) override;
141 S getVolume( ) override;
142 Vector<S,4> calcMofiAndMass(const S density) override;
143 Vector<S,3> calcCenterOfMass() override;
144};
145
146
147template <typename T, typename W>
149template <typename T, typename BaseType>
150class BlockDataF3D;
151
152//implements a custom shaped smooth particle //TODO: Check for consistency
153//ALSO: adap .hh
154template <typename T, typename S, bool PARTICLE=false>
155class SmoothIndicatorCustom3D final: public SmoothIndicatorF3D<T, S, PARTICLE> {
156private:
157 std::shared_ptr<IndicatorF3D<T>> _indPtr;
159 const T _latticeSpacing;
161 PhysR<T,3> _center;
163 Cuboid3D<T> _cuboid;
165 std::unique_ptr<BlockData<3,T,BaseType<T>>> _blockData;
167 std::unique_ptr<BlockDataF3D<T,BaseType<T>>> _cacheFunctor;
169 std::unique_ptr<AnalyticalFfromBlockF3D<T,T>> _interpolateCache;
171 T _volume;
172
173 void initBlockData(IndicatorF3D<T>& ind);
174 void calcCenter();
175 void calcCircumRadius();
176
177public:
178 // TODO: Add specialized constructors (for PARTICLE = true and PARTICLE = false)
179 SmoothIndicatorCustom3D(T latticeSpacing,
180 std::shared_ptr<IndicatorF3D<T>> indPtr, Vector<T,3> pos, T epsilon,
181 Vector<T,3> theta=Vector<T,3>(0.));
182
184 S getVolume( ) override;
185 Vector<T,4> calcMofiAndMass(T rhoP) override;
186 Vector<S,3> surfaceNormal(const Vector<S,3>& pos, const S meshSize) override;
187 Vector<S,3> surfaceNormal(const Vector<S,3>& pos, const S meshSize,
188 std::function<Vector<S,3>(const Vector<S,3>&)> transformPos) override;
189 const S signedDistance( const PhysR<S,3> input ) override;
190 bool regardCell(int input[3]);
191 bool operator()(T output[], const S input[]) override;
192};
193
195template <typename T, typename S, bool PARTICLE=false>
196class SmoothIndicatorFactoredCircle3D final : public SmoothIndicatorF3D<T,S,PARTICLE> {
197private:
198 S _radius;
199 S _factor;
200public:
201 SmoothIndicatorFactoredCircle3D(Vector<S,3> center, S radius, S epsilon, S density=0, Vector<S,3> vel = Vector<S,3> (0.,0.,0.), S omega = 0, S factor = 1.);
202 bool operator() (T output[], const S input[]) override;
203 Vector<S,4> calcMofiAndMass(const S density) override;
204};
205
206
207}
208
209#endif
210
Converts block functors to analytical functors.
BlockDataF3D can store data of any BlockFunctor3D.
A regular single 3D cuboid is the basic component of a 3D cuboid structure which defines the grid.
Definition cuboid3D.h:58
indicator function for a 3d frustum
indicator function for a 3d-cuboid, parallel to the planes x=0, y=0, z=0.
indicator function for a 3d-cylinder
indicator function for an ellipsoid
IndicatorF3D is an application from .
indicator function for a 3D-sphere
indicator function for a super ellipsoid
implements a smooth particle cone in 3D with an _epsilon sector
const S signedDistance(const PhysR< S, 3 > input) override
SmoothIndicatorCone3D(IndicatorCone3D< S > &indPtr, S epsilon, Vector< S, 3 > theta=Vector< S, 3 >(0., 0., 0.))
IndicatorCone3D< S > & getIndicator()
Vector< S, 4 > calcMofiAndMass(const S density) override
Vector< S, 3 > surfaceNormal(const Vector< S, 3 > &pos, const S meshSize) override
Vector< S, 3 > calcCenterOfMass() override
implements a smooth particle cuboid in 3D with an _epsilon sector.
Vector< S, 4 > calcMofiAndMass(const S density) override
SmoothIndicatorCuboid3D(IndicatorCuboid3D< S > &ind, S epsilon, Vector< S, 3 > theta=Vector< S, 3 >(0., 0., 0.))
const S signedDistance(const PhysR< S, 3 > input) override
IndicatorCuboid3D< S > & getIndicator()
Vector< S, 3 > surfaceNormal(const Vector< S, 3 > &pos, const S meshSize) override
Vector< S, 3 > surfaceNormal(const Vector< S, 3 > &pos, const S meshSize) override
SmoothIndicatorCustom3D(T latticeSpacing, std::shared_ptr< IndicatorF3D< T > > indPtr, Vector< T, 3 > pos, T epsilon, Vector< T, 3 > theta=Vector< T, 3 >(0.))
const S signedDistance(const PhysR< S, 3 > input) override
bool operator()(T output[], const S input[]) override
Vector< T, 4 > calcMofiAndMass(T rhoP) override
implements a smooth particle cylinder in 3D with an _epsilon sector.
const S signedDistance(const PhysR< S, 3 > input) override
SmoothIndicatorCylinder3D(IndicatorCylinder3D< S > &ind, S epsilon, Vector< S, 3 > theta=Vector< S, 3 >(0., 0., 0.))
Vector< S, 3 > surfaceNormal(const Vector< S, 3 > &pos, const S meshSize) override
Vector< S, 4 > calcMofiAndMass(const S density) override
IndicatorCylinder3D< S > & getIndicator()
implements a smooth particle ellipsoid in 3D with an _epsilon sector.
Vector< S, 4 > calcMofiAndMass(const S density) override
const S signedDistance(const PhysR< S, 3 > input) override
IndicatorEllipsoid3D< S > & getIndicator()
Vector< S, 3 > surfaceNormal(const Vector< S, 3 > &pos, const S meshSize) override
bool operator()(T output[], const S input[]) override
SmoothIndicatorEllipsoid3D(IndicatorEllipsoid3D< S > &ind, S epsilon, Vector< S, 3 > theta=Vector< S, 3 >(0., 0., 0.))
factorizable output smooth sphere in 3D with a tangiant or ramp epsilon sector
SmoothIndicatorFactoredCircle3D(Vector< S, 3 > center, S radius, S epsilon, S density=0, Vector< S, 3 > vel=Vector< S, 3 >(0., 0., 0.), S omega=0, S factor=1.)
bool operator()(T output[], const S input[]) override
Vector< S, 4 > calcMofiAndMass(const S density) override
implements a smooth sphere in 3D with an _epsilon sector
SmoothIndicatorSphere3D(IndicatorSphere3D< S > &ind, S epsilon)
const S signedDistance(const PhysR< S, 3 > input) override
IndicatorSphere3D< S > & getIndicator()
Vector< S, 4 > calcMofiAndMass(const S density) override
Vector< S, 3 > surfaceNormal(const Vector< S, 3 > &pos, const S meshSize) override
implements a smooth particle super-ellipsoid in 3D. The epsilon sector is currently missing.
SmoothIndicatorSuperEllipsoid3D(IndicatorSuperEllipsoid3D< S > &ind, S epsilon, Vector< S, 3 > theta=Vector< S, 3 >(0., 0., 0.))
const S signedDistance(const PhysR< S, 3 > input) override
IndicatorSuperEllipsoid3D< S > & getIndicator()
Vector< S, 3 > surfaceNormal(const Vector< S, 3 > &pos, const S meshSize) override
bool operator()(T output[], const S input[]) override
Vector< S, 4 > calcMofiAndMass(const S density) override
Plain old scalar vector.
Definition vector.h:47
This file contains indicator functions.
Top level namespace for all of OpenLB.
Unit conversion handling – header file.
Input/Output in XML format – header file.