9 template <
typename Discr>
26 kernel = Factory::getKernel<3>(settings);
42 return n == other.n && xi == other.xi;
45 template <
bool Symmetrize>
50 const Float phi = xi *
pow(w / wp[i], n);
54 const Vector f = Pi * grad;
55 const Float heating = 0.5_f *
dot(Pi * (v[i] - v[j]), grad);
56 return { f, heating };
61 kernel = Factory::getKernel<3>(settings);
68 switch (formulation) {
70 struct StandardDiscr {
74 const Float rhoj)
const {
75 return asi /
sqr(rhoi) + asj /
sqr(rhoj);
81 struct BenzAsphaugDiscr {
85 const Float rhoj)
const {
86 return (asi + asj) / (rhoi * rhoj);
103 const SymmetricTensor sigma = SymmetricTensor(s[i]) - p[i] * SymmetricTensor::identity();
106 Eigen eigen = eigenDecomposition(sigma);
107 AffineMatrix matrix = eigen.vectors;
108 Vector sigma_diag = eigen.values;
111 const Vector as_diag = -max(sigma_diag, Vector(0._f));
114 as[i] = transform(SymmetricTensor(as_diag, Vector(0._f)), matrix.transpose());
124 for (
Size i = 0; i < r.size(); ++i) {
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
INLINE AutoPtr< T > makeAuto(TArgs &&... args)
@ 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.
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
constexpr INLINE Float pow(const Float v)
Power for floats.
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
@ DEVIATORIC_STRESS
Deviatoric stress tensor, always a traceless tensor.
@ INTERPARTICLE_SPACING_KERNEL
Auxiliary quantity needed for evaluating artificial stress.
@ PRESSURE
Pressure, affected by yielding and fragmentation model, always a scalar quantity.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ DENSITY
Density, always a scalar quantity.
@ AV_STRESS
Artificial stress by Monaghan .
@ ZERO
Quantity without derivatives, or "zero order" of quantity.
Interface for executing tasks (potentially) asynchronously.
INLINE void parallelFor(IScheduler &scheduler, const Size from, const Size to, TFunctor &&functor)
Executes a functor concurrently from all available threads.
StaticArray< T0 &, sizeof...(TArgs)+1 > tie(T0 &t0, TArgs &... rest)
Creates a static array from a list of l-value references.
Form of tensor artificial viscosity for SPH with stress tensor.
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.
Container holding derivatives and the storage they accumulate to.
virtual void require(AutoPtr< IDerivative > &&derivative)
Adds derivative if not already present.
Material settings and functions specific for one material.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Generic container for storing scalar, vector or tensor quantity and its derivatives.
INLINE Array< TValue > & getValue()
Returns a reference to array of quantity values.
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.
INLINE bool additionalEquals(const Derivative &other) const
INLINE Tuple< Vector, Float > eval(const Size i, const Size j, const Vector &grad)
INLINE void additionalCreate(Accumulated &UNUSED(results)) const
INLINE void additionalInitialize(const Storage &input, Accumulated &UNUSED(results))
Derivative(const RunSettings &settings)
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.
virtual void finalize(IScheduler &scheduler, Storage &storage, const Float t) override
Computes all the derivatives and/or quantity values based on accumulated derivatives.
StressAV(const RunSettings &settings)
virtual void setDerivatives(DerivativeHolder &derivatives, const RunSettings &settings) override
Sets derivatives required by this term.
Symmetric tensor of 2nd order.
static INLINE SymmetricTensor null()
Returns a tensor with all zeros.
INLINE Float value(const Vector &r1, const Vector &r2) const
Symmetric traceless 2nd order tensor.
Heterogeneous container capable of storing a fixed number of values.
Creating code components based on values from settings.
@ STANDARD
P_i / rho_i^2 + P_j / rho_j^2.
@ BENZ_ASPHAUG
(P_i + P_j) / (rho_i rho_j)
@ SPH_AV_STRESS_FACTOR
Multiplicative factor of the artificial stress term (= strength of the viscosity)
@ SPH_AV_STRESS_EXPONENT
Weighting function exponent n in artificial stress term.
@ SPH_DISCRETIZATION
Specifies a discretization of SPH equations; see DiscretizationEnum.