OpenLB 1.7
Searching...
No Matches
olb::Hyperplane3D< T > Struct Template Reference

Definition of a analytical 2D plane embedded in 3D space. More...

`#include <hyperplane3D.h>`

Collaboration diagram for olb::Hyperplane3D< T >:

## Public Member Functions

Hyperplane3D ()=default

Hyperplane3DoriginAt (const Vector< T, 3 > &origin)
Center the hyperplane at the given origin vector.

Hyperplane3DcenteredIn (const Cuboid3D< T > &cuboid)
Center the hyperplane relative to the given cuboid.

Hyperplane3DspannedBy (const Vector< T, 3 > &u, const Vector< T, 3 > &v)
Span the hyperplane using two span vectors.

Hyperplane3DnormalTo (const Vector< T, 3 > &normal)
Calculate the spanning vectors of the hyperplane to be orthogonal to the given normal.

Hyperplane3DapplyMatrixToSpan (const Vector< T, 3 > &row0, const Vector< T, 3 > &row1, const Vector< T, 3 > &row2)
Apply a matrix given by its row vectors to both span vectors.

Hyperplane3DrotateSpanAroundX (T r)
Rotate the spanning vectors around the X axis.

Hyperplane3DrotateSpanAroundY (T r)
Rotate the spanning vectors around the Y axis.

Hyperplane3DrotateSpanAroundZ (T r)
Rotate the spanning vectors around the Z axis.

bool isXYPlane () const

bool isXZPlane () const

bool isYZPlane () const

Vector< T, 3 > project (const Vector< T, 2 > &x) const

## Public Attributes

Vector< T, 3 > origin

Vector< T, 3 > u

Vector< T, 3 > v

Vector< T, 3 > normal

## Detailed Description

template<typename T>
struct olb::Hyperplane3D< T >

Definition of a analytical 2D plane embedded in 3D space.

Hyperplane3D defines a hyperplane using its origin and two span vectors.

In practice it might be preferable to define a hyperplane using a normal vector or to automatically center the origin in a given cuboid. For this purpose a fluent construction interface is offered:

// construct a hyperplane positioned at (1,1,1) and normal to (1,0,0)
auto plane = Hyperplane3D<T>().originAt({1,1,1})
.normalTo({1,0,0});
Definition of a analytical 2D plane embedded in 3D space.
Hyperplane3D & normalTo(const Vector< T, 3 > &normal)
Calculate the spanning vectors of the hyperplane to be orthogonal to the given normal.
Hyperplane3D & originAt(const Vector< T, 3 > &origin)
Center the hyperplane at the given origin vector.

The primary reason for this development was the increasing constructor clutter in BlockReduction3D2D: Instead of using the correct Vector<T,3> types for passing span and origin vectors they were passed as a mix between raw values and array types to prevent the constructor from becoming ambiguous. e.g. on the type level passing two span vectors is indistinguishable from passing normal and origin vectors.

Definition at line 53 of file hyperplane3D.h.

## ◆ Hyperplane3D()

template<typename T >
 olb::Hyperplane3D< T >::Hyperplane3D ( )
explicitdefault

## ◆ applyMatrixToSpan()

template<typename T >
 Hyperplane3D< T > & olb::Hyperplane3D< T >::applyMatrixToSpan ( const Vector< T, 3 > & row0, const Vector< T, 3 > & row1, const Vector< T, 3 > & row2 )

Apply a matrix given by its row vectors to both span vectors.

Returns
Hyperplane3D reference for further construction

Definition at line 107 of file hyperplane3D.hh.

111{
112 const auto u_prime = u;
113 const auto v_prime = v;
114
115 u[0] = row0 * u_prime;
116 u[1] = row1 * u_prime;
117 u[2] = row2 * u_prime;
118
119 v[0] = row0 * v_prime;
120 v[1] = row1 * v_prime;
121 v[2] = row2 * v_prime;
122
123 return *this;
124}
Vector< T, 3 > u
Vector< T, 3 > v

## ◆ centeredIn()

template<typename T >
 Hyperplane3D< T > & olb::Hyperplane3D< T >::centeredIn ( const Cuboid3D< T > & cuboid )

Center the hyperplane relative to the given cuboid.

Returns
Hyperplane3D reference for further construction

Definition at line 90 of file hyperplane3D.hh.

91{
92 const Vector<T,3>& cuboidOrigin = cuboid.getOrigin();
93 const Vector<int,3>& extend = cuboid.getExtent();
94 const T deltaR = cuboid.getDeltaR();
95
96 origin[0] = (cuboidOrigin[0] + 0.5 * deltaR * extend[0]);
97 origin[1] = (cuboidOrigin[1] + 0.5 * deltaR * extend[1]);
98 origin[2] = (cuboidOrigin[2] + 0.5 * deltaR * extend[2]);
99 origin[0] -= 2*std::numeric_limits<T>::epsilon()*util::fabs(origin[0]);
100 origin[1] -= 2*std::numeric_limits<T>::epsilon()*util::fabs(origin[1]);
101 origin[2] -= 2*std::numeric_limits<T>::epsilon()*util::fabs(origin[2]);
102
103 return *this;
104}
cpu::simd::Pack< T > fabs(cpu::simd::Pack< T > value)
Definition pack.h:106
Vector< T, 3 > origin
Here is the call graph for this function:

## ◆ isXYPlane()

template<typename T >
 bool olb::Hyperplane3D< T >::isXYPlane ( ) const
Returns
true iff normal is orthogonal to X, Y axis

Definition at line 158 of file hyperplane3D.hh.

159{
160 return util::nearZero(util::dotProduct3D(normal, {1,0,0})) &&
162}
T dotProduct3D(const Vector< T, 3 > &a, const Vector< T, 3 > &b)
dot product, only valid in 3d
bool nearZero(const ADf< T, DIM > &a)
Vector< T, 3 > normal

References olb::util::dotProduct3D(), and olb::util::nearZero().

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

## ◆ isXZPlane()

template<typename T >
 bool olb::Hyperplane3D< T >::isXZPlane ( ) const
Returns
true iff normal is orthogonal to X, Z axis

Definition at line 165 of file hyperplane3D.hh.

166{
167 return util::nearZero(util::dotProduct3D(normal, {1,0,0})) &&
169}

References olb::util::dotProduct3D(), and olb::util::nearZero().

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

## ◆ isYZPlane()

template<typename T >
 bool olb::Hyperplane3D< T >::isYZPlane ( ) const
Returns
true iff normal is orthogonal to Y, Z axis

Definition at line 172 of file hyperplane3D.hh.

173{
174 return util::nearZero(util::dotProduct3D(normal, {0,1,0})) &&
176}

References olb::util::dotProduct3D(), and olb::util::nearZero().

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

## ◆ normalTo()

template<typename T >
 Hyperplane3D< T > & olb::Hyperplane3D< T >::normalTo ( const Vector< T, 3 > & normal )

Calculate the spanning vectors of the hyperplane to be orthogonal to the given normal.

Returns
Hyperplane3D reference for further construction

Definition at line 49 of file hyperplane3D.hh.

50{
51 normal = n;
52
53 if ( util::nearZero(normal[0]*normal[1]*normal[2]) ) {
54 if ( util::nearZero(normal[0]) ) {
55 u = {T(1), T(), T()};
56 }
57 else if ( util::nearZero(normal[1]) ) {
58 u = {T(), T(1), T()};
59 }
60 else if ( util::nearZero(normal[2]) ) {
61 u = {T(), T(), T(1)};
62 }
63 }
64 else {
65 u = {normal[2], T(), -normal[0]};
66 }
67
69 u = normalize(u);
71
75
76 return *this;
77}
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
#define OLB_POSTCONDITION(COND)
Definition olbDebug.h:47
Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ originAt()

template<typename T >
 Hyperplane3D< T > & olb::Hyperplane3D< T >::originAt ( const Vector< T, 3 > & origin )

Center the hyperplane at the given origin vector.

Returns
Hyperplane3D reference for further construction

Definition at line 80 of file hyperplane3D.hh.

81{
82 origin[0] = o[0] - 2*std::numeric_limits<T>::epsilon()*util::fabs(o[0]);
83 origin[1] = o[1] - 2*std::numeric_limits<T>::epsilon()*util::fabs(o[1]);
84 origin[2] = o[2] - 2*std::numeric_limits<T>::epsilon()*util::fabs(o[2]);
85
86 return *this;
87}

References olb::util::fabs().

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

## ◆ project()

template<typename T >
 Vector< T, 3 > olb::Hyperplane3D< T >::project ( const Vector< T, 2 > & x ) const
Returns
2D vector relative to origin projected to 3D

Definition at line 179 of file hyperplane3D.hh.

180{
181 return origin + x[0]*u + x[1]*v;
182}

## ◆ rotateSpanAroundX()

template<typename T >
 Hyperplane3D< T > & olb::Hyperplane3D< T >::rotateSpanAroundX ( T r )

Rotate the spanning vectors around the X axis.

Returns
Hyperplane3D reference for further construction

Definition at line 127 of file hyperplane3D.hh.

128{
129 return applyMatrixToSpan(
130 {1, 0, 0 },
131 {0, util::cos(r), -util::sin(r)},
132 {0, util::sin(r), util::cos(r)}
133 );
134
135}
Hyperplane3D & applyMatrixToSpan(const Vector< T, 3 > &row0, const Vector< T, 3 > &row1, const Vector< T, 3 > &row2)
Apply a matrix given by its row vectors to both span vectors.

References olb::util::cos(), and olb::util::sin().

Here is the call graph for this function:

## ◆ rotateSpanAroundY()

template<typename T >
 Hyperplane3D< T > & olb::Hyperplane3D< T >::rotateSpanAroundY ( T r )

Rotate the spanning vectors around the Y axis.

Returns
Hyperplane3D reference for further construction

Definition at line 138 of file hyperplane3D.hh.

139{
140 return applyMatrixToSpan(
141 { util::cos(r), 0, util::sin(r)},
142 { 0, 1, 0 },
143 {-util::sin(r), 0, util::cos(r)}
144 );
145}

References olb::util::cos(), and olb::util::sin().

Here is the call graph for this function:

## ◆ rotateSpanAroundZ()

template<typename T >
 Hyperplane3D< T > & olb::Hyperplane3D< T >::rotateSpanAroundZ ( T r )

Rotate the spanning vectors around the Z axis.

Returns
Hyperplane3D reference for further construction

Definition at line 148 of file hyperplane3D.hh.

149{
150 return applyMatrixToSpan(
151 {util::cos(r), -util::sin(r), 0},
152 {util::sin(r), util::cos(r), 0},
153 {0, 0, 1}
154 );
155}

References olb::util::cos(), and olb::util::sin().

Here is the call graph for this function:

## ◆ spannedBy()

template<typename T >
 Hyperplane3D< T > & olb::Hyperplane3D< T >::spannedBy ( const Vector< T, 3 > & u, const Vector< T, 3 > & v )

Span the hyperplane using two span vectors.

Returns
Hyperplane3D reference for further construction

Definition at line 35 of file hyperplane3D.hh.

36{
37 u = a;
38 v = b;
40
44
45 return *this;
46}
Here is the call graph for this function:

## ◆ normal

template<typename T >
 Vector olb::Hyperplane3D< T >::normal

Definition at line 57 of file hyperplane3D.h.

## ◆ origin

template<typename T >
 Vector olb::Hyperplane3D< T >::origin

Definition at line 54 of file hyperplane3D.h.

## ◆ u

template<typename T >
 Vector olb::Hyperplane3D< T >::u

Definition at line 55 of file hyperplane3D.h.

## ◆ v

template<typename T >
 Vector olb::Hyperplane3D< T >::v

Definition at line 56 of file hyperplane3D.h.

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