27 static constexpr
Float multiplier = 1.e17_f;
55 INLINE bool additionalEquals(
const Derivative& other)
const {
56 return eta == other.eta && zeta == other.zeta;
59 template <
bool Symmetrize>
63 const Vector shear = eta * (dgv + gdv / 3._f);
64 const Vector iso = zeta * gdv;
65 const Vector term = (shear + iso) / (rho[i] * rho[j]);
66 gradDivV[i] += m[j] / rho[j] * gdv * multiplier;
67 divGradV[i] += m[j] / rho[j] * dgv * multiplier;
69 gradDivV[j] -= m[i] / rho[i] * gdv * multiplier;
70 divGradV[j] -= m[i] / rho[i] * dgv * multiplier;
73 return { term, 0._f };
79 derivatives.
require(makeAuto<Derivative>(settings));
126 INLINE bool additionalEquals(
const Derivative& other)
const {
127 return eta == other.eta;
130 template <
bool Symmetrize>
138 frict[i] += m[j] * f;
140 frict[j] -= m[i] * f;
151 derivatives.
require(makeDerivative<VelocityGradient>(settings, flags));
152 derivatives.
require(makeAuto<Derivative>(settings));
194 INLINE bool additionalEquals(
const Derivative&
UNUSED(other))
const {
198 template <
bool Symmetrize>
200 const Float csbar = 0.5_f * (cs[i] + cs[j]);
201 const Vector f = k * (v[i] - v[j]) / csbar;
209 derivatives.
require(makeAuto<Derivative>(settings));
@ 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...
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.
Base class for all particle materials.
INLINE Vector gradientOfDivergence(const Vector &value, const Vector &grad, const Vector &dr)
Second derivative of vector quantity, applying gradient on a divergence.
INLINE T laplacian(const T &value, const Vector &grad, const Vector &dr)
SPH approximation of laplacian, computed from a kernel gradient.
constexpr INLINE Float pow< 2 >(const Float v)
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
@ VELOCITY_GRADIENT
Velocity gradient.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ ENERGY
Specific internal energy, always a scalar quantity.
@ DENSITY
Density, always a scalar quantity.
@ MASS
Paricles masses, always a scalar quantity.
@ SOUND_SPEED
Sound speed, always a scalar quantity.
@ VELOCITY_GRADIENT_OF_DIVERGENCE
@ 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.
BasicVector< Float > Vector
Helper template specifically used to implement forces.
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.
Object providing safe access to continuous memory of data.
Container holding derivatives and the storage they accumulate to.
virtual void require(AutoPtr< IDerivative > &&derivative)
Adds derivative if not already present.
Represents a term or terms appearing in evolutionary equations.
Material settings and functions specific for one material.
INLINE TValue getParam(const BodySettingsId paramIdx) const
Returns a parameter associated with given particle.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Non-owning wrapper of a material and particles with this material.
virtual void finalize(IScheduler &UNUSED(scheduler), Storage &UNUSED(storage), const Float UNUSED(t)) override
virtual void create(Storage &storage, IMaterial &UNUSED(material)) const override
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 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 create(Storage &UNUSED(storage), IMaterial &UNUSED(material)) const override
virtual void finalize(IScheduler &UNUSED(scheduler), Storage &UNUSED(storage), const Float UNUSED(t)) override
Container storing all quantities used within the simulations.
bool isHomogeneous(const BodySettingsId param) const
Checks if the particles in the storage are homogeneous with respect to given parameter.
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.
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.
Symmetric tensor of 2nd order.
static INLINE SymmetricTensor identity()
Returns an identity tensor.
static INLINE SymmetricTensor null()
Returns a tensor with all zeros.
Heterogeneous container capable of storing a fixed number of values.
virtual void finalize(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 create(Storage &storage, IMaterial &material) const override
Creates all quantities needed by the term using given material.
virtual void initialize(IScheduler &UNUSED(scheduler), Storage &UNUSED(storage), const Float UNUSED(t)) override
@ ENERGY
Initial specific internal energy.