OpenLB 1.7
Loading...
Searching...
No Matches
smoothIndicatorF2D.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2016 Thomas Henn, Cyril Masquelier, Jan Marquardt, Mathias J. Krause
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_2D_H
25#define SMOOTH_INDICATOR_F_2D_H
26
27#include <vector>
28
30#include "io/xmlReader.h"
32
33#include "core/blockData.h"
34#include "core/unitConverter.h"
39
40namespace olb {
41
42
44
51template <typename T, typename S, bool PARTICLE=false>
52class SmoothIndicatorCuboid2D final : public SmoothIndicatorF2D<T,S,PARTICLE> {
53private:
55public:
56 SmoothIndicatorCuboid2D(IndicatorCuboid2D<S>& ind, S epsilon, S theta=0);
57 SmoothIndicatorCuboid2D(Vector<S,2>center, S xLength, S yLength, S epsilon, S theta=0);
59 Vector<S,2> surfaceNormal(const Vector<S,2>& pos, const S meshSize) override;
60 const S signedDistance( const Vector<S,2> input ) override;
61 bool distance(S& distance, const Vector<S,2>& origin, const Vector<S,2>& direction, S precision, S pitch) override;
62 S getArea( ) override;
63 Vector<S,2> calcMofiAndMass(const S density) override;
64};
65
67template <typename T, typename S, bool PARTICLE=false>
68class SmoothIndicatorCircle2D final : public SmoothIndicatorF2D<T,S,PARTICLE> {
69private:
71public:
73 SmoothIndicatorCircle2D(Vector<S,2>center, S radius, S epsilon);
75 Vector<S,2> surfaceNormal(const Vector<S,2>& pos, const S meshSize) override;
76 const S signedDistance( const Vector<S,2> input ) override;
77 bool distance(S& distance, const Vector<S,2>& origin, const Vector<S,2>& direction, S precision, S pitch) override;
78 S getArea( ) override;
79 Vector<S,2> calcMofiAndMass(const S density) override;
80};
81
83template <typename T, typename S, bool PARTICLE=false>
84class SmoothIndicatorTriangle2D final : public SmoothIndicatorF2D<T,S,PARTICLE> {
85private:
87public:
88 SmoothIndicatorTriangle2D(IndicatorEquiTriangle2D<S>& indPtr, S epsilon, S theta=0);
89 SmoothIndicatorTriangle2D(Vector<S,2>center, S radius, S epsilon, S theta=0);
91 Vector<S,2> surfaceNormal(const Vector<S,2>& pos, const S meshSize) override;
92 const S signedDistance( const Vector<S,2> input ) override;
93 bool distance(S& distance, const Vector<S,2>& origin, const Vector<S,2>& direction, S precision, S pitch) override;
94 S getArea( ) override;
95 Vector<S,2> calcMofiAndMass(const S density) override;
96};
97
98/*
100template <typename T, typename S, bool PARTICLE=false>
101class SmoothIndicatorTriangle2D final : public SmoothIndicatorF2D<T,S,PARTICLE> {
102private:
104 Vector<S, 2> _PointA, _PointB, _PointC;
106 Vector<S, 2> _ab, _bc, _ca;
108 S _ab_d, _bc_d, _ca_d;
109public:
110 SmoothIndicatorTriangle2D(Vector<S,2> center, S radius, S epsilon, S theta=0, S density=0, Vector<S,2> vel = Vector<S,2> (0.,0.), S omega = 0);
111 bool operator() (T output[], const S input[]) override;
112};
113*/
114
115template <typename T, typename W>
117template <typename T, typename BaseType>
118class BlockDataF2D;
119
120//implements a custom shaped smooth particle //TODO: Check for consistency
121//ALSO: adap .hh
122template <typename T, typename S, bool PARTICLE=false>
123class SmoothIndicatorCustom2D : public SmoothIndicatorF2D<T, S, PARTICLE> {
124private:
125 std::shared_ptr<IndicatorF2D<T>> _indPtr;
127 const T _latticeSpacing;
128 // _center is the local center
129 Vector<T,2> _center;
131 std::unique_ptr<Cuboid2D<T>> _cuboid;
133 std::unique_ptr<BlockData<2,T,BaseType<T>>> _blockData;
135 std::unique_ptr<BlockDataF2D<T,BaseType<T>>> _cacheFunctor;
137 std::unique_ptr<AnalyticalFfromBlockF2D<T,T>> _interpolateCache;
139 T _area;
140
141 void initData(IndicatorF2D<T>& ind);
142 void initBlockData(IndicatorF2D<T>& ind);
143 void calcCenter();
144 void calcCircumRadius();
145
146public:
147 SmoothIndicatorCustom2D(T latticeSpacing,
148 std::shared_ptr<IndicatorF2D<T>> indPtr, Vector<T,2> pos, T epsilon,
149 T theta=0.);
150
152 S getArea( ) override;
153 Vector<T,2> calcMofiAndMass(T rhoP) override;
154 Vector<S,2> surfaceNormal(const Vector<S,2>& pos, const S meshSize) override;
155 const S signedDistance( const Vector<S,2> input ) override;
156 bool regardCell(int input[2]);
157 bool operator()(T output[], const S input[]) override;
158};
159
160//Geng2019:
162template <typename T, typename S, bool PARTICLE=false>
163class SmoothIndicatorHTCircle2D final : public SmoothIndicatorF2D<T,S,PARTICLE> {
164private:
165 S _radius;
166public:
167 SmoothIndicatorHTCircle2D(Vector<S,2> center, S radius, S epsilon, S density=0, Vector<S,2> vel = Vector<S,2> (0.,0.), S omega = 0);
168 bool operator() (T output[], const S input[]) override;
169 Vector<S,2> calcMofiAndMass(const S density) override;
170};
171
173template <typename T, typename S, bool PARTICLE=false>
174class SmoothIndicatorFactoredCircle2D final : public SmoothIndicatorF2D<T,S,PARTICLE> {
175private:
176 S _radius;
177 S _factor;
178public:
179 SmoothIndicatorFactoredCircle2D(Vector<S,2> center, S radius, S epsilon, S density=0, Vector<S,2> vel = Vector<S,2> (0.,0.), S omega = 0, S factor = 1.);
180 bool operator() (T output[], const S input[]) override;
181 Vector<S,2> calcMofiAndMass(const S density) override;
182};
183
185template <typename T, typename S, bool PARTICLE=false>
186class SmoothIndicatorFactoredCuboid2D final : public SmoothIndicatorF2D<T,S,PARTICLE> {
187private:
188 S _xLength;
189 S _yLength;
190 S _factor;
191public:
192 SmoothIndicatorFactoredCuboid2D(Vector<S,2> center, S xLength, S yLength, S epsilon, S density=0, Vector<S,2> vel = Vector<S,2> (0.,0.), S omega = 0, S factor = 1.);
193 bool operator() (T output[], const S input[]) override;
194 Vector<S,2> calcMofiAndMass(const S density) override;
195};
196
197}
198
199#endif
200
Converts block functors to analytical functors.
BlockDataF2D can store data of any BlockFunctor2D.
indicator function for a 2D circle
indicator function for a 2D-cuboid, parallel to the planes x=0, y=0; theta rotates cuboid around its ...
indicator function for a 2D equilateral triangle
IndicatorF2D is an application from .
implements a smooth circle in 2D with an _epsilon sector
Vector< S, 2 > surfaceNormal(const Vector< S, 2 > &pos, const S meshSize) override
IndicatorCircle2D< S > & getIndicator()
Vector< S, 2 > calcMofiAndMass(const S density) override
SmoothIndicatorCircle2D(IndicatorCircle2D< S > &indPtr, S epsilon)
const S signedDistance(const Vector< S, 2 > input) override
bool distance(S &distance, const Vector< S, 2 > &origin, const Vector< S, 2 > &direction, S precision, S pitch) override
implements a smooth cuboid in 2D with an _epsilon sector.
bool distance(S &distance, const Vector< S, 2 > &origin, const Vector< S, 2 > &direction, S precision, S pitch) override
IndicatorCuboid2D< S > & getIndicator()
Vector< S, 2 > surfaceNormal(const Vector< S, 2 > &pos, const S meshSize) override
const S signedDistance(const Vector< S, 2 > input) override
Vector< S, 2 > calcMofiAndMass(const S density) override
SmoothIndicatorCuboid2D(IndicatorCuboid2D< S > &ind, S epsilon, S theta=0)
Vector< S, 2 > surfaceNormal(const Vector< S, 2 > &pos, const S meshSize) override
bool operator()(T output[], const S input[]) override
SmoothIndicatorCustom2D(T latticeSpacing, std::shared_ptr< IndicatorF2D< T > > indPtr, Vector< T, 2 > pos, T epsilon, T theta=0.)
const S signedDistance(const Vector< S, 2 > input) override
Vector< T, 2 > calcMofiAndMass(T rhoP) override
calculates and returns mofi and mass of the particle (mofi is at index 0 and mass at index 1)
factorizable output smooth circle in 2D with a tangiant or ramp epsilon sector
Vector< S, 2 > calcMofiAndMass(const S density) override
SmoothIndicatorFactoredCircle2D(Vector< S, 2 > center, S radius, S epsilon, S density=0, Vector< S, 2 > vel=Vector< S, 2 >(0., 0.), S omega=0, S factor=1.)
bool operator()(T output[], const S input[]) override
factorizable output smooth cuboid in 2D with a tangiant or ramp epsilon sector
Vector< S, 2 > calcMofiAndMass(const S density) override
SmoothIndicatorFactoredCuboid2D(Vector< S, 2 > center, S xLength, S yLength, S epsilon, S density=0, Vector< S, 2 > vel=Vector< S, 2 >(0., 0.), S omega=0, S factor=1.)
bool operator()(T output[], const S input[]) override
implements a smooth circle in 2D with an tangiant _epsilon sector
Vector< S, 2 > calcMofiAndMass(const S density) override
SmoothIndicatorHTCircle2D(Vector< S, 2 > center, S radius, S epsilon, S density=0, Vector< S, 2 > vel=Vector< S, 2 >(0., 0.), S omega=0)
bool operator()(T output[], const S input[]) override
implements a smooth triangle in 2D with an _epsilon sector
Vector< S, 2 > surfaceNormal(const Vector< S, 2 > &pos, const S meshSize) override
IndicatorEquiTriangle2D< S > & getIndicator()
SmoothIndicatorTriangle2D(IndicatorEquiTriangle2D< S > &indPtr, S epsilon, S theta=0)
Vector< S, 2 > calcMofiAndMass(const S density) override
bool distance(S &distance, const Vector< S, 2 > &origin, const Vector< S, 2 > &direction, S precision, S pitch) override
const S signedDistance(const Vector< S, 2 > input) 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.