OGS
LargeDeformation/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
6#include <vector>
7
19
20namespace ProcessLib
21{
22namespace LargeDeformation
23{
24template <int DisplacementDim>
28{
30 MeshLib::Element const& e,
31 NumLib::GenericIntegrationMethod const& integration_method,
32 bool const is_axially_symmetric,
34 : process_data_(process_data),
35 integration_method_(integration_method),
36 element_(e),
37 is_axially_symmetric_(is_axially_symmetric),
38 solid_material_(MaterialLib::Solids::selectSolidConstitutiveRelation(
39 process_data_.solid_materials, process_data_.material_ids,
40 element_.getID()))
41 {
42 unsigned const n_integration_points =
43 integration_method_.getNumberOfPoints();
44
45 material_states_.reserve(n_integration_points);
46 for (unsigned ip = 0; ip < n_integration_points; ++ip)
47 {
48 material_states_.emplace_back(
49 solid_material_.createMaterialStateVariables());
50 }
51
52 current_states_.resize(n_integration_points);
53 prev_states_.resize(n_integration_points);
54 output_data_.resize(n_integration_points);
55 }
56
57 std::size_t setIPDataInitialConditions(std::string_view name,
58 double const* values,
59 int const integration_order)
60 {
61 if (integration_order !=
62 static_cast<int>(integration_method_.getIntegrationOrder()))
63 {
65 "Setting integration point initial conditions; The integration "
66 "order of the local assembler for element {:d} is different "
67 "from the integration order in the initial condition.",
68 element_.getID());
69 }
70
71 if (name.starts_with("material_state_variable_"))
72 {
73 name.remove_prefix(24);
74
75 auto const& internal_variables =
76 solid_material_.getInternalVariables();
77 if (auto const iv = std::find_if(
78 begin(internal_variables), end(internal_variables),
79 [&name](auto const& iv) { return iv.name == name; });
80 iv != end(internal_variables))
81 {
82 DBUG("Setting material state variable '{:s}'", name);
83 return ProcessLib::
85 values, material_states_,
87 DisplacementDim>::material_state_variables,
88 iv->reference);
89 }
90
91 WARN(
92 "Could not find variable {:s} in solid material model's "
93 "internal variables.",
94 name);
95 return 0;
96 }
97
98 // TODO this logic could be pulled out of the local assembler into the
99 // process. That might lead to a slightly better performance due to less
100 // string comparisons.
102 name, values, current_states_);
103 }
104
105 // TODO move to NumLib::ExtrapolatableElement
107 {
108 return integration_method_.getNumberOfPoints();
109 }
110
111 int getMaterialID() const
112 {
113 return process_data_.material_ids == nullptr
114 ? 0
115 : (*process_data_.material_ids)[element_.getID()];
116 }
117
119 std::function<std::span<double>(
121 MaterialStateVariables&)> const& get_values_span,
122 int const& n_components) const
123 {
127 get_values_span, n_components);
128 }
129
131 DisplacementDim>::MaterialStateVariables const&
132 getMaterialStateVariablesAt(unsigned integration_point) const
133 {
134 return *material_states_[integration_point].material_state_variables;
135 }
136
138 {
140
142 &Self::current_states_, &Self::output_data_);
143 }
144
145protected:
147
148 // Material state is special, because it contains both the current and the
149 // old state.
150 std::vector<MaterialStateData<DisplacementDim>> material_states_;
151 std::vector<typename ConstitutiveRelations::StatefulData<DisplacementDim>>
152 current_states_; // TODO maybe do not store but rather re-evaluate for
153 // state update
154 std::vector<
157 std::vector<typename ConstitutiveRelations::OutputData<DisplacementDim>>
159
164 DisplacementDim> const& solid_material_;
165};
166
167} // namespace LargeDeformation
168} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:34
ProcessLib::ConstitutiveRelations::PrevStateOf< StatefulData< DisplacementDim > > StatefulDataPrev
MSM::MFrontGeneric< DisplacementDim, boost::mp11::mp_list< MSM::DeformationGradient >, boost::mp11::mp_list< MSM::SecondPiolaKirchhoffStress >, boost::mp11::mp_list< MSM::Temperature > > SolidConstitutiveRelation
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)
std::vector< typename ConstitutiveRelations::StatefulDataPrev< DisplacementDim > > prev_states_
MaterialLib::Solids::MechanicsBase< DisplacementDim >::MaterialStateVariables const & getMaterialStateVariablesAt(unsigned integration_point) const
std::size_t setIPDataInitialConditions(std::string_view name, double const *values, int const integration_order)
Returns number of read integration points.
std::vector< double > getMaterialStateVariableInternalState(std::function< std::span< double >(typename MaterialLib::Solids::MechanicsBase< DisplacementDim >::MaterialStateVariables &)> const &get_values_span, int const &n_components) const
LargeDeformationLocalAssemblerInterface(MeshLib::Element const &e, NumLib::GenericIntegrationMethod const &integration_method, bool const is_axially_symmetric, LargeDeformationProcessData< DisplacementDim > &process_data)
std::vector< typename ConstitutiveRelations::StatefulData< DisplacementDim > > current_states_
std::vector< typename ConstitutiveRelations::OutputData< DisplacementDim > > output_data_
ConstitutiveRelations::SolidConstitutiveRelation< DisplacementDim > const & solid_material_