Dampings< FP, D > Class Template Reference
|
CPP API
|
collection of dampings at different time points. More...
#include <damping.h>
Public Types | |
| using | const_iterator = typename std::vector< value_type >::const_iterator |
| using | const_reference = const value_type & |
| using | iterator = typename std::vector< value_type >::iterator |
| using | Matrix = typename Shape::Matrix |
| using | reference = value_type & |
| using | Shape = typename D::Shape |
| using | value_type = D |
Public Member Functions | |
| void | add (const value_type &damping) |
| add a damping. More... | |
| template<class... T> | |
| void | add (FP d, T... t) |
| template<class... T> | |
| void | add (T &&... t) |
| iterator | begin () |
| STL iterators over matrices. More... | |
| const_iterator | begin () const |
| void | clear () |
| remove all dampings. More... | |
| Dampings (std::initializer_list< value_type > il) | |
| create damping collection. More... | |
| template<class... T> | |
| requires std::is_constructible_v< Shape, T... > | Dampings (T... shape_args) |
| create damping collection. More... | |
| iterator | end () |
| const_iterator | end () const |
| auto | get_matrix_at (SimulationTime< FP > t) const |
| Computes the real contact frequency at a point in time. More... | |
| size_t | get_num_dampings () const |
| get the number of matrices. More... | |
| Shape | get_shape () const |
| dimensions of the damping matrix. More... | |
| bool | operator!= (const Dampings &other) const |
| bool | operator== (const Dampings &other) const |
| equality operators. More... | |
| reference | operator[] (size_t i) |
| access one damping in this collection. More... | |
| const_reference | operator[] (size_t i) const |
| void | remove (size_t i) |
| remove the damping at index i. More... | |
| template<class IOContext > | |
| void | serialize (IOContext &io) const |
| serialize this. More... | |
| void | set_automatic_cache_update (bool b) |
| Disable the internal cache to speed up multiple modifications in a row. More... | |
Static Public Member Functions | |
| template<class IOContext > | |
| static IOResult< Dampings > | deserialize (IOContext &io) |
| deserialize an object of this class. More... | |
Private Member Functions | |
| void | add_ (const value_type &damping) |
| internal add. More... | |
| void | automatic_cache_update () |
| updates the cache if automatic cache updates are enabled. More... | |
| void | update_cache () |
| compute the cache of accumulated dampings. More... | |
Static Private Member Functions | |
| template<class Tuple > | |
| static Matrix | inclusive_exclusive_sum (const std::vector< Tuple > &v) |
| template<class Iter > | |
| static void | inclusive_exclusive_sum_rec (Iter b, Iter e, Matrix &sum) |
| e.g. More... | |
| static void | update_active_dampings (const value_type &damping, std::vector< std::tuple< std::reference_wrapper< const Matrix >, DampingLevel, DampingType >> &active_by_type, std::vector< std::tuple< Matrix, DampingLevel >> &sum_by_level) |
| replace matrices of the same type, sum up matrices on the same level. More... | |
Private Attributes | |
| std::vector< std::tuple< Matrix, SimulationTime< FP > > > | m_accumulated_dampings_cached |
| bool | m_automatic_cache_update = true |
| std::vector< value_type > | m_dampings |
| Shape | m_shape |
Friends | |
| void | PrintTo (const Dampings &self, std::ostream *os) |
| GTest printer. More... | |
Detailed Description
template<typename FP, class D>
class mio::Dampings< FP, D >
collection of dampings at different time points.
combination of dampings is computed in the way described at get_matrix_at.
- See also
- get_matrix_at
- Template Parameters
-
FP Floating point type, e.g., double D an instance of Damping template or compatible type.
Member Typedef Documentation
◆ const_iterator
| using mio::Dampings< FP, D >::const_iterator = typename std::vector<value_type>::const_iterator |
◆ const_reference
| using mio::Dampings< FP, D >::const_reference = const value_type& |
◆ iterator
| using mio::Dampings< FP, D >::iterator = typename std::vector<value_type>::iterator |
◆ Matrix
| using mio::Dampings< FP, D >::Matrix = typename Shape::Matrix |
◆ reference
| using mio::Dampings< FP, D >::reference = value_type& |
◆ Shape
| using mio::Dampings< FP, D >::Shape = typename D::Shape |
◆ value_type
| using mio::Dampings< FP, D >::value_type = D |
Constructor & Destructor Documentation
◆ Dampings() [1/2]
|
inlineexplicit |
create damping collection.
- Parameters
-
shape_args shape constructor arguments. num_dampings number of initial elements in the collection
- Template Parameters
-
T Shape constructor arguments.
◆ Dampings() [2/2]
|
inline |
create damping collection.
- Parameters
-
il initializer list of Dampings
Member Function Documentation
◆ add() [1/3]
|
inline |
add a damping.
- Parameters
-
damping a Damping
◆ add() [2/3]
|
inline |
◆ add() [3/3]
|
inline |
◆ add_()
|
private |
internal add.
◆ automatic_cache_update()
|
inlineprivate |
updates the cache if automatic cache updates are enabled.
◆ begin() [1/2]
|
inline |
STL iterators over matrices.
◆ begin() [2/2]
|
inline |
◆ clear()
|
inline |
remove all dampings.
◆ deserialize()
|
inlinestatic |
deserialize an object of this class.
- See also
- mio::deserialize
◆ end() [1/2]
|
inline |
◆ end() [2/2]
|
inline |
◆ get_matrix_at()
|
inline |
Computes the real contact frequency at a point in time.
Combines the dampings that are active at a point in time according to type and level rules. Dampings on different levels apply "multiplicatively". Dampings on the same level apply additively. e.g. Two dampings a and b on different levels combine to (1 - (1 - a)(1 - b)) or (a + b - ab). Two dampings a and b on the same level combine to (a + b).
Transitions between different contact frequencies are smoothed out over one day to avoid discontinuities. Uses lazy evaluation, coefficients are calculated on indexed access.
- Parameters
-
t time in the simulation
- Returns
- matrix expression
◆ get_num_dampings()
|
inline |
get the number of matrices.
◆ get_shape()
|
inline |
dimensions of the damping matrix.
◆ inclusive_exclusive_sum()
|
inlinestaticprivate |
◆ inclusive_exclusive_sum_rec()
|
inlinestaticprivate |
e.g.
inclusive_exclusive_sum({A, B, C}) = A + B + C - AB - BC - AC + ABC equal to but more efficient than 1 - (1 - A)(1 - B)(1 - C))
◆ operator!=()
|
inline |
◆ operator==()
|
inline |
equality operators.
◆ operator[]() [1/2]
|
inline |
access one damping in this collection.
◆ operator[]() [2/2]
|
inline |
◆ remove()
|
inline |
remove the damping at index i.
◆ serialize()
|
inline |
serialize this.
- See also
- mio::serialize
◆ set_automatic_cache_update()
|
inline |
Disable the internal cache to speed up multiple modifications in a row.
This class has an internal cache where all dampings are combined into a single time series of matrices for faster lookup. By default, the cache is automatically updated when dampings are added or removed, but this can be expensive. This function can be used to disable the cache so that add() or remove() can be called multiple times in a row more efficiently. Afterwards, the cache needs to be reenabled.
- Parameters
-
b True if cache updates are enabled.
◆ update_active_dampings()
|
staticprivate |
replace matrices of the same type, sum up matrices on the same level.
add new types/levels if necessary.
◆ update_cache()
|
private |
compute the cache of accumulated dampings.
if this is used after adding dampings, all subsequent calls to get_matrix_at() are quick and threadsafe. Otherwise the cache is updated automatically on the first call.
Friends And Related Function Documentation
◆ PrintTo
|
friend |
GTest printer.
Member Data Documentation
◆ m_accumulated_dampings_cached
|
private |
◆ m_automatic_cache_update
|
private |
◆ m_dampings
|
private |
◆ m_shape
|
private |
Generated by