chombo-discharge
Loading...
Searching...
No Matches
CD_SignedDistanceBVHImplem.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_SignedDistanceBVHImplem_H
13#define CD_SignedDistanceBVHImplem_H
14
15// Std includes
16#include <chrono>
17
18// Our includes
20#include <CD_NamespaceHeader.H>
21
22using namespace std::chrono;
23
24template <class T, class BV, int K>
26 const bool a_flipInside,
27 const Real a_zCoord)
28{
29 m_root = a_root;
30 m_zCoord = a_zCoord;
31 m_flipInside = a_flipInside;
32
33 m_numCalled = 0L;
34 m_timespan = std::chrono::duration<double>(0.0);
35}
36
37template <class T, class BV, int K>
39{
40 m_root = a_primitive.m_root;
41 m_zCoord = a_primitive.m_zCoord;
42 m_flipInside = a_primitive.m_flipInside;
43
44 m_numCalled = 0L;
45 m_timespan = std::chrono::duration<double>(0.0);
46}
47
48template <class T, class BV, int K>
50{
51 if (m_numCalled > 0L) {
52 pout() << "In file CD_SignedDistanceBVHImplem: SignedDistanceBVH::~SignedDistanceBVH() On destructor: Calls: "
53 << m_numCalled << "\t Tot: " << m_timespan.count()
54 << "\t Avg./Call = " << m_timespan.count() / (1.0 * m_numCalled) << endl;
55 }
56}
57
58template <class T, class BV, int K>
59Real
61{
62
63 // TLDR: In 2D we ignore z-variations, freezing that coordinate to some value. We then use the bounding volume hierarchy methodology for computing the signed distance.
64#if CH_SPACEDIM == 2
65 Vec3 p(a_point[0], a_point[1], m_zCoord);
66#else
67 Vec3 p(a_point[0], a_point[1], a_point[2]);
68#endif
69
71 auto d = m_root->signedDistance(p);
74
75 if (m_flipInside) {
76 d = -d;
77 }
78
79 m_timespan += time_span;
80 m_numCalled++;
81
82 return Real(d);
83}
84
85template <class T, class BV, int K>
86BaseIF*
88{
89 return static_cast<BaseIF*>(new SignedDistanceBVH(*this));
90}
91
92#include <CD_NamespaceFooter.H>
93
94#endif
Declaration of an signe distance function class that gets its value function from a DCEL surface Tess...
Signed distance function for a DCEL mesh.
Definition CD_SignedDistanceBVH.H:35
BaseIF * newImplicitFunction() const override
Factory method. Sends pointers around.
Definition CD_SignedDistanceBVHImplem.H:87
SignedDistanceBVH()=delete
Disallowed weak construction.
EBGeometry::Vec3T< T > Vec3
Alias for always-3D vector with template.
Definition CD_SignedDistanceBVH.H:40
virtual ~SignedDistanceBVH()
Destructor (does nothing)
Definition CD_SignedDistanceBVHImplem.H:49
Real value(const RealVect &a_point) const override
Value function.
Definition CD_SignedDistanceBVHImplem.H:60
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:37
TracerParticleSolver()
Default constructor.
Definition CD_TracerParticleSolverImplem.H:25