chombo-discharge
Loading...
Searching...
No Matches
Source
ImplicitFunctions
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
19
#include <
CD_SignedDistanceBVH.H
>
20
#include <CD_NamespaceHeader.H>
21
22
using namespace
std::chrono;
23
24
template
<
class
T,
class
BV,
int
K>
25
SignedDistanceBVH<T, BV, K>::SignedDistanceBVH
(
const
std::shared_ptr<Node>
&
a_root
,
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 = 0
L
;
34
m_timespan = std::chrono::duration<double>(0.0);
35
}
36
37
template
<
class
T,
class
BV,
int
K>
38
SignedDistanceBVH<T, BV, K>::SignedDistanceBVH
(
const
SignedDistanceBVH
&
a_primitive
)
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 = 0
L
;
45
m_timespan = std::chrono::duration<double>(0.0);
46
}
47
48
template
<
class
T,
class
BV,
int
K>
49
SignedDistanceBVH<T, BV, K>::~SignedDistanceBVH
()
50
{
51
if
(m_numCalled > 0
L
) {
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
58
template
<
class
T,
class
BV,
int
K>
59
Real
60
SignedDistanceBVH<T, BV, K>::value
(
const
RealVect
&
a_point
)
const
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
70
high_resolution_clock::time_point
t1
=
high_resolution_clock::now
();
71
auto
d
= m_root->signedDistance(p);
72
high_resolution_clock::time_point
t2
=
high_resolution_clock::now
();
73
duration<double>
time_span
=
duration_cast<duration<double>
>(
t2
-
t1
);
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
85
template
<
class
T,
class
BV,
int
K>
86
BaseIF*
87
SignedDistanceBVH<T, BV, K>::newImplicitFunction
()
const
88
{
89
return
static_cast<
BaseIF*
>
(
new
SignedDistanceBVH
(*
this
));
90
}
91
92
#include <CD_NamespaceFooter.H>
93
94
#endif
CD_SignedDistanceBVH.H
Declaration of an signe distance function class that gets its value function from a DCEL surface Tess...
SignedDistanceBVH
Signed distance function for a DCEL mesh.
Definition
CD_SignedDistanceBVH.H:35
SignedDistanceBVH::newImplicitFunction
BaseIF * newImplicitFunction() const override
Factory method. Sends pointers around.
Definition
CD_SignedDistanceBVHImplem.H:87
SignedDistanceBVH::SignedDistanceBVH
SignedDistanceBVH()=delete
Disallowed weak construction.
SignedDistanceBVH::Vec3
EBGeometry::Vec3T< T > Vec3
Alias for always-3D vector with template.
Definition
CD_SignedDistanceBVH.H:40
SignedDistanceBVH::~SignedDistanceBVH
virtual ~SignedDistanceBVH()
Destructor (does nothing)
Definition
CD_SignedDistanceBVHImplem.H:49
SignedDistanceBVH::value
Real value(const RealVect &a_point) const override
Value function.
Definition
CD_SignedDistanceBVHImplem.H:60
TracerParticleSolver
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition
CD_TracerParticleSolver.H:37
TracerParticleSolver::TracerParticleSolver
TracerParticleSolver()
Default constructor.
Definition
CD_TracerParticleSolverImplem.H:25
Generated by
1.9.8