28 const Float eps = 1.e-2_f;
48 template <
bool Symmetric>
51 const Float heating = 0.5_f * Pi *
dot(v[i] - v[j], grad);
53 return { Pi * grad, heating };
57 const Float dvdr =
dot(v[i] - v[j], r[i] - r[j]);
61 const Float hbar = 0.5_f * (r[i][
H] + r[j][
H]);
62 const Float csbar = 0.5_f * (cs[i] + cs[j]);
63 const Float rhobar = 0.5_f * (rho[i] + rho[j]);
64 const Float alphabar = 0.5_f * (alpha[i] + alpha[j]);
65 const Float betabar = 2._f * alphabar;
67 return 1._f / rhobar * (-alphabar * csbar * mu + betabar *
sqr(mu));
72 derivatives.
require(makeDerivative<VelocityDivergence>(settings));
73 derivatives.
require(makeAuto<Derivative>(settings));
86 constexpr
Float eps = 0.1_f;
91 const Float tau = r[i][
H] / (eps * cs[i]);
95 dalpha[i] = decayTerm + sourceTerm;
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.
constexpr INLINE T max(const T &f1, const T &f2)
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
@ AV_ALPHA
Coefficient alpha of the artificial viscosity. Coefficient beta is always 2*alpha.
@ VELOCITY_DIVERGENCE
Velocity divergence.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ DENSITY
Density, always a scalar quantity.
@ SOUND_SPEED
Sound speed, always a scalar quantity.
@ 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.
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.
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.
void setRange(const QuantityId id, const Interval &range, const Float minimal)
Sets the timestepping parameters of given quantity.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Object representing a 1D interval of real numbers.
INLINE Float lower() const
Returns lower bound of the interval.
INLINE Float upper() const
Returns upper bound of the interval.
Non-owning wrapper of a material and particles with this material.
INLINE IndexSequence sequence()
Returns iterable index sequence.
Derivative(const RunSettings &settings)
INLINE Float evalAv(const Size i, const Size j) const
INLINE bool additionalEquals(const Derivative &UNUSED(other)) const
INLINE void additionalInitialize(const Storage &input, Accumulated &UNUSED(results))
INLINE Tuple< Vector, Float > eval(const Size i, const Size j, const Vector &grad)
INLINE void additionalCreate(Accumulated &UNUSED(results))
Time-dependent artificial viscosity with non-homogeneous oefficients alpha and beta.
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 &storage, const Float UNUSED(t)) override
virtual void create(Storage &storage, IMaterial &material) const override
Creates all quantities needed by the term using given material.
Container storing all quantities used within the simulations.
Size getMaterialCnt() const
Return the number of materials in the storage.
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.
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.
Heterogeneous container capable of storing a fixed number of values.
Generic storage and input/output routines of settings.
@ AV_ALPHA_RANGE
Lower and upper bound of the alpha coefficient, used only for time-dependent artificial viscosity.