chombo-discharge
Loading...
Searching...
No Matches
CD_KDNodeImplem.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_KDNodeImplem_H
13#define CD_KDNodeImplem_H
14
15// Std includes
16#include <utility>
17#include <type_traits>
18
19// Our includes
20#include <CD_KDNode.H>
21#include <CD_NamespaceHeader.H>
22
23template <class P>
24inline KDNode<P>::KDNode() : m_left(nullptr), m_right(nullptr), m_weight(0.0)
25{}
26
27template <class P>
29 : m_left(nullptr), m_right(nullptr), m_weight(0.0), m_particles(std::move(a_particles))
30{}
31
32template <class P>
34{}
35
36template <class P>
37inline const typename KDNode<P>::ParticleList&
42
43template <class P>
44inline typename KDNode<P>::ParticleList&
49
50template <class P>
51inline const Real&
53{
54 return m_weight;
55}
56
57template <class P>
58inline Real&
60{
61 return m_weight;
62}
63
64template <class P>
65inline bool
67{
68 return (m_left == nullptr) && (m_right == nullptr);
69}
70
71template <class P>
72inline bool
74{
75 return !(this->isLeafNode());
76}
77
78template <class P>
79inline typename KDNode<P>::ParticleList
81{
83
84 this->gatherParticles(primitives);
85
86 return primitives;
87}
88
89template <class P>
90inline void
92{
93 if (this->isLeafNode()) {
94 a_particles.reserve(a_particles.size() + m_particles.size());
95 a_particles.insert(a_particles.end(), m_particles.begin(), m_particles.end());
96 }
97 else {
98 m_left->gatherParticles(a_particles);
99 m_right->gatherParticles(a_particles);
100 }
101}
102
103template <class P>
104inline typename KDNode<P>::ParticleList
106{
108
109 this->moveParticles(primitives);
110
111 return primitives;
112}
113
114template <class P>
115inline void
117{
118 if (this->isLeafNode()) {
119 a_particles.reserve(a_particles.size() + m_particles.size());
120
121 std::move(m_particles.begin(), m_particles.end(), std::back_inserter(a_particles));
122 }
123 else {
124 m_left->moveParticles(a_particles);
125 m_right->moveParticles(a_particles);
126 }
127}
128
129template <class P>
132{
133 return m_left;
134}
135
136template <class P>
139{
140 return m_right;
141}
142
143#include <CD_NamespaceFooter.H>
144
145#endif
Namespace containing various particle management utilities.
ParticleList moveParticles() noexcept
Move the particles list further down in the subtree into this vector.
Definition CD_KDNodeImplem.H:105
const Real & weight() const noexcept
Get the node weight.
Definition CD_KDNodeImplem.H:52
const ParticleList & getParticles() const noexcept
Get particles in this node.
Definition CD_KDNodeImplem.H:38
KDNode()
Default constructor.
Definition CD_KDNodeImplem.H:24
std::shared_ptr< KDNode< P > > & getRight() noexcept
Get the right node.
Definition CD_KDNodeImplem.H:138
ParticleList gatherParticles() const noexcept
Gather particles further down in the subtree and return all particles (in the leaf nodes)
Definition CD_KDNodeImplem.H:80
virtual ~KDNode()
Destructor. Does nothing.
Definition CD_KDNodeImplem.H:33
std::shared_ptr< KDNode< P > > & getLeft() noexcept
Get the left node.
Definition CD_KDNodeImplem.H:131
std::vector< P > ParticleList
List of particles. This is aliased because the KD-tree construction may require both random access an...
Definition CD_KDNode.H:39
bool isLeafNode() const noexcept
Is leaf node or not.
Definition CD_KDNodeImplem.H:66
bool isInteriorNode() const noexcept
Is leaf node or not.
Definition CD_KDNodeImplem.H:73
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:37
ParticleContainer< P > m_particles
Computational particles.
Definition CD_TracerParticleSolver.H:405
TracerParticleSolver()
Default constructor.
Definition CD_TracerParticleSolverImplem.H:25