26 for (
Size k = 0; k < neighs.
size(); ++k) {
27 const Size j = neighs[k];
28 const Vector f = p[i] /
sqr(rho[i]) * gradi[k] + p[j] /
sqr(rho[j]) * gradj[k];
55 const Size j = n.index;
56 const Vector r_ji = r[j] - r[i];
65 omega[i] = 1._f + r[i][
H] / (3._f * rho[i]) *
sum;
77 , secondData(scheduler) {
78 for (
auto& term : asymmetricTerms) {
79 term->setAsymmetricDerivatives(asymmetricDerivatives);
91 for (
auto& deriv : asymmetricDerivatives) {
100 for (
Size i = 0; i < r.
size(); ++i) {
101 maxH =
max(maxH, r[i][
H]);
106 GradH gradH(storage);
124 for (
auto& n : data.neighs) {
125 const Size j = n.index;
130 data.idxs.emplaceBack(j);
131 data.grads.emplaceBack(gradi);
139 for (
auto& deriv : asymmetricDerivatives) {
140 deriv->evalAsymmetric(i, data.idxs, data.grads, secondGrads);
143 neighs[i] = data.idxs.
size();
@ SHARED
Multiple derivatives may accumulate into the buffer.
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.
constexpr int DIMENSIONS
Number of spatial dimensions in the code.
Extension of SPH solver taking into account the gradient of smoothing lengths.
constexpr INLINE T max(const T &f1, const T &f2)
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
#define NAMESPACE_SPH_END
@ PRESSURE
Pressure, affected by yielding and fragmentation model, always a scalar quantity.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ DENSITY
Density, always a scalar quantity.
@ MASS
Paricles masses, always a scalar quantity.
@ NEIGHBOUR_CNT
Number of neighbouring particles (in radius h * kernel.radius)
Holder of quantity values and their temporal derivatives.
@ SECOND
Quantity with 1st and 2nd derivative.
@ 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.
StaticArray< T0 &, sizeof...(TArgs)+1 > tie(T0 &t0, TArgs &... rest)
Creates a static array from a list of l-value references.
BasicVector< Float > Vector
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.
Array< TValue > & getBuffer(const QuantityId id, const OrderEnum order)
Returns the buffer of given quantity and given order.
void insert(const QuantityId id, const OrderEnum order, const BufferSource source)
Creates a new storage with given ID.
INLINE TCounter size() const
Generic dynamically allocated resizable storage.
StorageType & emplaceBack(TArgs &&... args)
Constructs a new element at the end of the array in place, using the provided arguments.
void clear()
Removes all elements from the array, but does NOT release the memory.
virtual void initialize(const Storage &input, Accumulated &results) override
Initialize derivative before iterating over neighbours.
virtual void create(Accumulated &results) override
Emplace all needed buffers into shared storage.
virtual void evalAsymmetric(const Size i, ArrayView< const Size > neighs, ArrayView< const Vector > gradi, ArrayView< const Vector > gradj) override
Compute a part of derivatives from interaction of particle pairs.
Generic SPH solver, evaluating equations for each particle separately.
ThreadLocal< ThreadData > threadData
DerivativeHolder derivatives
Holds all derivatives (shared for all threads)
Wrapper of pointer that deletes the resource from destructor.
void eval(const Size idx, ArrayView< const Size > neighs, ArrayView< const Vector > grads)
Evaluates all held derivatives for given particle.
INLINE Accumulated & getAccumulated()
Container holding equation terms.
GradHSolver(IScheduler &scheduler, const RunSettings &settings, const EquationHolder &basicTerms, Array< AutoPtr< IAsymmetricTerm >> &&asymmetricTerms)
virtual void create(Storage &storage, IMaterial &material) const override
Initializes all quantities needed by the solver in the storage.
virtual void loop(Storage &storage, Statistics &stats) override
Object evaluating grad-h terms.
void eval(const LutKernel< DIMENSIONS > &kernel, const Size i, ArrayView< const NeighbourRecord > neighs)
Special derivative evaluated by GradHSolver.
IScheduler & scheduler
Scheduler used to parallelize the solver.
LutKernel< DIMENSIONS > kernel
Selected SPH kernel.
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.
virtual RawPtr< const IBasicFinder > getFinder(ArrayView< const Vector > r)
Returns a finder, already build using the provided positions.
Interface of objects finding neighbouring particles.
Material settings and functions specific for one material.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
INLINE Float value(const Vector &r, const Float h) const noexcept
INLINE Vector grad(const Vector &r, const Float h) const noexcept
INLINE Float radius() const noexcept
Object holding various statistics about current run.
Container storing all quantities used within the simulations.
Quantity & insert(const QuantityId key, const OrderEnum order, const TValue &defaultValue)
Creates a quantity in the storage, given its key, value type and order.
auto getValues(const QuantityId first, const QuantityId second, const TArgs... others)
Retrieves an array of quantities from the key.
Array< TValue > & getValue(const QuantityId key)
Retrieves a quantity values from the storage, given its key and value type.
INLINE Type & local()
Return a value for current thread.
Holds information about a neighbour particles.