16 for (
Size i = 0; i < r.
size(); ++i) {
17 cellSize =
max(cellSize, r[i][
H] * kernelRadius);
20 std::unordered_map<Indices, Float, std::hash<Indices>, IndicesEqual> newMap;
21 for (
Size i = 0; i < r.
size(); ++i) {
30 for (
const auto& p : newMap) {
33 for (
int i = -1; i <= 1; ++i) {
34 for (
int j = -1; j <= 1; ++j) {
35 for (
int k = -1; k <= 1; ++k) {
37 auto iter = newMap.find(idxs);
38 if (iter != newMap.end()) {
51 const auto iter = map.find(idxs);
52 if (iter != map.end()) {
61 : scheduler(scheduler) {
62 kernel = Factory::getKernel<DIMENSIONS>(settings);
85 this->
loop(storage, stats);
107 for (
Size i = 0; i < r.
size(); ++i) {
108 maxH =
max(maxH, r[i][
H]);
130 , threadData(scheduler) {
162 Float maxRadius = 0._f;
174 auto functor = [
this, r, &neighs, maxRadius, &symmetrizedKernel, &actFinder](
Size i,
ThreadData& data) {
178 actFinder.findAll(i,
radius, data.neighs);
181 for (
auto& n : data.neighs) {
182 const Size j = n.index;
183 const Float hbar = 0.5_f * (r[i][
H] + r[j][
H]);
189 const Vector gr = symmetrizedKernel.grad(r[i], r[j]);
191 data.grads.emplaceBack(gr);
192 data.idxs.emplaceBack(j);
195 neighs[i] = data.idxs.
size();
206 accumulated.
store(storage);
219 for (
Size i = 0; i < size; ++i) {
220 neighsStats.accumulate(neighs[i]);
229 "No solver of smoothing length specified; add either ConstSmootingLength or "
230 "AdaptiveSmootingLength into the list of equations");
Buffer storing quantity values accumulated by summing over particle pairs.
INLINE bool isReal(const AntisymmetricTensor &t)
#define SPH_ASSERT(x,...)
SPH solver with asymmetric particle evaluation.
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.
Additional equation terms computing SPH statistics rather than physical quantities.
Base class for all particle materials.
#define VERBOSE_LOG
Helper macro, creating.
constexpr INLINE T max(const T &f1, const T &f2)
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
INLINE auto floor(const T &f)
#define NAMESPACE_SPH_END
#define PROFILE_SCOPE(name)
@ POSITION
Positions (velocities, accelerations) of particles, always a vector 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.
Statistics gathered and periodically displayed during the run.
@ NEIGHBOUR_COUNT
Number of neighbours (min, max, mean)
@ RUN_TIME
Current time of the simulation in code units. Does not necessarily have to be 0 when run starts.
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 store(Storage &storage)
Stores accumulated values to corresponding quantities.
Evolutionary equation for the (scalar) smoothing length.
Object providing safe access to continuous memory of data.
INLINE TCounter size() const
Generic SPH solver, evaluating equations for each particle separately.
AutoPtr< IBoundaryCondition > bc
virtual void beforeLoop(Storage &storage, Statistics &stats) override
virtual void sanityCheck(const Storage &storage) const override
AsymmetricSolver(IScheduler &scheduler, const RunSettings &settings, const EquationHolder &eqs)
virtual void afterLoop(Storage &storage, Statistics &stats) override
virtual void loop(Storage &storage, Statistics &stats) override
ThreadLocal< ThreadData > threadData
DerivativeHolder derivatives
Holds all derivatives (shared for all threads)
Helper term to keep smoothing length constant during the simulation.
void eval(const Size idx, ArrayView< const Size > neighs, ArrayView< const Vector > grads)
Evaluates all held derivatives for given particle.
INLINE Accumulated & getAccumulated()
virtual void initialize(const Storage &input)
Initialize derivatives before loop.
Container holding equation terms.
void setDerivatives(DerivativeHolder &derivatives, const RunSettings &settings) const
Calls EquationTerm::setDerivatives for all stored equation terms.
bool contains() const
Checks if the holder contains term of given type.
void create(Storage &storage, IMaterial &material) const
Calls EquationTerm::create for all stored equation terms.
void initialize(IScheduler &scheduler, Storage &storage, const Float t)
Calls EquationTerm::initialize for all stored equation terms.
void finalize(IScheduler &scheduler, Storage &storage, const Float t)
Calls EquationTerm::finalize for all stored equation terms.
Base class for asymmetric SPH solvers.
IScheduler & scheduler
Scheduler used to parallelize the solver.
Float getMaxSearchRadius(const Storage &storage) const
virtual void loop(Storage &storage, Statistics &stats)=0
virtual void sanityCheck(const Storage &storage) const =0
LutKernel< DIMENSIONS > kernel
Selected SPH kernel.
EquationHolder equations
Holds all equation terms evaluated by the solver.
Optional< RadiiHashMap > radiiMap
Hash map used to determine search radii of particles.
virtual void beforeLoop(Storage &storage, Statistics &stats)=0
virtual void afterLoop(Storage &storage, Statistics &stats)=0
AutoPtr< ISymmetricFinder > finder
Structure used to search for neighbouring particles.
virtual void create(Storage &storage, IMaterial &material) const override
Initializes all quantities needed by the solver in the storage.
IAsymmetricSolver(IScheduler &scheduler, const RunSettings &settings, const EquationHolder &eqs)
virtual RawPtr< const IBasicFinder > getFinder(ArrayView< const Vector > r)
Returns a finder, already build using the provided positions.
virtual void integrate(Storage &storage, Statistics &stats) override
Computes derivatives of all time-dependent quantities.
Interface of objects finding neighbouring particles.
virtual void finalize(Storage &storage)=0
Applies the boundary conditions after the derivatives are computed.
virtual void initialize(Storage &storage)=0
Applies the boundary conditions before the derivatives are computed.
Material settings and functions specific for one material.
Interface that allows unified implementation of sequential and parallelized versions of algorithms.
void build(IScheduler &scheduler, ArrayView< const Vector > points, Flags< FinderFlag > flags=FinderFlag::MAKE_RANK)
Constructs the struct with an array of vectors.
Helper object for storing three (possibly four) int or bool values.
Thrown when components of the run are mutually incompatible.
INLINE Float radius() const noexcept
Non-owning wrapper of a material and particles with this material.
INLINE IndexSequence sequence()
Returns iterable index sequence.
Helper class for statistics, accumulating minimal, maximal and mean value of a set of numbers.
void emplace(TArgs &&... args)
Constructs the uninitialized object from a list of arguments.
Float getRadius(const Vector &r) const
Returns the required search radius for particle at given position.
void build(ArrayView< const Vector > r, const Float kernelRadius)
Computes the search radii at each cell in space.
Non-owning wrapper of pointer.
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.
Object holding various statistics about current run.
Statistics & set(const StatisticsId idx, TValue &&value)
Sets new values 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.
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.
Size getParticleCnt() const
Returns the number of particles.
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.
@ SPH_ASYMMETRIC_COMPUTE_RADII_HASH_MAP
Provides a convenient way to construct objects from settings.
AutoPtr< ISymmetricFinder > getFinder(const RunSettings &settings)
AutoPtr< IBoundaryCondition > getBoundaryConditions(const RunSettings &settings, SharedPtr< IDomain > domain)
Overload of std::swap for Sph::Array.