26 static constexpr
Float normalization = 32._f /
PI;
34 return normalization * (2._f *
pow<3>(1._f - q) *
pow<3>(q) - 1._f / 64._f);
82 template <
bool Symmetrize>
85 return {
Vector(0._f), 0._f };
91 const Vector f = -gamma * C * dr - gamma * (n[i] - n[j]);
125 template <
bool Symmetrize>
127 n[i] += r[i][
H] * m[j] / rho[j] * grad;
129 n[j] -= r[j][
H] * m[i] / rho[i] * grad;
137 derivatives.
require(makeAuto<CohesionDerivative>(settings));
138 derivatives.
require(makeAuto<ColorFieldDerivative>(settings));
@ UNIQUE
Only a single derivative accumulates to this buffer.
INLINE bool isReal(const AntisymmetricTensor &t)
#define SPH_ASSERT(x,...)
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 T sqrt(const T f)
Return a squared root of a value.
constexpr INLINE Float pow< 3 >(const Float v)
constexpr Float PI
Mathematical constants.
#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.
@ SURFACE_NORMAL
Vector approximating surface normal.
@ MASS
Paricles masses, always a scalar quantity.
@ 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
INLINE Vector getNormalized(const Vector &v)
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.
INLINE void additionalInitialize(const Storage &input, Accumulated &UNUSED(results))
INLINE Tuple< Vector, Float > eval(const Size i, const Size j, const Vector &UNUSED(grad))
INLINE bool additionalEquals(const CohesionDerivative &UNUSED(other)) const
INLINE void additionalCreate(Accumulated &UNUSED(results))
CohesionDerivative(const RunSettings &settings)
Helper kernel used to simulate Lennard-Jones forces.
INLINE Float radius() const
INLINE Float gradImpl(const Float UNUSED(qSqr)) const
INLINE Float valueImpl(const Float qSqr) const
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 create(Storage &storage, IMaterial &UNUSED(material)) const override
virtual void finalize(IScheduler &UNUSED(scheduler), Storage &UNUSED(storage), const Float UNUSED(t)) override
Computes the color field of the fluid.
INLINE bool additionalEquals(const ColorFieldDerivative &UNUSED(other)) const
INLINE void eval(const Size i, const Size j, const Vector &grad)
ColorFieldDerivative(const RunSettings &settings)
INLINE void additionalInitialize(const Storage &input, Accumulated &results)
INLINE void additionalCreate(Accumulated &results)
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.
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.
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.
INLINE Float value(const Vector &r1, const Vector &r2) const
Heterogeneous container capable of storing a fixed number of values.
@ SURFACE_TENSION
Coefficient of surface tension.