OpenLB 1.7
Loading...
Searching...
No Matches
hyperplane2D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2018 Adrian Kummerlaender
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef HYPERPLANE_2D_HH
25#define HYPERPLANE_2D_HH
26
27#include "hyperplane2D.h"
28#include "core/olbDebug.h"
30
31namespace olb {
32
33
34template <typename T>
36{
37 origin[0] = o[0] - 2*std::numeric_limits<T>::epsilon()*util::fabs(o[0]);
38 origin[1] = o[1] - 2*std::numeric_limits<T>::epsilon()*util::fabs(o[1]);
39
40 return *this;
41}
42
43template <typename T>
45{
46 const Vector<T,2>& cuboidOrigin = cuboid.getOrigin();
47 const Vector<int,2>& extend = cuboid.getExtent();
48 const T deltaR = cuboid.getDeltaR();
49
50 origin[0] = (cuboidOrigin[0] + 0.5 * deltaR * extend[0]);
51 origin[1] = (cuboidOrigin[1] + 0.5 * deltaR * extend[1]);
52 origin[0] -= 2*std::numeric_limits<T>::epsilon()*util::fabs(origin[0]);
53 origin[1] -= 2*std::numeric_limits<T>::epsilon()*util::fabs(origin[1]);
54
55 return *this;
56}
57
58template <typename T>
60{
61 u = direction;
62 normal = normalize(Vector<T,2>({ u[1], -u[0] }));
63
65
66 return *this;
67}
68
69template <typename T>
71{
72 normal = n;
73
74 if ( util::nearZero(normal[0]*normal[1]) ) {
75 if ( util::nearZero(normal[0]) ) {
76 u = {T(1), T()};
77 }
78 else if ( util::nearZero(normal[1]) ) {
79 u = {T(), T(1)};
80 }
81 }
82 else {
83 u = {normal[1], -normal[0]};
84 }
85
86 u = normalize(u);
87 normal = normalize(normal);
88
90
91 return *this;
92}
93
94template <typename T>
96{
97 return util::nearZero(util::dotProduct2D(normal, {1,0}));
98}
99
100template <typename T>
102{
103 return util::nearZero(util::dotProduct2D(normal, {0,1}));
104}
105
106
107}
108
109#endif
A regular single 2D cuboid is the basic component of a 2D cuboid structure which defines the grid.
Definition cuboid2D.h:54
Vector< int, 2 > const getExtent() const
Read only access to the number of voxels in every dimension.
Definition cuboid2D.hh:124
T getDeltaR() const
Read access to the distance of cuboid nodes.
Definition cuboid2D.hh:106
Vector< T, 2 > const getOrigin() const
Read only access to left lower corner coordinates.
Definition cuboid2D.hh:100
Plain old scalar vector.
Definition vector.h:47
cpu::simd::Pack< T > fabs(cpu::simd::Pack< T > value)
Definition pack.h:106
bool nearZero(const ADf< T, DIM > &a)
Definition aDiff.h:1087
T dotProduct2D(const Vector< T, 2 > &a, const Vector< T, 2 > &b)
dot product, only valid in 2d
Top level namespace for all of OpenLB.
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
Definition of a analytical line embedded in 2D space.
Hyperplane2D & parallelTo(const Vector< T, 2 > &direction)
Set the direction of the line parallel to a vector.
bool isParallelToY() const
Hyperplane2D & centeredIn(const Cuboid2D< T > &cuboid)
Center the line relative to the given cuboid.
Hyperplane2D & originAt(const Vector< T, 2 > &origin)
Center the line at the given origin vector.
bool isParallelToX() const
Hyperplane2D & normalTo(const Vector< T, 2 > &normal)
Calculate the direction vector of the line to be orthogonal to the given normal.