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),
44 _process_data(std::move(process_data))
56 std::make_unique<MeshLib::IntegrationPointWriter>(
63 std::make_unique<MeshLib::IntegrationPointWriter>(
70 std::make_unique<MeshLib::IntegrationPointWriter>(
77template <
int DisplacementDim>
83template <
int DisplacementDim>
86 const int process_id)
const
90 if (_use_monolithic_scheme || process_id == 2)
92 auto const& l = *_local_to_global_index_map;
93 return {l.dofSizeWithoutGhosts(), l.dofSizeWithoutGhosts(),
94 &l.getGhostIndices(), &this->_sparsity_pattern};
98 auto const& l = *_local_to_global_index_map_with_base_nodes;
99 return {l.dofSizeWithoutGhosts(), l.dofSizeWithoutGhosts(),
100 &l.getGhostIndices(), &_sparsity_pattern_with_linear_element};
103template <
int DisplacementDim>
107 _mesh_subset_all_nodes =
108 std::make_unique<MeshLib::MeshSubset>(_mesh, _mesh.getNodes());
111 _mesh_subset_base_nodes =
112 std::make_unique<MeshLib::MeshSubset>(_mesh, _base_nodes);
116 std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{
117 *_mesh_subset_all_nodes};
118 _local_to_global_index_map_single_component =
119 std::make_unique<NumLib::LocalToGlobalIndexMap>(
120 std::move(all_mesh_subsets_single_component),
124 if (_use_monolithic_scheme)
127 std::vector<MeshLib::MeshSubset> all_mesh_subsets{
128 *_mesh_subset_base_nodes};
131 all_mesh_subsets.push_back(*_mesh_subset_base_nodes);
134 const int monolithic_process_id = 0;
135 std::generate_n(std::back_inserter(all_mesh_subsets),
136 getProcessVariables(monolithic_process_id)[2]
138 .getNumberOfGlobalComponents(),
139 [&]() {
return *_mesh_subset_all_nodes; });
141 std::vector<int>
const vec_n_components{1, 1, DisplacementDim};
142 _local_to_global_index_map =
143 std::make_unique<NumLib::LocalToGlobalIndexMap>(
144 std::move(all_mesh_subsets), vec_n_components,
146 assert(_local_to_global_index_map);
151 const int process_id = 2;
152 std::vector<MeshLib::MeshSubset> all_mesh_subsets;
153 std::generate_n(std::back_inserter(all_mesh_subsets),
154 getProcessVariables(process_id)[0]
156 .getNumberOfGlobalComponents(),
157 [&]() {
return *_mesh_subset_all_nodes; });
159 std::vector<int>
const vec_n_components{DisplacementDim};
160 _local_to_global_index_map =
161 std::make_unique<NumLib::LocalToGlobalIndexMap>(
162 std::move(all_mesh_subsets), vec_n_components,
167 std::vector<MeshLib::MeshSubset> all_mesh_subsets_base_nodes{
168 *_mesh_subset_base_nodes};
169 _local_to_global_index_map_with_base_nodes =
170 std::make_unique<NumLib::LocalToGlobalIndexMap>(
171 std::move(all_mesh_subsets_base_nodes),
176 *_local_to_global_index_map_with_base_nodes, _mesh);
178 assert(_local_to_global_index_map);
179 assert(_local_to_global_index_map_with_base_nodes);
183template <
int DisplacementDim>
187 unsigned const integration_order)
195 auto add_secondary_variable = [&](std::string
const& name,
196 int const num_components,
197 auto get_ip_values_function)
199 _secondary_variables.addSecondaryVariable(
203 std::move(get_ip_values_function)));
206 add_secondary_variable(
209 DisplacementDim>::RowsAtCompileTime,
212 add_secondary_variable(
215 DisplacementDim>::RowsAtCompileTime,
218 add_secondary_variable(
221 DisplacementDim>::RowsAtCompileTime,
224 add_secondary_variable(
227 DisplacementDim>::RowsAtCompileTime,
230 add_secondary_variable(
231 "ice_volume_fraction", 1,
234 add_secondary_variable(
238 add_secondary_variable(
242 add_secondary_variable(
246 _process_data.element_fluid_density =
259 DisplacementDim>::RowsAtCompileTime);
261 _process_data.pressure_interpolated =
266 _process_data.temperature_interpolated =
268 const_cast<MeshLib::Mesh&
>(mesh),
"temperature_interpolated",
276 add_secondary_variable);
280 _process_data.solid_materials, _local_assemblers,
281 _integration_point_writer, integration_order);
289 _local_assemblers, *_local_to_global_index_map);
292template <
int DisplacementDim>
294 std::map<
int, std::shared_ptr<MaterialPropertyLib::Medium>>
const& media)
296 if (_use_monolithic_scheme)
298 const int process_id_of_thermohydromechancs = 0;
299 initializeProcessBoundaryConditionsAndSourceTerms(
300 *_local_to_global_index_map, process_id_of_thermohydromechancs,
307 const int thermal_process_id = 0;
308 initializeProcessBoundaryConditionsAndSourceTerms(
309 *_local_to_global_index_map_with_base_nodes, thermal_process_id, media);
312 const int hydraulic_process_id = 1;
313 initializeProcessBoundaryConditionsAndSourceTerms(
314 *_local_to_global_index_map_with_base_nodes, hydraulic_process_id,
318 const int mechanical_process_id = 2;
319 initializeProcessBoundaryConditionsAndSourceTerms(
320 *_local_to_global_index_map, mechanical_process_id, media);
323template <
int DisplacementDim>
327 int const process_id)
329 DBUG(
"SetInitialConditions ThermoHydroMechanicsProcess.");
333 _local_assemblers, getDOFTables(x.size()), x, t, process_id);
336template <
int DisplacementDim>
338 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
339 std::vector<GlobalVector*>
const& x_prev,
int const process_id,
342 DBUG(
"Assemble the equations for ThermoHydroMechanics");
344 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
345 _local_to_global_index_map.get()};
349 getActiveElementIDs(), dof_table, t, dt, x, x_prev, process_id, &M, &K,
353template <
int DisplacementDim>
356 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
357 std::vector<GlobalVector*>
const& x_prev,
int const process_id,
361 if (_use_monolithic_scheme)
364 "Assemble the Jacobian of ThermoHydroMechanics for the monolithic "
373 "Assemble the Jacobian equations of heat transport process in "
374 "ThermoHydroMechanics for the staggered scheme.");
376 else if (process_id == 1)
379 "Assemble the Jacobian equations of liquid fluid process in "
380 "ThermoHydroMechanics for the staggered scheme.");
385 "Assemble the Jacobian equations of mechanical process in "
386 "ThermoHydroMechanics for the staggered scheme.");
390 auto const dof_tables = getDOFTables(x.size());
394 _local_assemblers, getActiveElementIDs(), dof_tables, t, dt, x, x_prev,
395 process_id, &b, &Jac);
397 auto copyRhs = [&](
int const variable_id,
auto& output_vector)
399 if (_use_monolithic_scheme)
401 transformVariableFromGlobalVector(b, variable_id, *dof_tables[0],
403 std::negate<double>());
407 transformVariableFromGlobalVector(b, 0, *dof_tables[process_id],
409 std::negate<double>());
412 if (_use_monolithic_scheme || process_id == 0)
414 copyRhs(0, *_heat_flux);
416 if (_use_monolithic_scheme || process_id == 1)
418 copyRhs(1, *_hydraulic_flow);
420 if (_use_monolithic_scheme || process_id == 2)
422 copyRhs(2, *_nodal_forces);
426template <
int DisplacementDim>
428 std::vector<GlobalVector*>
const& x,
double const t,
double const dt,
429 const int process_id)
431 DBUG(
"PreTimestep ThermoHydroMechanicsProcess.");
433 if (hasMechanicalProcess(process_id))
437 _local_assemblers, *_local_to_global_index_map, *x[process_id], t,
442template <
int DisplacementDim>
444 std::vector<GlobalVector*>
const& x,
445 std::vector<GlobalVector*>
const& x_prev,
double const t,
double const dt,
446 const int process_id)
453 DBUG(
"PostTimestep ThermoHydroMechanicsProcess.");
457 _local_assemblers, getActiveElementIDs(), getDOFTables(x.size()), x,
458 x_prev, t, dt, process_id);
461template <
int DisplacementDim>
464 std::vector<GlobalVector*>
const& x,
466 const int process_id)
473 DBUG(
"Compute the secondary variables for ThermoHydroMechanicsProcess.");
477 _local_assemblers, getActiveElementIDs(), getDOFTables(x.size()), t, dt,
478 x, x_prev, process_id);
481template <
int DisplacementDim>
483 DisplacementDim>::getDOFTableForExtrapolatorData()
const
485 const bool manage_storage =
false;
486 return std::make_tuple(_local_to_global_index_map_single_component.get(),
490template <
int DisplacementDim>
493 const int process_id)
const
495 if (hasMechanicalProcess(process_id))
497 return *_local_to_global_index_map;
501 return *_local_to_global_index_map_with_base_nodes;
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::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > _integration_point_writer
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
MeshLib::PropertyVector< double > * _hydraulic_flow
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
std::vector< std::unique_ptr< LocalAssemblerInterface< DisplacementDim > > > _local_assemblers
MeshLib::PropertyVector< double > * _heat_flux
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
MeshLib::PropertyVector< double > * _nodal_forces
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
void constructDofTable() override
void assemble(std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, double const 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)
void assembleWithJacobian(std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, 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)
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 executeSelectedMemberDereferenced(Object &object, 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)