58 template <
typename TValue>
75 initDerivatives(
size);
79 : v(
std::move(values))
81 initDerivatives(v.
size());
135 return { v, dv_dt, d2v_dt2 };
148 return { v, dv_dt, d2v_dt2 };
164 void initDerivatives(
const Size size);
166 template <
typename TFunctor>
169 template <
typename TFunctor>
202 template <
typename... TArgs>
210 : data(std::move(holder)) {}
225 template <
typename TValue>
232 template <
typename TValue>
242 return forValue(data, [](
auto& holder)
INL {
return holder.getOrderEnum(); });
253 return forValue(data, [flags](
auto& holder) ->
Holder {
return holder.clone(flags); });
261 return holder.createZeros(particleCnt);
271 forValue(data, [flags, &other](
auto& holder) {
272 using Type = std::decay_t<decltype(holder)>;
273 return holder.
swap(other.data.
get<Type>(), flags);
279 return forValue(data, [](
auto& holder)
INL {
return holder.size(); });
286 template <
typename TValue>
288 return get<TValue>().getValue();
292 template <
typename TValue>
294 return get<TValue>().getValue();
298 return forValue(data, [order](
auto& holder)
INL {
return holder.setOrder(order); });
306 template <
typename TValue>
308 return get<TValue>().getDt();
312 template <
typename TValue>
314 return get<TValue>().getDt();
322 template <
typename TValue>
324 return get<TValue>().getD2t();
328 template <
typename TValue>
330 return get<TValue>().getD2t();
337 template <
typename TValue>
339 return get<TValue>().getAll();
342 template <
typename TValue>
344 return get<TValue>().getAll();
350 template <
typename TIndexSequence>
352 forValue(data, [&sequence, range](
auto& v) {
353 auto& values = v.getValue();
354 for (
Size idx : sequence) {
361 template <
typename TValue>
366 template <
typename TValue>
Generic dynamically allocated resizable storage.
#define SPH_ASSERT(x,...)
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
Wrapper over enum allowing setting (and querying) individual bits of the stored value.
uint32_t Size
Integral type used to index arrays (by default).
constexpr INLINE T max(const T &f1, const T &f2)
constexpr INLINE T clamp(const T &f, const T &f1, const T &f2)
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
Conversions for quantity enums.
VisitorEnum
Types of iteration over storage.
@ FIRST_ORDER
Iterates only over first-order quantities. Passes values and derivatives as arguments of functor.
@ SECOND
Quantity with 1st and 2nd derivative.
@ FIRST
Quantity with 1st derivative.
@ ZERO
Quantity without derivatives, or "zero order" of quantity.
Object capable of storing values of different types.
decltype(auto) INLINE forValue(Variant< TArgs... > &variant, TFunctor &&functor)
void resize(const TCounter newSize)
Resizes the array to new size.
void fill(const T &t)
Sets all elements of the array to given value.
INLINE TCounter size() const noexcept
void swap(Holder &other, Flags< VisitorEnum > flags)
INLINE Array< TValue > & getD2t()
Holder createZeros(const Size particleCnt) const
Holder(const OrderEnum order, Array< TValue > &&values)
INLINE const Array< TValue > & getValue() const
void setOrder(const OrderEnum newOrder)
Holder(const OrderEnum order, const TValue &defaultValue, const Size size)
INLINE StaticArray< Array< TValue > &, 3 > getAll()
INLINE const Array< TValue > & getDt() const
INLINE const Array< TValue > & getD2t() const
INLINE OrderEnum getOrderEnum() const
Returns number of derivatives stored within the quantity.
INLINE Array< TValue > & getValue()
INLINE Size size() const
Returns size of the stored arrays (=number of particles).
Holder clone(const Flags< VisitorEnum > flags) const
INLINE ValueEnum getValueEnum() const
Return type of quantity values.
INLINE Array< TValue > & getDt()
INLINE StaticArray< const Array< TValue > &, 3 > getAll() const
Wrapper of an integral value providing functions for reading and modifying individual bits.
Object representing a 1D interval of real numbers.
Generic container for storing scalar, vector or tensor quantity and its derivatives.
INLINE const Array< TValue > & getDt() const
Returns a reference to array of first derivatives of quantity, const version.
INLINE Size size() const
Returns the size of the quantity (number of particles)
void setOrder(const OrderEnum order)
Quantity()=default
Constructs an empty quantity.
Quantity createZeros(const Size particleCnt) const
Creates a new quantity with the same type and order as this one.
Quantity clone(const Flags< VisitorEnum > flags) const
Clones all buffers contained by the quantity, or optionally only selected ones.
INLINE const Array< TValue > & getD2t() const
Returns a reference to array of second derivatives of quantity, const version.
OrderEnum getOrderEnum() const
Returns the order of the quantity.
INLINE Array< TValue > & getD2t()
Returns a reference to array of second derivatives of quantity.
INLINE const Array< TValue > & getValue() const
Returns a reference to array of quantity values, const version.
StaticArray< Array< TValue > &, 3 > getAll()
Returns all buffers of given type stored in this quantity.
StaticArray< const Array< TValue > &, 3 > getAll() const
INLINE Array< TValue > & getValue()
Returns a reference to array of quantity values.
void clamp(const TIndexSequence &sequence, const Interval range)
Quantity(const OrderEnum order, const TValue &defaultValue, const Size size)
Creates a quantity given number of particles and default value of the quantity.
INLINE Array< TValue > & getDt()
Returns a reference to array of first derivatives of quantity.
void swap(Quantity &other, const Flags< VisitorEnum > flags)
Swap quantity (or selected part of it) with other quantity.
ValueEnum getValueEnum() const
Returns the value order of the quantity.
Quantity(const OrderEnum order, Array< TValue > &&values)
Creates a quantity from an array of values.
Array with fixed number of allocated elements.
Variant, an implementation of type-safe union, similar to std::variant or boost::variant.
void swap(Variant &other)
Swaps value stored in the variant with value of different variant.
INLINE Size getTypeIdx() const
Returns index of type currently stored in variant.
INLINE T & get()
Returns the stored value.
Overload of std::swap for Sph::Array.
Convert type to ValueType enum.
Object with deleted copy constructor and copy operator.