OGS
RichardsMechanics/LocalAssemblerInterface.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
16
17namespace ProcessLib
18{
19namespace RichardsMechanics
20{
21template <int DisplacementDim>
24{
26 MeshLib::Element const& e,
27 NumLib::GenericIntegrationMethod const& integration_method,
28 bool const is_axially_symmetric,
30 : process_data_(process_data),
31 integration_method_(integration_method),
32 element_(e),
33 is_axially_symmetric_(is_axially_symmetric),
34 solid_material_(MaterialLib::Solids::selectSolidConstitutiveRelation(
35 process_data_.solid_materials, process_data_.material_ids,
36 e.getID()))
37 {
38 unsigned const n_integration_points =
39 integration_method_.getNumberOfPoints();
40
41 current_states_.resize(n_integration_points);
42 prev_states_.resize(n_integration_points);
43 output_data_.resize(n_integration_points);
44
45 material_states_.reserve(n_integration_points);
46
47 for (unsigned ip = 0; ip < n_integration_points; ++ip)
48 {
49 material_states_.emplace_back(
50 solid_material_.createMaterialStateVariables());
51
52 // Set initial strain field to zero.
53 std::get<StrainData<DisplacementDim>>(current_states_[ip]).eps =
55 }
56 }
57
58 std::size_t setIPDataInitialConditions(std::string_view name,
59 double const* values,
60 int const integration_order)
61 {
62 if (integration_order !=
63 static_cast<int>(integration_method_.getIntegrationOrder()))
64 {
66 "Setting integration point initial conditions; The integration "
67 "order of the local assembler for element {:d} is different "
68 "from the integration order in the initial condition.",
69 element_.getID());
70 }
71
72 if (name == "sigma" && process_data_.initial_stress.value != nullptr)
73 {
75 "Setting initial conditions for stress from integration "
76 "point data and from a parameter '{:s}' is not possible "
77 "simultaneously.",
78 process_data_.initial_stress.value->name);
79 }
80
81 if (name.starts_with("material_state_variable_"))
82 {
83 name.remove_prefix(24);
84
85 auto const& internal_variables =
86 solid_material_.getInternalVariables();
87 if (auto const iv = std::find_if(
88 begin(internal_variables), end(internal_variables),
89 [&name](auto const& iv) { return iv.name == name; });
90 iv != end(internal_variables))
91 {
92 DBUG("Setting material state variable '{:s}'", name);
93 return ProcessLib::
95 values, material_states_,
97 DisplacementDim>::material_state_variables,
98 iv->reference);
99 }
100 return 0;
101 }
102
103 // TODO this logic could be pulled out of the local assembler into the
104 // process. That might lead to a slightly better performance due to less
105 // string comparisons.
107 name, values, current_states_);
108 }
109
111 std::function<std::span<double>(
113 MaterialStateVariables&)> const& get_values_span,
114 int const& n_components) const
115 {
119 DisplacementDim>::material_state_variables,
120 get_values_span, n_components);
121 }
122
123 // TODO move to NumLib::ExtrapolatableElement
125 {
126 return integration_method_.getNumberOfPoints();
127 }
128
129 int getMaterialID() const
130 {
131 return process_data_.material_ids == nullptr
132 ? 0
133 : (*process_data_.material_ids)[element_.getID()];
134 }
135
137 DisplacementDim>::MaterialStateVariables const&
138 getMaterialStateVariablesAt(unsigned integration_point) const
139 {
140 return *material_states_[integration_point].material_state_variables;
141 }
142
144 {
146
148 &Self::current_states_, &Self::output_data_);
149 }
150
151 void postTimestepConcrete(Eigen::VectorXd const& /*local_x*/,
152 Eigen::VectorXd const& /*local_x_prev*/,
153 double const /*t*/, double const /*dt*/,
154 int const /*process_id*/) override final
155 {
156 unsigned const n_integration_points =
157 integration_method_.getNumberOfPoints();
158
159 for (auto& s : material_states_)
160 {
161 s.pushBackState();
162 }
163
164 for (unsigned ip = 0; ip < n_integration_points; ip++)
165 {
167 }
168 }
169
170protected:
175
177
178 std::vector<StatefulData<DisplacementDim>> current_states_;
179 std::vector<StatefulDataPrev<DisplacementDim>> prev_states_;
180 std::vector<
183 std::vector<OutputData<DisplacementDim>> output_data_;
184};
185} // namespace RichardsMechanics
186} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
KV::KelvinVectorType< DisplacementDim > KelvinVector
std::size_t reflectSetIPData(std::string_view const name, double const *values, std::vector< IPData > &ip_data_vector)
auto reflectWithoutName(Accessors &&... accessors)
std::size_t setIntegrationPointDataMaterialStateVariables(double const *values, IntegrationPointDataVector &ip_data_vector, MemberType member, std::function< std::span< double >(MaterialStateVariables &)> get_values_span)
std::vector< double > getIntegrationPointDataMaterialStateVariables(IntegrationPointDataVector const &ip_data_vector, MemberType member, std::function< std::span< double >(MaterialStateVariables &)> get_values_span, int const n_components)
LocalAssemblerInterface(MeshLib::Element const &e, NumLib::GenericIntegrationMethod const &integration_method, bool const is_axially_symmetric, RichardsMechanicsProcessData< DisplacementDim > &process_data)
MaterialLib::Solids::MechanicsBase< DisplacementDim >::MaterialStateVariables const & getMaterialStateVariablesAt(unsigned integration_point) const
MaterialLib::Solids::MechanicsBase< DisplacementDim > const & solid_material_
std::vector< ProcessLib::ThermoRichardsMechanics::MaterialStateData< DisplacementDim > > material_states_
void postTimestepConcrete(Eigen::VectorXd const &, Eigen::VectorXd const &, double const, double const, int const) override final
std::vector< double > getMaterialStateVariableInternalState(std::function< std::span< double >(typename MaterialLib::Solids::MechanicsBase< DisplacementDim >::MaterialStateVariables &)> const &get_values_span, int const &n_components) const
std::size_t setIPDataInitialConditions(std::string_view name, double const *values, int const integration_order)