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

indicator function for a 3D-sphere More...

#include <indicatorF3D.h>

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

Public Member Functions

 IndicatorSphere3D (Vector< S, 3 > center, S radius)
 
 IndicatorSphere3D (const IndicatorSphere3D &)
 
Vector< S, 3 > const & getCenter () const
 
S const getRadius () const
 
signedDistance (const Vector< S, 3 > &input) override
 Returns signed distance to the nearest point on the indicator surface.
 
bool distance (S &distance, const Vector< S, 3 > &origin, const Vector< S, 3 > &direction, int iC=-1) override
 
- Public Member Functions inherited from olb::IndicatorF3D< S >
virtual Vector< S, 3 > & getMin ()
 
virtual Vector< S, 3 > & getMax ()
 
virtual bool distance (S &distance, const Vector< S, 3 > &origin, S precision, const Vector< S, 3 > &direction)
 
virtual bool distance (S &distance, const Vector< S, 3 > &origin, const Vector< S, 3 > &direction, S precision, S pitch)
 
virtual bool distance (S &distance, const Vector< S, 3 > &origin)
 
virtual bool distance (S &distance, const S input[])
 
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
 
virtual bool rotOnAxis (Vector< S, 3 > &vec_rot, const Vector< S, 3 > &vec, const Vector< S, 3 > &axis, S &theta)
 Rotate vector around axis by angle theta.
 
virtual bool operator() (bool output[1], const S input[3])
 Returns true if input is inside the indicator.
 
virtual Vector< S, 3 > surfaceNormal (const Vector< S, 3 > &pos, const S meshSize)
 Return surface normal.
 
Vector< S, 3 > surfaceNormal (const Vector< S, 3 > &pos, const S meshSize, std::function< Vector< S, 3 >(const Vector< S, 3 > &)> transformPos)
 Return surface normal after possible translation and rotation.
 
bool isInsideBox (Vector< S, 3 > point)
 Returns true if point is inside a cube with corners _myMin and _myMax
 
virtual Vector< S, 3 > getSample (const std::function< S()> &randomness) const
 
- 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
 
virtual bool operator() (bool output[], const S input[])=0
 has to be implemented for 'every' derived class
 
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::IndicatorF3D< S >
 IndicatorF3D ()
 
- Protected Member Functions inherited from olb::GenericF< bool, S >
 GenericF (int targetDim, int sourceDim)
 
- Protected Attributes inherited from olb::IndicatorF3D< S >
Vector< S, 3 > _myMin
 
Vector< S, 3 > _myMax
 

Detailed Description

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

indicator function for a 3D-sphere

Definition at line 98 of file indicatorF3D.h.

Constructor & Destructor Documentation

◆ IndicatorSphere3D() [1/2]

template<typename S >
olb::IndicatorSphere3D< S >::IndicatorSphere3D ( Vector< S, 3 > center,
S radius )

Definition at line 131 of file indicatorF3D.hh.

132 : _center(center), _radius(radius), _radius2(_radius*_radius)
133{
134 this->_myMin = _center - radius;
135 this->_myMax = _center + radius;
136}
Vector< S, 3 > _myMin
Vector< S, 3 > _myMax

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

◆ IndicatorSphere3D() [2/2]

template<typename S >
olb::IndicatorSphere3D< S >::IndicatorSphere3D ( const IndicatorSphere3D< S > & sphere)

Definition at line 139 of file indicatorF3D.hh.

140{
141 this->_myMin = sphere._myMin;
142 this->_myMax = sphere._myMax;
143 _center = sphere._center;
144 _radius = sphere._radius;
145 _radius2 = sphere._radius2;
146}
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

Member Function Documentation

◆ distance()

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

Reimplemented from olb::IndicatorF3D< S >.

Definition at line 168 of file indicatorF3D.hh.

170{
171 // computes pos. distance by solving quadratic equation by a-b-c-formula
172 S a = direction[0]*direction[0] + direction[1]*direction[1] + direction[2]*direction[2];
173
174 // returns 0 if point is at the boundary of the sphere
175 if ( util::approxEqual(a,_radius2) ) {
176 distance = S();
177 return true;
178 }
179 // norm of direction
180 a = util::sqrt(a);
181
182 S b = 2.*((origin[0] - _center[0])*direction[0] +
183 (origin[1] - _center[1])*direction[1] +
184 (origin[2] - _center[2])*direction[2])/a;
185 S c = -_radius2 + (origin[0] - _center[0])*(origin[0] - _center[0])
186 + (origin[1] - _center[1])*(origin[1] - _center[1])
187 + (origin[2] - _center[2])*(origin[2] - _center[2]);
188
189 // discriminant
190 S d = b*b - 4.*c;
191 if (d < 0) {
192 return false;
193 }
194
195 S x1 = (- b + util::sqrt(d)) *0.5;
196 S x2 = (- b - util::sqrt(d)) *0.5;
197
198 // case if origin is inside the sphere
199 if ((x1<0.) || (x2<0.)) {
200 if (x1>0.) {
201 distance = x1;
202 return true;
203 }
204 if (x2>0.) {
205 distance = x2;
206 return true;
207 }
208 }
209 // case if origin is outside the sphere
210 else {
211 distance = util::min(x1,x2);
212 return true;
213 }
214
215 return false;
216}
bool distance(S &distance, const Vector< S, 3 > &origin, const Vector< S, 3 > &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, 3 > const & olb::IndicatorSphere3D< S >::getCenter ( ) const

Definition at line 149 of file indicatorF3D.hh.

150{
151 return _center;
152}

◆ getRadius()

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

Definition at line 155 of file indicatorF3D.hh.

156{
157 return _radius;
158}

◆ signedDistance()

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

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

Reimplemented from olb::IndicatorF3D< S >.

Definition at line 161 of file indicatorF3D.hh.

162{
163 Vector<S,3> p = input - _center;
164 return sdf::sphere(p, _radius);
165}

References olb::sdf::sphere().

+ Here is the call graph for this function:

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