45 : solver(
std::move(solver))
46 , timeRange(timeRange)
50 : solver(
std::move(solver)) {
66 computeBodyData(storage);
74 for (
Size i = 0; i < r.
size(); ++i) {
76 const Float factor = 1._f +
lerp(delta * dt, 0._f, (t - timeRange.
lower()) / timeRange.
size());
81 const Vector v_local =
cross(data->omega, r[i] - data->center);
84 v[i] = (v[i] - v_local) / factor + v_local;
94 for (
Size i = 0; i < D.
size(); ++i) {
102 for (
Size i = 0; i <
Y.size(); ++i) {
110 solver->
collide(storage, stats, dt);
114 solver->
create(storage, material);
118 void computeBodyData(
const Storage& storage) {
Various function for interpretation of the results of a simulation.
INLINE bool isReal(const AntisymmetricTensor &t)
#define SPH_ASSERT(x,...)
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.
Base interface for all solvers.
INLINE T lerp(const T v1, const T v2, const TAmount amount)
#define NAMESPACE_SPH_END
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ MASS
Paricles masses, always a scalar quantity.
@ STRESS_REDUCING
Total stress reduction factor due to damage and yielding. Is always scalar.
StaticArray< T0 &, sizeof...(TArgs)+1 > tie(T0 &t0, TArgs &... rest)
Creates a static array from a list of l-value references.
Statistics gathered and periodically displayed during the run.
@ RUN_TIME
Current time of the simulation in code units. Does not necessarily have to be 0 when run starts.
@ TIMESTEP_VALUE
Current value of timestep.
INLINE BasicVector< float > cross(const BasicVector< float > &v1, const BasicVector< float > &v2)
Cross product between two vectors.
Object providing safe access to continuous memory of data.
INLINE TCounter size() const
Material settings and functions specific for one material.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Base class for all solvers.
virtual void integrate(Storage &storage, Statistics &stats)=0
Computes derivatives of all time-dependent quantities.
virtual void create(Storage &storage, IMaterial &material) const =0
Initializes all quantities needed by the solver in the storage.
virtual void collide(Storage &UNUSED(storage), Statistics &UNUSED(stats), const Float UNUSED(dt))
Detects the collisions and computes new positions of particles.
Object representing a 1D interval of real numbers.
INLINE Float lower() const
Returns lower bound of the interval.
INLINE Float size() const
Returns the size of the interval.
void emplace(TArgs &&... args)
Constructs the uninitialized object from a list of arguments.
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.
Helper solver used to converge into stable initial conditions.
virtual void integrate(Storage &storage, Statistics &stats) override
Computes derivatives of all time-dependent quantities.
StabilizationSolver(const Interval timeRange, const Float delta, AutoPtr< ISolver > &&solver)
virtual void create(Storage &storage, IMaterial &material) const override
Initializes all quantities needed by the solver in the storage.
StabilizationSolver(IScheduler &scheduler, const RunSettings &settings, AutoPtr< IBoundaryCondition > &&bc)
StabilizationSolver(const RunSettings &settings, AutoPtr< ISolver > &&solver)
virtual void collide(Storage &storage, Statistics &stats, const Float dt) override
Object holding various statistics about current run.
TValue get(const StatisticsId idx) const
Returns value of a statistic.
TValue getOr(const StatisticsId idx, const TValue &other) const
Returns value of a statistic, or a given value if the statistic is not stored.
Container storing all quantities used within the simulations.
StaticArray< Array< TValue > &, 3 > getAll(const QuantityId key)
Retrieves quantity buffers from the storage, given its key and value type.
Array< TValue > & getDt(const QuantityId key)
Retrieves a quantity derivative from the storage, given its key and value type.
MaterialView getMaterial(const Size matIdx) const
Returns an object containing a reference to given material.
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.
Creating code components based on values from settings.
Generic storage and input/output routines of settings.
@ DAMAGE
Initial damage of the body.
@ SPH_STABILIZATION_DAMPING
Provides a convenient way to construct objects from settings.
AutoPtr< ISolver > getSolver(IScheduler &scheduler, const RunSettings &settings)
Vector getAngularFrequency(ArrayView< const Float > m, ArrayView< const Vector > r, ArrayView< const Vector > v, const Vector &r0, const Vector &v0, ArrayView< const Size > idxs=nullptr)
Computes the immediate vector of angular frequency of a rigid body.
Vector getCenterOfMass(ArrayView< const Float > m, ArrayView< const Vector > r, ArrayView< const Size > idxs=nullptr)
Computes the center of mass.
Overload of std::swap for Sph::Array.