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

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

#include <frameChangeF3D.h>

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

Public Member Functions

 CartesianToSpherical3D (std::vector< T > cartesianOrigin, std::vector< T > axisDirection)
 
bool operator() (T output[], const S x[]) override
 operator writes shperical coordinates of Cartesian point x into output field, output[0] = radius ( >= 0), output[1] = phi (in [0, 2Pi)), output[2] = theta (in [0, Pi])
 
- 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

std::vector< T > _cartesianOrigin
 origin of the Cartesian coordinate system
 
std::vector< T > _axisDirection
 direction of the axis along which the spherical coordinates are calculated
 

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::CartesianToSpherical3D< T, S >

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

Initial situation for the spherical coordinate system is that angle phi lies in x-y-plane and theta in x-z-plane. The z axis is the orientation for the mathematical positive sense of phi.

Definition at line 472 of file frameChangeF3D.h.

Constructor & Destructor Documentation

◆ CartesianToSpherical3D()

template<typename T , typename S >
olb::CartesianToSpherical3D< T, S >::CartesianToSpherical3D ( std::vector< T > cartesianOrigin,
std::vector< T > axisDirection )

Definition at line 1089 of file frameChangeF3D.hh.

1091 : AnalyticalF3D<T, S>(3),
1092 _cartesianOrigin(cartesianOrigin),
1093 _axisDirection(axisDirection)
1094{
1095 this->getName() = "const";
1096}
std::vector< T > _axisDirection
direction of the axis along which the spherical coordinates are calculated
std::vector< T > _cartesianOrigin
origin of the Cartesian coordinate system
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:

Member Function Documentation

◆ operator()()

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

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

Implements olb::GenericF< T, S >.

Definition at line 1101 of file frameChangeF3D.hh.

1102{
1103 T x_rot[3] = {T(),T(),T()};
1104 x_rot[0] = x[0];
1105 x_rot[1] = x[1];
1106 x_rot[2] = x[2];
1107
1108 Vector<T,3> axisDirection(_axisDirection);
1109 Vector<T,3> e3(T(), T(), T(1));
1110 Vector<T,3> normal = crossProduct3D(axisDirection,e3);
1111
1112 Vector<T,3> normalAxisDir = axisDirection;
1113 normalAxisDir = normalize(normalAxisDir);
1114 Vector<T,3> cross;
1115 // if axis has to be rotated
1116 if ( !( util::nearZero(normalAxisDir[0]) && util::nearZero(normalAxisDir[1]) && util::nearZero(normalAxisDir[2]-1) ) ) {
1117 AngleBetweenVectors3D<T, S> angle(util::fromVector3(e3), util::fromVector3(normal));
1118 T tmp[3] = {T(),T(),T()};
1119 for (int i=0; i<3; ++i) {
1120 tmp[i] = axisDirection[i];
1121 }
1122 T alpha[1] = {T(0)};
1123 angle(alpha,tmp);
1124 // cross is rotation axis
1125 cross = crossProduct3D(e3, axisDirection);
1126 // rotation with angle alpha to (0,0,1)
1127 RotationRoundAxis3D<T, S> rotRAxis(_cartesianOrigin, util::fromVector3(normal), -alpha[0]);
1128 rotRAxis(x_rot,x);
1129 }
1130
1131 CartesianToPolar2D<T, S> car2pol(_cartesianOrigin, util::fromVector3(e3), util::fromVector3(cross));
1132 // y[0] = car2pol(x_rot)[0];
1133 Vector<T, 3> difference;
1134
1135 for (int i=0; i<3; ++i) {
1136 difference[i] = x_rot[i] - _cartesianOrigin[i];
1137 }
1138
1139 T distance = T();
1140 for (int i = 0; i <= 2; ++i) {
1141 distance += difference[i]*difference[i];
1142 }
1143 distance = util::sqrt(distance);
1144
1145 car2pol(output, x_rot);
1146 output[0] = distance;
1147 output[2] = util::acos(difference[2]/output[0]); // angle between z-axis and r-vector
1148
1149 return true; // output[0] = radius, output[1] = phi, output[2] = theta
1150}
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)
ADf< T, DIM > acos(const ADf< T, DIM > &a)
Definition aDiff.h:605
bool nearZero(const ADf< T, DIM > &a)
Definition aDiff.h:1087
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::util::acos(), olb::crossProduct3D(), olb::util::fromVector3(), olb::util::nearZero(), olb::normalize(), and olb::util::sqrt().

+ Here is the call graph for this function:

Member Data Documentation

◆ _axisDirection

template<typename T , typename S >
std::vector<T> olb::CartesianToSpherical3D< T, S >::_axisDirection
protected

direction of the axis along which the spherical coordinates are calculated

Definition at line 477 of file frameChangeF3D.h.

◆ _cartesianOrigin

template<typename T , typename S >
std::vector<T> olb::CartesianToSpherical3D< T, S >::_cartesianOrigin
protected

origin of the Cartesian coordinate system

Definition at line 475 of file frameChangeF3D.h.


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