OGS
ConstitutiveRelations/Base.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <boost/mp11.hpp>
7
11
13{
14namespace KV = MathLib::KelvinVector;
15
16template <int DisplacementDim>
17using KelvinVector = KV::KelvinVectorType<DisplacementDim>;
18
19template <int DisplacementDim>
20using KelvinMatrix = KV::KelvinMatrixType<DisplacementDim>;
21
22template <int DisplacementDim>
23using GlobalDimVector = Eigen::Vector<double, DisplacementDim>;
24
25template <int DisplacementDim>
27 Eigen::Matrix<double, DisplacementDim, DisplacementDim, Eigen::RowMajor>;
28
30
31template <int DisplacementDim>
33 struct SpecificBodyForceTag>;
34
36template <typename T>
38{
39 PrevState() = default;
40 explicit PrevState(T const& t) : t{t} {}
41 explicit PrevState(T&& t) : t{std::move(t)} {}
42
44 {
45 t = u;
46 return *this;
47 }
48
50 {
51 t = std::move(u);
52 return *this;
53 }
54
55 T& operator*() { return t; }
56 T const& operator*() const { return t; }
57
58 T* operator->() { return &t; }
59 T const* operator->() const { return &t; }
60
61private:
62 T t;
63};
64
66template <typename Tuple>
67using PrevStateOf = boost::mp11::mp_transform<PrevState, Tuple>;
68
69namespace detail
70{
71template <typename... Ts, std::size_t... Idcs>
72void assign(std::tuple<PrevState<Ts>...>& prev_states,
73 std::tuple<Ts...> const& current_states,
74 std::index_sequence<Idcs...>)
75{
76 ((std::get<Idcs>(prev_states) = std::get<Idcs>(current_states)), ...);
77}
78} // namespace detail
79
81template <typename... Ts>
82void assign(std::tuple<PrevState<Ts>...>& prev_states,
83 std::tuple<Ts...> const& current_states)
84{
85 detail::assign(prev_states, current_states,
86 std::make_index_sequence<sizeof...(Ts)>{});
87}
88
95
97static constexpr double nan = std::numeric_limits<double>::quiet_NaN();
98
99} // namespace ProcessLib::ConstitutiveRelations
void assign(std::tuple< PrevState< Ts >... > &prev_states, std::tuple< Ts... > const &current_states, std::index_sequence< Idcs... >)
boost::mp11::mp_transform< PrevState, Tuple > PrevStateOf
Applies PrevState to a tuple of constitutive data.
Eigen::Vector< double, DisplacementDim > GlobalDimVector
Eigen::Matrix< double, DisplacementDim, DisplacementDim, Eigen::RowMajor > GlobalDimMatrix
KV::KelvinMatrixType< DisplacementDim > KelvinMatrix
BaseLib::StrongType< double, struct TemperatureTag > Temperature
static constexpr double nan
Convenience alias for not a number.
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.
BaseLib::StrongType< GlobalDimVector< DisplacementDim >, struct SpecificBodyForceTag > SpecificBodyForce
KV::KelvinVectorType< DisplacementDim > KelvinVector