OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::IndicatorCircle2D< S > Class Template Reference

indicator function for a 2D circle More...

#include <indicatorF2D.h>

+ Inheritance diagram for olb::IndicatorCircle2D< S >:
+ Collaboration diagram for olb::IndicatorCircle2D< S >:

Public Member Functions

 IndicatorCircle2D (Vector< S, 2 > center, S radius)
 
Vector< S, 2 > const & getCenter () const
 
S const getRadius () const
 
bool operator() (bool output[], const S input[]) override
 has to be implemented for 'every' derived class
 
bool distance (S &distance, const Vector< S, 2 > &origin, const Vector< S, 2 > &direction, int iC=-1) override
 
bool normal (Vector< S, 2 > &normal, const Vector< S, 2 > &origin, const Vector< S, 2 > &direction, int iC=-1) override
 returns true and the normal if there was one found for an given origin and direction
 
signedDistance (const Vector< S, 2 > &input) override
 Returns signed distance to the nearest point on the indicator surface.
 
- Public Member Functions inherited from olb::IndicatorF2D< S >
virtual Vector< S, 2 > & getMin ()
 
virtual Vector< S, 2 > & getMax ()
 
virtual bool distance (S &distance, const Vector< S, 2 > &origin, S precision, const Vector< S, 2 > &direction)
 returns false or true and pos. distance if there was one found for an given origin and direction
 
virtual bool distance (S &distance, const Vector< S, 2 > &origin, const Vector< S, 2 > &direction, S precision, S pitch)
 
virtual bool distance (S &distance, const Vector< S, 2 > &origin)
 
virtual bool distance (S &distance, const S input[])
 
virtual bool operator() (bool output[1], const S input[2])
 Returns true if input is inside the indicator.
 
virtual Vector< S, 2 > surfaceNormal (const Vector< S, 2 > &pos, const S meshSize)
 Return surface normal.
 
Vector< S, 2 > surfaceNormal (const Vector< S, 2 > &pos, const S meshSize, std::function< Vector< S, 2 >(const Vector< S, 2 > &)> transformPos)
 Return surface normal after possible translation and rotation.
 
bool isInsideBox (Vector< S, 2 > point)
 Returns true if point is inside a cube with corners _myMin and _myMax
 
virtual bool operator() (const S input[])
 Indicator specific function operator overload.
 
- Public Member Functions inherited from olb::GenericF< bool, S >
virtual ~GenericF ()=default
 
int getSourceDim () const
 read only access to member variable _m
 
int getTargetDim () const
 read only access to member variable _n
 
std::string & getName ()
 read and write access to name
 
std::string const & getName () const
 read only access to name
 
bool operator() (bool output[])
 wrapper that call the pure virtual operator() (T output[], const S input[]) from above
 
bool operator() (bool output[], S input0)
 
bool operator() (bool output[], S input0, S input1)
 
bool operator() (bool output[], S input0, S input1, S input2)
 
bool operator() (bool output[], S input0, S input1, S input2, S input3)
 

Additional Inherited Members

- Public Types inherited from olb::GenericF< bool, S >
using targetType
 
using sourceType
 
- Public Attributes inherited from olb::GenericF< bool, S >
std::shared_ptr< GenericF< bool, S > > _ptrCalcC
 memory management, frees resouces (calcClass)
 
- Protected Member Functions inherited from olb::IndicatorF2D< S >
 IndicatorF2D ()
 
- Protected Member Functions inherited from olb::GenericF< bool, S >
 GenericF (int targetDim, int sourceDim)
 
- Protected Attributes inherited from olb::IndicatorF2D< S >
Vector< S, 2 > _myMin
 
Vector< S, 2 > _myMax
 

Detailed Description

template<typename S>
class olb::IndicatorCircle2D< S >

indicator function for a 2D circle

Definition at line 91 of file indicatorF2D.h.

Constructor & Destructor Documentation

◆ IndicatorCircle2D()

template<typename S >
olb::IndicatorCircle2D< S >::IndicatorCircle2D ( Vector< S, 2 > center,
S radius )

Definition at line 154 of file indicatorF2D.hh.

155 : _center(center),
156 _radius(radius),
157 _radius2(radius*radius)
158{
159 this->_myMin = _center - radius;
160 this->_myMax = _center + radius;
161}
Vector< S, 2 > _myMin
Vector< S, 2 > _myMax

References olb::IndicatorF2D< S >::_myMax, and olb::IndicatorF2D< S >::_myMin.

Member Function Documentation

◆ distance()

template<typename S >
bool olb::IndicatorCircle2D< S >::distance ( S & distance,
const Vector< S, 2 > & origin,
const Vector< S, 2 > & direction,
int iC = -1 )
overridevirtual

Reimplemented from olb::IndicatorF2D< S >.

Definition at line 185 of file indicatorF2D.hh.

186{
187 S a = direction[0]*direction[0] + direction[1]*direction[1];
188
189 // returns 0 if point is at the boundary of the sphere
190 if ( util::approxEqual(a,_radius2) ) {
191 distance = S(0);
192 return true;
193 }
194 // norm of direction
195 a = util::sqrt(a);
196
197 S b = 2.*((origin[0] - _center[0])*direction[0] +
198 (origin[1] - _center[1])*direction[1])/a;
199 S c = -_radius2 + (origin[0] - _center[0])*(origin[0] - _center[0])
200 + (origin[1] - _center[1])*(origin[1] - _center[1]);
201
202 // discriminant
203 S d = b*b - 4.*c;
204 if (d < 0) {
205 return false;
206 }
207
208 S x1 = (- b + util::sqrt(d)) *0.5;
209 S x2 = (- b - util::sqrt(d)) *0.5;
210
211 // case if origin is inside the sphere
212 if ((x1<0.) || (x2<0.)) {
213 if (x1>0.) {
214 distance = x1;
215 return true;
216 }
217 if (x2>0.) {
218 distance = x2;
219 return true;
220 }
221 }
222 // case if origin is ouside the sphere
223 else {
224 distance = util::min(x1,x2);
225 return true;
226 }
227
228 return false;
229}
bool distance(S &distance, const Vector< S, 2 > &origin, const Vector< S, 2 > &direction, int iC=-1) override
platform_constant int c[Q][D]
constexpr int d() any_platform
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
Definition pack.h:100
cpu::simd::Pack< T > min(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:124
bool approxEqual(T a, U b, W epsilon)

References olb::util::approxEqual(), olb::util::min(), and olb::util::sqrt().

+ Here is the call graph for this function:

◆ getCenter()

template<typename S >
Vector< S, 2 > const & olb::IndicatorCircle2D< S >::getCenter ( ) const

Definition at line 164 of file indicatorF2D.hh.

165{
166 return _center;
167}

◆ getRadius()

template<typename S >
S const olb::IndicatorCircle2D< S >::getRadius ( ) const

Definition at line 170 of file indicatorF2D.hh.

171{
172 return _radius;
173}
+ Here is the caller graph for this function:

◆ normal()

template<typename S >
bool olb::IndicatorCircle2D< S >::normal ( Vector< S, 2 > & normal,
const Vector< S, 2 > & origin,
const Vector< S, 2 > & direction,
int iC = -1 )
overridevirtual

returns true and the normal if there was one found for an given origin and direction

(mind that the default computation is done by a numerical approximation which searches .. [TODO])

Reimplemented from olb::IndicatorF2D< S >.

Definition at line 233 of file indicatorF2D.hh.

234{
235 S dist;
236 if (!(distance(dist, origin, direction, iC)) ) {
237 return false;
238 }
239
240 Vector<S,2> intresection(origin + dist*direction);
241
242 normal = intresection - _center;
243
244 return true;
245}
bool normal(Vector< S, 2 > &normal, const Vector< S, 2 > &origin, const Vector< S, 2 > &direction, int iC=-1) override
returns true and the normal if there was one found for an given origin and direction

◆ operator()()

template<typename S >
bool olb::IndicatorCircle2D< S >::operator() ( bool output[],
const S input[] )
overridevirtual

has to be implemented for 'every' derived class

Implements olb::GenericF< bool, S >.

Definition at line 177 of file indicatorF2D.hh.

178{
179 output[0] = ( util::pow(_center[0] - input[0],2) + util::pow(_center[1] - input[1], 2) <= _radius2 );
180 return output[0];
181}
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
Definition pack.h:112

References olb::util::pow().

+ Here is the call graph for this function:

◆ signedDistance()

template<typename S >
S olb::IndicatorCircle2D< S >::signedDistance ( const Vector< S, 2 > & input)
overridevirtual

Returns signed distance to the nearest point on the indicator surface.

Reimplemented from olb::IndicatorF2D< S >.

Definition at line 248 of file indicatorF2D.hh.

249{
250 Vector<S,2> p = input - _center;
251 return sdf::sphere(p, _radius);
252}
T sphere(Vector< T, D > p, T r) any_platform
Exact signed distance to the surface of circle (in 2D) or sphere (in 3D).
Definition sdf.h:104

References olb::sdf::sphere().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: