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

indicator function for a 3d frustum More...

#include <indicatorF3D.h>

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

Public Member Functions

 IndicatorCone3D (Vector< S, 3 > center1, Vector< S, 3 > center2, S radius1, S radius2=0)
 
Vector< S, 3 > const & getCenter1 () const
 
Vector< S, 3 > const & getCenter2 () const
 
getRadius1 () const
 
getRadius2 () const
 
bool operator() (bool output[], const S input[]) override
 has to be implemented for 'every' derived class
 
signedDistance (const Vector< S, 3 > &input) override
 Returns signed distance to the nearest point on the indicator surface.
 
- 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, const Vector< S, 3 > &direction, int iC=-1)
 
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
 
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::IndicatorCone3D< S >

indicator function for a 3d frustum

Definition at line 171 of file indicatorF3D.h.

Constructor & Destructor Documentation

◆ IndicatorCone3D()

template<typename S >
olb::IndicatorCone3D< S >::IndicatorCone3D ( Vector< S, 3 > center1,
Vector< S, 3 > center2,
S radius1,
S radius2 = 0 )

Definition at line 439 of file indicatorF3D.hh.

441 : _center1(center1), _center2(center2),
442 _ba(center2 - center1), _baba(_ba*_ba),
443 _radius1(radius1), _radius2(radius2),
444 _length(util::sqrt((_center2 - _center1)*(_center2 - _center1)))
445{
446 // _I,_J,_K is the new base where _K is the axe of the cone
447 _K = (_center2 - _center1)/_length;
448
449 // _I and _J form an orthonormal base with _K
450 if ( util::approxEqual(_center2[1],_center1[1]) && util::approxEqual(_center2[0],_center1[0]) ) {
451 if ( util::approxEqual(_center2[2],_center1[2]) ) {
452 OstreamManager clout = OstreamManager(std::cout,"IndicatorCone3D");
453 clout << "Warning: in the cone, the two centers have the same coordinates" << std::endl;
454 clout << _center1 << std::endl;
455 clout << _center2 << std::endl;
456 }
457 _I = {1,0,0};
458 _J = {0,1,0};
459 }
460 else {
461 S normi = util::sqrt(_K[1]*_K[1] + _K[0]*_K[0]);
462 _I = {-_K[1]/normi, _K[0]/normi,0};
463 _J = {_K[1]*_I[2] - _K[2]*_I[1], _K[2]*_I[0] - _K[0]*_I[2], _K[0]*_I[1] - _K[1]*_I[0]};
464 }
465
466 S maxx= _center1[0] + util::max( util::sqrt(_I[0]*_I[0]+_J[0]*_J[0])*_radius1,
467 util::sqrt(_I[0]*_I[0]+_J[0]*_J[0])*_radius2 + _K[0]*_length);
468 S minx= _center1[0] + util::min(-util::sqrt(_I[0]*_I[0]+_J[0]*_J[0])*_radius1,
469 -util::sqrt(_I[0]*_I[0]+_J[0]*_J[0])*_radius2 + _K[0]*_length);
470
471 S maxy= _center1[1] + util::max( util::sqrt(_I[1]*_I[1]+_J[1]*_J[1])*_radius1,
472 util::sqrt(_I[1]*_I[1]+_J[1]*_J[1])*_radius2 + _K[1]*_length);
473 S miny= _center1[1] + util::min(-util::sqrt(_I[1]*_I[1]+_J[1]*_J[1])*_radius1,
474 -util::sqrt(_I[1]*_I[1]+_J[1]*_J[1])*_radius2 + _K[1]*_length);
475
476 S maxz= _center1[2] + util::max( util::sqrt(_I[2]*_I[2]+_J[2]*_J[2])*_radius1,
477 util::sqrt(_I[2]*_I[2]+_J[2]*_J[2])*_radius2 + _K[2]*_length);
478 S minz= _center1[2] + util::min(-util::sqrt(_I[2]*_I[2]+_J[2]*_J[2])*_radius1,
479 -util::sqrt(_I[2]*_I[2]+_J[2]*_J[2])*_radius2 + _K[2]*_length);
480
481 this->_myMin = {minx, miny, minz};
482 this->_myMax = {maxx, maxy, maxz};
483}
Vector< S, 3 > _myMin
Vector< S, 3 > _myMax
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)
cpu::simd::Pack< T > max(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:130

References olb::IndicatorF3D< S >::_myMax, olb::IndicatorF3D< S >::_myMin, olb::util::approxEqual(), olb::util::max(), olb::util::min(), and olb::util::sqrt().

+ Here is the call graph for this function:

Member Function Documentation

◆ getCenter1()

template<typename S >
Vector< S, 3 > const & olb::IndicatorCone3D< S >::getCenter1 ( ) const

Definition at line 501 of file indicatorF3D.hh.

502{
503 return _center1;
504}

◆ getCenter2()

template<typename S >
Vector< S, 3 > const & olb::IndicatorCone3D< S >::getCenter2 ( ) const

Definition at line 507 of file indicatorF3D.hh.

508{
509 return _center2;
510}

◆ getRadius1()

template<typename S >
S olb::IndicatorCone3D< S >::getRadius1 ( ) const

Definition at line 513 of file indicatorF3D.hh.

514{
515 return _radius1;
516}

◆ getRadius2()

template<typename S >
S olb::IndicatorCone3D< S >::getRadius2 ( ) const

Definition at line 519 of file indicatorF3D.hh.

520{
521 return _radius2;
522}

◆ operator()()

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

has to be implemented for 'every' derived class

Implements olb::GenericF< bool, S >.

Definition at line 487 of file indicatorF3D.hh.

488{
489 // radius: the radius of the cone at the point x
490 Vector<S,3> pa(Vector<S,3>(input) - _center1);
491 S X = _I[0]*pa[0] + _I[1]*pa[1] + _I[2]*pa[2];
492 S Y = _J[0]*pa[0] + _J[1]*pa[1] + _J[2]*pa[2];
493 S Z = _K[0]*pa[0] + _K[1]*pa[1] + _K[2]*pa[2];
494 S radius = _radius1 + (_radius2 - _radius1)*Z / _length;
495
496 output[0] = ( Z <= _length && Z >= 0 && X*X + Y*Y <= radius*radius );
497 return true;
498}

◆ signedDistance()

template<typename S >
S olb::IndicatorCone3D< 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 525 of file indicatorF3D.hh.

526{
527 return sdf::cone(input, _center1, _ba, _baba, _radius1, _radius2);
528}
T cone(Vector< T, 3 > p, Vector< T, 3 > a, Vector< T, 3 > ba, T baba, T ra, T rb) any_platform
Exact signed distance to the surface of three-dimensional (capped) cone.
Definition sdf.h:210

References olb::sdf::cone().

+ Here is the call graph for this function:

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