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

This class converts Cartesian coordinates of point x to polar coordinates wrote into output field (output[0] = radius>= 0, output[1] = phi in [0, 2Pi). More...

#include <frameChangeF2D.h>

+ Inheritance diagram for olb::CartesianToPolar2D< T, S >:
+ Collaboration diagram for olb::CartesianToPolar2D< T, S >:

Public Member Functions

 CartesianToPolar2D (olb::Vector< T, 3 > cartesianOrigin, olb::Vector< T, 3 > axisDirection, olb::Vector< T, 3 > orientation={T(1), T(), T()})
 
 CartesianToPolar2D (T cartesianOriginX, T cartesianOriginY, T cartesianOriginZ, T axisDirectionX, T axisDirectionY, T axisDirectionZ, T orientationX=T(1), T orientationY=T(), T orientationZ=T())
 
bool operator() (T output[], const S x[]) override
 operator writes polar coordinates of Cartesian point x into output field, returns output[0] = radius ( >= 0 ), output[1] = phi in [0, 2Pi)
 
- Public Member Functions inherited from olb::AnalyticalF< D, T, S >
AnalyticalF< D, T, S > & operator- (AnalyticalF< D, T, S > &rhs)
 
AnalyticalF< D, T, S > & operator+ (AnalyticalF< D, T, S > &rhs)
 
AnalyticalF< D, T, S > & operator* (AnalyticalF< D, T, S > &rhs)
 
AnalyticalF< D, T, S > & operator/ (AnalyticalF< D, T, S > &rhs)
 
- Public Member Functions inherited from olb::GenericF< T, 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() (T output[])
 wrapper that call the pure virtual operator() (T output[], const S input[]) from above
 
bool operator() (T output[], S input0)
 
bool operator() (T output[], S input0, S input1)
 
bool operator() (T output[], S input0, S input1, S input2)
 
bool operator() (T output[], S input0, S input1, S input2, S input3)
 

Protected Attributes

olb::Vector< T, 3 > _cartesianOrigin
 origin of the Cartesian coordinate system
 
olb::Vector< T, 3 > _axisDirection
 direction of the axis along which the polar coordinates are calculated
 
olb::Vector< T, 3 > _orientation
 direction to know orientation for math positive to obtain angle phi of Cartesian point x
 

Additional Inherited Members

- Public Types inherited from olb::AnalyticalF< D, T, S >
using identity_functor_type = AnalyticalIdentity<D,T,S>
 
- Public Types inherited from olb::GenericF< T, S >
using targetType = T
 
using sourceType = S
 
- Public Attributes inherited from olb::GenericF< T, S >
std::shared_ptr< GenericF< T, S > > _ptrCalcC
 memory management, frees resouces (calcClass)
 
- Static Public Attributes inherited from olb::AnalyticalF< D, T, S >
static constexpr unsigned dim = D
 
- Protected Member Functions inherited from olb::AnalyticalF< D, T, S >
 AnalyticalF (int n)
 
- Protected Member Functions inherited from olb::GenericF< T, S >
 GenericF (int targetDim, int sourceDim)
 

Detailed Description

template<typename T, typename S>
class olb::CartesianToPolar2D< T, S >

This class converts Cartesian coordinates of point x to polar coordinates wrote into output field (output[0] = radius>= 0, output[1] = phi in [0, 2Pi).

Initial situation for the polar coordinate system is that angle phi lies in plane perpendicular to the _axisDirection and turns around the _cartesianOrigin. The radius is the distance of point x to the _axisDirection.

Definition at line 146 of file frameChangeF2D.h.

Constructor & Destructor Documentation

◆ CartesianToPolar2D() [1/2]

template<typename T , typename S >
olb::CartesianToPolar2D< T, S >::CartesianToPolar2D ( olb::Vector< T, 3 > cartesianOrigin,
olb::Vector< T, 3 > axisDirection,
olb::Vector< T, 3 > orientation = {T(1),T(),T()} )

Definition at line 211 of file frameChangeF2D.hh.

214 : AnalyticalF2D<T, S>(2),
215 _cartesianOrigin(cartesianOrigin),
216 _axisDirection(axisDirection),
217 _orientation(orientation)
218{
219 this->getName() = "const";
220}
olb::Vector< T, 3 > _cartesianOrigin
origin of the Cartesian coordinate system
olb::Vector< T, 3 > _orientation
direction to know orientation for math positive to obtain angle phi of Cartesian point x
olb::Vector< T, 3 > _axisDirection
direction of the axis along which the polar coordinates are calculated
std::string & getName()
read and write access to name
Definition genericF.hh:51

References olb::GenericF< T, S >::getName().

+ Here is the call graph for this function:

◆ CartesianToPolar2D() [2/2]

template<typename T , typename S >
olb::CartesianToPolar2D< T, S >::CartesianToPolar2D ( T cartesianOriginX,
T cartesianOriginY,
T cartesianOriginZ,
T axisDirectionX,
T axisDirectionY,
T axisDirectionZ,
T orientationX = T(1),
T orientationY = T(),
T orientationZ = T() )

Definition at line 191 of file frameChangeF2D.hh.

195 : AnalyticalF2D<T, S>(2)
196{
197 _cartesianOrigin[0] = cartesianOriginX;
198 _cartesianOrigin[1] = cartesianOriginY;
199 _cartesianOrigin[2] = cartesianOriginZ;
200
201 _axisDirection[0] = axisDirectionX;
202 _axisDirection[1] = axisDirectionY;
203 _axisDirection[2] = axisDirectionZ;
204
205 _orientation[0] = orientationX;
206 _orientation[1] = orientationY;
207 _orientation[2] = orientationZ;
208}

References olb::CartesianToPolar2D< T, S >::_axisDirection, olb::CartesianToPolar2D< T, S >::_cartesianOrigin, and olb::CartesianToPolar2D< T, S >::_orientation.

Member Function Documentation

◆ operator()()

template<typename T , typename S >
bool olb::CartesianToPolar2D< T, S >::operator() ( T output[],
const S x[] )
overridevirtual

operator writes polar coordinates of Cartesian point x into output field, returns output[0] = radius ( >= 0 ), output[1] = phi in [0, 2Pi)

Implements olb::GenericF< T, S >.

Definition at line 225 of file frameChangeF2D.hh.

226{
227 //Vector<T, 3> x_rot(x[this->getSourceDim()]); //// CAUSES ERROR
228 int dim = this->getSourceDim();
229 //std::cout<<"Source dim return: "<<dim<<std::endl; //sourceDim = 2
230 Vector<T, 3> x_rot;
231 for (int i = 0; i < dim; ++i) {
232 x_rot[i] = x[i];
233 }
234 Vector<T, 3> e3(T(), T(), 1);
235 Vector<T, 3> axisDirection(_axisDirection);
236
237 Vector<T, 3> normal = crossProduct3D(axisDirection, e3);
238 Vector<T, 3> normalAxisDir(axisDirection);
239 normalAxisDir = normalize(normalAxisDir);
240
241 // if axis has to be rotated
242 if (!( util::nearZero(normalAxisDir[0]) && util::nearZero(normalAxisDir[1]) && util::nearZero(normalAxisDir[2]-1) ) ) {
243
245 normal = _orientation;
246 }
247
248 // normal is orientation direction
249 AngleBetweenVectors3D<T, S> angle(util::fromVector3(e3), util::fromVector3(normal));
250 T tmp[3] = {_axisDirection[0],_axisDirection[1],_axisDirection[2]};
251 T alpha[1] = {};
252 angle(alpha, tmp);
253
254 // cross is rotation axis
255 //Vector<T, 3> cross = crossProduct3D(e3, axisDirection);
256 // rotation with angle alpha to rotAxisDir
257 RotationRoundAxis3D<T, S> rotRAxis(_cartesianOrigin, util::fromVector3(normal), -alpha[0]);
258 T x_tmp[3] = {};
259 x_tmp[0] = x[0];
260 x_tmp[1] = x[1];
261 x_tmp[2] = x[2];
262 T tmp2[3] = {};
263 rotRAxis(tmp2,x_tmp);
264 x_rot[0] = tmp2[0];
265 x_rot[1] = tmp2[1];
266 x_rot[2] = tmp2[2];
267 }
268
269 // calculates r, phi related to cartesianAxisDirection and their origin
270 Vector<T, 2> difference;
271 difference[0] = x_rot[0] - _cartesianOrigin[0];
272 difference[1] = x_rot[1] - _cartesianOrigin[1];
273 T distance = T();
274
275 for (int i = 0; i < 2; ++i) {
276 distance += difference[i]*difference[i];
277 }
278
279 distance = util::sqrt(distance);
280 T phi[1] = {};
281
282 if (distance > T()) {
283 Vector<T, 3> e1(T(1), T(), T());
284 AngleBetweenVectors3D<T, S> angle(util::fromVector3(e1), util::fromVector3(e3));
285
286 T x_help[3] = {difference[0],difference[1],0.};
287 angle(phi, x_help);
288 }
289
290 output[0] = distance;
291 output[1] = phi[0];
292 return true;
293}
static constexpr unsigned dim
int getSourceDim() const
read only access to member variable _m
Definition genericF.hh:39
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
Definition pack.h:100
bool distance(S &distance, const Vector< S, D > &origin, const Vector< S, D > &direction, S precision, S pitch, F1 isInside, F2 isInsideBoundingBox)
std::vector< T > fromVector3(const Vector< T, 3 > &vec)
bool nearZero(const ADf< T, DIM > &a)
Definition aDiff.h:1087
constexpr T norm(const ScalarVector< T, D, IMPL > &a)
Euclidean vector norm.
constexpr Vector< T, 3 > crossProduct3D(const ScalarVector< T, 3, IMPL > &a, const ScalarVector< T, 3, IMPL_ > &b) any_platform
Definition vector.h:224
constexpr Vector< T, D > normalize(const ScalarVector< T, D, IMPL > &a, T scale=T{1})
Definition vector.h:245

References olb::crossProduct3D(), olb::util::fromVector3(), olb::util::nearZero(), olb::norm(), olb::normalize(), and olb::util::sqrt().

+ Here is the call graph for this function:

Member Data Documentation

◆ _axisDirection

template<typename T , typename S >
olb::Vector<T, 3> olb::CartesianToPolar2D< T, S >::_axisDirection
protected

direction of the axis along which the polar coordinates are calculated

Definition at line 151 of file frameChangeF2D.h.

◆ _cartesianOrigin

template<typename T , typename S >
olb::Vector<T, 3> olb::CartesianToPolar2D< T, S >::_cartesianOrigin
protected

origin of the Cartesian coordinate system

Definition at line 149 of file frameChangeF2D.h.

◆ _orientation

template<typename T , typename S >
olb::Vector<T, 3> olb::CartesianToPolar2D< T, S >::_orientation
protected

direction to know orientation for math positive to obtain angle phi of Cartesian point x

Definition at line 154 of file frameChangeF2D.h.


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