chombo-discharge
Loading...
Searching...
No Matches
CD_SignedDistanceDCELImplem.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_SIGNEDDISTANCEDCELIMPLEM_H
14#define CD_SIGNEDDISTANCEDCELIMPLEM_H
15
16// Our includes
18#include <CD_NamespaceHeader.H>
19
20template <class T>
21SignedDistanceDCEL<T>::SignedDistanceDCEL(const std::shared_ptr<Mesh>& a_mesh,
22 const bool a_flipInside,
23 const Real a_zCoord)
24{
25 m_mesh = a_mesh;
26 m_zCoord = a_zCoord;
27 m_flipInside = a_flipInside;
28}
29
30template <class T>
32{
33 m_mesh = a_object.m_mesh;
34 m_zCoord = a_object.m_zCoord;
35 m_flipInside = a_object.m_flipInside;
36}
37
38template <class T>
41
42template <class T>
43Real
44SignedDistanceDCEL<T>::value(const RealVect& a_point) const
45{
46
47#if CH_SPACEDIM == 2
48 EBGeometry::Vec3T<T> p(a_point[0], a_point[1], m_zCoord);
49#else
50 EBGeometry::Vec3T<T> p(a_point[0], a_point[1], a_point[2]);
51#endif
52
53 T retval = m_mesh->signedDistance(p); // Note that Dcel::mesh can return either positive or negative for outside,
54 // depending on the orientation of the input normals.
55
56 if (m_flipInside) {
57 retval = -retval;
58 }
59
60 return Real(retval);
61}
62
63template <class T>
64BaseIF*
66{
67 return static_cast<BaseIF*>(new SignedDistanceDCEL(*this));
68}
69
70#include <CD_NamespaceFooter.H>
71
72#endif
Declaration of an implicit-function class that gets its value function from a DCEL surface Tessellati...
Signed distance function from a DCEL mesh.
Definition CD_SignedDistanceDCEL.H:36
Real m_zCoord
For 2D only. z-coordinate through which we slice the 3D object.
Definition CD_SignedDistanceDCEL.H:96
~SignedDistanceDCEL()
Destructor (does nothing)
Definition CD_SignedDistanceDCELImplem.H:39
Real value(const RealVect &a_point) const override
Value function.
Definition CD_SignedDistanceDCELImplem.H:44
std::shared_ptr< Mesh > m_mesh
DCEL mesh.
Definition CD_SignedDistanceDCEL.H:86
bool m_flipInside
Hook for turning inside to outside.
Definition CD_SignedDistanceDCEL.H:91
SignedDistanceDCEL()=delete
Disallowed, use the full constructor.
BaseIF * newImplicitFunction() const override
Factory method.
Definition CD_SignedDistanceDCELImplem.H:65