27namespace ThermoHydroMechanics
29template <
int DisplacementDim>
33 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
34 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>
const& parameters,
35 unsigned const integration_order,
36 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
40 bool const use_monolithic_scheme)
41 :
Process(std::move(name), mesh, std::move(jacobian_assembler), parameters,
42 integration_order, std::move(process_variables),
43 std::move(secondary_variables), use_monolithic_scheme),
46 _process_data(std::move(process_data))
58 _integration_point_writer.emplace_back(
59 std::make_unique<MeshLib::IntegrationPointWriter>(
61 static_cast<int>(mesh.getDimension() == 2 ? 4 : 6) ,
62 integration_order, local_assemblers_,
65 _integration_point_writer.emplace_back(
66 std::make_unique<MeshLib::IntegrationPointWriter>(
68 static_cast<int>(mesh.getDimension() == 2 ? 4 : 6) ,
69 integration_order, local_assemblers_,
72 _integration_point_writer.emplace_back(
73 std::make_unique<MeshLib::IntegrationPointWriter>(
75 static_cast<int>(mesh.getDimension() == 2 ? 4 : 6) ,
76 integration_order, local_assemblers_,
80template <
int DisplacementDim>
86template <
int DisplacementDim>
89 const int process_id)
const
93 if (_use_monolithic_scheme || process_id == 2)
95 auto const& l = *_local_to_global_index_map;
96 return {l.dofSizeWithoutGhosts(), l.dofSizeWithoutGhosts(),
97 &l.getGhostIndices(), &this->_sparsity_pattern};
101 auto const& l = *_local_to_global_index_map_with_base_nodes;
102 return {l.dofSizeWithoutGhosts(), l.dofSizeWithoutGhosts(),
103 &l.getGhostIndices(), &_sparsity_pattern_with_linear_element};
106template <
int DisplacementDim>
110 _mesh_subset_all_nodes =
111 std::make_unique<MeshLib::MeshSubset>(_mesh, _mesh.getNodes());
114 _mesh_subset_base_nodes =
115 std::make_unique<MeshLib::MeshSubset>(_mesh, _base_nodes);
119 std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{
120 *_mesh_subset_all_nodes};
121 _local_to_global_index_map_single_component =
122 std::make_unique<NumLib::LocalToGlobalIndexMap>(
123 std::move(all_mesh_subsets_single_component),
127 if (_use_monolithic_scheme)
130 std::vector<MeshLib::MeshSubset> all_mesh_subsets{
131 *_mesh_subset_base_nodes};
134 all_mesh_subsets.push_back(*_mesh_subset_base_nodes);
137 const int monolithic_process_id = 0;
138 std::generate_n(std::back_inserter(all_mesh_subsets),
139 getProcessVariables(monolithic_process_id)[2]
141 .getNumberOfGlobalComponents(),
142 [&]() {
return *_mesh_subset_all_nodes; });
144 std::vector<int>
const vec_n_components{1, 1, DisplacementDim};
145 _local_to_global_index_map =
146 std::make_unique<NumLib::LocalToGlobalIndexMap>(
147 std::move(all_mesh_subsets), vec_n_components,
149 assert(_local_to_global_index_map);
154 const int process_id = 2;
155 std::vector<MeshLib::MeshSubset> all_mesh_subsets;
156 std::generate_n(std::back_inserter(all_mesh_subsets),
157 getProcessVariables(process_id)[0]
159 .getNumberOfGlobalComponents(),
160 [&]() {
return *_mesh_subset_all_nodes; });
162 std::vector<int>
const vec_n_components{DisplacementDim};
163 _local_to_global_index_map =
164 std::make_unique<NumLib::LocalToGlobalIndexMap>(
165 std::move(all_mesh_subsets), vec_n_components,
170 std::vector<MeshLib::MeshSubset> all_mesh_subsets_base_nodes{
171 *_mesh_subset_base_nodes};
172 _local_to_global_index_map_with_base_nodes =
173 std::make_unique<NumLib::LocalToGlobalIndexMap>(
174 std::move(all_mesh_subsets_base_nodes),
179 *_local_to_global_index_map_with_base_nodes, _mesh);
181 assert(_local_to_global_index_map);
182 assert(_local_to_global_index_map_with_base_nodes);
186template <
int DisplacementDim>
190 unsigned const integration_order)
198 auto add_secondary_variable = [&](std::string
const& name,
199 int const num_components,
200 auto get_ip_values_function)
202 _secondary_variables.addSecondaryVariable(
206 std::move(get_ip_values_function)));
209 add_secondary_variable(
212 DisplacementDim>::RowsAtCompileTime,
215 add_secondary_variable(
218 DisplacementDim>::RowsAtCompileTime,
221 add_secondary_variable(
224 DisplacementDim>::RowsAtCompileTime,
227 add_secondary_variable(
230 DisplacementDim>::RowsAtCompileTime,
233 add_secondary_variable(
234 "ice_volume_fraction", 1,
237 add_secondary_variable(
241 add_secondary_variable(
245 add_secondary_variable(
249 _process_data.element_fluid_density =
262 DisplacementDim>::RowsAtCompileTime);
264 _process_data.pressure_interpolated =
269 _process_data.temperature_interpolated =
271 const_cast<MeshLib::Mesh&
>(mesh),
"temperature_interpolated",
279 add_secondary_variable);
283 _process_data.solid_materials, local_assemblers_,
284 _integration_point_writer, integration_order);
292 local_assemblers_, *_local_to_global_index_map);
295template <
int DisplacementDim>
297 std::map<
int, std::shared_ptr<MaterialPropertyLib::Medium>>
const& media)
299 if (_use_monolithic_scheme)
301 const int process_id_of_thermohydromechancs = 0;
302 initializeProcessBoundaryConditionsAndSourceTerms(
303 *_local_to_global_index_map, process_id_of_thermohydromechancs,
310 const int thermal_process_id = 0;
311 initializeProcessBoundaryConditionsAndSourceTerms(
312 *_local_to_global_index_map_with_base_nodes, thermal_process_id, media);
315 const int hydraulic_process_id = 1;
316 initializeProcessBoundaryConditionsAndSourceTerms(
317 *_local_to_global_index_map_with_base_nodes, hydraulic_process_id,
321 const int mechanical_process_id = 2;
322 initializeProcessBoundaryConditionsAndSourceTerms(
323 *_local_to_global_index_map, mechanical_process_id, media);
326template <
int DisplacementDim>
330 int const process_id)
332 DBUG(
"SetInitialConditions ThermoHydroMechanicsProcess.");
336 local_assemblers_, getDOFTables(x.size()), x, t, process_id);
339template <
int DisplacementDim>
341 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
342 std::vector<GlobalVector*>
const& x_prev,
int const process_id,
345 DBUG(
"Assemble the equations for ThermoHydroMechanics");
348 t, dt, x, x_prev, process_id, M, K, b);
351template <
int DisplacementDim>
354 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
355 std::vector<GlobalVector*>
const& x_prev,
int const process_id,
359 if (_use_monolithic_scheme)
362 "Assemble the Jacobian of ThermoHydroMechanics for the monolithic "
371 "Assemble the Jacobian equations of heat transport process in "
372 "ThermoHydroMechanics for the staggered scheme.");
374 else if (process_id == 1)
377 "Assemble the Jacobian equations of liquid fluid process in "
378 "ThermoHydroMechanics for the staggered scheme.");
383 "Assemble the Jacobian equations of mechanical process in "
384 "ThermoHydroMechanics for the staggered scheme.");
388 auto const dof_tables = getDOFTables(x.size());
391 assembleWithJacobian(t, dt, x, x_prev, process_id, b, Jac);
393 auto copyRhs = [&](
int const variable_id,
auto& output_vector)
395 if (_use_monolithic_scheme)
397 transformVariableFromGlobalVector(b, variable_id, *dof_tables[0],
399 std::negate<double>());
403 transformVariableFromGlobalVector(b, 0, *dof_tables[process_id],
405 std::negate<double>());
408 if (_use_monolithic_scheme || process_id == 0)
410 copyRhs(0, *_heat_flux);
412 if (_use_monolithic_scheme || process_id == 1)
414 copyRhs(1, *_hydraulic_flow);
416 if (_use_monolithic_scheme || process_id == 2)
418 copyRhs(2, *_nodal_forces);
422template <
int DisplacementDim>
424 std::vector<GlobalVector*>
const& x,
double const t,
double const dt,
425 const int process_id)
427 DBUG(
"PreTimestep ThermoHydroMechanicsProcess.");
429 if (hasMechanicalProcess(process_id))
433 local_assemblers_, *_local_to_global_index_map, *x[process_id], t,
437 updateActiveElements();
441template <
int DisplacementDim>
443 std::vector<GlobalVector*>
const& x,
444 std::vector<GlobalVector*>
const& x_prev,
double const t,
double const dt,
445 const int process_id)
452 DBUG(
"PostTimestep ThermoHydroMechanicsProcess.");
456 local_assemblers_, getActiveElementIDs(), getDOFTables(x.size()), x,
457 x_prev, t, dt, process_id);
460template <
int DisplacementDim>
461std::vector<std::vector<std::string>>
463 std::vector<std::reference_wrapper<MeshLib::Mesh>>
const& meshes)
465 INFO(
"ThermoHydroMechanicsProcess process initializeSubmeshOutput().");
466 std::vector<std::vector<std::string>> per_process_residuum_names;
467 if (_process_variables.size() == 1)
469 per_process_residuum_names = {
470 {
"HeatFlowRate",
"MassFlowRate",
"NodalForces"}};
474 per_process_residuum_names = {
475 {
"HeatFlowRate"}, {
"MassFlowRate"}, {
"NodalForces"}};
479 initializeAssemblyOnSubmeshes(meshes, per_process_residuum_names);
481 return per_process_residuum_names;
484template <
int DisplacementDim>
487 std::vector<GlobalVector*>
const& x,
489 const int process_id)
496 DBUG(
"Compute the secondary variables for ThermoHydroMechanicsProcess.");
500 local_assemblers_, getActiveElementIDs(), getDOFTables(x.size()), t, dt,
501 x, x_prev, process_id);
504template <
int DisplacementDim>
506 DisplacementDim>::getDOFTableForExtrapolatorData()
const
508 const bool manage_storage =
false;
509 return std::make_tuple(_local_to_global_index_map_single_component.get(),
506 DisplacementDim>::getDOFTableForExtrapolatorData()
const {
…}
513template <
int DisplacementDim>
516 const int process_id)
const
518 if (hasMechanicalProcess(process_id))
520 return *_local_to_global_index_map;
524 return *_local_to_global_index_map_with_base_nodes;
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Global vector based on Eigen vector.
bool isAxiallySymmetric() const
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Properties & getProperties()
std::unique_ptr< ProcessLib::AbstractJacobianAssembler > _jacobian_assembler
Handles configuration of several secondary variables from the project file.
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
NumLib::LocalToGlobalIndexMap const & getDOFTable(const int process_id) const override
void initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
Process specific initialization called by initialize().
void preTimestepConcreteProcess(std::vector< GlobalVector * > const &x, double const t, double const dt, const int process_id) override
ThermoHydroMechanicsProcess(std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const ¶meters, unsigned const integration_order, std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > &&process_variables, ThermoHydroMechanicsProcessData< DisplacementDim > &&process_data, SecondaryVariableCollection &&secondary_variables, bool const use_monolithic_scheme)
void initializeBoundaryConditions(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media) override
void computeSecondaryVariableConcrete(double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_prev, const int process_id) override
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 postTimestepConcreteProcess(std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, const double t, const double dt, int const process_id) override
MathLib::MatrixSpecifications getMatrixSpecifications(const int process_id) const override
void setInitialConditionsConcreteProcess(std::vector< GlobalVector * > &x, double const t, int const process_id) override
bool isLinear() const override
std::vector< std::vector< std::string > > initializeAssemblyOnSubmeshes(std::vector< std::reference_wrapper< MeshLib::Mesh > > const &meshes) override
void constructDofTable() override
Eigen::Matrix< double, kelvin_vector_dimensions(DisplacementDim), 1, Eigen::ColMajor > KelvinVectorType
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)
std::vector< Node * > getBaseNodes(std::vector< Element * > const &elements)
@ BY_LOCATION
Ordering data by spatial location.
GlobalSparsityPattern computeSparsityPattern(LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh)
Computes a sparsity pattern for the given inputs.
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)
void createLocalAssemblersHM(std::vector< MeshLib::Element * > const &mesh_elements, NumLib::LocalToGlobalIndexMap const &dof_table, std::vector< std::unique_ptr< LocalAssemblerInterface > > &local_assemblers, ProviderOrOrder const &provider_or_order, ExtraCtorArgs &&... extra_ctor_args)
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)