OGS
ThermoRichardsMechanicsProcess.cpp
Go to the documentation of this file.
1
12
13#include <cassert>
14
15#include "BaseLib/Error.h"
22#include "ProcessLib/Process.h"
26
27namespace ProcessLib
28{
29namespace ThermoRichardsMechanics
30{
31template <int DisplacementDim, typename ConstitutiveTraits>
34 std::string name,
35 MeshLib::Mesh& mesh,
36 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&&
37 jacobian_assembler,
38 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const&
39 parameters,
40 unsigned const integration_order,
41 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
42 process_variables,
44 ConstitutiveTraits>&& process_data,
45 SecondaryVariableCollection&& secondary_variables,
46 bool const use_monolithic_scheme)
47 : Process(std::move(name), mesh, std::move(jacobian_assembler), parameters,
48 integration_order, std::move(process_variables),
49 std::move(secondary_variables), use_monolithic_scheme),
51 ThermoRichardsMechanicsProcess<DisplacementDim, ConstitutiveTraits>>{
53 process_data_(std::move(process_data))
54{
56 DisplacementDim>(LocalAssemblerIF::getReflectionDataForOutput(),
57 _integration_point_writer, integration_order,
58 local_assemblers_);
59}
60
61template <int DisplacementDim, typename ConstitutiveTraits>
62bool ThermoRichardsMechanicsProcess<DisplacementDim,
63 ConstitutiveTraits>::isLinear() const
64{
65 return false;
66}
67
68template <int DisplacementDim, typename ConstitutiveTraits>
70 DisplacementDim,
71 ConstitutiveTraits>::getMatrixSpecifications(const int /*process_id*/) const
72{
73 auto const& l = *_local_to_global_index_map;
74 return {l.dofSizeWithoutGhosts(), l.dofSizeWithoutGhosts(),
75 &l.getGhostIndices(), &this->_sparsity_pattern};
76}
77
78template <int DisplacementDim, typename ConstitutiveTraits>
79void ThermoRichardsMechanicsProcess<DisplacementDim,
80 ConstitutiveTraits>::constructDofTable()
81{
82 // Create single component dof in every of the mesh's nodes.
83 _mesh_subset_all_nodes = std::make_unique<MeshLib::MeshSubset>(
84 _mesh, _mesh.getNodes(), process_data_.use_TaylorHood_elements);
85 // Create single component dof in the mesh's base nodes.
86 base_nodes_ = MeshLib::getBaseNodes(_mesh.getElements());
87 mesh_subset_base_nodes_ = std::make_unique<MeshLib::MeshSubset>(
88 _mesh, base_nodes_, process_data_.use_TaylorHood_elements);
89
90 // TODO move the two data members somewhere else.
91 // for extrapolation of secondary variables of stress or strain
92 std::vector<MeshLib::MeshSubset> all__meshsubsets_single_component{
93 *_mesh_subset_all_nodes};
94 local_to_global_index_map_single_component_ =
95 std::make_unique<NumLib::LocalToGlobalIndexMap>(
96 std::move(all__meshsubsets_single_component),
97 // by location order is needed for output
99
100 // For temperature, which is the first variable.
101 std::vector<MeshLib::MeshSubset> all__meshsubsets{*mesh_subset_base_nodes_};
102
103 // For pressure, which is the second variable
104 all__meshsubsets.push_back(*mesh_subset_base_nodes_);
105
106 // For displacement.
107 const int monolithic_process_id = 0;
108 std::generate_n(std::back_inserter(all__meshsubsets),
109 getProcessVariables(monolithic_process_id)[2]
110 .get()
111 .getNumberOfGlobalComponents(),
112 [&]() { return *_mesh_subset_all_nodes; });
113
114 std::vector<int> const vec_n_components{1, 1, DisplacementDim};
115 _local_to_global_index_map =
116 std::make_unique<NumLib::LocalToGlobalIndexMap>(
117 std::move(all__meshsubsets), vec_n_components,
119 assert(_local_to_global_index_map);
120}
121
122template <int DisplacementDim, typename ConstitutiveTraits>
125 MeshLib::Mesh const& mesh,
126 unsigned const integration_order)
127{
128 createLocalAssemblers<DisplacementDim, ConstitutiveTraits>(
129 mesh.getElements(), dof_table, local_assemblers_,
130 NumLib::IntegrationOrder{integration_order}, mesh.isAxiallySymmetric(),
131 process_data_);
132
133 auto add_secondary_variable = [&](std::string const& name,
134 int const num_components,
135 auto get_ip_values_function)
136 {
137 _secondary_variables.addSecondaryVariable(
138 name,
139 makeExtrapolator(num_components, getExtrapolator(),
140 local_assemblers_,
141 std::move(get_ip_values_function)));
142 };
143
144 ProcessLib::Reflection::addReflectedSecondaryVariables<DisplacementDim>(
145 LocalAssemblerIF::getReflectionDataForOutput(), _secondary_variables,
146 getExtrapolator(), local_assemblers_);
147
148 //
149 // enable output of internal variables defined by material models
150 //
152 LocalAssemblerIF>(process_data_.solid_materials,
153 add_secondary_variable);
154
157 process_data_.solid_materials, local_assemblers_,
158 _integration_point_writer, integration_order);
159
160 process_data_.pressure_interpolated =
161 MeshLib::getOrCreateMeshProperty<double>(
162 const_cast<MeshLib::Mesh&>(mesh), "pressure_interpolated",
164 process_data_.temperature_interpolated =
165 MeshLib::getOrCreateMeshProperty<double>(
166 const_cast<MeshLib::Mesh&>(mesh), "temperature_interpolated",
168
169 setIPDataInitialConditions(_integration_point_writer, mesh.getProperties(),
170 local_assemblers_);
171
172 // Initialize local assemblers after all variables have been set.
173 GlobalExecutor::executeMemberOnDereferenced(&LocalAssemblerIF::initialize,
174 local_assemblers_,
175 *_local_to_global_index_map);
176}
177
178template <int DisplacementDim, typename ConstitutiveTraits>
181 std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const&
182 media)
183{
184 const int process_id = 0;
185 initializeProcessBoundaryConditionsAndSourceTerms(
186 *_local_to_global_index_map, process_id, media);
187}
188
189template <int DisplacementDim, typename ConstitutiveTraits>
191 setInitialConditionsConcreteProcess(std::vector<GlobalVector*>& x,
192 double const t,
193 int const process_id)
194{
195 DBUG("SetInitialConditions ThermoRichardsMechanicsProcess.");
196
198 &LocalAssemblerIF::setInitialConditions, local_assemblers_,
199 getDOFTables(x.size()), x, t, process_id);
200}
201
202template <int DisplacementDim, typename ConstitutiveTraits>
204 assembleConcreteProcess(const double /*t*/, double const /*dt*/,
205 std::vector<GlobalVector*> const& /*x*/,
206 std::vector<GlobalVector*> const& /*x_prev*/,
207 int const /*process_id*/, GlobalMatrix& /*M*/,
208 GlobalMatrix& /*K*/, GlobalVector& /*b*/)
209{
210 OGS_FATAL(
211 "The Picard method or the Newton-Raphson method with numerical "
212 "Jacobian is not implemented for ThermoRichardsMechanics with the full "
213 "monolithic coupling scheme");
214}
215
216template <int DisplacementDim, typename ConstitutiveTraits>
219 const double t, double const dt, std::vector<GlobalVector*> const& x,
220 std::vector<GlobalVector*> const& x_prev, int const process_id,
221 GlobalVector& b, GlobalMatrix& Jac)
222{
224 DisplacementDim, ConstitutiveTraits>>::assembleWithJacobian(t, dt, x,
225 x_prev,
226 process_id,
227 b, Jac);
228}
229
230template <int DisplacementDim, typename ConstitutiveTraits>
232 preTimestepConcreteProcess(std::vector<GlobalVector*> const& /*x*/,
233 const double /*t*/,
234 const double /*dt*/,
235 const int /*process_id*/)
236{
238 DisplacementDim, ConstitutiveTraits>>::updateActiveElements();
239}
240
241template <int DisplacementDim, typename ConstitutiveTraits>
242std::vector<std::vector<std::string>>
245 std::vector<std::reference_wrapper<MeshLib::Mesh>> const& meshes)
246{
247 INFO("TRM process initializeSubmeshOutput().");
248 std::vector<std::vector<std::string>> residuum_names{
249 {"HeatFlowRate", "MassFlowRate", "NodalForces"}};
250
253 initializeAssemblyOnSubmeshes(meshes, residuum_names);
254
255 return residuum_names;
256}
257
258template <int DisplacementDim, typename ConstitutiveTraits>
260 postTimestepConcreteProcess(std::vector<GlobalVector*> const& x,
261 std::vector<GlobalVector*> const& x_prev,
262 double const t, double const dt,
263 const int process_id)
264{
265 DBUG("PostTimestep ThermoRichardsMechanicsProcess.");
266
268 &LocalAssemblerIF::postTimestep, local_assemblers_,
269 getActiveElementIDs(), getDOFTables(x.size()), x, x_prev, t, dt,
270 process_id);
271}
272
273template <int DisplacementDim, typename ConstitutiveTraits>
275 computeSecondaryVariableConcrete(const double t, const double dt,
276 std::vector<GlobalVector*> const& x,
277 GlobalVector const& x_prev,
278 int const process_id)
279{
280 DBUG("Compute the secondary variables for ThermoRichardsMechanicsProcess.");
281
283 &LocalAssemblerIF::computeSecondaryVariable, local_assemblers_,
284 getActiveElementIDs(), getDOFTables(x.size()), t, dt, x, x_prev,
285 process_id);
286
287 computeCellAverages<DisplacementDim>(cell_average_data_, local_assemblers_);
288}
289
290template <int DisplacementDim, typename ConstitutiveTraits>
291std::tuple<NumLib::LocalToGlobalIndexMap*, bool> ThermoRichardsMechanicsProcess<
292 DisplacementDim, ConstitutiveTraits>::getDOFTableForExtrapolatorData() const
293{
294 const bool manage_storage = false;
295 return std::make_tuple(local_to_global_index_map_single_component_.get(),
296 manage_storage);
297}
298
299template <int DisplacementDim, typename ConstitutiveTraits>
301 DisplacementDim, ConstitutiveTraits>::getDOFTable(const int /*process_id*/)
302 const
303{
304 return *_local_to_global_index_map;
305}
306
307template class ThermoRichardsMechanicsProcess<
309template class ThermoRichardsMechanicsProcess<
311
312#if OGS_USE_MFRONT
313template class ThermoRichardsMechanicsProcess<
314 2, ConstitutiveStressSaturation_StrainPressureTemperature::
315 ConstitutiveTraits<2>>;
316template class ThermoRichardsMechanicsProcess<
317 3, ConstitutiveStressSaturation_StrainPressureTemperature::
318 ConstitutiveTraits<3>>;
319#endif
320
321} // namespace ThermoRichardsMechanics
322} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
Global vector based on Eigen vector.
Definition EigenVector.h:25
bool isAxiallySymmetric() const
Definition Mesh.h:137
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
Properties & getProperties()
Definition Mesh.h:134
std::unique_ptr< ProcessLib::AbstractJacobianAssembler > _jacobian_assembler
Definition Process.h:376
Handles configuration of several secondary variables from the project file.
Global assembler for the monolithic scheme of the non-isothermal Richards flow coupled with mechanics...
void assembleConcreteProcess(const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b) override
void preTimestepConcreteProcess(std::vector< GlobalVector * > const &, const double, const double, const int) override
void computeSecondaryVariableConcrete(double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_prev, int const process_id) override
void assembleWithJacobianConcreteProcess(const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalVector &b, GlobalMatrix &Jac) override
ThermoRichardsMechanicsProcess(std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > &&process_variables, ThermoRichardsMechanicsProcessData< DisplacementDim, ConstitutiveTraits > &&process_data, SecondaryVariableCollection &&secondary_variables, bool const use_monolithic_scheme)
std::vector< std::vector< std::string > > initializeAssemblyOnSubmeshes(std::vector< std::reference_wrapper< MeshLib::Mesh > > const &meshes) override
void setInitialConditionsConcreteProcess(std::vector< GlobalVector * > &x, double const t, int const process_id) override
void initializeBoundaryConditions(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media) override
void initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
Process specific initialization called by initialize().
void postTimestepConcreteProcess(std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, double const t, double const dt, const int process_id) override
std::vector< Node * > getBaseNodes(std::vector< Element * > const &elements)
Definition Utils.h:26
@ BY_LOCATION
Ordering data by spatial location.
void solidMaterialInternalVariablesToIntegrationPointWriter(std::map< int, std::shared_ptr< SolidMaterial > > const &solid_materials, std::vector< std::unique_ptr< LocalAssemblerInterface > > const &local_assemblers, std::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > &integration_point_writer, int const integration_order)
void solidMaterialInternalToSecondaryVariables(std::map< int, std::shared_ptr< SolidMaterial > > const &solid_materials, AddSecondaryVariableCallback const &add_secondary_variable)
void addReflectedIntegrationPointWriters(ReflData const &reflection_data, std::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > &integration_point_writers, unsigned const integration_order, std::vector< std::unique_ptr< LocAsmIF > > const &local_assemblers)
SecondaryVariableFunctions makeExtrapolator(const unsigned num_components, NumLib::Extrapolator &extrapolator, LocalAssemblerCollection const &local_assemblers, typename NumLib::ExtrapolatableLocalAssemblerCollection< LocalAssemblerCollection >::IntegrationPointValuesMethod integration_point_values_method)
void setIPDataInitialConditions(std::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > const &_integration_point_writer, MeshLib::Properties const &mesh_properties, LocalAssemblersVector &local_assemblers)
static void executeSelectedMemberOnDereferenced(Method method, Container const &container, std::vector< std::size_t > const &active_container_ids, Args &&... args)
static void executeMemberOnDereferenced(Method method, Container const &container, Args &&... args)