19 for (
Size i = 0; i < r.
size(); ++i) {
21 finder->findLowerRank(i, r[i][
H] * radius, neighs);
22 for (
auto& n : neighs) {
39 for (
Pair& p : pairs) {
58 for (
Size i = 0; i < r.
size(); ++i) {
59 finder->findLowerRank(i, r[i][
H] * radius, neighs);
60 for (
auto& n : neighs) {
61 const Size j = n.index;
62 if (
abs(r[i][
H] - r[j][
H]) > limit * (r[i][
H] + r[j][
H])) {
71 error.
description =
"Discontinuity in smoothing lengths found";
72 for (
Pair& p : pairs) {
73 const Float actual =
abs(r[p.i1][
H] - r[p.i2][
H]);
74 const Float expected = limit * (r[p.i1][
H] + r[p.i2][
H]);
75 const std::string message =
76 "dH = " + std::to_string(actual) +
" (limit = " + std::to_string(expected) +
")";
85 : factor(timescaleFactor) {}
93 error.
description =
"Probable CFL instability detected";
94 for (
Size i = 0; i < r.
size(); ++i) {
95 const Float limit = r[i][
H] / dt2;
97 error.offendingParticles[i] =
98 "dv = " + std::to_string(
getLength(dv[i])) +
" (limit = " + std::to_string(limit) +
")";
101 if (error.offendingParticles.empty()) {
113 error.
description =
"Particle overcooling detected";
118 const Float u1 = u[i] + du[i] * dt;
119 if (u1 < range.
lower()) {
120 error.offendingParticles[i] =
121 "u = " + std::to_string(u1) +
" (limit = " + std::to_string(range.
lower()) +
")";
125 if (error.offendingParticles.empty()) {
Looking for problems in SPH simulation and reporting potential errors.
BasicOutcome< DiagnosticsError > DiagnosticsReport
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 sqr(const T &f) noexcept
Return a squared value.
INLINE auto abs(const T &f)
#define NAMESPACE_SPH_END
const SuccessTag SUCCESS
Global constant for successful outcome.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ ENERGY
Specific internal energy, always a scalar quantity.
SequentialScheduler SEQUENTIAL
Global instance of the sequential scheduler.
Interface for executing tasks (potentially) asynchronously.
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.
@ TIMESTEP_VALUE
Current value of timestep.
INLINE Float getLength(const Vector &v)
Returns the length of the vector. Enabled only for vectors of floating-point precision.
INLINE Float getSqrLength(const Vector &v)
Object providing safe access to continuous memory of data.
INLINE TCounter size() const
Generic dynamically allocated resizable storage.
INLINE void push(U &&u)
Adds new element to the end of the array, resizing the array if necessary.
INLINE bool empty() const noexcept
Expected-like class that does not contain any value.
CourantInstabilityDiagnostic(const Float timescaleFactor)
virtual DiagnosticsReport check(const Storage &storage, const Statistics &stats) const override
Object representing a 1D interval of real numbers.
INLINE Float lower() const
Returns lower bound of the interval.
Non-owning wrapper of a material and particles with this material.
INLINE IndexSequence sequence()
Returns iterable index sequence.
virtual DiagnosticsReport check(const Storage &storage, const Statistics &stats) const override
virtual DiagnosticsReport check(const Storage &storage, const Statistics &stats) const override
Checks for particle pairs, returns SUCCESS if no pair is found.
Array< Pair > getPairs(const Storage &storage) const
Returns the list of particles forming pairs, i.e. particles on top of each other or very close.
static const Settings & getDefaults()
\brief Returns a reference to object containing default values of all settings.
virtual DiagnosticsReport check(const Storage &storage, const Statistics &stats) const override
Array with fixed number of allocated elements.
Object holding various statistics about current run.
TValue get(const StatisticsId idx) const
Returns value of a statistic.
Container storing all quantities used within the simulations.
Size getMaterialCnt() const
Return the number of materials in the storage.
StaticArray< Array< TValue > &, 3 > getAll(const QuantityId key)
Retrieves quantity buffers 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.
AutoPtr< ISymmetricFinder > getFinder(const RunSettings &settings)
Object containing a reported error message.
std::string description
Description of the encountered problem.
std::map< Size, std::string > offendingParticles
Problematic particles and optional error message for each of them.