chombo-discharge
CD_EBGeometryIFImplem.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2022 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_EBGeometryIFImplem_H
13 #define CD_EBGeometryIFImplem_H
14 
15 #include <CD_EBGeometryIF.H>
16 #include <CD_NamespaceHeader.H>
17 
18 template <typename T>
20 {
21  this->m_sdf = nullptr;
22  this->m_flipInside = false;
23  this->m_zCoord = 0.0;
24 }
25 
26 template <typename T>
27 EBGeometryIF<T>::EBGeometryIF(const std::shared_ptr<EBGeometry::ImplicitFunction<T>>& a_sdf,
28  const bool a_flipInside,
29  const Real a_zCoord)
30 
31 {
32  this->m_sdf = a_sdf;
33  this->m_flipInside = a_flipInside;
34  this->m_zCoord = a_zCoord;
35 }
36 
37 template <typename T>
39 {
40  this->m_sdf = a_inputIF.m_sdf;
41  this->m_flipInside = a_inputIF.m_flipInside;
42  this->m_zCoord = a_inputIF.m_zCoord;
43 }
44 
45 template <typename T>
47 {
48  m_sdf = nullptr;
49 }
50 
51 template <typename T>
52 Real
53 EBGeometryIF<T>::value(const RealVect& a_point) const
54 {
55 #if CH_SPACEDIM == 2
56  EBGeometry::Vec3T<T> p(a_point[0], a_point[1], m_zCoord);
57 #else
58  EBGeometry::Vec3T<T> p(a_point[0], a_point[1], a_point[2]);
59 #endif
60 
61  Real ret = Real(m_sdf->value(p));
62 
63  if (m_flipInside) {
64  ret = -ret;
65  }
66 
67  return ret;
68 }
69 
70 template <typename T>
71 BaseIF*
73 {
74  return (BaseIF*)(new EBGeometryIF(*this));
75 }
76 
77 #include <CD_NamespaceFooter.H>
78 
79 #endif
Binding of EBGeometry signed distance functions to Chombo objcts.
Shallow binding of EBGeometry signed distance functions to Chombo.
Definition: CD_EBGeometryIF.H:35
virtual ~EBGeometryIF()
Destructor. Does nothing.
Definition: CD_EBGeometryIFImplem.H:46
std::shared_ptr< const EBGeometry::ImplicitFunction< T > > m_sdf
Signed distance function.
Definition: CD_EBGeometryIF.H:80
EBGeometryIF()
Constructor. Sets shape to nullptr.
Definition: CD_EBGeometryIFImplem.H:19
virtual BaseIF * newImplicitFunction() const override
IF factory method.
Definition: CD_EBGeometryIFImplem.H:72
Real m_zCoord
z-coordinate through which the object is sliced.
Definition: CD_EBGeometryIF.H:90
virtual Real value(const RealVect &a_point) const override
Value function. Returns distance to object.
Definition: CD_EBGeometryIFImplem.H:53
bool m_flipInside
Hook for making outside -> inside.
Definition: CD_EBGeometryIF.H:85