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