16 template <
typename Type>
17 std::enable_if_t<!std::is_constructible<Type, const RunSettings&>::value, Type>
makeFromSettings(
24 template <
typename Type>
25 std::enable_if_t<std::is_constructible<Type, const RunSettings&>::value, Type>
makeFromSettings(
28 return Type(settings);
47 template <
typename AV>
50 static_assert(std::is_base_of<IEquationTerm, AV>::value,
"AV must be derived from IEquationTerm");
58 typename AV::Derivative av;
59 const Float eps = 1.e-4_f;
77 av.initialize(input, results);
80 INLINE bool additionalEquals(
const Derivative& other)
const {
81 return av.equals(other.av);
84 template <
bool Symmetrize>
86 const Float Pi = 0.5_f * (factor(i) + factor(j)) * av.evalAv(i, j);
88 const Float heating = 0.5_f * Pi *
dot(v[i] - v[j], grad);
89 return { Pi * grad, heating };
95 return dv / (dv + rv + eps * cs[i] / r[i][
H]);
111 derivatives.
require(makeDerivative<VelocityDivergence>(settings));
112 derivatives.
require(makeDerivative<VelocityRotation>(settings));
113 derivatives.
require(makeAuto<Derivative>(settings));
117 av.initialize(scheduler, storage, t);
121 av.finalize(scheduler, storage, t);
129 for (
Size i = 0; i < factor.size(); ++i) {
132 factor[i] = dv / (dv + rv + 1.e-4_f * cs[i] / r[i][
H]);
143 av.create(storage, material);
INLINE bool isReal(const AntisymmetricTensor &t)
#define SPH_ASSERT(x,...)
NAMESPACE_SPH_BEGIN std::enable_if_t<!std::is_constructible< Type, const RunSettings & >::value, Type > makeFromSettings(const RunSettings &UNUSED(settings))
Helper function allowing to construct an object from settings if the object defines such constructor,...
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.
INLINE auto abs(const T &f)
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
@ VELOCITY_DIVERGENCE
Velocity divergence.
@ AV_BALSARA
Balsara factor.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ VELOCITY_ROTATION
Velocity rotation.
@ SOUND_SPEED
Sound speed, 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.
INLINE Float getLength(const Vector &v)
Returns the length of the vector. Enabled only for vectors of floating-point precision.
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...
Helper template specifically used to implement forces.
Storage for accumulating derivatives.
Implementation of the Balsara switch , designed to reduce artificial viscosity in shear flows and avo...
virtual void setDerivatives(DerivativeHolder &derivatives, const RunSettings &settings) override
Sets derivatives required by this term.
BalsaraSwitch(const RunSettings &settings)
virtual void finalize(IScheduler &scheduler, Storage &storage, const Float t) override
Computes all the derivatives and/or quantity values based on accumulated derivatives.
virtual void create(Storage &storage, IMaterial &material) const override
Creates all quantities needed by the term using given material.
virtual void initialize(IScheduler &scheduler, Storage &storage, const Float t) override
Initialize all the derivatives and/or quantity values before derivatives are computed.
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.
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.
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.
@ SPH_AV_BALSARA_STORE
If true, Balsara factors will be saved as quantity AV_BALSARA. Mainly for debugging purposes.