17 equations += makeTerm<PressureForce>();
20 equations += makeTerm<SolidStressForce>(settings);
28 equations += makeTerm<ConstSmoothingLength>();
41 :
SymmetricSolver<Dim>(scheduler, settings, getEquations(settings) + additionalEquations,
std::move(bc)) {
44 densityKernel = Factory::getKernel<Dim>(settings);
63 this->equations.create(storage, material);
78 for (
Size i = 0; i < r.
size(); ++i) {
90 auto functor = [
this, r, m, eta, &totalDiff](
const Size i, ThreadData& data) {
93 this->finder->findAll(i, h[i] * densityKernel.radius(), data.neighs);
94 SPH_ASSERT(data.neighs.size() > 0, data.neighs.size());
96 const Float rho0 = rho[i];
98 for (
auto& n : data.neighs) {
99 const Size j = n.index;
101 rho[i] += m[j] * densityKernel.value(r[i] - r[j], h[i]);
104 h[i] = eta * root<Dim>(m[i] / rho[i]);
106 totalDiff +=
abs(rho[i] - rho0) / (rho[i] + rho0);
109 this->finder->build(this->scheduler, r);
110 Size iterationIdx = 0;
111 for (; iterationIdx < maxIteration; ++iterationIdx) {
114 if (diff < targetDensityDifference) {
122 for (
Size i = 0; i < r.
size(); ++i) {
#define SPH_ASSERT(x,...)
Implementation of number with atomic operators.
const EmptyFlags EMPTY_FLAGS
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.
constexpr INLINE T max(const T &f1, const T &f2)
INLINE auto abs(const T &f)
#define NAMESPACE_SPH_END
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ DENSITY
Density, always a scalar quantity.
@ MASS
Paricles masses, always a scalar quantity.
@ NEIGHBOUR_CNT
Number of neighbouring particles (in radius h * kernel.radius)
@ 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.
Standard SPH artificial viscosity.
Statistics gathered and periodically displayed during the run.
@ SOLVER_SUMMATION_ITERATIONS
Number of iterations used to compute density and smoothing length in summation solver.
Solver using direction summation to compute density and smoothing length.
Object providing safe access to continuous memory of data.
INLINE TCounter size() const
void resize(const TCounter newSize)
Resizes the array to new size.
Atomic value implemented using compare-exchange.
Container holding equation terms.
Wrapper of an integral value providing functions for reading and modifying individual bits.
constexpr INLINE bool has(const TEnum flag) const
Checks if the object has a given flag.
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.
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.
Flags< TValue > getFlags(const TEnum idx) const
Returns Flags from underlying value stored in settings.
Object holding various statistics about current run.
Statistics & set(const StatisticsId idx, TValue &&value)
Sets new values of a statistic.
Container storing all quantities used within the simulations.
Size getMaterialCnt() const
Return the number of materials in the storage.
Quantity & insert(const QuantityId key, const OrderEnum order, const TValue &defaultValue)
Creates a quantity in the storage, given its key, value type and order.
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.
SPH solver using density and specific energy as independent variables.
virtual void create(Storage &storage, IMaterial &material) const override
Initializes all quantities needed by the solver in the storage.
SummationSolver(IScheduler &scheduler, const RunSettings &settings, const EquationHolder &additionalEquations={})
Basic solver for integration of SPH equations.
virtual void beforeLoop(Storage &storage, Statistics &stats)
Creating code components based on values from settings.
@ PRESSURE
Use force from pressure gradient in the solver.
@ SELF_GRAVITY
Use gravitational force in the model.
@ DENSITY_RANGE
Allowed range of density. Densities of all particles all clamped to fit in the range.
@ DENSITY
Density at zero pressure.
@ SMOOTHING_LENGTH_ETA
Eta-factor between smoothing length and particle concentration (h = eta * n^(-1/d) )
@ SPH_SUMMATION_MAX_ITERATIONS
Maximum number of iterations for self-consistent density computation of summation solver.
@ SPH_SOLVER_FORCES
List of forces to compute by the solver.
@ SPH_ADAPTIVE_SMOOTHING_LENGTH
Solution for evolutions of the smoothing length.
@ SPH_SUMMATION_DENSITY_DELTA
Provides a convenient way to construct objects from settings.
AutoPtr< IEquationTerm > getArtificialViscosity(const RunSettings &settings)
AutoPtr< IBoundaryCondition > getBoundaryConditions(const RunSettings &settings, SharedPtr< IDomain > domain)
Overload of std::swap for Sph::Array.
void swap(Sph::Array< T, TCounter > &ar1, Sph::Array< T, TCounter > &ar2)