VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
GbHalfSpace3D.cpp
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
33//=======================================================================================
35
36using namespace std;
37
38/*==========================================================*/
40{
41 GbPoint3D *PointA = triangle->getPoint1();
42 GbPoint3D *PointB = triangle->getPoint2();
43 GbPoint3D *PointC = triangle->getPoint3();
44
45 GbVector3D A(PointA->x1, PointA->x2, PointA->x3);
46 GbVector3D BA(PointB->x1 - PointA->x1, PointB->x2 - PointA->x2, PointB->x3 - PointA->x3);
47 GbVector3D CA(PointC->x1 - PointA->x1, PointC->x2 - PointA->x2, PointC->x3 - PointA->x3);
49 // this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize();
51 // this->Normal = BACA;
52 normalX = BACA[0];
53 normalY = BACA[1];
54 normalZ = BACA[2];
55 // this->d = this->Normal.Dot(A);
56 this->d = normalX * A[0] + normalY * A[1] + normalZ * A[2];
57}
58/*==========================================================*/
60{
61 GbVector3D A(PointA->x1, PointA->x2, PointA->x3);
62 GbVector3D BA(PointB->x1 - PointA->x1, PointB->x2 - PointA->x2, PointB->x3 - PointA->x3);
63 GbVector3D CA(PointC->x1 - PointA->x1, PointC->x2 - PointA->x2, PointC->x3 - PointA->x3);
65 // this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize();
67 // this->Normal = BACA;
68 normalX = BACA[0];
69 normalY = BACA[1];
70 normalZ = BACA[2];
71 // this->d = this->Normal.Dot(A);
72 this->d = normalX * A[0] + normalY * A[1] + normalZ * A[2];
73}
74/*==========================================================*/
76{
77 GbVector3D A(PointA->x1, PointA->x2, PointA->x3);
78 GbVector3D B(PointB->x1, PointB->x2, PointB->x3);
79 GbVector3D K(0.0, 0.0, 0.99); // the vector from PointA - third point
80
84
85 // this->Normal = PointBAK;
86 normalX = PointBAK[0];
87 normalY = PointBAK[1];
88 normalZ = PointBAK[2];
89
90 // this->d = this->Normal.Dot(A);
91 this->d = normalX * PointA->x1 + normalY * PointA->x2 + normalZ * PointA->x3;
92}
93/*==========================================================*/
94GbHalfSpace3D::GbHalfSpace3D(const double &p1x, const double &p1y, const double &p1z, const double &p2x,
95 const double &p2y, const double &p2z, const double &p3x, const double &p3y,
96 const double &p3z)
97{
98 double p2minusP1x = p2x - p1x;
99 double p2minusP1y = p2y - p1y;
100 double p2minusP1z = p2z - p1z;
101
102 double P3minusP1x = p3x - p1x;
103 double P3minusP1y = p3y - p1y;
104 double P3minusP1z = p3z - p1z;
105
106 // normal = BA x CA
110
111 // normalize BACA
112 double oneOverNormalLength = 1.0 / (std::sqrt(normalX * normalX + normalY * normalY + normalZ * normalZ));
113 normalX *= oneOverNormalLength;
114 normalY *= oneOverNormalLength;
115 normalZ *= oneOverNormalLength;
116
117 // d = normal * p1
118 this->d = normalX * p1x + normalY * p1y + normalZ * p1z;
119}
120/*==========================================================*/
121GbHalfSpace3D::GbHalfSpace3D(const double &p1x, const double &p1y, const double &p1z, const double &nx,
122 const double &ny, const double &nz)
123{
124 // normal = BA x CA
125 normalX = nx;
126 normalY = ny;
127 normalZ = nz;
128
129 // d = normal * p1
130 this->d = nx * p1x + ny * p1y + nz * p1z;
131}
132/*==========================================================*/
133
This Class provides basic 3D point objects.
Definition GbPoint3D.h:49
This Class provides basic 3D triangle objects.
This Class provides basic 3D vector objects.
Definition GbVector3D.h:47
std::shared_ptr< T > SPtr
GbVector3D Cross(const GbVector3D &rkV) const
GbHalfSpace3D(GbTriangle3D *triangle)
double Normalize()
const uint ny
const uint nz
const uint nx