damping.h Source File
|
CPP API
|
damping.h
Go to the documentation of this file.
91 class Damping : public std::tuple<typename S::Matrix, DampingLevel, DampingType, SimulationTime<FP>>
119 Damping(const Eigen::MatrixBase<ME>& m, DampingLevel level, DampingType type, SimulationTime<FP> t)
137 : Damping(Matrix::Constant(Shape(shape_args...).rows(), Shape(shape_args...).cols(), d), level, type, t)
386 auto ub = std::upper_bound(m_accumulated_dampings_cached.begin(), m_accumulated_dampings_cached.end(),
538 std::vector<std::tuple<std::reference_wrapper<const Matrix>, DampingLevel, DampingType>>& active_by_type,
579 std::vector<std::tuple<std::reference_wrapper<const Matrix>, DampingLevel, DampingType>> active_by_type;
619 std::vector<std::tuple<std::reference_wrapper<const Matrix>, DampingLevel, DampingType>>& active_by_type,
627 auto iter_active_same_type = std::find_if(active_by_type.begin(), active_by_type.end(), [&damping](auto& active) {
635 auto& sum_same_level = *std::find_if(sum_by_level.begin(), sum_by_level.end(), [&damping](auto& sum) {
639 get<MatrixIdx>(sum_same_level) += get<MatrixIdx>(damping) - get<MatrixIdx>(active_same_type).get();
644 active_by_type.emplace_back(get<MatrixIdx>(damping), get<DampingLevel>(damping), get<DampingType>(damping));
646 auto iter_sum_same_level = std::find_if(sum_by_level.begin(), sum_by_level.end(), [&damping](auto& sum) {
represent interventions or effects that affect contact frequencies between multiple groups.
Definition: damping.h:92
requires std::is_constructible_v< Shape, T... > Damping(T... shape_args)
create a default Damping.
Definition: damping.h:105
requires std::is_constructible_v< Shape, T... > Damping(FP d, SimulationTime< FP > t, T... shape_args)
create a Damping with constant coefficients and zero level and type.
Definition: damping.h:162
static IOResult< Damping > deserialize(IOContext &io)
deserialize an object of this class.
Definition: damping.h:252
Damping(const Eigen::MatrixBase< ME > &m, DampingLevel level, DampingType type, SimulationTime< FP > t)
create a Damping.
Definition: damping.h:119
const Matrix & get_coeffs() const
the coefficients of this damping.
Definition: damping.h:206
DampingLevel & get_level()
the level of this damping.
Definition: damping.h:182
friend void PrintTo(const Damping &self, std::ostream *os)
GTest printer.
Definition: damping.h:226
requires std::is_constructible_v< Shape, T... > Damping(FP d, DampingLevel level, DampingType type, SimulationTime< FP > t, T... shape_args)
create a Damping with constant coefficients.
Definition: damping.h:136
SimulationTime< FP > & get_time()
the time this damping becomes active.
Definition: damping.h:170
std::tuple< Matrix, DampingLevel, DampingType, SimulationTime< FP > > Base
Definition: damping.h:96
Damping(const Eigen::MatrixBase< ME > &m, SimulationTime< FP > t)
create a Damping at level and type zero
Definition: damping.h:148
reference operator[](size_t i)
access one damping in this collection.
Definition: damping.h:401
friend void PrintTo(const Dampings &self, std::ostream *os)
GTest printer.
Definition: damping.h:461
size_t get_num_dampings() const
get the number of matrices.
Definition: damping.h:425
bool operator==(const Dampings &other) const
equality operators.
Definition: damping.h:413
Dampings(std::initializer_list< value_type > il)
create damping collection.
Definition: damping.h:306
auto get_matrix_at(SimulationTime< FP > t) const
Computes the real contact frequency at a point in time.
Definition: damping.h:381
std::vector< std::tuple< Matrix, SimulationTime< FP > > > m_accumulated_dampings_cached
Definition: damping.h:566
void set_automatic_cache_update(bool b)
Disable the internal cache to speed up multiple modifications in a row.
Definition: damping.h:361
typename std::vector< value_type >::iterator iterator
Definition: damping.h:284
typename std::vector< value_type >::const_iterator const_iterator
Definition: damping.h:285
static IOResult< Dampings > deserialize(IOContext &io)
deserialize an object of this class.
Definition: damping.h:488
void automatic_cache_update()
updates the cache if automatic cache updates are enabled.
Definition: damping.h:525
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.
Definition: damping.h:617
static void inclusive_exclusive_sum_rec(Iter b, Iter e, Matrix &sum)
e.g.
Definition: damping.h:546
void update_cache()
compute the cache of accumulated dampings.
Definition: damping.h:571
static Matrix inclusive_exclusive_sum(const std::vector< Tuple > &v)
Definition: damping.h:556
requires std::is_constructible_v< Shape, T... > Dampings(T... shape_args)
create damping collection.
Definition: damping.h:295
Shape get_shape() const
dimensions of the damping matrix.
Definition: damping.h:433
base class to add default operator +, +=, -, -= to a class derived from TypeSafe.
Definition: type_safe.h:175
base class to add operator <, <=, >, >= to a class derived from TypeSafe.
Definition: type_safe.h:228
base class to add operator *, *=, /, /= with a scalar to a class derived from TypeSafe.
Definition: type_safe.h:202
Typesafe wrapper for a floating-point simulation time value (in days).
Definition: damping.h:78
Typesafe wrapper around any type to make function arguments, tuple elements, etc.
Definition: type_safe.h:59
static min_max_return_type< ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 >, ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > >::type max(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &a, const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &b)
Definition: ad.hpp:2596
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
auto failure(const IOStatus &s)
Create an object that is implicitly convertible to an error IOResult<T>.
Definition: io.h:381
@ InvalidValue
boost::outcome_v2::in_place_type_t< T > Tag
Type that is used for overload resolution.
Definition: io.h:408
details::ApplyResultT< F, T... > apply(IOContext &io, F f, const IOResult< T > &... rs)
Evaluate a function with zero or more unpacked IOResults as arguments.
Definition: io.h:482
requires(!std::is_trivial_v< T >) void BinarySerializerObject
Definition: binary_serializer.h:333
auto success()
Create an object that is implicitly convertible to a succesful IOResult<void>.
Definition: io.h:360
DECL_TYPESAFE(int, DampingLevel)
Typesafe integer representing the level of a damping.
constexpr std::tuple_element< I, std::tuple< Index< CategoryTags >... > >::type & get(Index< CategoryTags... > &i) noexcept
Retrieves the Index (by reference) at the Ith position of a MultiIndex.
Definition: index.h:304
boost::outcome_v2::unchecked< T, IOStatus > IOResult
Value-or-error type for operations that return a value but can fail.
Definition: io.h:354
Generated by