chombo-discharge
Loading...
Searching...
No Matches
Source
Particle
CD_ParticleMap.H
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_ParticleMap_H
13
#define CD_ParticleMap_H
14
15
// Std includes
16
#include <cstdint>
17
#include <utility>
18
#include <unordered_map>
19
#include <map>
20
21
// Our includes
22
#include <CD_NamespaceHeader.H>
23
24
// Compile-time sanity checks (optional but nice)
25
static_assert
(
sizeof
(
uint32_t
) == 4,
"uint32_t must be 32 bits"
);
26
static_assert
(
sizeof
(
uint64_t
) == 8,
"uint64_t must be 64 bits"
);
27
static_assert
(
sizeof
(
size_t
) == 8,
"size_t must be 64 bits"
);
28
35
static
inline
uint64_t
36
encodePair(
uint32_t
a_level
,
uint32_t
a_gridIndex
)
noexcept
37
{
38
return
(
std::uint64_t
(
a_level
) << 32) |
std::uint64_t
(
a_gridIndex
);
39
}
40
46
static
inline
std::pair<uint32_t, uint32_t>
47
decodePair(
uint64_t
key
)
noexcept
48
{
49
return
{
uint32_t
(
key
>> 32),
uint32_t
(
key
)};
50
}
51
55
struct
PairHash
56
{
57
std::size_t
58
operator()(
const
std::pair<uint32_t, uint32_t>
& p)
const
noexcept
59
{
60
return
encodePair(p.first, p.second);
61
}
62
};
63
68
template
<
typename
T>
69
using
ParticleMap =
std::unordered_map<std::pair<uint32_t, uint32_t>
, T,
PairHash
>;
70
71
#include <CD_NamespaceFooter.H>
72
73
#endif
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
PairHash
Simple pair-hashing struct for interfacing into unordered_map.
Definition
CD_ParticleMap.H:56
Generated by
1.9.8