19 : scheduler(scheduler)
20 , threadData(scheduler)
25 kernel = Factory::getKernel<Dim>(settings);
35 equations += makeTerm<NeighbourCountTerm>();
42 if (!data.derivatives.isSymmetric()) {
43 throw InvalidSetup(
"Asymmetric derivative used within symmetric solver");
63 material->initialize(scheduler, storage, material.
sequence());
69 equations.initialize(scheduler, storage, t);
72 bc->initialize(storage);
75 this->beforeLoop(storage, stats);
78 this->loop(storage, stats);
81 this->afterLoop(storage, stats);
84 equations.finalize(scheduler, storage, t);
87 bc->finalize(storage);
93 material->finalize(scheduler, storage, material.sequence());
105 this->sanityCheck(storage);
114 finder->build(scheduler, r);
120 auto functor = [
this, r, &symmetrizedKernel](
const Size i,
ThreadData& data) {
121 finder->findLowerRank(i, r[i][
H] * kernel.radius(), data.neighs);
124 for (
auto& n : data.neighs) {
125 const Size j = n.index;
126 const Float hbar = 0.5_f * (r[i][
H] + r[j][
H]);
132 const Vector gr = symmetrizedKernel.
grad(r[i], r[j]);
134 data.grads.emplaceBack(gr);
135 data.idxs.emplaceBack(j);
137 data.derivatives.evalSymmetric(i, data.idxs, data.grads);
148 data.derivatives.initialize(storage);
160 first = &data.derivatives.getAccumulated();
163 threadLocalAccumulated.
push(&data.derivatives.getAccumulated());
167 first->
sum(scheduler, threadLocalAccumulated);
170 first->
store(storage);
176 for (
Size i = 0; i < size; ++i) {
185 finder->build(scheduler, r);
194 "No solver of smoothing length specified; add either ConstSmootingLength or "
195 "AdaptiveSmootingLength into the list of equations");
INLINE bool isReal(const AntisymmetricTensor &t)
#define SPH_ASSERT(x,...)
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Additional equation terms computing SPH statistics rather than physical quantities.
Base class for all particle materials.
AutoPtr< IMaterial > getMaterial(const MaterialEnum type)
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
#define NAMESPACE_SPH_END
Tool to measure time spent in functions and profile the code.
#define MEASURE_SCOPE(name)
#define PROFILE_SCOPE(name)
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ NEIGHBOUR_CNT
Number of neighbouring particles (in radius h * kernel.radius)
@ ZERO
Quantity without derivatives, or "zero order" of quantity.
INLINE void parallelFor(IScheduler &scheduler, const Size from, const Size to, TFunctor &&functor)
Executes a functor concurrently from all available threads.
Statistics gathered and periodically displayed during the run.
@ NEIGHBOUR_COUNT
Number of neighbours (min, max, mean)
@ RUN_TIME
Current time of the simulation in code units. Does not necessarily have to be 0 when run starts.
Basic SPH solver, evaluating all interactions symmetrically.
INLINE Float getLength(const Vector &v)
Returns the length of the vector. Enabled only for vectors of floating-point precision.
INLINE Float getSqrLength(const Vector &v)
INLINE float dot(const BasicVector< float > &v1, const BasicVector< float > &v2)
Make sure the vector is trivially constructible and destructible, needed for fast initialization of a...
Storage for accumulating derivatives.
void sum(ArrayView< Accumulated * > others)
Sums values of a list of storages.
void store(Storage &storage)
Stores accumulated values to corresponding quantities.
Evolutionary equation for the (scalar) smoothing length.
Object providing safe access to continuous memory of data.
INLINE TCounter size() const
Generic dynamically allocated resizable storage.
INLINE void push(U &&u)
Adds new element to the end of the array, resizing the array if necessary.
Helper term to keep smoothing length constant during the simulation.
Container holding equation terms.
void setDerivatives(DerivativeHolder &derivatives, const RunSettings &settings) const
Calls EquationTerm::setDerivatives for all stored equation terms.
Material settings and functions specific for one material.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Thrown when components of the run are mutually incompatible.
Non-owning wrapper of a material and particles with this material.
INLINE IndexSequence sequence()
Returns iterable index sequence.
Helper class for statistics, accumulating minimal, maximal and mean value of a set of numbers.
INLINE void accumulate(const Float value)
Non-owning wrapper of pointer.
Object holding various statistics about current run.
Statistics & set(const StatisticsId idx, TValue &&value)
Sets new values of a statistic.
TValue getOr(const StatisticsId idx, const TValue &other) const
Returns value of a statistic, or a given value if the statistic is not stored.
Container storing all quantities used within the simulations.
Size getMaterialCnt() const
Return the number of materials in the storage.
Size getParticleCnt() const
Returns the number of particles.
MaterialView getMaterial(const Size matIdx) const
Returns an object containing a reference to given material.
Array< TValue > & getValue(const QuantityId key)
Retrieves a quantity values from the storage, given its key and value type.
Basic solver for integration of SPH equations.
virtual void create(Storage &storage, IMaterial &material) const override
Initializes all quantities needed by the solver in the storage.
LutKernel< Dim > kernel
Selected SPH kernel.
virtual void sanityCheck(const Storage &storage) const
Used to check internal consistency of the solver.
ThreadLocal< ThreadData > threadData
Thread-local structure caching all buffers needed to compute derivatives.
virtual void afterLoop(Storage &storage, Statistics &stats)
AutoPtr< ISymmetricFinder > finder
Structure used to search for neighbouring particles.
EquationHolder equations
Holds all equation terms evaluated by the solver.
virtual RawPtr< const IBasicFinder > getFinder(ArrayView< const Vector > r)
virtual void integrate(Storage &storage, Statistics &stats) override
Computes derivatives of all time-dependent quantities.
SymmetricSolver(IScheduler &scheduler, const RunSettings &settings, const EquationHolder &eqs, AutoPtr< IBoundaryCondition > &&bc)
Creates a symmetric solver, given the list of equations to solve.
virtual void beforeLoop(Storage &storage, Statistics &stats)
virtual void loop(Storage &storage, Statistics &stats)
INLINE Vector grad(const Vector &r1, const Vector &r2) const
Creating code components based on values from settings.
Provides a convenient way to construct objects from settings.
AutoPtr< ISymmetricFinder > getFinder(const RunSettings &settings)
AutoPtr< IBoundaryCondition > getBoundaryConditions(const RunSettings &settings, SharedPtr< IDomain > domain)
Overload of std::swap for Sph::Array.