VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
GbCylinderImplicit.h
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//=======================================================================================
34#ifndef GbCylinderImplicit_H
35#define GbCylinderImplicit_H
36
37#include <functional>
38#include <tuple>
39#ifdef VF_BOOST
40
41#include <vector>
42
43#include <GbPoint3D.h>
46
47#define _USE_MATH_DEFINES
48#include <cmath>
49#include <math.h>
50
51class GbLine3D;
53
54#include <PointerDefinitions.h>
57
58
59class GbCylinderImplicit : public GbObject3D, public UbObserver
60{
61public:
63 GbCylinderImplicit(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b, const double& dx, const double& OuterRadius, const double& InnerRadius=0);
66
67 GbCylinderImplicit* clone() override { return new GbCylinderImplicit(this); }
68 void finalize() override { throw UbException(UB_EXARGS, "finalize() - not implemented"); }
69
70 double getX1Centroid() override;
71 double getX1Minimum() override;
72 double getX1Maximum() override;
73 double getX2Centroid()override;
74 double getX2Minimum() override;
75 double getX2Maximum() override;
76 double getX3Centroid()override;
77 double getX3Minimum() override;
78 double getX3Maximum() override;
79 void setCenterCoordinates(const double &x1, const double &x2, const double &x3) override {throw UbException(UB_EXARGS, "finalize() - not implemented");
80 }
81
82 void translate(const double& x1, const double& x2, const double& x3) override { throw UbException(UB_EXARGS, "finalize() - not implemented"); }
83 void rotate(const double& rx1, const double& rx2, const double& rx3) override{ throw UbException(UB_EXARGS, "finalize() - not implemented"); }
84 void scale(const double& sx1, const double& sx2, const double& sx3) override { throw UbException(UB_EXARGS, "finalize() - not implemented"); }
85
86 double getLengthX1();
87 double getLengthX2();
88 double getLengthX3();
89
90 bool isPointInGbObject3D(const double &x1p, const double &x2p, const double &x3p, bool &pointinboundary) override;
91 bool isPointInGbObject3D(const double &x1p, const double &x2p, const double &x3p) override;
92 bool isCellInsideGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b,
93 const double &x2b, const double &x3b) override;
94 bool isCellCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b,
95 const double &x2b, const double &x3b) override;
96 bool isCellInsideOrCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b,
97 const double &x2b, const double &x3b) override;
98 double getCellVolumeInsideGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b,
99 const double &x2b, const double &x3b) override { throw UbException(UB_EXARGS, "finalize() - not implemented"); }
100 GbPoint3D *calculateInterSectionPoint3D(GbPoint3D &point1, GbPoint3D &point2);
101 GbLine3D *createClippedLine3D (GbPoint3D &point1, GbPoint3D &point2) override { throw UbException(UB_EXARGS, "finalize() - not implemented"); }
102 std::vector<GbTriangle3D *> getSurfaceTriangleSet() override { throw UbException(UB_EXARGS, "finalize() - not implemented"); }
103 void addSurfaceTriangleSet(std::vector<UbTupleFloat3> &nodes, std::vector<UbTupleInt3> &triangles) override { throw UbException(UB_EXARGS, "finalize() - not implemented"); }
104 bool hasRaytracing() override { return true; }
105 double getIntersectionRaytraceFactor (const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) override;
106 //double evaluateImplicitFunction(const double & x1, const double & x2, const double & x3);
107 double getDistance(const double& x1p, const double& x2p, const double& x3p) { throw UbException(UB_EXARGS, "finalize() - not implemented"); }
108 std::string toString() override { throw UbException(UB_EXARGS, "finalize() - not implemented"); }
109 void objectChanged(UbObservable *changedObject) override;
110 void objectWillBeDeleted(UbObservable *objectForDeletion) override;
112
113protected:
114 GbPoint3D* p1;
115 GbPoint3D* p2;
116 GbPoint3D* p3;
117 GbPoint3D* p4;
118 double dx, InnerRadius, OuterRadius;
119 double e1x,e1y,e1z;
120 double e2x,e2y,e2z;
122
123
124
125private:
126/*=======================================================*/
128 bool operator() (double min, double max) {
129 return abs(min - max) <= 10e-10;
130 }
131};
132/*=======================================================*/
134 double x, y, z;
135 double x0, y0, z0;
136 double x1, y1, z1;
137 double nx, ny, nz;
138 double r,q,dir1,dir2,dir3, l,delx,dely,delz,R;
139
140 void init(){
141 dir1=dir2=dir3=0;
142 delx=x1-x0;
143 dely=y1-y0;
144 delz=z1-z0;
145 l = sqrt(pow(delx,2) + pow(dely,2) + pow(delz,2));
146 nx = delx/l;
147 ny = dely/l;
148 nz = delz/l;
149 }
150
151 std::function<double(double)> heaviside = [](double value) {return value >= 0 ? 1.0 : 0.0; };
152
153 std::function<double(double)> f1 = [=](double q) {
154 return
155 1.-(1-heaviside(-sqrt(pow(dir1*q + x - x0,2) + pow(dir2*q + y - y0,2) + pow(dir3*q + z - z0,2)) +
156 sqrt(pow(r,2) + pow((dir1*q + x - x0)*(-delx) + (dir2*q + y - y0)*(-dely) + (dir3*q + z - z0)*(-delz),2)/(l*l))))
157 *(1-heaviside(sqrt(pow(dir1*q + x - x0,2) + pow(dir2*q + y - y0,2) + pow(dir3*q + z - z0,2)) -
158 sqrt(pow(R,2) + pow((dir1*q + x - x0)*(-delx) + (dir2*q + y - y0)*(-dely) + (dir3*q + z - z0)*(-delz),2)/(l*l))))
159 *(heaviside((dir1*q + x - x0)*nx + (dir2*q + y - y0)*ny + (dir3*q + z - z0)*nz))
160 *(1-heaviside((dir1*q + x - x1)*nx + (dir2*q + y - y1)*ny + (dir3*q + z - z1)*nz))
161 -0.5
162 ;
163 };
164
165// std::function<double(double)> f1 = [=](double q) {return 0.5 - (-1 + heaviside(-sqrt(pow(dir1*q + x - x0,2) + pow(dir2*q + y - y0,2) + pow(dir3*q + z - z0,2)) +
166// sqrt(pow(r,2) + pow((dir1*q + x - x0)*(x0 - x1) + (dir2*q + y - y0)*(y0 - y1) + (dir3*q + z - z0)*(z0 - z1),2)/
167// (l*l))))*(-1 +
168// heaviside(sqrt(pow(dir1*q + x - x0,2) + pow(dir2*q + y - y0,2) + pow(dir3*q + z - z0,2)) -
169// sqrt(pow(R,2) + pow((dir1*q + x - x0)*(x0 - x1) + (dir2*q + y - y0)*(y0 - y1) + (dir3*q + z - z0)*(z0 - z1),2)/
170// (l*l))));};
171
172 //std::function<double(double)> f1 = [=](double q) {return pow((x+q*dir1) - x0,2) + pow((y+q*dir2) - y0,2) + pow((z+q*dir3) - z0,2) -
173 //(pow(r,2) + pow(((x+q*dir1) - x0)*(x0 - x1) + ((y+q*dir2) - y0)*(y0 - y1) + ((z+q*dir3) - z0)*(z0 - z1),2)/(l*l));
174 //};
175
176 // std::function<double(double)> f2 = [=](double q){return ( -((x+q*dir1 - x0)*nx + (y+q*dir2 - y0)*ny + (z+q*dir3 - z0)*nz)) ;};
177
178 //std::function<double(double)> f3 = [=](double q){return ( ((x+q*dir1 - x1)*nx + (y+q*dir2 - y1)*ny + (z+q*dir3 - z1)*nz));};
179
180 // std::function<double(double)> f2 = [=](double q){return ((x + q *dir1)*(-nx) + (y + q *dir2)*(-ny) + (z + q *dir3)*(-nz))-
181 // abs(x0*(-nx) + y0*(-ny) + z0*(-nz) );};
182
183
184
185};
186
188};
189
190
191
192#endif
193#endif
194
This Class provides basic 3D line objects.
Definition GbLine3D.h:59
This Interface provides basic 3D geometry objects methods.
Definition GbObject3D.h:64
This Class provides basic 3D point objects.
Definition GbPoint3D.h:49
Observable object.
Observer.
Definition UbObserver.h:51
std::shared_ptr< T > SPtr
virtual bool isPointInGbObject3D(GbPoint3D *p)
@ z
Definition Axis.h:44
@ x
Definition Axis.h:42
@ y
Definition Axis.h:43
const real dx
const uint ny
const uint nz
const uint nx
#define UB_EXARGS
Definition UbException.h:73
double getDistance(const GbPoint3D &p11, const GbPoint3D &p12)
std::string toString(const T &x, int precision=15)
Definition UbSystem.h:199