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

IndicatorF2D is an application from $ \Omega \subset R^2 \to {0,1} $. More...

#include <indicatorBaseF2D.h>

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

Public Member Functions

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, const Vector< S, 2 > &direction, int iC=-1)
 
virtual bool distance (S &distance, const Vector< S, 2 > &origin)
 
virtual bool distance (S &distance, const S input[])
 
virtual bool normal (Vector< S, 2 > &normal, const Vector< S, 2 > &origin, const Vector< S, 2 > &direction, int iC=-1)
 returns true and the normal if there was one found for an given origin and direction
 
virtual bool operator() (bool output[1], const S input[2])
 Returns true if input is inside the indicator.
 
virtual S signedDistance (const Vector< S, 2 > &input)
 Returns signed distance to the nearest point on the indicator surface.
 
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
 
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)
 

Protected Member Functions

 IndicatorF2D ()
 
- Protected Member Functions inherited from olb::GenericF< bool, S >
 GenericF (int targetDim, int sourceDim)
 

Protected Attributes

Vector< S, 2 > _myMin
 
Vector< S, 2 > _myMax
 

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)
 

Detailed Description

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

IndicatorF2D is an application from $ \Omega \subset R^2 \to {0,1} $.

Parameters
_myMinholds minimal(component wise) vector of the domain $ \Omega $.
_myMaxholds maximal(component wise) vector of the domain $ \Omega $.

Definition at line 70 of file indicatorBaseF2D.h.

Constructor & Destructor Documentation

◆ IndicatorF2D()

template<typename S >
olb::IndicatorF2D< S >::IndicatorF2D ( )
protected

Definition at line 64 of file indicatorBaseF2D.hh.

65 : GenericF<bool,S>(1, 2)
66{ }

Member Function Documentation

◆ distance() [1/5]

template<typename S >
bool olb::IndicatorF2D< S >::distance ( S & distance,
const S input[] )
virtual

Definition at line 120 of file indicatorBaseF2D.hh.

121{
123 return true;
124}
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 S signedDistance(const Vector< S, 2 > &input)
Returns signed distance to the nearest point on the indicator surface.
ADf< T, DIM > abs(const ADf< T, DIM > &a)
Definition aDiff.h:1019

References olb::util::abs().

+ Here is the call graph for this function:

◆ distance() [2/5]

template<typename S >
bool olb::IndicatorF2D< S >::distance ( S & distance,
const Vector< S, 2 > & origin )
virtual

Definition at line 113 of file indicatorBaseF2D.hh.

114{
115 S input[3] = {origin[0],origin[1],origin[2]};
116 return this->distance(distance, input);
117}

◆ distance() [3/5]

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

Reimplemented in olb::IndicatorCircle2D< S >.

Definition at line 105 of file indicatorBaseF2D.hh.

106{
107 S precision = .0001;
108 S pitch = 0.5;
109 return this->distance(distance, origin, direction, precision, pitch);
110}

◆ distance() [4/5]

template<typename S >
bool olb::IndicatorF2D< S >::distance ( S & distance,
const Vector< S, 2 > & origin,
const Vector< S, 2 > & direction,
S precision,
S pitch )
virtual

Definition at line 93 of file indicatorBaseF2D.hh.

94{
95 return util::distance(distance, origin, direction, precision, pitch,
96 [&](bool output[1], const S input[2]) {
97 return (*this)(output, input);
98 },
99 [&](const Vector<S,2>& pos) {
100 return isInsideBox(pos);
101 });
102}
bool isInsideBox(Vector< S, 2 > point)
Returns true if point is inside a cube with corners _myMin and _myMax
bool distance(S &distance, const Vector< S, D > &origin, const Vector< S, D > &direction, S precision, S pitch, F1 isInside, F2 isInsideBoundingBox)

◆ distance() [5/5]

template<typename S >
bool olb::IndicatorF2D< S >::distance ( S & distance,
const Vector< S, 2 > & origin,
S precision,
const Vector< S, 2 > & direction )
virtual

returns false or true and pos. distance 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])

Definition at line 81 of file indicatorBaseF2D.hh.

82{
83 return util::distance(distance, origin, direction, precision,
84 [&](const Vector<S,2> input) {
85 return this->signedDistance(input);
86 },
87 [&](const Vector<S,2>& pos) {
88 return isInsideBox(pos);
89 });
90}

References olb::util::distance().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMax()

template<typename S >
Vector< S, 2 > & olb::IndicatorF2D< S >::getMax ( )
virtual

Definition at line 75 of file indicatorBaseF2D.hh.

76{
77 return _myMax;
78}
Vector< S, 2 > _myMax
+ Here is the caller graph for this function:

◆ getMin()

template<typename S >
Vector< S, 2 > & olb::IndicatorF2D< S >::getMin ( )
virtual

Definition at line 69 of file indicatorBaseF2D.hh.

70{
71 return _myMin;
72}
Vector< S, 2 > _myMin
+ Here is the caller graph for this function:

◆ isInsideBox()

template<typename S >
bool olb::IndicatorF2D< S >::isInsideBox ( Vector< S, 2 > point)

Returns true if point is inside a cube with corners _myMin and _myMax

Definition at line 195 of file indicatorBaseF2D.hh.

196{
197 return point >= _myMin && point <= _myMax;
198}

◆ normal()

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

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 in olb::IndicatorCircle2D< S >.

Definition at line 134 of file indicatorBaseF2D.hh.

135{
136 //OstreamManager clout(std::cout,"normal");
137 //clout << "Calculating IndicatorF2D Normal " << std::endl;
138 bool originValue;
139 (*this)(&originValue, origin.data());
140 Vector<S,2> currentPoint(origin);
141
142 S precision = .0001;
143
144 S dist;
145 distance(dist, origin, direction, iC);
146
147
148 Vector<S,2> POS(origin + dist*direction*(1/norm(direction))); //Point on Surface
149
150 Vector<S,2> point1;
151 Vector<S,2> point2;
152
153 bool currentValue;
154
155 for (int n: {
156 -90,90
157 }) { //std::range<int> n = {-90, 90};
158 S rotate(n);
159 S pitch(rotate/2.);
160 while (util::abs(pitch) >= precision) {
161 S theta( util::degreeToRadian(rotate) );
162
163 Vector<S,2> vec(util::cos(theta)*direction[0]+util::sin(theta)*direction[1],-util::sin(theta)*direction[0]+util::cos(theta)*direction[1]);
164 currentPoint = POS + vec;
165 (*this)(&currentValue, currentPoint.data());
166
167 if (currentValue == originValue) {
168 rotate -= pitch;
169 }
170 else {
171 rotate += pitch;
172 }
173 pitch /= 2.;
174 }
175
176 if (n == -90) {
177 point1 = currentPoint;
178 }
179 else if (n == 90) {
180 point2 = currentPoint;
181 }
182 }
183 // Calculate Normal from point1 and point2
184 normal = Vector<S,2>((point2[1] - point1[1]), (-1)*(point2[0] - point1[0]));
185
186
187 //S dist;
188 //Vector<S,2> dist;
189 //distance(dist, origin, direction, iC);
190 //normal = Vector<S,2>(dist);
191 return true;
192}
virtual bool normal(Vector< S, 2 > &normal, const Vector< S, 2 > &origin, const Vector< S, 2 > &direction, int iC=-1)
returns true and the normal if there was one found for an given origin and direction
constexpr const T * data() const any_platform
Definition vector.h:161
ADf< T, DIM > sin(const ADf< T, DIM > &a)
Definition aDiff.h:569
decltype(Vector< decltype(util::sqrt(T())), D >()) degreeToRadian(const Vector< T, D > &angle)
ADf< T, DIM > cos(const ADf< T, DIM > &a)
Definition aDiff.h:578
constexpr T norm(const ScalarVector< T, D, IMPL > &a)
Euclidean vector norm.

References olb::util::abs(), olb::util::cos(), olb::Vector< T, D >::data(), olb::util::degreeToRadian(), olb::norm(), and olb::util::sin().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator()() [1/2]

template<typename S >
bool olb::IndicatorF2D< S >::operator() ( bool output[1],
const S input[2] )
virtual

Returns true if input is inside the indicator.

Reimplemented in olb::IndicatorIdentity2D< S >.

Definition at line 239 of file indicatorBaseF2D.hh.

240{
241 output[0] = this->operator()(input);
242 return output[0];
243}
virtual bool operator()(bool output[1], const S input[2])
Returns true if input is inside the indicator.

◆ operator()() [2/2]

template<typename S >
bool olb::IndicatorF2D< S >::operator() ( const S input[])
virtual

Indicator specific function operator overload.

Returns
Domain indicator i.e. true iff the input lies within the described domain.

Definition at line 201 of file indicatorBaseF2D.hh.

202{
203 return this->signedDistance(input) <= 0;
204}

◆ signedDistance()

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

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

Reimplemented in olb::IndicatorCuboid2D< S >, olb::IndicatorCircle2D< S >, olb::IndicatorTriangle2D< S >, olb::IndicatorEquiTriangle2D< S >, olb::IndicatorBlockData2D< S >, olb::IndicPlus2D< S >, olb::IndicMinus2D< S >, olb::IndicMultiplication2D< S >, olb::IndicCalc2D< S, F >, olb::IndicCalc2D< S, util::minus >, olb::IndicCalc2D< S, util::multiplies >, and olb::IndicCalc2D< S, util::plus >.

Definition at line 215 of file indicatorBaseF2D.hh.

216{
217 // TODO: Add fallback algorithm here
218 assert(false);
219 return std::numeric_limits<double>::quiet_NaN();
220}

◆ surfaceNormal() [1/2]

template<typename S >
Vector< S, 2 > olb::IndicatorF2D< S >::surfaceNormal ( const Vector< S, 2 > & pos,
const S meshSize )
virtual

Return surface normal.

Definition at line 223 of file indicatorBaseF2D.hh.

224{
225 return util::surfaceNormal(pos, meshSize,
226 [&](const Vector<S,2>& pos) {
227 return this->signedDistance(pos);
228 });
229}
Vector< S, D > surfaceNormal(const Vector< S, D > &pos, const S meshSize, F1 sdf)

References olb::util::surfaceNormal().

+ Here is the call graph for this function:

◆ surfaceNormal() [2/2]

template<typename S >
Vector< S, 2 > olb::IndicatorF2D< S >::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.

Definition at line 232 of file indicatorBaseF2D.hh.

234{
235 return this->surfaceNormal(transformPos(pos), meshSize);
236}
virtual Vector< S, 2 > surfaceNormal(const Vector< S, 2 > &pos, const S meshSize)
Return surface normal.

Member Data Documentation

◆ _myMax

template<typename S >
Vector<S,2> olb::IndicatorF2D< S >::_myMax
protected

Definition at line 74 of file indicatorBaseF2D.h.

◆ _myMin

template<typename S >
Vector<S,2> olb::IndicatorF2D< S >::_myMin
protected

Definition at line 73 of file indicatorBaseF2D.h.


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