39 template <
bool Symmetrize>
42 const Vector f = (rho[j] - rho[i]) * grad;
43 drho[i] += m[j] / rho[j] * f;
45 drho[j] += m[i] / rho[i] * f;
72 bool additionalEquals(
const Derivative& other)
const {
73 return delta == other.delta;
84 template <
bool Symmetrize>
86 const Vector dr = r[j] - r[i];
87 const Vector psi = 2._f * (rho[j] - rho[i]) * dr /
getSqrLength(dr) - (gradRho[i] + gradRho[j]);
88 const Float hbar = 0.5_f * (r[i][
H] + r[j][
H]);
89 const Float cbar = 0.5_f * (cs[i] + cs[j]);
90 const Float f = delta * hbar * cbar *
dot(psi, grad);
92 drho[i] += m[j] / rho[j] * f;
95 drho[j] += m[i] / rho[i] * f;
102 derivatives.
require(makeAuto<RenormalizedDensityGradient>(settings));
103 derivatives.
require(makeAuto<Derivative>(settings));
140 bool additionalEquals(
const Derivative& other)
const {
141 return alpha == other.alpha;
152 template <
bool Symmetrize>
154 const Vector dr = r[j] - r[i];
156 const Float hbar = 0.5_f * (r[i][
H] + r[j][
H]);
158 const Float cbar = 0.5_f * (cs[i] + cs[j]);
159 const Vector f = alpha * hbar * cbar * pi * grad;
160 const Float dh = dv[i][
H];
161 dv[i] += m[j] / rho[j] * f;
166 dv[j] -= m[i] / rho[i] * f;
173 derivatives.
require(makeAuto<Derivative>(settings));
@ SHARED
Multiple derivatives may accumulate into the buffer.
@ UNIQUE
Only a single derivative accumulates to this buffer.
#define SPH_ASSERT(x,...)
@ SUM_ONLY_UNDAMAGED
Only undamaged particles (particles with damage > 0) from the same body (body with the same flag) wil...
@ CORRECTED
Use correction tensor on kernel gradient when evaluating the derivative.
Right-hand side term of SPH equations.
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.
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ DENSITY
Density, always a scalar quantity.
@ DELTASPH_DENSITY_GRADIENT
@ MASS
Paricles masses, always a scalar quantity.
@ SOUND_SPEED
Sound speed, always a scalar quantity.
@ SECOND
Quantity with 1st and 2nd derivative.
@ FIRST
Quantity with 1st derivative.
@ ZERO
Quantity without derivatives, or "zero order" of quantity.
StaticArray< T0 &, sizeof...(TArgs)+1 > tie(T0 &t0, TArgs &... rest)
Creates a static array from a list of l-value references.
INLINE Float getSqrLength(const Vector &v)
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.
Numerical diffusion of density.
virtual void initialize(IScheduler &UNUSED(scheduler), Storage &UNUSED(storage), const Float UNUSED(t)) override
virtual void setDerivatives(DerivativeHolder &derivatives, const RunSettings &settings) override
Sets derivatives required by this term.
virtual void finalize(IScheduler &UNUSED(scheduler), Storage &UNUSED(storage), const Float UNUSED(t)) override
virtual void create(Storage &storage, IMaterial &UNUSED(material)) const override
RenormalizedDensityGradient(const RunSettings &settings)
INLINE bool additionalEquals(const RenormalizedDensityGradient &UNUSED(other)) const
INLINE void eval(const Size i, const Size j, const Vector &grad)
void additionalCreate(Accumulated &results)
INLINE void additionalInitialize(const Storage &input, Accumulated &results)
Numerical diffusion of velocity.
virtual void setDerivatives(DerivativeHolder &derivatives, const RunSettings &settings) override
Sets derivatives required by this term.
virtual void initialize(IScheduler &UNUSED(scheduler), Storage &UNUSED(storage), const Float UNUSED(t)) override
virtual void finalize(IScheduler &UNUSED(scheduler), Storage &UNUSED(storage), const Float UNUSED(t)) override
virtual void create(Storage &storage, IMaterial &UNUSED(material)) const override
Container holding derivatives and the storage they accumulate to.
virtual void require(AutoPtr< IDerivative > &&derivative)
Adds derivative if not already present.
Helper template for derivatives that define both the symmetrized and asymmetric variant.
Represents a term or terms appearing in evolutionary equations.
Material settings and functions specific for one material.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
TValue get(const TEnum idx, std::enable_if_t<!std::is_enum< std::decay_t< TValue >>::value, int >=0) const
Returns a value of given type from the settings.
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.
StaticArray< Array< TValue > &, 3 > getAll(const QuantityId key)
Retrieves quantity buffers from the storage, given its key and value type.
auto getValues(const QuantityId first, const QuantityId second, const TArgs... others)
Retrieves an array of quantities from the key.
@ SPH_VELOCITY_DIFFUSION_ALPHA
Alpha-coefficient of the delta-SPH modification.
@ SPH_DENSITY_DIFFUSION_DELTA
Delta-coefficient of the delta-SPH modification, see Marrone et al. 2011.