preCICE v3.1.2
Loading...
Searching...
No Matches
Tetrahedron.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <iostream>
5#include <tuple>
6
7#include "mesh/Vertex.hpp"
9#include "utils/assertion.hpp"
10
11// ----------------------------------------------------------- CLASS DEFINITION
12
13namespace precice {
14namespace mesh {
15
18public:
20 static constexpr int vertexCount{4};
21
28 Vertex &vertexOne,
29 Vertex &vertexTwo,
30 Vertex &vertexThree,
31 Vertex &vertexFour);
32
34 int getDimensions() const;
35
39 Vertex &vertex(int i);
40
44 const Vertex &vertex(int i) const;
45
47 double getVolume() const;
48
50 const Eigen::VectorXd getCenter() const;
51
53 double getEnclosingRadius() const;
54
60 bool operator==(const Tetrahedron &other) const;
61
63 bool operator!=(const Tetrahedron &other) const;
64
66 bool operator<(const Tetrahedron &other) const
67 {
68 return std::make_tuple(_vertices[0]->getID(), _vertices[1]->getID(), _vertices[2]->getID(), _vertices[3]->getID()) <
69 std::make_tuple(other._vertices[0]->getID(), other._vertices[1]->getID(), other._vertices[2]->getID(), other._vertices[3]->getID());
70 }
71
72private:
75};
76
77// --------------------------------------------------------- HEADER DEFINITIONS
78
80{
81 PRECICE_ASSERT((i >= 0) && (i < 4), i);
82 return *_vertices[i];
83}
84
85inline const Vertex &Tetrahedron::vertex(int i) const
86{
87 PRECICE_ASSERT((i >= 0) && (i < 4), i);
88 return *_vertices[i];
89}
90
92
93} // namespace mesh
94} // namespace precice
#define PRECICE_ASSERT(...)
Definition assertion.hpp:87
Tetrahedron of a mesh, defined by 4 vertices.
Vertex & vertex(int i)
Returns tetrahedron vertex with index 0, 1, 2 or 3.
std::array< Vertex *, 4 > _vertices
Vertices defining the Tetrahedron.
const Eigen::VectorXd getCenter() const
Returns the barycenter of the tetrahedron.
static constexpr int vertexCount
Amount of vertices.
double getEnclosingRadius() const
Returns the radius of the sphere enclosing the tetrahedron.
double getVolume() const
Returns the unsigned volume of the tetrahedron.
bool operator!=(const Tetrahedron &other) const
Not equal, implemented in terms of equal.
bool operator==(const Tetrahedron &other) const
Compares two Tetrahedrons for equality.
int getDimensions() const
Returns dimensionalty of space the Tetrahedron is embedded in.
bool operator<(const Tetrahedron &other) const
Weak ordering based on vertex ids.
Tetrahedron(Vertex &vertexOne, Vertex &vertexTwo, Vertex &vertexThree, Vertex &vertexFour)
Vertex of a mesh.
Definition Vertex.hpp:16
T make_tuple(T... args)
std::ostream & operator<<(std::ostream &os, const BoundingBox &bb)
Main namespace of the precice library.