40 const Float eps = 1.e-2_f;
59 return alpha == other.alpha && beta == other.beta;
62 template <
bool Symmetrize>
66 const Vector Pi = av * grad;
67 const Float heating = 0.5_f * av *
dot(v[i] - v[j], grad);
69 return { -Pi, heating };
74 const Float dvdr =
dot(v[i] - v[j], r[i] - r[j]);
78 const Float hbar = 0.5_f * (r[i][
H] + r[j][
H]);
79 const Float rhobar = 0.5_f * (rho[i] + rho[j]);
80 const Float csbar = 0.5_f * (cs[i] + cs[j]);
82 return 1._f / rhobar * (-alpha * csbar * mu + beta *
sqr(mu));
87 derivatives.
require(makeAuto<Derivative>(settings));
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.
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
#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.
@ SOUND_SPEED
Sound speed, always a scalar quantity.
StaticArray< T0 &, sizeof...(TArgs)+1 > tie(T0 &t0, TArgs &... rest)
Creates a static array from a list of l-value references.
Container for storing particle quantities and materials.
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...
Helper template specifically used to implement forces.
Storage for accumulating derivatives.
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.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
INLINE Float evalAv(const Size i, const Size j) const
Term used for Balsara switch.
INLINE void additionalCreate(Accumulated &UNUSED(results))
INLINE bool additionalEquals(const Derivative &other) const
INLINE Tuple< Vector, Float > eval(const Size i, const Size j, const Vector &grad)
INLINE void additionalInitialize(const Storage &input, Accumulated &UNUSED(results))
Derivative(const RunSettings &settings)
Standard artificial viscosity Monaghan & Gingold .
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
virtual void initialize(IScheduler &UNUSED(scheduler), Storage &UNUSED(storage), const Float UNUSED(t)) override
Container storing all quantities used within the simulations.
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.
Heterogeneous container capable of storing a fixed number of values.
Generic storage and input/output routines of settings.
RunSettingsId
Settings relevant for whole run of the simulation.
@ SPH_AV_BETA
Artificial viscosity beta coefficient.
@ SPH_AV_ALPHA
Artificial viscosity alpha coefficient.