11 return makeFailed(
"Different number of particles.\nTest has ",
18 return makeFailed(
"Different number of quantities.\nTest has ",
25 auto checkZeroOrder = [&](
QuantityId id,
const auto& px,
const auto& cx) {
30 for (
Size i = 0; i < px.size(); ++i) {
33 "Difference in ",
getMetadata(
id).quantityName,
"\n", px[i],
" == ", cx[i],
"\n\n");
38 iteratePair<VisitorEnum::ZERO_ORDER>(test, ref, checkZeroOrder);
48 for (
Size i = 0; i < px.size(); ++i) {
51 "Difference in ",
getMetadata(
id).quantityName,
"\n", px[i],
" == ", cx[i],
"\n\n");
56 "Difference in ",
getMetadata(
id).derivativeName,
"\n", pdx[i],
" == ", cdx[i],
"\n\n");
61 iteratePair<VisitorEnum::FIRST_ORDER>(test, ref, checkFirstOrder);
73 for (
Size i = 0; i < px.size(); ++i) {
76 "Difference in ",
getMetadata(
id).quantityName,
"\n", px[i],
" == ", cx[i],
"\n\n");
81 "Difference in ",
getMetadata(
id).derivativeName,
"\n", pdx[i],
" == ", cdx[i],
"\n\n");
96 iteratePair<VisitorEnum::SECOND_ORDER>(test, ref, checkSecondOrder);
103 const Float fraction,
104 const Float maxDeviation,
113 const Size count =
Size(
max(r1.size(), r2.size()) * fraction);
114 if (count >= r1.size() || count >= r2.size()) {
115 return makeFailed(
"Number of particles differs significantly\n.Test has ",
126 for (
Size i = 0; i < count; ++i) {
128 const Size p2 = order[i];
131 tree.findAll(r2[p2], maxDeviation, neighs);
132 bool matchFound =
false;
134 const Size p1 = n.index;
152 return makeFailed(
"No matching test particle found for the ",
154 "-th largest particle in the reference state.");
INLINE bool almostEqual(const AffineMatrix &m1, const AffineMatrix &m2, const Float eps=EPS)
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.
Functions for iterating over individual quantities in Storage.
K-d tree for efficient search of neighbouring particles.
constexpr INLINE T max(const T &f1, const T &f2)
@ SKIP_RANK
The rank of particles is not created. 'Dummy' option that can be used to improve readability.
#define NAMESPACE_SPH_END
Helper object defining permutation.
INLINE Order getOrder(ArrayView< const Float > values, const TLess less=TLess{})
Finds the order of values in given array.
const SuccessTag SUCCESS
Global constant for successful outcome.
INLINE Outcome makeFailed(TArgs &&... args)
Constructs failed object with error message.
QuantityMetadata getMetadata(const QuantityId key)
Returns the quantity information using quantity ID.
QuantityId
Unique IDs of basic quantities of SPH particles.
@ POSITION
Positions (velocities, accelerations) of particles, always a vector quantity,.
@ MASS
Paricles masses, always a scalar quantity.
SequentialScheduler SEQUENTIAL
Global instance of the sequential scheduler.
Interface for executing tasks (potentially) asynchronously.
void build(IScheduler &scheduler, ArrayView< const Vector > points, Flags< FinderFlag > flags=FinderFlag::MAKE_RANK)
Constructs the struct with an array of vectors.
K-d tree, used for hierarchical clustering of particles and accelerated Kn queries.
Permutation, i.e. (discrete) invertible function int->int.
Container storing all quantities used within the simulations.
Array< TValue > & getDt(const QuantityId key)
Retrieves a quantity derivative from the storage, given its key and value type.
Size getParticleCnt() const
Returns the number of particles.
Size getQuantityCnt() const
Returns the number of stored quantities.
Array< TValue > & getValue(const QuantityId key)
Retrieves a quantity values from the storage, given its key and value type.
Outcome compareLargeSpheres(const Storage &test, const Storage &ref, const Float fraction, const Float maxDeviation, const Float eps=1.e-6_f)
Compares the positions, velocities and radii of the largest particles in given states.
Outcome compareParticles(const Storage &test, const Storage &ref, const Float eps=1.e-6_f)
Compares particle positions and state quantities of two storages.
Holds information about a neighbour particles.