VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
GbSphere3D.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 GBSPHERE3D_H
35#define GBSPHERE3D_H
36
37#ifdef CAB_CTL
38#include <ctl.h>
39#endif // CAB_CTL
40
41#include <cmath>
42#include <vector>
43
45
48
49#include <PointerDefinitions.h>
50
51class GbLine3D;
52class GbTriangle3D;
54
55class GbSphere3D : public GbObject3D, public UbObserver
56{
57public:
59
61 // Konstruktoren
62 GbSphere3D();
63 GbSphere3D(const double &x1, const double &x2, const double &x3, const double &radius);
65 GbSphere3D(GbSphere3D *sphere); //<-unschoen!
66
67 ~GbSphere3D() override;
68
69 GbSphere3D *clone() override { return new GbSphere3D(*this); }
70 void finalize() override;
71
73
74 double getRadius() const { return this->radius; }
75
76 double getX1Centroid() override { return midPoint->getX1Coordinate(); }
77 double getX1Minimum() override { return midPoint->getX1Coordinate() - radius; }
78 double getX1Maximum() override { return midPoint->getX1Coordinate() + radius; }
79 double getX2Centroid() override { return midPoint->getX2Coordinate(); }
80 double getX2Minimum() override { return midPoint->getX2Coordinate() - radius; }
81 double getX2Maximum() override { return midPoint->getX2Coordinate() + radius; }
82 double getX3Centroid() override { return midPoint->getX3Coordinate(); }
83 double getX3Minimum() override { return midPoint->getX3Coordinate() - radius; }
84 double getX3Maximum() override { return midPoint->getX3Coordinate() + radius; }
85
86 void setCenterX1Coordinate(const double &value) override;
87 void setCenterX2Coordinate(const double &value) override;
88 void setCenterX3Coordinate(const double &value) override;
89 void setCenterCoordinates(const double &x1, const double &x2, const double &x3) override;
90 void setCenterCoordinates(const UbTupleDouble3 &position) override;
91 void setRadius(const double &radius);
92
94 double getDistance(GbPoint3D *p);
95 double getDistance(const double &x1p, const double &x2p, const double &x3p);
96
97 bool isPointInGbObject3D(const double &x1, const double &x2, const double &x3) override;
98 bool isPointInGbObject3D(const double &x1p, const double &x2p, const double &x3p, bool &pointIsOnBoundary) override;
99
100 bool isCellCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b,
101 const double &x2b, const double &x3b) override;
102 bool isCellInsideOrCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b,
103 const double &x2b, const double &x3b) override;
104 double getCellVolumeInsideGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b,
105 const double &x2b, const double &x3b) override;
106 double getCellVolumeInsideGbObject3DHelperFunction(const double &x1a, const double &x2a, const double &x3a,
107 const double &x1b, const double &x2b, const double &x3b);
108
109 std::vector<GbTriangle3D *> getSurfaceTriangleSet() override;
110 void addSurfaceTriangleSet(std::vector<UbTupleFloat3> &nodes, std::vector<UbTupleInt3> &triangles) override;
111
112 bool hasRaytracing() override { return true; }
113 /*|r| must be 1! einheitsvector!!*/
114 double getIntersectionRaytraceFactor(const double &x1, const double &x2, const double &x3, const double &rx1,
115 const double &rx2, const double &rx3) override;
116
118
119 std::string toString() override;
120
121 void translate(const double &x1, const double &x2, const double &x3) override
122 {
123 this->midPoint->translate(x1, x2, x3);
125 }
126 void rotate(const double &rx1, const double &rx2, const double &rx3) override
127 { /* rotation makes no sense*/
128 }
129 void scale(const double &sx1, const double & /*sx2*/, const double & /*sx3*/) override
130 {
131 this->radius *= sx1;
133 }
134
135 void transform(const double matrix[4][4]);
136
137 TRIANGULATIONMODE getTriangulationMode() { return triangulationMode; }
138 void setTriangulationMode(TRIANGULATIONMODE mode) { this->triangulationMode = mode; }
139
140 // virtuelle Methoden von UbObserver
141 void objectChanged(UbObservable * /*changedObject*/) override
142 {
144 // std::cout<<"GbSphere:objectChanged() - toDo-);";
145 }
146 void objectWillBeDeleted(UbObservable * /*objectForDeletion*/) override
147 {
148 throw UbException(UB_EXARGS, "not implemented");
149 }
150
151 using GbObject3D::isPointInGbObject3D; // Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht
152 // ausprogrammieren, welche sonst hier "ueberdeckt" waere, weil man eine
153
154#ifdef CAB_CTL
155 ctl::oStream &write(ctl::oStream &os) const
156 {
157 midPoint->write(os);
158 return os << radius;
159 }
160 ctl::iStream &read(ctl::iStream &is)
161 {
162 midPoint->read(is);
163 return is >> radius;
164 }
165#endif // CAB_CTL
166
167private:
168 GbPoint3D *midPoint;
169 double radius; // Radius des Kreises
170 TRIANGULATIONMODE triangulationMode;
171};
172
173#endif // GBSPHERE3D_H
174
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
double getX3Coordinate() const
Definition GbPoint3D.h:84
double getX1Coordinate() const
Definition GbPoint3D.h:82
double getX2Coordinate() const
Definition GbPoint3D.h:83
double getRadius() const
Definition GbSphere3D.h:74
bool hasRaytracing() override
Definition GbSphere3D.h:112
void objectChanged(UbObservable *) override
Definition GbSphere3D.h:141
void scale(const double &sx1, const double &, const double &) override
Definition GbSphere3D.h:129
void objectWillBeDeleted(UbObservable *) override
Definition GbSphere3D.h:146
void rotate(const double &rx1, const double &rx2, const double &rx3) override
Definition GbSphere3D.h:126
double getX1Maximum() override
Definition GbSphere3D.h:78
@ CUBOIDPROJECTION
Definition GbSphere3D.h:58
void setTriangulationMode(TRIANGULATIONMODE mode)
Definition GbSphere3D.h:138
TRIANGULATIONMODE getTriangulationMode()
Definition GbSphere3D.h:137
double getX3Centroid() override
Definition GbSphere3D.h:82
GbSphere3D * clone() override
Definition GbSphere3D.h:69
void translate(const double &x1, const double &x2, const double &x3) override
Definition GbSphere3D.h:121
double getX2Minimum() override
Definition GbSphere3D.h:80
double getX1Centroid() override
Definition GbSphere3D.h:76
double getX2Centroid() override
Definition GbSphere3D.h:79
double getX3Maximum() override
Definition GbSphere3D.h:84
double getX3Minimum() override
Definition GbSphere3D.h:83
double getX1Minimum() override
Definition GbSphere3D.h:77
double getX2Maximum() override
Definition GbSphere3D.h:81
This Class provides basic 3D triangle objects.
Observable object.
virtual void notifyObserversObjectChanged()
Observer.
Definition UbObserver.h:51
A class implements a tuple.
Definition UbTuple.h:477
std::shared_ptr< T > SPtr
void setCenterCoordinates(const double &x1, const double &x2, const double &x3) override
bool isCellInsideOrCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b, const double &x2b, const double &x3b) override
void translate(const double &x1, const double &x2, const double &x3) override
void addSurfaceTriangleSet(std::vector< UbTupleFloat3 > &nodes, std::vector< UbTupleInt3 > &triangles) override
void setCenterX2Coordinate(const double &value) override
double getDistance(GbPoint3D *p)
bool intersects(SPtr< GbSphere3D > sphere)
virtual bool isPointInGbObject3D(GbPoint3D *p)
void transform(const double matrix[4][4])
double getCellVolumeInsideGbObject3DHelperFunction(const double &x1a, const double &x2a, const double &x3a, const double &x1b, const double &x2b, const double &x3b)
std::string toString() override
this->isPointInCrossection(x11, x22) || !this->isPointInCrossection(x21, x12)) return true;
double getIntersectionRaytraceFactor(const double &x1, const double &x2, const double &x3, const double &rx1, const double &rx2, const double &rx3) override
std::vector< GbTriangle3D * > getSurfaceTriangleSet() override
bool isCellCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b, const double &x2b, const double &x3b) override
~GbSphere3D() override
double getCellVolumeInsideGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b, const double &x2b, const double &x3b) override
void finalize() override
void setCenterX3Coordinate(const double &value) override
GbLine3D * createClippedLine3D(GbPoint3D &point1, GbPoint3D &point2) override
void setCenterX1Coordinate(const double &value) override
void setRadius(const double &radius)
bool isPointInGbObject3D(const double &x1, const double &x2, const double &x3) override
bool hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction)
#define UB_EXARGS
Definition UbException.h:73