chombo-discharge
Loading...
Searching...
No Matches
CD_Triangle.H
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
13#ifndef CD_TRIANGLE_H
14#define CD_TRIANGLE_H
15
16// Std includes
17#include <array>
18
19// Chombo includes
20#include <RealVect.H>
21
22// Our includes
23#include <EBGeometry.hpp>
24#include <CD_NamespaceHeader.H>
25
30class Triangle : public EBGeometry::Triangle<Real, std::array<Real, 3>>
31{
32public:
36 using Vec3 = EBGeometry::Vec3T<Real>;
37
44 Triangle() noexcept;
45
52 Triangle(const std::array<Vec3, 3>& a_vertexPositions) noexcept;
53
57 virtual ~Triangle() noexcept;
58
65 void
66 computeArea() noexcept;
67
74 void
75 setVertexPositions(const std::array<Vec3, 3>& a_vertexPositions) noexcept;
76
81 void
82 setVertexData(const std::array<Real, 3>& a_vertexData) noexcept;
83
89 Vec3
90 projectToTrianglePlane(const Vec3& a_point) const noexcept;
91
103 bool
104 isInside(const Vec3& a_point) const noexcept;
105
117 Real
118 interpolate(const Vec3& a_point) const noexcept;
119
120protected:
124 Real m_area = Real(0);
125
134 static inline Real
135 computeTriangleArea(const Vec3& a_x1, const Vec3& a_x2, const Vec3& a_x3) noexcept;
136};
137
138#include <CD_NamespaceFooter.H>
139
140#endif
Class that represents a single triangle together with associated metadata on the vertices (one float ...
Definition CD_Triangle.H:31
void setVertexPositions(const std::array< Vec3, 3 > &a_vertexPositions) noexcept
Set vertex positions and recompute the triangle area.
Definition CD_Triangle.cpp:32
static Real computeTriangleArea(const Vec3 &a_x1, const Vec3 &a_x2, const Vec3 &a_x3) noexcept
Compute the area of a triangle defined by three vertices.
Definition CD_Triangle.cpp:70
void computeArea() noexcept
Compute and store the triangle area in m_area.
Definition CD_Triangle.cpp:44
bool isInside(const Vec3 &a_point) const noexcept
Check if a point lies inside the triangle.
Definition CD_Triangle.cpp:56
EBGeometry::Vec3T< Real > Vec3
Alias for always-3D vector type.
Definition CD_Triangle.H:36
Triangle() noexcept
Default constructor.
Definition CD_Triangle.cpp:17
Real interpolate(const Vec3 &a_point) const noexcept
Interpolate vertex data at a point using barycentric coordinates or IDW fallback.
Definition CD_Triangle.cpp:79
void setVertexData(const std::array< Real, 3 > &a_vertexData) noexcept
Set meta-data on the vertices.
Definition CD_Triangle.cpp:38
Real m_area
Triangle area.
Definition CD_Triangle.H:124
Vec3 projectToTrianglePlane(const Vec3 &a_point) const noexcept
Project the input point to the triangle plane.
Definition CD_Triangle.cpp:50