chombo-discharge
CD_SignedDistanceDCELImplem.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2021 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_SignedDistanceDCELImplem_H
13 #define CD_SignedDistanceDCELImplem_H
14 
15 // Our includes
16 #include <CD_SignedDistanceDCEL.H>
17 #include <CD_NamespaceHeader.H>
18 
19 template <class T>
20 SignedDistanceDCEL<T>::SignedDistanceDCEL(const std::shared_ptr<Mesh>& a_mesh,
21  const bool a_flipInside,
22  const Real a_zCoord)
23 {
24  m_mesh = a_mesh;
25  m_zCoord = a_zCoord;
26  m_flipInside = a_flipInside;
27 }
28 
29 template <class T>
31 {
32  m_mesh = a_object.m_mesh;
33  m_zCoord = a_object.m_zCoord;
34  m_flipInside = a_object.m_flipInside;
35 }
36 
37 template <class T>
39 {}
40 
41 template <class T>
42 Real
43 SignedDistanceDCEL<T>::value(const RealVect& a_point) const
44 {
45 
46 #if CH_SPACEDIM == 2
47  EBGeometry::Vec3T<T> p(a_point[0], a_point[1], m_zCoord);
48 #else
49  EBGeometry::Vec3T<T> p(a_point[0], a_point[1], a_point[2]);
50 #endif
51 
52  T retval = m_mesh->signedDistance(
53  p); // Note that Dcel::mesh can return either positive or negative for outside, depending on the orientation of the input normals.
54 
55  if (m_flipInside) {
56  retval = -retval;
57  }
58 
59  return Real(retval);
60 }
61 
62 template <class T>
63 BaseIF*
65 {
66  return static_cast<BaseIF*>(new SignedDistanceDCEL(*this));
67 }
68 
69 #include <CD_NamespaceFooter.H>
70 
71 #endif
Declaration of an implicit-function class that gets its value function from a DCEL surface Tesselatio...
Signed distance function from a DCEL mesh.
Definition: CD_SignedDistanceDCEL.H:34
Real m_zCoord
For 2D only. z-coordinate through which we slice the 3D object.
Definition: CD_SignedDistanceDCEL.H:92
~SignedDistanceDCEL()
Destructor (does nothing)
Definition: CD_SignedDistanceDCELImplem.H:38
Real value(const RealVect &a_point) const override
Value function.
Definition: CD_SignedDistanceDCELImplem.H:43
std::shared_ptr< Mesh > m_mesh
DCEL mesh.
Definition: CD_SignedDistanceDCEL.H:82
bool m_flipInside
Hook for turning inside to outside.
Definition: CD_SignedDistanceDCEL.H:87
SignedDistanceDCEL()=delete
Disallowed, use the full constructor.
BaseIF * newImplicitFunction() const override
Factory method.
Definition: CD_SignedDistanceDCELImplem.H:64