10 template <
typename TValue>
12 const auto& values = q.
getAll<TValue>();
15 data[id].d2t = values[2][idx];
18 data[id].dt = values[1][idx];
21 data[id].value = values[0][idx];
33 quantities.
insert(i.id, InternalQuantityData{});
36 dispatch(i.quantity.getValueEnum(), visitor, i.id, i.quantity, idx);
42 quantities.
insert(
id, InternalQuantityData{});
43 quantities[id].value = value;
51 *
this = std::move(other);
55 quantities = other.quantities.
clone();
56 material = other.material.
clone();
62 quantities = std::move(other.quantities);
63 material = std::move(other.material);
70 quantities.
insert(
id, InternalQuantityData{});
72 quantities[id].value = value;
78 quantities.
insert(
id, InternalQuantityData{});
80 quantities[id].dt = value;
86 quantities.
insert(
id, InternalQuantityData{});
88 quantities[id].d2t = value;
104 return quantity->
value;
116 return quantity->d2t;
122 return value.
value();
135 const InternalQuantityData&
internal = iter->
value;
137 if (
internal.value) {
138 type =
internal.value.
getType();
139 SPH_ASSERT(
internal.dt.empty() ||
internal.dt.getType() == type);
140 SPH_ASSERT(
internal.d2t.empty() ||
internal.d2t.getType() == type);
141 }
else if (
internal.dt) {
142 type =
internal.dt.getType();
143 SPH_ASSERT(
internal.d2t.empty() ||
internal.d2t.getType() == type);
146 type =
internal.d2t.getType();
148 return { iter->key, type,
internal.value,
internal.dt,
internal.d2t };
152 return iter != other.iter;
156 : first(particle.quantities.begin(), {})
157 , last(particle.quantities.end(), {}) {}
181 return { iter->key, iter->
value };
185 return iter != other.iter;
190 : first(particle.material.begin(), {})
191 , last(particle.material.end(), {}) {}
#define SPH_ASSERT(x,...)
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
DynamicId
Enum representing a value type stored in a Value object.
uint32_t Size
Integral type used to index arrays (by default).
#define NAMESPACE_SPH_END
const NothingType NOTHING
decltype(auto) dispatch(const ValueEnum value, TVisitor &&visitor, TArgs &&... args)
Selects type based on run-time ValueEnum value and runs visit<Type>() method of the visitor.
QuantityId
Unique IDs of basic quantities of SPH particles.
Holder of quantity values and their temporal derivatives.
@ SECOND
Quantity with 1st and 2nd derivative.
@ FIRST
Quantity with 1st derivative.
@ ZERO
Quantity without derivatives, or "zero order" of quantity.
Container for storing particle quantities and materials.
Helper class used to allow calling a function only from within T.
Convenient object for storing a single value of different types.
DynamicId getType() const
INLINE bool contains(const TKey &key) const
Returns true if the map contains element of given key.
INLINE TValue & insert(const TKey &key, const TValue &value)
Adds a new element into the map or sets new value of element with the same key.
INLINE Optional< TValue & > tryGet(const TKey &key)
Returns a reference to the value matching the given key, or NOTHING if no such value exists.
Wrapper of type value of which may or may not be present.
INLINE Type & value()
Returns the reference to the stored value.
bool operator!=(const ParamIterator &other) const
Inequality operator.
ParamIterator & operator++()
Advances the iterator to next quantity.
ParamData operator*() const
Returns all data associated with currently referenced parameter.
ParamIterator(const ActIterator iterator, Badge< Particle >)
Constructs the iterator from internal type.
Helper for enumerating all stored parameters.
ParamIterator begin() const
Returns iterator pointing to the first parameter.
ParamSequence(const Particle &particle)
Creates a sequence of all material parameters of given particle.
ParamIterator end() const
Returns iterator pointing to the one-past-last parameter.
Iterator used to enumerate all stored quantities.
QuantityData operator*() const
Returns all data associated with currently referenced quantity.
bool operator!=(const QuantityIterator &other) const
Inequality operator.
QuantityIterator(const ActIterator iterator, Badge< Particle >)
Constructs the iterator from internal type.
QuantityIterator & operator++()
Advances the iterator to next quantity.
Helper for enumerating all stored quantities.
QuantityIterator end() const
Returns iterator pointing to the one-past-last quantity.
QuantityIterator begin() const
Returns iterator pointing to the first quantity.
QuantitySequence(const Particle &particle)
Creates a sequence of all quantities of given particle.
Object holding information about single particle.
QuantitySequence getQuantities() const
Returns a range for enumerating all stored quantities.
Dynamic getDt(const QuantityId id) const
Retrieves a quantity derivative of the particle.
Particle()=default
Default constructor, defined only for convenient usage in containers, etc.
Dynamic getValue(const QuantityId id) const
Retrieves a quantity value of the particle.
Particle & operator=(const Particle &other)
Particle & addD2t(const QuantityId id, const Dynamic &value)
Adds another quantity 2nd derivative or updates the 2nd derivative of quantity previously stored.
Dynamic getParameter(const BodySettingsId id) const
Retrieves a material parameter of the particle.
Particle & addParameter(const BodySettingsId id, const Dynamic &value)
Adds another material parameter or updates the one stored previously.
Dynamic getD2t(const QuantityId id) const
Retrieves a quantity 2nd derivative of the particle.
Particle & addValue(const QuantityId id, const Dynamic &value)
Adds another quantity value or updates the value of quantity previously stored.
ParamSequence getParameters() const
Returns a range for enumerating all stored parameters.
Particle & addDt(const QuantityId id, const Dynamic &value)
Adds another quantity derivative or updates the derivative of quantity previously stored.
Generic container for storing scalar, vector or tensor quantity and its derivatives.
OrderEnum getOrderEnum() const
Returns the order of the quantity.
StaticArray< Array< TValue > &, 3 > getAll()
Returns all buffers of given type stored in this quantity.
Container storing all quantities used within the simulations.
StorageSequence getQuantities()
Returns the sequence of quantities.
BodySettingsId
Settings of a single body / gas phase / ...
void visit(const QuantityId id, const Quantity &q, const Size idx)
FlatMap< QuantityId, Particle::InternalQuantityData > & data
Stored info about a material parameter.
Dynamic value
Parameter value.
Stored info about a quantity.
Dynamic value
Quantity value.