#include <EntityCollection.hpp>
Public Types | |
using | Map = std::unordered_map< int, double > |
Public Member Functions | |
EntityCollection () | |
double | accumulate (std::function< double(int m)> value) |
void | add (int m, double w) |
void | addSingle (int m) |
std::pair< double, double > | average (std::function< double(int m)> value, std::function< double(int m)> weight) |
std::pair< Vec, double > | average (std::function< Vec(int m)> value, std::function< double(int m)> weight) |
double | averageValue (std::function< double(int m)> value, std::function< double(int m)> weight) |
Vec | averageValue (std::function< Vec(int m)> value, std::function< double(int m)> weight) |
Map::const_iterator | begin () const |
void | clear () |
Map::const_iterator | end () const |
Private Attributes | |
Map | _entities |
EntityCollection is a helper class used with the Snapshot class and its subclasses. As indicated there, some snapshot types use smoothed particles and some use spatial cells as their basic constituents. The generic term entity refers to either particles or cells. Assuming a snapshot with
An EntityCollection object contains an unordered collection of unique entity indices with corresponding weights. This can be used to represent the set of entities that overlap a given position or path in space with their corresponding relative weights. The relative weights would, depending on the circumstances, take into account the smoothing kernel of an imported particle and/or the length of the path segment overlapping the particle or cell.
An EntityCollection instance can be reused for storing a new collection without forcing memory reallocations.
using EntityCollection::Map = std::unordered_map<int, double> |
Type declaration for the unordered map underlying the entity collection.
EntityCollection::EntityCollection | ( | ) |
The constructor creates an empty collection.
double EntityCollection::accumulate | ( | std::function< double(int m)> | value | ) |
This function returns the accumulated weighted value of a given scalar field
The argument specifies the scalar field
void EntityCollection::add | ( | int | m, |
double | w | ||
) |
This function adds an entity with index
void EntityCollection::addSingle | ( | int | m | ) |
This function removes any pre-existing entities from the collection and then adds a single entity with index
std::pair< double, double > EntityCollection::average | ( | std::function< double(int m)> | value, |
std::function< double(int m)> | weight | ||
) |
This function returns the nominator and denominator for the weighted average of a given scalar field
The function combines the external weights with the weights stored internally for each entity in the collection. Specifically, it calculates
std::pair< Vec, double > EntityCollection::average | ( | std::function< Vec(int m)> | value, |
std::function< double(int m)> | weight | ||
) |
This function returns the nominator and denominator for the weighted average of a given vector field
The function combines the external weights with the weights stored internally for each entity in the collection. Specifically, it calculates
double EntityCollection::averageValue | ( | std::function< double(int m)> | value, |
std::function< double(int m)> | weight | ||
) |
This function returns the weighted average of a given scalar field
The function combines the external weights with the weights stored internally for each entity in the collection. Specifically, it calculates
Vec EntityCollection::averageValue | ( | std::function< Vec(int m)> | value, |
std::function< double(int m)> | weight | ||
) |
This function returns the weighted average of a given vector field
The function combines the external weights with the weights stored internally for each entity in the collection. Specifically, it calculates
|
inline |
This function returns read-only iterator to the first entity in the collection. Each entity consists of a key/value pair, where the key is the index
void EntityCollection::clear | ( | ) |
This function removes any entities from the collection, resulting in an empty collection.
|
inline |
This function returns read-only iterator just beyond the last entity in the collection.