OpenLB 1.8.1
Loading...
Searching...
No Matches
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 511 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 1115 of file frameChangeF3D.hh.

1118 _cartesianOrigin(cartesianOrigin),
1119 _axisDirection(axisDirection)
1120{
1121 this->getName() = "const";
1122}
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
AnalyticalF< 3, T, S > AnalyticalF3D

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 1127 of file frameChangeF3D.hh.

1128{
1129 T x_rot[3] = {T(),T(),T()};
1130 x_rot[0] = x[0];
1131 x_rot[1] = x[1];
1132 x_rot[2] = x[2];
1133
1134 Vector<T,3> axisDirection(_axisDirection);
1135 Vector<T,3> e3(T(), T(), T(1));
1136 Vector<T,3> normal = crossProduct3D(axisDirection,e3);
1137
1138 Vector<T,3> normalAxisDir = axisDirection;
1139 normalAxisDir = normalize(normalAxisDir);
1140 Vector<T,3> cross;
1141 // if axis has to be rotated
1142 if ( !( util::nearZero(normalAxisDir[0]) && util::nearZero(normalAxisDir[1]) && util::nearZero(normalAxisDir[2]-1) ) ) {
1143 AngleBetweenVectors3D<T, S> angle(util::fromVector3(e3), util::fromVector3(normal));
1144 T tmp[3] = {T(),T(),T()};
1145 for (int i=0; i<3; ++i) {
1146 tmp[i] = axisDirection[i];
1147 }
1148 T alpha[1] = {T(0)};
1149 angle(alpha,tmp);
1150 // cross is rotation axis
1151 cross = crossProduct3D(e3, axisDirection);
1152 // rotation with angle alpha to (0,0,1)
1153 RotationRoundAxis3D<T, S> rotRAxis(_cartesianOrigin, util::fromVector3(normal), -alpha[0]);
1154 rotRAxis(x_rot,x);
1155 }
1156
1157 CartesianToPolar2D<T, S> car2pol(_cartesianOrigin, util::fromVector3(e3), util::fromVector3(cross));
1158 // y[0] = car2pol(x_rot)[0];
1159 Vector<T, 3> difference;
1160
1161 for (int i=0; i<3; ++i) {
1162 difference[i] = x_rot[i] - _cartesianOrigin[i];
1163 }
1164
1165 T distance = T();
1166 for (int i = 0; i <= 2; ++i) {
1167 distance += difference[i]*difference[i];
1168 }
1169 distance = util::sqrt(distance);
1170
1171 car2pol(output, x_rot);
1172 output[0] = distance;
1173 output[2] = util::acos(difference[2]/output[0]); // angle between z-axis and r-vector
1174
1175 return true; // output[0] = radius, output[1] = phi, output[2] = theta
1176}
Distribution< T > normal(T mean, T stddev)
bool distance(S &distance, const Vector< S, D > &origin, const Vector< S, D > &direction, S precision, S pitch, F1 isInside, F2 isInsideBoundingBox)
Expr sqrt(Expr x)
Definition expr.cpp:225
std::vector< T > fromVector3(const Vector< T, 3 > &vec)
ADf< T, DIM > acos(const ADf< T, DIM > &a)
Definition aDiff.h:605
bool nearZero(T a) any_platform
return true if a is close to zero
Definition util.h:402
constexpr Vector< T, 3 > crossProduct3D(const ScalarVector< T, 3, IMPL > &a, const ScalarVector< T, 3, IMPL_ > &b) any_platform
Definition vector.h:263
constexpr Vector< T, D > normalize(const ScalarVector< T, D, IMPL > &a, T scale=T{1})
Definition vector.h:284

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 516 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 514 of file frameChangeF3D.h.


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