KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
plane_3d.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Pooyan Dadvand
11 // contributors: Ruben Zorrilla
12 //
13 
14 #if !defined(KRATOS_PLANE_3D_H_INCLUDED)
15 #define KRATOS_PLANE_3D_H_INCLUDED
16 
17 // System includes
18 
19 // External includes
20 
21 // Project includes
22 #include "geometries/point.h"
23 #include "includes/checks.h"
24 #include "utilities/math_utils.h"
25 
26 namespace Kratos
27 {
28 
31 
35 
39 
43 
47 
50 class Plane3D
51 {
52 public:
56 
59 
63 
64  Plane3D() = delete;
65 
66  Plane3D(array_1d<double, 3> const &rNormal, double DistanceToOrigin) : mD(DistanceToOrigin), mNormal(rNormal) {}
67 
68  Plane3D(array_1d<double, 3> const &rNormal, const Point &rReferencePoint)
69  {
70  // Compute the unit normal
71  mNormal = rNormal;
72  auto normal_length = norm_2(mNormal);
73  KRATOS_DEBUG_CHECK_GREATER(normal_length, std::numeric_limits<double>::epsilon());
74  mNormal /= normal_length;
75  // Compute the distance to origin
76  mD = -inner_prod(mNormal,rReferencePoint);
77  }
78 
79  Plane3D(const Point &Point1, const Point &Point2, const Point &Point3)
80  {
81  // Compute the unit normal
82  array_1d<double,3> v_1 = Point2 - Point1;
83  array_1d<double,3> v_2 = Point3 - Point1;
84  MathUtils<double>::CrossProduct(mNormal, v_1, v_2);
85  auto normal_length = norm_2(mNormal);
86  KRATOS_DEBUG_CHECK_GREATER(normal_length, std::numeric_limits<double>::epsilon());
87  mNormal /= normal_length;
88  // Compute the distance to origin
89  mD = -inner_prod(mNormal, Point1);
90  }
91 
93  ~Plane3D() {}
94 
98 
99 
103 
108  {
109  return mNormal;
110  }
111 
116  {
117  return mD;
118  }
119 
123  double CalculateSignedDistance(Point const &rPoint)
124  {
125  return inner_prod(mNormal, rPoint) + mD;
126  }
127 
133  std::string Info() const
134  {
135  return "a 3D plane auxiliar class";
136  }
137 
143  void PrintInfo(std::ostream& rOStream) const
144  {
145  rOStream << "a 3D plane auxiliar class";
146  }
147 
155  void PrintData(std::ostream& rOStream) const
156  {
157  rOStream << "a 3D plane auxiliar class with:\n";
158  rOStream << "\t- distance to origin: " << mD << "\n";
159  rOStream << "\t- normal: (" << mNormal[0] << " , " << mNormal[1] << " , " << mNormal[2] << ")";
160  }
161 
165 
166 
168 
169 private:
170 
173 
174  double mD;
175  array_1d<double,3> mNormal;
176 
178 
179 }; // Class Plane3D
180 
182 
185 
186 
190 
192 inline std::istream& operator >> (std::istream& rIStream,
193  Plane3D& rThis);
194 
196 inline std::ostream& operator << (std::ostream& rOStream,
197  const Plane3D& rThis)
198 {
199  rThis.PrintInfo(rOStream);
200  rOStream << std::endl;
201  rThis.PrintData(rOStream);
202 
203  return rOStream;
204 }
205 
207 
208 } // namespace Kratos.
209 
210 #endif // KRATOS_PLANE_3D_H_INCLUDED defined
211 
212 
static T CrossProduct(const T &a, const T &b)
Performs the vector product of the two input vectors a,b.
Definition: math_utils.h:762
Definition: plane_3d.h:51
~Plane3D()
Destructor. Do nothing!!!
Definition: plane_3d.h:93
void PrintData(std::ostream &rOStream) const
Definition: plane_3d.h:155
Plane3D(array_1d< double, 3 > const &rNormal, const Point &rReferencePoint)
Definition: plane_3d.h:68
Plane3D(array_1d< double, 3 > const &rNormal, double DistanceToOrigin)
Definition: plane_3d.h:66
Plane3D()=delete
void PrintInfo(std::ostream &rOStream) const
Definition: plane_3d.h:143
double CalculateSignedDistance(Point const &rPoint)
Definition: plane_3d.h:123
Plane3D(const Point &Point1, const Point &Point2, const Point &Point3)
Definition: plane_3d.h:79
double GetDistanceToOrigin()
Definition: plane_3d.h:115
KRATOS_CLASS_POINTER_DEFINITION(Plane3D)
Pointer definition of Point2D.
array_1d< double, 3 > const & GetNormal()
Definition: plane_3d.h:107
std::string Info() const
Definition: plane_3d.h:133
Point class.
Definition: point.h:59
#define KRATOS_DEBUG_CHECK_GREATER(a, b)
Definition: checks.h:226
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432