246 MatRange() =
default;
296 template <
typename TValue>
312 template <
typename TValue>
316 template <
typename TValue>
324 template <
typename TValue>
328 template <
typename TValue>
336 template <
typename TValue>
340 template <
typename TValue>
348 template <
typename TValue>
352 template <
typename TValue>
358 template <
typename TValue,
typename... TArgs>
360 return tie(getValue<TValue>(first), getValue<TValue>(second), getValue<TValue>(others)...);
364 template <
typename TValue,
typename... TArgs>
367 return tie(getValue<TValue>(first), getValue<TValue>(second), getValue<TValue>(others)...);
383 template <
typename TValue>
394 template <
typename TValue>
432 template <
typename TValue>
573 void addMissingBuffers(
const Storage& source);
Generic dynamically allocated resizable storage.
Wrapper over enum allowing setting (and querying) individual bits of the stored value.
const EmptyFlags EMPTY_FLAGS
Key-value associative container implemented as a sorted array.
Generic wrappers of lambdas, functors and other callables.
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.
#define NAMESPACE_SPH_END
Return value of function that may fail, containing either SUCCEES (true) or error message.
QuantityId
Unique IDs of basic quantities of SPH particles.
VisitorEnum
Types of iteration over storage.
StaticArray< T0 &, sizeof...(TArgs)+1 > tie(T0 &t0, TArgs &... rest)
Creates a static array from a list of l-value references.
Vector getCenterOfMass(const Storage &storage)
Returns the center of mass of all particles.
void setPersistentIndices(Storage &storage)
Adds or updates a quantity holding particle indices to the storage.
Box getBoundingBox(const Storage &storage, const Float radius=2._f)
Convenience function to get the bounding box of all particles.
Helper class used to allow calling a function only from within T.
Helper object defining three-dimensional interval (box).
Helper class for iterating over quantities stored in Storage, const version.
bool operator!=(const ConstStorageIterator &other) const
bool operator==(const ConstStorageIterator &other) const
ConstStorageIterator & operator++()
ConstStorageElement operator*()
ConstStorageIterator(const ActIterator iterator, Badge< ConstStorageSequence >)
Helper class, provides functions begin and end, returning const iterators to the first and last quant...
ConstStorageSequence(const FlatMap< QuantityId, Quantity > &quantities, Badge< Storage >)
Size size() const
Returns the number of quantities.
ConstStorageIterator end()
Returns iterator pointing to the one-past-the-end element of the quantity storage.
ConstStorageIterator begin()
Returns iterator pointing to the beginning of the quantity storage.
Wrapper of an integral value providing functions for reading and modifying individual bits.
Material settings and functions specific for one material.
Base class for arbitrary data stored in the storage alongside particles.
Object representing a 1D interval of real numbers.
Exception thrown when accessing missing quantities, casting to different types, etc.
InvalidStorageAccess(const QuantityId id)
Non-owning wrapper of a material and particles with this material.
Generic container for storing scalar, vector or tensor quantity and its derivatives.
Array with fixed number of allocated elements.
Helper class for iterating over quantities stored in Storage.
StorageIterator & operator++()
bool operator!=(const StorageIterator &other) const
StorageIterator(const ActIterator iterator, Badge< StorageSequence >)
StorageElement operator*()
bool operator==(const StorageIterator &other) const
Helper class, provides functions begin and end, returning iterators to the first and last quantity in...
Size size() const
Returns the number of quantities.
StorageSequence(FlatMap< QuantityId, Quantity > &quantities, Badge< Storage >)
StorageIterator end()
Returns iterator pointing to the one-past-the-end element of the quantity storage.
StorageIterator begin()
Returns iterator pointing to the beginning of the quantity storage.
Container storing all quantities used within the simulations.
Size getMaterialCnt() const
Return the number of materials in the storage.
Array< TValue > getMaterialParams(const BodySettingsId param) const
Returns the given material parameter for all materials in the storage.
bool isHomogeneous(const BodySettingsId param) const
Checks if the particles in the storage are homogeneous with respect to given parameter.
void merge(Storage &&other)
Merges another storage into this object.
Quantity & getQuantity(const QuantityId key)
Retrieves quantity with given key from the storage.
void resize(const Size newParticleCnt, const Flags< ResizeFlag > flags=EMPTY_FLAGS)
Changes number of particles for all quantities stored in the storage.
Outcome isValid(const Flags< ValidFlag > flags=ValidFlag::COMPLETE) const
Checks whether the storage is in valid state.
void setMaterial(const Size matIdx, const SharedPtr< IMaterial > &material)
Modifies material with given index.
Quantity & insert(const QuantityId key, const OrderEnum order, const TValue &defaultValue)
Creates a quantity in the storage, given its key, value type and order.
auto getValues(const QuantityId first, const QuantityId second, const TArgs... others) const
Retrieves an array of quantities from the key, const version.
@ COMPLETE
Checks that the storage is complete, i.e. there are no empty buffers.
MaterialView getMaterialOfParticle(const Size particleIdx) const
Returns material view for material of given particle.
bool empty() const
Checks if the storage is empty, i.e. without particles.
void addDependent(const WeakPtr< Storage > &other)
Registers a dependent storage.
StaticArray< Array< TValue > &, 3 > getAll(const QuantityId key)
Retrieves quantity buffers from the storage, given its key and value type.
void swap(Storage &other, const Flags< VisitorEnum > flags)
Swap quantities or given subset of quantities between two storages.
Storage()
Creates a storage with no material.
Array< TValue > & getDt(const QuantityId key)
Retrieves a quantity derivative from the storage, given its key and value type.
void removeAll()
Removes all particles with all quantities (including materials) from the storage.
void setUserData(SharedPtr< IStorageUserData > newData)
Stores new user data into the storage.
Size getParticleCnt() const
Returns the number of particles.
StorageSequence getQuantities()
Returns the sequence of quantities.
auto getValues(const QuantityId first, const QuantityId second, const TArgs... others)
Retrieves an array of quantities from the key.
Size getQuantityCnt() const
Returns the number of stored quantities.
void propagate(const Function< void(Storage &storage)> &functor)
Executes a given functor recursively for all dependent storages.
Array< Size > duplicate(ArrayView< const Size > idxs, const Flags< IndicesFlag > flags=EMPTY_FLAGS)
Duplicates some particles in the storage.
SharedPtr< IStorageUserData > getUserData() const
Returns the stored user data.
Interval getRange(const QuantityId id, const Size matIdx) const
Returns the bounding range of given quantity.
@ INDICES_SORTED
Use if the given array is already sorted (optimization)
void remove(ArrayView< const Size > idxs, const Flags< IndicesFlag > flags=EMPTY_FLAGS)
Removes specified particles from the storage.
Storage & operator=(Storage &&other)
Array< TValue > & getD2t(const QuantityId key)
Retrieves a quantity second derivative from the storage, given its key and value type.
MaterialView getMaterial(const Size matIdx) const
Returns an object containing a reference to given material.
bool has(const QuantityId key) const
Checks if the storage contains quantity with given key.
ResizeFlag
Options for the storage resize.
@ KEEP_EMPTY_UNCHANGED
Empty buffers will not be resized to new values.
void zeroHighestDerivatives()
Sets all highest-level derivatives of quantities to zero.
Storage clone(const Flags< VisitorEnum > buffers) const
Clones specified buffers of the storage.
Array< TValue > & getValue(const QuantityId key)
Retrieves a quantity values from the storage, given its key and value type.
BodySettingsId
Settings of a single body / gas phase / ...
const Quantity & quantity
Object with deleted copy constructor and copy operator.
Base class for all polymorphic objects.