OGS
Base.h
Go to the documentation of this file.
1
10#pragma once
11
12#include <boost/mp11.hpp>
13
15
17{
19template <typename T>
21{
22 PrevState() = default;
23 explicit PrevState(T const& t) : t{t} {}
24 explicit PrevState(T&& t) : t{std::move(t)} {}
25
27 {
28 t = u;
29 return *this;
30 }
31
33 {
34 t = std::move(u);
35 return *this;
36 }
37
38 T& operator*() { return t; }
39 T const& operator*() const { return t; }
40
41 T* operator->() { return &t; }
42 T const* operator->() const { return &t; }
43
44private:
45 T t;
46};
47
49template <typename Tuple>
50using PrevStateOf = boost::mp11::mp_transform<PrevState, Tuple>;
51
52namespace detail
53{
54template <typename... Ts, std::size_t... Idcs>
55void assign(std::tuple<PrevState<Ts>...>& prev_states,
56 std::tuple<Ts...> const& current_states,
57 std::index_sequence<Idcs...>)
58{
59 ((std::get<Idcs>(prev_states) = std::get<Idcs>(current_states)), ...);
60}
61} // namespace detail
62
64template <typename... Ts>
65void assign(std::tuple<PrevState<Ts>...>& prev_states,
66 std::tuple<Ts...> const& current_states)
67{
68 detail::assign(prev_states, current_states,
69 std::make_index_sequence<sizeof...(Ts)>{});
70}
71
78
80static constexpr double nan = std::numeric_limits<double>::quiet_NaN();
81
82} // namespace ProcessLib::ConstitutiveRelations
void assign(std::tuple< PrevState< Ts >... > &prev_states, std::tuple< Ts... > const &current_states, std::index_sequence< Idcs... >)
Definition Base.h:55
boost::mp11::mp_transform< PrevState, Tuple > PrevStateOf
Applies PrevState to a tuple of constitutive data.
Definition Base.h:50
static constexpr double nan
Convenience alias for not a number.
Definition Base.h:80
void assign(std::tuple< PrevState< Ts >... > &prev_states, std::tuple< Ts... > const &current_states)
Assigns a tuple of current states to a tuple of previous states.
Definition Base.h:65
Represents a previous state of type T.
Definition Base.h:21
PrevState< T > & operator=(T &&u)
Definition Base.h:32
PrevState< T > & operator=(T const &u)
Definition Base.h:26
ParameterLib::SpatialPosition x
Definition Base.h:74