40 : scheduler(scheduler)
41 , threadData(scheduler) {
43 kernel = Factory::getKernel<DIMENSIONS>(settings);
55 tie(p[i], cs[i]) = eos.evaluate(rho[i], u[i]);
60 finder->
build(scheduler, r);
63 const auto maxHIter = std::max_element(
65 const Float searchRadius = (*maxHIter)[
H] * kernel.
radius();
72 auto functor = [&](
Size i, ThreadData& data) {
73 finder->
findAll(r[i], searchRadius, data.neighs);
76 const Float h_bar = 0.5_f * (r[i][
H] + r[j][
H]);
82 const Vector grad = kernel.
grad(r[j] - r[i], h_bar);
85 dv[i] -= m[j] * (p[i] /
sqr(rho[i]) + p[j] /
sqr(rho[j])) * grad;
88 drho[i] += m[j] *
dot(v[j] - v[i], grad);
91 du[i] += m[j] * p[i] /
sqr(rho[i]) *
dot(v[j] - v[i], grad);
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 interface for all solvers.
SPH-specific implementation of particle materials.
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
#define NAMESPACE_SPH_END
@ PRESSURE
Pressure, affected by yielding and fragmentation model, always a scalar quantity.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ ENERGY
Specific internal energy, always a scalar quantity.
@ DENSITY
Density, always a scalar quantity.
@ MASS
Paricles masses, always a scalar quantity.
@ SOUND_SPEED
Sound speed, always a scalar quantity.
Holder of quantity values and their temporal derivatives.
@ FIRST
Quantity with 1st derivative.
@ ZERO
Quantity without derivatives, or "zero order" of quantity.
INLINE void parallelFor(IScheduler &scheduler, const Size from, const Size to, TFunctor &&functor)
Executes a functor concurrently from all available threads.
Template for thread-local storage.
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...
INLINE TCounter size() const
INLINE Iterator< StorageType > begin()
INLINE Iterator< StorageType > end()
Material holding equation of state.
virtual Size findAll(const Size index, const Float radius, Array< NeighbourRecord > &neighbours) const =0
Finds all neighbours within given radius from the point given by index.
Base class for equations of state.
Material settings and functions specific for one material.
INLINE TValue getParam(const BodySettingsId paramIdx) const
Returns a parameter associated with given particle.
void setRange(const QuantityId id, const Interval &range, const Float minimal)
Sets the timestepping parameters of given quantity.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
Base class for all solvers.
void build(IScheduler &scheduler, ArrayView< const Vector > points, Flags< FinderFlag > flags=FinderFlag::MAKE_RANK)
Constructs the struct with an array of vectors.
INLINE Vector grad(const Vector &r, const Float h) const noexcept
INLINE Float radius() const noexcept
Minimalistic SPH solver, mainly used for benchmarking and educational purposes.
virtual void create(Storage &storage, IMaterial &material) const override
Initializes all quantities needed by the solver in the storage.
virtual void integrate(Storage &storage, Statistics &UNUSED(stats)) override
SimpleSolver(IScheduler &scheduler, const RunSettings &settings)
Object holding various statistics about current run.
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.
Array< TValue > & getDt(const QuantityId key)
Retrieves a quantity derivative from the storage, given its key and value type.
Array< TValue > & getD2t(const QuantityId key)
Retrieves a quantity second 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.
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.
@ ENERGY_MIN
Estimated minimal value of energy used to determine timestepping error.
@ DENSITY_RANGE
Allowed range of density. Densities of all particles all clamped to fit in the range.
@ ENERGY
Initial specific internal energy.
@ DENSITY
Density at zero pressure.
@ ENERGY_RANGE
Allowed range of specific internal energy.
AutoPtr< ISymmetricFinder > getFinder(const RunSettings &settings)
AutoPtr< IEos > getEos(const BodySettings &settings)
Holds information about a neighbour particles.
Size index
Index of particle in the storage.
Float distanceSqr
Squared distance of the particle from the queried particle / position.