chombo-discharge
CD_KDNode.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_KDNode_H
13 #define CD_KDNode_H
14 
15 // Std includes
16 #include <memory>
17 #include <vector>
18 
19 // Chombo includes
20 #include <RealVect.H>
21 #include <List.H>
22 
23 // Our includes
24 #include <CD_NamespaceHeader.H>
25 
31 template <class P>
32 class KDNode
33 {
34 public:
39  using ParticleList = std::vector<P>;
40 
44  KDNode(const KDNode&) = delete;
45 
49  KDNode(const KDNode&&) = delete;
50 
54  KDNode&
55  operator=(const KDNode&) = delete;
56 
60  KDNode&
61  operator=(const KDNode&&) = delete;
62 
66  KDNode();
67 
73  KDNode(ParticleList& a_particles);
74 
78  virtual ~KDNode();
79 
83  inline const Real&
84  weight() const noexcept;
85 
89  inline Real&
90  weight() noexcept;
91 
95  inline const ParticleList&
96  getParticles() const noexcept;
97 
101  inline ParticleList&
102  getParticles() noexcept;
103 
107  inline bool
108  isLeafNode() const noexcept;
109 
113  inline bool
114  isInteriorNode() const noexcept;
115 
119  inline ParticleList
120  gatherParticles() const noexcept;
121 
127  inline ParticleList
128  moveParticles() noexcept;
129 
133  inline std::shared_ptr<KDNode<P>>&
134  getLeft() noexcept;
135 
139  inline std::shared_ptr<KDNode<P>>&
140  getRight() noexcept;
141 
142 protected:
146  std::shared_ptr<KDNode> m_left;
147 
151  std::shared_ptr<KDNode> m_right;
152 
156  Real m_weight;
157 
162 
167  inline void
168  gatherParticles(ParticleList& a_particles) const noexcept;
169 
176  inline void
177  moveParticles(ParticleList& a_particles) noexcept;
178 };
179 
180 #include <CD_NamespaceFooter.H>
181 
182 #include <CD_KDNodeImplem.H>
183 
184 #endif
Implementation of CD_KDNode.H.
Node in a particle-merging KD-tree.
Definition: CD_KDNode.H:33
ParticleList moveParticles() noexcept
Move the particles list further down in the subtree into this vector.
Definition: CD_KDNodeImplem.H:105
KDNode & operator=(const KDNode &&)=delete
Disallowed assignment.
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
std::shared_ptr< KDNode > m_right
Right KD-node.
Definition: CD_KDNode.H:151
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
ParticleList m_particles
List of particles.
Definition: CD_KDNode.H:161
Real m_weight
Node weight.
Definition: CD_KDNode.H:156
std::shared_ptr< KDNode< P > > & getLeft() noexcept
Get the left node.
Definition: CD_KDNodeImplem.H:131
KDNode & operator=(const KDNode &)=delete
Disallowed assignment.
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
KDNode(const KDNode &&)=delete
Disallowed constructor.
std::shared_ptr< KDNode > m_left
Left KD-node.
Definition: CD_KDNode.H:146
KDNode(const KDNode &)=delete
Disallowed constructor.
bool isInteriorNode() const noexcept
Is leaf node or not.
Definition: CD_KDNodeImplem.H:73