27namespace HydroMechanics
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))
48 _integration_point_writer.emplace_back(
49 std::make_unique<MeshLib::IntegrationPointWriter>(
51 static_cast<int>(mesh.getDimension() == 2 ? 4 : 6) ,
52 integration_order, local_assemblers_, &LocalAssemblerIF::getSigma));
54 _integration_point_writer.emplace_back(
55 std::make_unique<MeshLib::IntegrationPointWriter>(
57 static_cast<int>(mesh.getDimension() == 2 ? 4 : 6) ,
58 integration_order, local_assemblers_,
59 &LocalAssemblerIF::getEpsilon));
61 if (!_use_monolithic_scheme)
63 _integration_point_writer.emplace_back(
64 std::make_unique<MeshLib::IntegrationPointWriter>(
65 "strain_rate_variable_ip", 1, integration_order,
66 local_assemblers_, &LocalAssemblerIF::getStrainRateVariable));
70template <
int DisplacementDim>
76template <
int DisplacementDim>
79 const int process_id)
const
83 if (process_id == process_data_.mechanics_related_process_id)
85 auto const& l = *_local_to_global_index_map;
86 return {l.dofSizeWithoutGhosts(), l.dofSizeWithoutGhosts(),
87 &l.getGhostIndices(), &this->_sparsity_pattern};
91 auto const& l = *local_to_global_index_map_with_base_nodes_;
92 return {l.dofSizeWithoutGhosts(), l.dofSizeWithoutGhosts(),
93 &l.getGhostIndices(), &sparsity_pattern_with_linear_element_};
96template <
int DisplacementDim>
100 _mesh_subset_all_nodes = std::make_unique<MeshLib::MeshSubset>(
101 _mesh, _mesh.getNodes(), process_data_.use_taylor_hood_elements);
105 mesh_subset_base_nodes_ = std::make_unique<MeshLib::MeshSubset>(
106 _mesh, base_nodes_, process_data_.use_taylor_hood_elements);
110 std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{
111 *_mesh_subset_all_nodes};
112 local_to_global_index_map_single_component_ =
113 std::make_unique<NumLib::LocalToGlobalIndexMap>(
114 std::move(all_mesh_subsets_single_component),
118 if (process_data_.isMonolithicSchemeUsed())
121 std::vector<MeshLib::MeshSubset> all_mesh_subsets{
122 *mesh_subset_base_nodes_};
125 const int monolithic_process_id = 0;
126 std::generate_n(std::back_inserter(all_mesh_subsets),
127 getProcessVariables(monolithic_process_id)[1]
129 .getNumberOfGlobalComponents(),
130 [&]() {
return *_mesh_subset_all_nodes; });
132 std::vector<int>
const vec_n_components{1, DisplacementDim};
133 _local_to_global_index_map =
134 std::make_unique<NumLib::LocalToGlobalIndexMap>(
135 std::move(all_mesh_subsets), vec_n_components,
137 assert(_local_to_global_index_map);
142 const int process_id = 1;
143 std::vector<MeshLib::MeshSubset> all_mesh_subsets;
144 std::generate_n(std::back_inserter(all_mesh_subsets),
145 getProcessVariables(process_id)[0]
147 .getNumberOfGlobalComponents(),
148 [&]() {
return *_mesh_subset_all_nodes; });
150 std::vector<int>
const vec_n_components{DisplacementDim};
151 _local_to_global_index_map =
152 std::make_unique<NumLib::LocalToGlobalIndexMap>(
153 std::move(all_mesh_subsets), vec_n_components,
158 std::vector<MeshLib::MeshSubset> all_mesh_subsets_base_nodes{
159 *mesh_subset_base_nodes_};
160 local_to_global_index_map_with_base_nodes_ =
161 std::make_unique<NumLib::LocalToGlobalIndexMap>(
162 std::move(all_mesh_subsets_base_nodes),
167 *local_to_global_index_map_with_base_nodes_, _mesh);
169 assert(_local_to_global_index_map);
170 assert(local_to_global_index_map_with_base_nodes_);
174template <
int DisplacementDim>
178 unsigned const integration_order)
186 auto add_secondary_variable = [&](std::string
const& name,
187 int const num_components,
188 auto get_ip_values_function)
190 _secondary_variables.addSecondaryVariable(
194 std::move(get_ip_values_function)));
197 add_secondary_variable(
"sigma",
199 DisplacementDim>::RowsAtCompileTime,
200 &LocalAssemblerIF::getIntPtSigma);
202 add_secondary_variable(
"epsilon",
204 DisplacementDim>::RowsAtCompileTime,
205 &LocalAssemblerIF::getIntPtEpsilon);
207 add_secondary_variable(
"velocity", DisplacementDim,
208 &LocalAssemblerIF::getIntPtDarcyVelocity);
215 add_secondary_variable);
217 process_data_.pressure_interpolated =
222 process_data_.principal_stress_vector[0] =
224 const_cast<MeshLib::Mesh&
>(mesh),
"principal_stress_vector_1",
227 process_data_.principal_stress_vector[1] =
229 const_cast<MeshLib::Mesh&
>(mesh),
"principal_stress_vector_2",
232 process_data_.principal_stress_vector[2] =
234 const_cast<MeshLib::Mesh&
>(mesh),
"principal_stress_vector_3",
237 process_data_.principal_stress_values =
253 *_local_to_global_index_map);
256template <
int DisplacementDim>
258 std::map<
int, std::shared_ptr<MaterialPropertyLib::Medium>>
const& media)
260 if (process_data_.isMonolithicSchemeUsed())
262 const int process_id_of_hydromechanics = 0;
263 initializeProcessBoundaryConditionsAndSourceTerms(
264 *_local_to_global_index_map, process_id_of_hydromechanics, media);
270 const int hydraulic_process_id = 0;
271 initializeProcessBoundaryConditionsAndSourceTerms(
272 *local_to_global_index_map_with_base_nodes_, hydraulic_process_id,
276 const int mechanical_process_id = 1;
277 initializeProcessBoundaryConditionsAndSourceTerms(
278 *_local_to_global_index_map, mechanical_process_id, media);
281template <
int DisplacementDim>
283 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
284 std::vector<GlobalVector*>
const& x_prev,
int const process_id,
287 DBUG(
"Assemble the equations for HydroMechanics");
293 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
294 _local_to_global_index_map.get()};
298 getActiveElementIDs(), dof_table, t, dt, x, x_prev, process_id, &M, &K,
302template <
int DisplacementDim>
305 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
306 std::vector<GlobalVector*>
const& x_prev,
int const process_id,
310 bool const use_monolithic_scheme = process_data_.isMonolithicSchemeUsed();
311 if (use_monolithic_scheme)
314 "Assemble the Jacobian of HydroMechanics for the monolithic "
320 if (process_id == process_data_.hydraulic_process_id)
323 "Assemble the Jacobian equations of liquid fluid process in "
324 "HydroMechanics for the staggered scheme.");
329 "Assemble the Jacobian equations of mechanical process in "
330 "HydroMechanics for the staggered scheme.");
335 t, dt, x, x_prev, process_id, b, Jac);
338template <
int DisplacementDim>
340 std::vector<GlobalVector*>
const& x,
double const t,
double const dt,
341 const int process_id)
343 DBUG(
"PreTimestep HydroMechanicsProcess.");
345 if (hasMechanicalProcess(process_id))
348 &LocalAssemblerIF::preTimestep, local_assemblers_,
349 getActiveElementIDs(), *_local_to_global_index_map, *x[process_id],
354template <
int DisplacementDim>
355std::vector<std::vector<std::string>>
357 std::vector<std::reference_wrapper<MeshLib::Mesh>>
const& meshes)
359 INFO(
"HydroMechanicsProcess initializeSubmeshOutput().");
360 std::vector<std::vector<std::string>> per_process_residuum_names;
361 if (_process_variables.size() == 1)
363 per_process_residuum_names = {{
"MassFlowRate",
"NodalForces"}};
367 per_process_residuum_names = {{
"MassFlowRate"}, {
"NodalForces"}};
371 initializeAssemblyOnSubmeshes(meshes, per_process_residuum_names);
373 return per_process_residuum_names;
376template <
int DisplacementDim>
378 std::vector<GlobalVector*>
const& x,
379 std::vector<GlobalVector*>
const& x_prev,
double const t,
double const dt,
380 const int process_id)
382 if (process_id != process_data_.hydraulic_process_id)
387 DBUG(
"PostTimestep HydroMechanicsProcess.");
390 &LocalAssemblerIF::postTimestep, local_assemblers_,
391 getActiveElementIDs(), getDOFTables(x.size()), x, x_prev, t, dt,
395template <
int DisplacementDim>
397 std::vector<GlobalVector*>
const& x,
398 std::vector<GlobalVector*>
const& x_prev,
const double t,
double const dt,
399 const int process_id)
401 DBUG(
"PostNonLinearSolver HydroMechanicsProcess.");
405 &LocalAssemblerIF::postNonLinearSolver, local_assemblers_,
406 getActiveElementIDs(), getDOFTables(x.size()), x, x_prev, t, dt,
410template <
int DisplacementDim>
414 int const process_id)
417 if (process_id != process_data_.mechanics_related_process_id)
422 DBUG(
"Set initial conditions of HydroMechanicsProcess.");
425 &LocalAssemblerIF::setInitialConditions, local_assemblers_,
426 getActiveElementIDs(), getDOFTables(x.size()), x, t, process_id);
429template <
int DisplacementDim>
431 double const t,
double const dt, std::vector<GlobalVector*>
const& x,
434 if (process_id != process_data_.hydraulic_process_id)
439 DBUG(
"Compute the secondary variables for HydroMechanicsProcess.");
442 &LocalAssemblerIF::computeSecondaryVariable, local_assemblers_,
443 getActiveElementIDs(), getDOFTables(x.size()), t, dt, x, x_prev,
447template <
int DisplacementDim>
448std::tuple<NumLib::LocalToGlobalIndexMap*, bool>
451 const bool manage_storage =
false;
452 return std::make_tuple(local_to_global_index_map_single_component_.get(),
456template <
int DisplacementDim>
460 if (hasMechanicalProcess(process_id))
462 return *_local_to_global_index_map;
466 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.
Properties & getProperties()
void assembleConcreteProcess(const double t, double const, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b) override
std::vector< std::vector< std::string > > initializeAssemblyOnSubmeshes(std::vector< std::reference_wrapper< MeshLib::Mesh > > const &meshes) override
HydroMechanicsProcess(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, HydroMechanicsProcessData< DisplacementDim > &&process_data, SecondaryVariableCollection &&secondary_variables, bool const use_monolithic_scheme)
void computeSecondaryVariableConcrete(double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_prev, const int process_id) override
void preTimestepConcreteProcess(std::vector< GlobalVector * > const &x, double const t, double const dt, const int process_id) override
void initializeBoundaryConditions(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media) override
NumLib::LocalToGlobalIndexMap const & getDOFTable(const int process_id) const override
void assembleWithJacobianConcreteProcess(const double t, double const, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalVector &b, GlobalMatrix &Jac) override
void constructDofTable() override
bool isLinear() const override
void postNonLinearSolverConcreteProcess(std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, const double t, double const dt, int const process_id) override
void setInitialConditionsConcreteProcess(std::vector< GlobalVector * > &x, double const t, int const process_id) override
MathLib::MatrixSpecifications getMatrixSpecifications(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().
std::tuple< NumLib::LocalToGlobalIndexMap *, bool > getDOFTableForExtrapolatorData() const 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
std::unique_ptr< ProcessLib::AbstractJacobianAssembler > _jacobian_assembler
Handles configuration of several secondary variables from the project file.
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)
constexpr int kelvin_vector_dimensions(int const displacement_dim)
Kelvin vector dimensions for given displacement dimension.
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)