OpenLB 1.7
Loading...
Searching...
No Matches
indicatorF3D.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, Berkay Oralalp
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 INDICATOR_F_3D_H
25#define INDICATOR_F_3D_H
26
27#include "indicatorBaseF3D.h"
28#include "io/xmlReader.h"
30
31
53namespace olb {
54
55template<typename S> class IndicatorIdentity3D;
56template<typename S> class IndicatorCylinder3D;
57
58template <typename S>
60private:
61 std::array<S,3> _translate;
62 IndicatorF3D<S>& _indicator;
63 Vector<S,3> _myMin;
64 Vector<S,3> _myMax;
65public:
66 IndicatorTranslate3D(std::array<S,3> translate, IndicatorF3D<S>& indicator);
67 bool operator() (bool output[], const S input[]) override;
68 S signedDistance(const Vector<S,3>& input) override;
69 Vector<S,3>& getMin() override;
70 Vector<S,3>& getMax() override;
71};
72
73
75// circle is realized as a cylinder with a very small height
76template <typename S>
78private:
79 Vector<S,3> _center;
80 Vector<S,3> _normal;
81 S _radius2;
82 IndicatorCylinder3D<S> _cylinder;
83public:
85 IndicatorCircle3D(S center0, S center1, S center2, S normal0, S normal1,
86 S normal2, S radius);
87 bool operator() (bool output[], const S input[]) override;
88 Vector<S,3> const& getCenter() const;
89 Vector<S,3> const& getNormal() const;
90 S getRadius() const;
91 //virtual bool distance(S& distance, Vector<S,3> origin, Vector<S,3> direction, int iC=-1);
92};
93
94
95
97template <typename S>
99private:
100 Vector<S,3> _center;
101 S _radius;
102 S _radius2;
103public:
104 IndicatorSphere3D(Vector<S,3> center, S radius);
106 Vector<S,3> const& getCenter() const;
107 S const getRadius() const;
108 S signedDistance(const Vector<S,3>& input) override;
109 bool distance(S& distance, const Vector<S,3>& origin,
110 const Vector<S,3>& direction, int iC=-1) override;
111 using IndicatorF3D<S>::distance;
112};
113
115template <typename S>
117private:
118 FunctorPtr<IndicatorF3D<S>> _indicatorF;
119 S _layerSize;
120public:
121 IndicatorLayer3D(FunctorPtr<IndicatorF3D<S>>&& indicatorF, S layerSize);
122 bool operator() (bool output[], const S input[]) override;
123 S signedDistance(const Vector<S,3>& input) override;
124};
125
127template <typename S>
129private:
130 IndicatorF3D<S>& _indicatorF;
131 S _layerSize;
132public:
133 IndicatorInternal3D(IndicatorF3D<S>& indicatorF, S layerSize);
134 bool operator() (bool output[], const S input[]) override;
135};
136
138template <typename S>
140private:
141 Vector<S,3> _center1;
142 Vector<S,3> _center2;
143 Vector<S,3> _ba;
144 Vector<S,3> _I;
145 Vector<S,3> _J;
146 Vector<S,3> _K;
147 S _baba;
148 S _radius2;
149 S _length;
150
151 void init();
152public:
153 IndicatorCylinder3D(Vector<S,3> center1, Vector<S,3> center2, S radius);
154 // eps is length of cylinder
155 IndicatorCylinder3D(Vector<S,3> center1, Vector<S,3> normal, S radius, S eps);
156 IndicatorCylinder3D(IndicatorCircle3D<S> const& circleF, S eps);
157 bool operator() (bool output[], const S input[]) override;
158 Vector<S,3> const& getCenter1() const;
159 Vector<S,3> const& getCenter2() const;
160 S getRadius() const;
161 S signedDistance(const Vector<S,3>& input) override;
162 // Returns random position in indicator domain
166 Vector<S,3> getSample(const std::function<S()>& randomness) const override;
167};
168
170template <typename S>
171class IndicatorCone3D : public IndicatorF3D<S> {
172private:
173 Vector<S,3> _center1;
174 Vector<S,3> _center2;
175 Vector<S,3> _ba;
176 Vector<S,3> _I;
177 Vector<S,3> _J;
178 Vector<S,3> _K;
179 S _baba;
180 S _radius1;
181 S _radius2; // The 2nd radius is optional: if not defined, _center2 is the vertex of the cone
182 S _length;
183
184public:
185 IndicatorCone3D(Vector<S,3> center1, Vector<S,3> center2, S radius1, S radius2=0);
186 Vector<S,3> const& getCenter1() const;
187 Vector<S,3> const& getCenter2() const;
188 S getRadius1() const;
189 S getRadius2() const;
190 bool operator() (bool output[], const S input[]) override;
191 S signedDistance(const Vector<S,3>& input) override;
192};
193
195template <typename S>
197private:
198 Vector<S,3> _center;
199 Vector<S,3> _radius;
200
201public:
203 Vector<S,3> const& getCenter() const;
204 Vector<S,3> const& getRadius() const;
205 S signedDistance(const Vector<S,3>& input) override;
206};
207
208
210template <typename S>
212private:
213 Vector<S,3> _center;
214 S _xHalfAxis;
215 S _yHalfAxis;
216 S _zHalfAxis;
217 S _exp1;
218 S _exp2;
219
220public:
221 IndicatorSuperEllipsoid3D(Vector<S,3> center, S xHalfAxis, S yHalfAxis, S zHalfAxis, S exponent1, S exponent2);
222 Vector<S,3> const& getCenter() const;
223 S getXHalfAxis() const;
224 S getYHalfAxis() const;
225 S getZHalfAxis() const;
226 S getExponent1() const;
227 S getExponent2() const;
228 bool operator() (bool output[], const S input[]) override;
229};
230
231
232
237template <typename S>
239private:
240 Vector<S,3> _center;
241 S _xLength;
242 S _yLength;
243 S _zLength;
244
246 Vector<S,3> distanceXYZ(const Vector<S,3> input);
247
248public:
252 IndicatorCuboid3D(S xlength, S ylength, S zlength, Vector<S,3> center);
253 Vector<S,3> const& getCenter() const;
254 S const getxLength() const;
255 S const getyLength() const;
256 S const getzLength() const;
258 bool operator() (bool output[], const S input[]) override;
260 S signedDistance(const Vector<S,3>& input) override;
261 Vector<S,3> getSample(const std::function<S()>& randomness) const override;
262};
263
264
273template <typename S>
275private:
276 S _theta;
277 int _plane;
278 Vector<S,3> _centerRotation;
279 void transformInput(const S input[3], S newInput[3]);
280public:
281 // constructs an cuboid turned by some angle theta around a given center of rotation
282 IndicatorCuboidRotate3D(Vector<S,3> extend, Vector<S,3> origin, S theta, int plane, Vector<S,3> centerRotation);
283 IndicatorCuboidRotate3D(S xlength, S ylength, S zlength, Vector<S,3> origin, S theta, int plane, Vector<S,3> centerRotation);
284 bool operator() (bool output[], const S input[]);
286 S signedDistance(const Vector<S,3>& input) override;
287};
288
289template <typename T>
290class IndicatorSDF3D : public IndicatorF3D<T> {
291private:
292 std::function<T(Vector<T, 3>)> _f;
293
294public:
295 IndicatorSDF3D(std::function<T(Vector<T, 3>)> f);
296
297 bool operator()(bool output[], const T input[]) override;
298};
299
300
302// creator function for geometric primitives
303template <typename S>
304std::shared_ptr<IndicatorF3D<S>> createIndicatorCircle3D(XMLreader const& params, bool verbose=false);
305
306template <typename S>
307std::shared_ptr<IndicatorF3D<S>> createIndicatorSphere3D(XMLreader const& params, bool verbose=false);
308
309template <typename S>
310std::shared_ptr<IndicatorF3D<S>> createIndicatorCylinder3D(XMLreader const& params, bool verbose=false);
311
312template <typename S>
313std::shared_ptr<IndicatorF3D<S>> createIndicatorCone3D(XMLreader const& params, bool verbose=false);
314
315template <typename S>
316std::shared_ptr<IndicatorF3D<S>> createIndicatorCuboid3D(XMLreader const& params, bool verbose=false);
317
318// arithmetic creator functions
319template <typename S>
320std::shared_ptr<IndicatorF3D<S>> createIndicatorUnion3D(XMLreader const& params, bool verbose=false);
321
322template <typename S>
323std::shared_ptr<IndicatorF3D<S>> createIndicatorWithout3D(XMLreader const& params, bool verbose=false);
324
325template <typename S>
326std::shared_ptr<IndicatorF3D<S>> createIndicatorIntersection3D(XMLreader const&params, bool verbose=false);
327
328// godfather
329template <typename S>
330std::shared_ptr<IndicatorF3D<S>> createIndicatorF3D(XMLreader const& params, bool verbose=false);
331
332
333
334}
335
336#endif
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
indicator function for a 3D circle
Vector< S, 3 > const & getCenter() const
IndicatorCircle3D(Vector< S, 3 > center, Vector< S, 3 > normal, S radius)
Vector< S, 3 > const & getNormal() const
bool operator()(bool output[], const S input[]) override
has to be implemented for 'every' derived class
indicator function for a 3d frustum
Vector< S, 3 > const & getCenter1() const
IndicatorCone3D(Vector< S, 3 > center1, Vector< S, 3 > center2, S radius1, S radius2=0)
S signedDistance(const Vector< S, 3 > &input) override
Returns signed distance to the nearest point on the indicator surface.
Vector< S, 3 > const & getCenter2() const
bool operator()(bool output[], const S input[]) override
has to be implemented for 'every' derived class
indicator function for a 3d-cuboid, parallel to the planes x=0, y=0, z=0.
Vector< S, 3 > const & getCenter() const
S const getxLength() const
IndicatorCuboid3D(Vector< S, 3 > extend, Vector< S, 3 > origin)
constructs an cuboid with x axis from origin[0] to origin[0]+extend[0], ...
S const getyLength() const
S const getzLength() const
Vector< S, 3 > getSample(const std::function< S()> &randomness) const override
S signedDistance(const Vector< S, 3 > &input) override
Returns signed distance to the nearest point on the indicator surface.
bool operator()(bool output[], const S input[]) override
returns true if input is inside, otherwise false
indicator function for a 3d-cuboid, turned by an angle theta around an axis of rotation
S signedDistance(const Vector< S, 3 > &input) override
Returns signed distance to the nearest point on the indicator surface.
bool operator()(bool output[], const S input[])
returns true if input is inside, otherwise false
IndicatorCuboidRotate3D(Vector< S, 3 > extend, Vector< S, 3 > origin, S theta, int plane, Vector< S, 3 > centerRotation)
indicator function for a 3d-cylinder
IndicatorCylinder3D(Vector< S, 3 > center1, Vector< S, 3 > center2, S radius)
Indicator function for a cylinder.
Vector< S, 3 > const & getCenter1() const
bool operator()(bool output[], const S input[]) override
has to be implemented for 'every' derived class
Vector< S, 3 > getSample(const std::function< S()> &randomness) const override
S signedDistance(const Vector< S, 3 > &input) override
Returns signed distance to the nearest point on the indicator surface.
Vector< S, 3 > const & getCenter2() const
indicator function for an ellipsoid
Vector< S, 3 > const & getCenter() const
Vector< S, 3 > const & getRadius() const
S signedDistance(const Vector< S, 3 > &input) override
Returns signed distance to the nearest point on the indicator surface.
IndicatorEllipsoid3D(Vector< S, 3 > center, Vector< S, 3 > radius)
IndicatorF3D is an application from .
virtual bool normal(Vector< S, 3 > &normal, const Vector< S, 3 > &origin, const Vector< S, 3 > &direction, int iC=-1)
returns true and the normal if there was one found for an given origin and direction
indicator function for the internal part of an input indicator
IndicatorInternal3D(IndicatorF3D< S > &indicatorF, S layerSize)
bool operator()(bool output[], const S input[]) override
has to be implemented for 'every' derived class
indicator function for a layer
S signedDistance(const Vector< S, 3 > &input) override
Returns signed distance to the nearest point on the indicator surface.
bool operator()(bool output[], const S input[]) override
has to be implemented for 'every' derived class
IndicatorLayer3D(FunctorPtr< IndicatorF3D< S > > &&indicatorF, S layerSize)
bool operator()(bool output[], const T input[]) override
IndicatorSDF3D(std::function< T(Vector< T, 3 >)> f)
indicator function for a 3D-sphere
Vector< S, 3 > const & getCenter() const
IndicatorSphere3D(Vector< S, 3 > center, S radius)
S signedDistance(const Vector< S, 3 > &input) override
Returns signed distance to the nearest point on the indicator surface.
S const getRadius() const
bool distance(S &distance, const Vector< S, 3 > &origin, const Vector< S, 3 > &direction, int iC=-1) override
indicator function for a super ellipsoid
Vector< S, 3 > const & getCenter() const
IndicatorSuperEllipsoid3D(Vector< S, 3 > center, S xHalfAxis, S yHalfAxis, S zHalfAxis, S exponent1, S exponent2)
bool operator()(bool output[], const S input[]) override
has to be implemented for 'every' derived class
Vector< S, 3 > & getMin() override
bool operator()(bool output[], const S input[]) override
has to be implemented for 'every' derived class
S signedDistance(const Vector< S, 3 > &input) override
Returns signed distance to the nearest point on the indicator surface.
IndicatorTranslate3D(std::array< S, 3 > translate, IndicatorF3D< S > &indicator)
Vector< S, 3 > & getMax() override
Plain old scalar vector.
Definition vector.h:47
Top level namespace for all of OpenLB.
std::shared_ptr< IndicatorF3D< S > > createIndicatorF3D(XMLreader const &params, bool verbose=false)
std::shared_ptr< IndicatorF3D< S > > createIndicatorIntersection3D(XMLreader const &params, bool verbose=false)
std::shared_ptr< IndicatorF3D< S > > createIndicatorCylinder3D(XMLreader const &params, bool verbose=false)
std::shared_ptr< IndicatorF3D< S > > createIndicatorUnion3D(XMLreader const &params, bool verbose=false)
std::shared_ptr< IndicatorF3D< S > > createIndicatorSphere3D(XMLreader const &params, bool verbose=false)
std::shared_ptr< IndicatorF3D< S > > createIndicatorCone3D(XMLreader const &params, bool verbose=false)
std::shared_ptr< IndicatorF3D< S > > createIndicatorCircle3D(XMLreader const &params, bool verbose=false)
std::shared_ptr< IndicatorF3D< S > > createIndicatorCuboid3D(XMLreader const &params, bool verbose=false)
std::shared_ptr< IndicatorF3D< S > > createIndicatorWithout3D(XMLreader const &params, bool verbose=false)
Input/Output in XML format – header file.