chombo-discharge
CD_ParticleOps.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 
13 #ifndef CD_ParticleOps_H
14 #define CD_ParticleOps_H
15 
16 // Chombo includes
17 #include <RefCountedPtr.H>
18 #include <BaseIF.H>
19 #include <RealVect.H>
20 
21 // Our includes
22 #include <CD_ParticleContainer.H>
23 #include <CD_NamespaceHeader.H>
24 
29 {
30 public:
37  static inline IntVect
38  getParticleCellIndex(const RealVect& a_particlePosition, const RealVect& a_probLo, const Real& a_dx) noexcept;
39 
46  static inline IntVect
47  getParticleCellIndex(const RealVect& a_particlePosition, const RealVect& a_probLo, const RealVect& a_dx) noexcept;
48 
58  template <typename P, const Real& (P::*weight)() const>
59  static inline void
60  getPhysicalParticlesPerCell(EBAMRCellData& a_ppc, const ParticleContainer<P>& a_src) noexcept;
61 
67  template <typename P>
68  static inline void
70 
77  static inline IntVect
78  getParticleGridCell(const RealVect& a_particlePosition, const RealVect& a_probLo, const RealVect& a_dx) noexcept;
79 
91  static inline bool
92  domainIntersection(const RealVect& a_oldPos,
93  const RealVect& a_newPos,
94  const RealVect& a_probLo,
95  const RealVect& a_probHi,
96  Real& a_s);
97 
110  static inline bool
111  ebIntersectionBisect(const RefCountedPtr<BaseIF>& a_impFunc,
112  const RealVect& a_oldPos,
113  const RealVect& a_newPos,
114  const Real& a_bisectStep,
115  Real& a_s);
116 
130  static inline bool
131  ebIntersectionRaycast(const RefCountedPtr<BaseIF>& a_impFunc,
132  const RealVect& a_oldPos,
133  const RealVect& a_newPos,
134  const Real& a_tolerance,
135  Real& a_s);
136 
142  template <typename P>
143  static inline void
144  copy(ParticleContainer<P>& a_dst, const ParticleContainer<P>& a_src) noexcept;
145 
151  template <typename P>
152  static inline void
154 
159  template <typename P, const Real& (P::*scalarQuantity)() const>
160  static inline Real
161  sum(const ParticleContainer<P>& a_particles) noexcept;
162 
168  template <typename P, Real (P::*scalarQuantity)()>
169  static inline Real
170  sum(const ParticleContainer<P>& a_particles) noexcept;
171 
177  template <typename P>
178  static inline void
179  removeParticles(ParticleContainer<P>& a_particles, const std::function<bool(const P&)>& a_removeCriterion) noexcept;
180 
187  template <typename P>
188  static inline void
189  transferParticles(ParticleContainer<P>& a_dstParticles,
190  ParticleContainer<P>& a_srcParticles,
191  const std::function<bool(const P&)>& a_transferCrit) noexcept;
192 
198  template <typename P>
199  static inline void
200  setData(ParticleContainer<P>& a_particles, const std::function<void(P&)>& a_functor) noexcept;
201 
207  template <typename P, Real& (P::*particleScalarField)()>
208  static inline void
209  setValue(ParticleContainer<P>& a_particles, const Real a_value) noexcept;
210 
216  template <typename P, RealVect& (P::*particleVectorField)()>
217  static inline void
218  setValue(ParticleContainer<P>& a_particles, const RealVect a_value) noexcept;
219 
220 #ifdef CH_MPI
230  template <typename P>
231  static inline void
232  scatterParticles(std::map<std::pair<unsigned int, unsigned int>, List<P>>& a_receivedParticles,
233  std::vector<std::map<std::pair<unsigned int, unsigned int>, List<P>>>& a_sentParticles) noexcept;
234 
235 #endif
236 };
237 
238 #include <CD_NamespaceFooter.H>
239 
240 #include <CD_ParticleOpsImplem.H>
241 
242 #endif
Declaration of a class for holding particles on an AMR hierarchy.
Implementation of CD_ParticleOps.H.
Templated class for holding particles on an AMR hierarchy with particle remapping.
Definition: CD_ParticleContainer.H:50
A shallow static class for doing various kinds of particle-related operations.
Definition: CD_ParticleOps.H:29
static void copy(ParticleContainer< P > &a_dst, const ParticleContainer< P > &a_src) noexcept
Copy all the particles from the a_src to a_dst.
Definition: CD_ParticleOpsImplem.H:268
static Real sum(const ParticleContainer< P > &a_particles) noexcept
Perform a sum of some particle quantity.
Definition: CD_ParticleOpsImplem.H:316
static void getComputationalParticlesPerCell(EBAMRCellData &a_ppc, const ParticleContainer< P > &a_src) noexcept
Get the number of computational particles per cell.
Definition: CD_ParticleOpsImplem.H:83
static void transferParticles(ParticleContainer< P > &a_dstParticles, ParticleContainer< P > &a_srcParticles, const std::function< bool(const P &)> &a_transferCrit) noexcept
Transfer particles if they fulfill a certain removal criterion. Takes particles from a_srcParticles a...
Definition: CD_ParticleOpsImplem.H:405
static bool ebIntersectionRaycast(const RefCountedPtr< BaseIF > &a_impFunc, const RealVect &a_oldPos, const RealVect &a_newPos, const Real &a_tolerance, Real &a_s)
Compute the intersection point between a particle path and an implicit function using a ray-casting a...
Definition: CD_ParticleOpsImplem.H:217
static bool ebIntersectionBisect(const RefCountedPtr< BaseIF > &a_impFunc, const RealVect &a_oldPos, const RealVect &a_newPos, const Real &a_bisectStep, Real &a_s)
Compute the intersection point between a particle path and an implicit function using a bisection alg...
Definition: CD_ParticleOpsImplem.H:173
static void setValue(ParticleContainer< P > &a_particles, const Real a_value) noexcept
Set value function. Lets the user set scalar particle quantity. Use with e.g. setValue<P,...
Definition: CD_ParticleOpsImplem.H:466
static void removeParticles(ParticleContainer< P > &a_particles, const std::function< bool(const P &)> &a_removeCriterion) noexcept
Remove particles if they fulfill certain removal criterion.
Definition: CD_ParticleOpsImplem.H:374
static Real sum(const ParticleContainer< P > &a_particles) noexcept
Perform a sum of some particle quantity.
static void getPhysicalParticlesPerCell(EBAMRCellData &a_ppc, const ParticleContainer< P > &a_src) noexcept
Get the number of physical particles per cell.
Definition: CD_ParticleOpsImplem.H:47
static void copyDestructive(ParticleContainer< P > &a_dst, ParticleContainer< P > &a_src) noexcept
Copy all the particles from the a_src to a_dst. This destroys the source particles.
Definition: CD_ParticleOpsImplem.H:291
static IntVect getParticleGridCell(const RealVect &a_particlePosition, const RealVect &a_probLo, const RealVect &a_dx) noexcept
Get the grid cell where the particle lives.
Definition: CD_ParticleOpsImplem.H:117
static IntVect getParticleCellIndex(const RealVect &a_particlePosition, const RealVect &a_probLo, const Real &a_dx) noexcept
Get the cell index corresponding to the particle position.
Definition: CD_ParticleOpsImplem.H:26
static void setData(ParticleContainer< P > &a_particles, const std::function< void(P &)> &a_functor) noexcept
Set value function. Lets the user set particle parameters.
Definition: CD_ParticleOpsImplem.H:441
static bool domainIntersection(const RealVect &a_oldPos, const RealVect &a_newPos, const RealVect &a_probLo, const RealVect &a_probHi, Real &a_s)
Compute the intersection point between a particle path and a domain side.
Definition: CD_ParticleOpsImplem.H:127