private:
public:
SpringForce(
const Float springConstant)
: k(springConstant) {}
}
}
dv[i] += -k / m[i] * r[i];
}
}
virtual void create(
Storage&, Abstract::Material&)
const override {
}
};
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.
StaticArray< Vector, 8 > POSITIONS
Object providing safe access to continuous memory of data.
INLINE TCounter size() const
Container holding derivatives and the storage they accumulate to.
Represents a term or terms appearing in evolutionary equations.
virtual void finalize(IScheduler &scheduler, Storage &storage, const Float t)=0
Computes all the derivatives and/or quantity values based on accumulated derivatives.
virtual void setDerivatives(DerivativeHolder &derivatives, const RunSettings &settings)=0
Sets derivatives required by this term.
virtual void initialize(IScheduler &scheduler, Storage &storage, const Float t)=0
Initialize all the derivatives and/or quantity values before derivatives are computed.
virtual void create(Storage &storage, IMaterial &material) const =0
Creates all quantities needed by the term using given material.
Container storing all quantities used within the simulations.
Array< TValue > & getD2t(const QuantityId key)
Retrieves a quantity second derivative 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.
Harmonic force only depends on the position of particle, independent for other particles. In other words, doesn't depend on spatial derivatives of any quantity. PressureForce, on the other hand, does depend. Implementations of IEquationTerm never directly compute interactions between particles. This is handled by different object, IDerivative.
enum class AdditionalId {
};
private:
public:
}
flow = results.getValue<
Float>(
QuantityId(AdditionalId::ENERGY_LAPLACIAN));
}
for (
Size k = 0; k < neighs.
size(); ++k) {
const Size j = neighs[k];
flow[i] += m[j] / rho[j] * f;
flow[j] -= m[i] / rho[i] * f;
}
}
for (
Size k = 0; k < neighs.
size(); ++k) {
const Size j = neighs[k];
flow[i] += m[j] / rho[j] * f;
}
}
};
private:
public:
: alpha(alpha) {}
}
}
for (
Size i = 0; i < du.size(); ++i) {
du[i] += -alpha * delta[i];
}
}
virtual void create(
Storage& storage, Abstract::Material&)
const override {
}
};
INLINE T laplacian(const T &value, const Vector &grad, const Vector &dr)
SPH approximation of laplacian, computed from a kernel gradient.
QuantityId
Unique IDs of basic quantities of SPH particles.
@ ENERGY_LAPLACIAN
Laplacian of internal energy, used in heat diffusion equation.
@ ENERGY
Specific internal energy, always a scalar quantity.
@ DENSITY
Density, 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 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...
Storage for accumulating derivatives.
void insert(const QuantityId id, const OrderEnum order, const BufferSource source)
Creates a new storage with given ID.
virtual void require(AutoPtr< IDerivative > &&derivative)
Adds derivative if not already present.
virtual void create(Accumulated &results) override final
virtual void evalSymmetric(const Size idx, ArrayView< const Size > neighs, ArrayView< const Vector > grads) override
virtual void initialize(const Storage &input, Accumulated &results) override final
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.
virtual void setDerivatives(DerivativeHolder &derivatives, const RunSettings &settings) override
Sets derivatives required by this term.
Derivative accumulated by summing up neighbouring particles.
Quantity & insert(const QuantityId key, const OrderEnum order, const TValue &defaultValue)
Creates a quantity in the storage, given its key, value type and order.
Array< TValue > & getDt(const QuantityId key)
Retrieves a quantity derivative 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.