40 for (
Size k = 0; k < neighs.
size(); ++k) {
41 const Size j = neighs[k];
42 if (idxs[i] != idxs[j] || reduce[i] == 0._f || reduce[j] == 0._f) {
47 C[i] += m[j] / rho[j] * t;
50 for (
Size k = 0; k < neighs.
size(); ++k) {
51 const Size j = neighs[k];
53 C[i] += m[j] / rho[j] * t;
62 if (C[i].determinant() > 0.01_f) {
63 C[i] = C[i].inverse();
82 if (
typeid(value1) ==
typeid(value2)) {
84 if (!value1.
equals(value2)) {
86 "Using two derivatives with the same type, but with different internal state. This is "
87 "currently unsupported; while it is allowed to require the same derivative more than "
88 "once, it MUST have the same state.");
93 derivatives.insert(std::move(derivative));
99 for (
const auto& deriv : derivatives) {
100 deriv->create(accumulated);
107 for (
const auto& deriv : derivatives) {
109 deriv->initialize(input, accumulated);
115 for (
const auto& deriv : derivatives) {
116 deriv->evalNeighs(idx, neighs, grads);
125 for (
const auto& deriv : derivatives) {
132 for (
const auto& deriv : derivatives) {
@ UNIQUE
Only a single derivative accumulates to this buffer.
INLINE Float minElement(const AntisymmetricTensor &t)
Returns the minimal element of the tensor.
#define SPH_ASSERT(x,...)
Spatial derivatives to be computed by SPH discretization.
DerivativePhase
Defines the phases of derivative evaluation.
@ PRECOMPUTE
Auxiliary quantities needed for evaluation of other derivatives (grad-h, correction tensor,...
Key-value associative container implemented as a sorted array.
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.
#define NAMESPACE_SPH_END
@ FLAG
ID of original body, used to implement discontinuities between bodies in SPH.
@ STRAIN_RATE_CORRECTION_TENSOR
Correction tensor used to improve conservation of total angular momentum.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ DENSITY
Density, always a scalar quantity.
@ MASS
Paricles masses, always a scalar quantity.
@ STRESS_REDUCING
Total stress reduction factor due to damage and yielding. Is always scalar.
Holder of quantity values and their temporal derivatives.
@ 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 SymmetricTensor symmetricOuter(const Vector &v1, const Vector &v2)
SYMMETRIZED outer product of two vectors.
Storage for accumulating derivatives.
void initialize(const Size size)
Initialize all storages.
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.
INLINE TCounter size() const
Wrapper of pointer that deletes the resource from destructor.
CorrectionTensor(const RunSettings &settings)
virtual void create(Accumulated &results) override
Emplace all needed buffers into shared storage.
virtual void initialize(const Storage &input, Accumulated &results) override
Initialize derivative before iterating over neighbours.
virtual DerivativePhase phase() const override
Returns the phase of the derivative.
virtual void evalNeighs(Size i, ArrayView< const Size > neighs, ArrayView< const Vector > grads) override
Compute derivatives of given particle.
virtual void require(AutoPtr< IDerivative > &&derivative)
Adds derivative if not already present.
void evalSymmetric(const Size idx, ArrayView< const Size > neighs, ArrayView< const Vector > grads)
Evaluates all held derivatives symetrically for given particle pairs.
void eval(const Size idx, ArrayView< const Size > neighs, ArrayView< const Vector > grads)
Evaluates all held derivatives for given particle.
bool isSymmetric() const
Returns true if all stored derivatives are symmetric.
virtual void initialize(const Storage &input)
Initialize derivatives before loop.
Derivative accumulated by summing up neighbouring particles.
virtual bool equals(const IDerivative &other) const
Returns true if this derivative is equal to the given derivative.
Extension of derivative, allowing a symmetrized evaluation.
virtual void evalSymmetric(const Size idx, ArrayView< const Size > neighs, ArrayView< const Vector > grads)=0
Compute a part of derivatives from interaction of particle pairs.
Thrown when components of the run are mutually incompatible.
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.
Size getParticleCnt() const
Returns the number of particles.
auto getValues(const QuantityId first, const QuantityId second, const TArgs... others)
Retrieves an array of quantities from the key.
bool has(const QuantityId key) const
Checks if the storage contains quantity with given key.
Array< TValue > & getValue(const QuantityId key)
Retrieves a quantity values from the storage, given its key and value type.
Symmetric tensor of 2nd order.
static INLINE SymmetricTensor identity()
Returns an identity tensor.
static INLINE SymmetricTensor null()
Returns a tensor with all zeros.