SPH
AsymmetricSolver.h
Go to the documentation of this file.
1 #pragma once
2 
7 
11 #include "sph/kernel/Kernel.h"
12 #include "thread/ThreadLocal.h"
13 #include "timestepping/ISolver.h"
14 #include <unordered_map>
15 
17 
18 class ISymmetricFinder;
19 class IBoundaryCondition;
20 
22 class RadiiHashMap {
23 private:
24  class IndicesEqual {
25  public:
26  INLINE bool operator()(const Indices& i1, const Indices& i2) const {
27  return all(i1 == i2);
28  }
29  };
30 
31  std::unordered_map<Indices, Float, std::hash<Indices>, IndicesEqual> map;
32  Float cellSize;
33 
34 public:
38  void build(ArrayView<const Vector> r, const Float kernelRadius);
39 
41  Float getRadius(const Vector& r) const;
42 };
43 
45 class IAsymmetricSolver : public ISolver {
46 protected:
51 
54 
57 
60 
63 
64 public:
65  IAsymmetricSolver(IScheduler& scheduler, const RunSettings& settings, const EquationHolder& eqs);
66 
67  virtual void integrate(Storage& storage, Statistics& stats) override;
68 
69  virtual void create(Storage& storage, IMaterial& material) const override;
70 
71 protected:
72  Float getMaxSearchRadius(const Storage& storage) const;
73 
79 
81  virtual void beforeLoop(Storage& storage, Statistics& stats) = 0;
82 
83  virtual void loop(Storage& storage, Statistics& stats) = 0;
84 
85  virtual void afterLoop(Storage& storage, Statistics& stats) = 0;
86 
87  virtual void sanityCheck(const Storage& storage) const = 0;
88 };
89 
104 protected:
107 
109 
110  struct ThreadData {
113 
116 
119  };
120 
122 
123 public:
124  AsymmetricSolver(IScheduler& scheduler, const RunSettings& settings, const EquationHolder& eqs);
125 
127  const RunSettings& settings,
128  const EquationHolder& eqs,
130 
132 
133 protected:
134  virtual void beforeLoop(Storage& storage, Statistics& stats) override;
135 
136  virtual void loop(Storage& storage, Statistics& stats) override;
137 
138  virtual void afterLoop(Storage& storage, Statistics& stats) override;
139 
140  virtual void sanityCheck(const Storage& storage) const override;
141 };
142 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Spatial derivatives to be computed by SPH discretization.
Right-hand side term of SPH equations.
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
Base interface for all solvers.
Vectorized computations with integral numbers.
INLINE bool all(const Indices &i)
Definition: Indices.h:144
SPH kernels.
#define INLINE
Macros for conditional compilation based on selected compiler.
Definition: Object.h:31
#define NAMESPACE_SPH_END
Definition: Object.h:12
Template for thread-local storage.
Object providing safe access to continuous memory of data.
Definition: ArrayView.h:17
Generic SPH solver, evaluating equations for each particle separately.
AutoPtr< IBoundaryCondition > bc
virtual void beforeLoop(Storage &storage, Statistics &stats) override
virtual void sanityCheck(const Storage &storage) const override
AsymmetricSolver(IScheduler &scheduler, const RunSettings &settings, const EquationHolder &eqs)
virtual void afterLoop(Storage &storage, Statistics &stats) override
virtual void loop(Storage &storage, Statistics &stats) override
ThreadLocal< ThreadData > threadData
DerivativeHolder derivatives
Holds all derivatives (shared for all threads)
Container holding derivatives and the storage they accumulate to.
Definition: Derivative.h:173
Container holding equation terms.
Definition: EquationTerm.h:238
Base class for asymmetric SPH solvers.
IScheduler & scheduler
Scheduler used to parallelize the solver.
Float getMaxSearchRadius(const Storage &storage) const
virtual void loop(Storage &storage, Statistics &stats)=0
virtual void sanityCheck(const Storage &storage) const =0
LutKernel< DIMENSIONS > kernel
Selected SPH kernel.
EquationHolder equations
Holds all equation terms evaluated by the solver.
Optional< RadiiHashMap > radiiMap
Hash map used to determine search radii of particles.
virtual void beforeLoop(Storage &storage, Statistics &stats)=0
virtual void afterLoop(Storage &storage, Statistics &stats)=0
AutoPtr< ISymmetricFinder > finder
Structure used to search for neighbouring particles.
virtual void create(Storage &storage, IMaterial &material) const override
Initializes all quantities needed by the solver in the storage.
IAsymmetricSolver(IScheduler &scheduler, const RunSettings &settings, const EquationHolder &eqs)
virtual RawPtr< const IBasicFinder > getFinder(ArrayView< const Vector > r)
Returns a finder, already build using the provided positions.
virtual void integrate(Storage &storage, Statistics &stats) override
Computes derivatives of all time-dependent quantities.
Base object for boundary conditions.
Definition: Boundary.h:29
Material settings and functions specific for one material.
Definition: IMaterial.h:110
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Definition: Scheduler.h:27
Base class for all solvers.
Definition: ISolver.h:20
Extension of IBasicFinder, allowing to search only particles with lower rank in smoothing length.
Helper object for storing three (possibly four) int or bool values.
Definition: Indices.h:16
Helper structure storing search radii for particles as hash map.
Float getRadius(const Vector &r) const
Returns the required search radius for particle at given position.
void build(ArrayView< const Vector > r, const Float kernelRadius)
Computes the search radii at each cell in space.
Non-owning wrapper of pointer.
Definition: RawPtr.h:19
Object holding various statistics about current run.
Definition: Statistics.h:22
Container storing all quantities used within the simulations.
Definition: Storage.h:230
Array< Size > idxs
Indices of real neighbours.
Array< Vector > grads
Cached array of gradients.
Array< NeighbourRecord > neighs
Cached array of neighbours, to avoid allocation every step.