SPH
EnergyConservingSolver.h
Go to the documentation of this file.
1 #pragma once
2 
5 #include "system/Statistics.h"
6 
8 
9 template <typename T>
10 class GravitySolver;
11 
14 public:
15  virtual void initialize(const Storage& storage) = 0;
16 
17  virtual void compute(const Size i,
18  ArrayView<const Size> neighs,
20  ArrayView<Float> f) const = 0;
21 };
22 
25 private:
26  FlatSet<RawPtr<IAcceleration>> accelerations;
27 
28 public:
29  virtual void require(AutoPtr<IDerivative>&& derivative) override {
30  RawPtr<IAcceleration> a = dynamicCast<IAcceleration>(derivative.get());
31  if (a) {
32  accelerations.insert(a);
33  }
34  DerivativeHolder::require(std::move(derivative));
35  }
36 
37  void evalAccelerations(const Size idx,
38  ArrayView<const Size> neighs,
40  Array<Vector>& dv) const {
41  dv.fill(Vector(0._f));
42  for (auto& a : accelerations) {
43  a->evalAcceleration(idx, neighs, grads, dv);
44  }
45  }
46 };
47 
51 
52 private:
53  AccelerationSeparatingHolder derivatives;
54 
55  Float initialDt;
56 
57  AutoPtr<IEnergyPartitioner> partitioner;
58 
59  struct ThreadData {
61 
63  Array<Float> energyChange;
64 
66  Array<Float> partitions;
67 
68  Array<Vector> accelerations;
69  };
70 
71  ThreadLocal<ThreadData> threadData;
72 
73  Array<Array<Size>> neighList;
74 
75  Array<Array<Vector>> gradList;
76 
77 public:
79 
81  const RunSettings& settings,
82  const EquationHolder& eqs,
84 
85 private:
86  virtual void sanityCheck(const Storage& storage) const override;
87 
88  virtual void beforeLoop(Storage& storage, Statistics& stats) override;
89 
90  virtual void loop(Storage& storage, Statistics& stats) override;
91 
92  virtual void afterLoop(Storage& storage, Statistics& stats) override;
93 };
94 
SPH solver with asymmetric particle evaluation.
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
uint32_t Size
Integral type used to index arrays (by default).
Definition: Globals.h:16
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
#define NAMESPACE_SPH_END
Definition: Object.h:12
Statistics gathered and periodically displayed during the run.
BasicVector< Float > Vector
Definition: Vector.h:539
Derivative holder, splitting the registered derivatives into accelerations and the rest.
virtual void require(AutoPtr< IDerivative > &&derivative) override
Adds derivative if not already present.
void evalAccelerations(const Size idx, ArrayView< const Size > neighs, ArrayView< const Vector > grads, Array< Vector > &dv) const
Generic dynamically allocated resizable storage.
Definition: Array.h:43
void fill(const T &t)
Sets all elements of the array to given value.
Definition: Array.h:187
Wrapper of pointer that deletes the resource from destructor.
Definition: AutoPtr.h:15
Container holding derivatives and the storage they accumulate to.
Definition: Derivative.h:173
virtual void require(AutoPtr< IDerivative > &&derivative)
Adds derivative if not already present.
Definition: Derivative.cpp:77
See Owen 2009: A compatibly differenced total energy conserving form of SPH.
EnergyConservingSolver(IScheduler &scheduler, const RunSettings &settings, const EquationHolder &eqs)
Container holding equation terms.
Definition: EquationTerm.h:238
bool insert(U &&value)
Definition: FlatSet.h:45
Extension of a generic SPH solver, including gravitational interactions of particles.
Definition: GravitySolver.h:22
Base class for asymmetric SPH solvers.
IScheduler & scheduler
Scheduler used to parallelize the solver.
Abstraction of the.
virtual void initialize(const Storage &storage)=0
virtual void compute(const Size i, ArrayView< const Size > neighs, ArrayView< const Float > e, ArrayView< Float > f) const =0
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Definition: Scheduler.h:27
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
Base class for all polymorphic objects.
Definition: Object.h:88