28namespace RichardsMechanics
30template <
int DisplacementDim>
34 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
35 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>
const& parameters,
36 unsigned const integration_order,
37 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
41 bool const use_monolithic_scheme)
42 :
Process(std::move(name), mesh, std::move(jacobian_assembler), parameters,
43 integration_order, std::move(process_variables),
44 std::move(secondary_variables), use_monolithic_scheme),
45 _process_data(std::move(process_data))
59template <
int DisplacementDim>
65template <
int DisplacementDim>
68 const int process_id)
const
72 if (_use_monolithic_scheme || process_id == 1)
74 auto const& l = *_local_to_global_index_map;
75 return {l.dofSizeWithoutGhosts(), l.dofSizeWithoutGhosts(),
76 &l.getGhostIndices(), &this->_sparsity_pattern};
80 auto const& l = *_local_to_global_index_map_with_base_nodes;
81 return {l.dofSizeWithoutGhosts(), l.dofSizeWithoutGhosts(),
82 &l.getGhostIndices(), &_sparsity_pattern_with_linear_element};
85template <
int DisplacementDim>
89 _mesh_subset_all_nodes =
90 std::make_unique<MeshLib::MeshSubset>(_mesh, _mesh.getNodes());
93 _mesh_subset_base_nodes =
94 std::make_unique<MeshLib::MeshSubset>(_mesh, _base_nodes);
98 std::vector<MeshLib::MeshSubset> all_mesh_subsets_single_component{
99 *_mesh_subset_all_nodes};
100 _local_to_global_index_map_single_component =
101 std::make_unique<NumLib::LocalToGlobalIndexMap>(
102 std::move(all_mesh_subsets_single_component),
106 if (_use_monolithic_scheme)
109 std::vector<MeshLib::MeshSubset> all_mesh_subsets{
110 *_mesh_subset_base_nodes};
113 const int monolithic_process_id = 0;
114 std::generate_n(std::back_inserter(all_mesh_subsets),
115 getProcessVariables(monolithic_process_id)[1]
117 .getNumberOfGlobalComponents(),
118 [&]() {
return *_mesh_subset_all_nodes; });
120 std::vector<int>
const vec_n_components{1, DisplacementDim};
121 _local_to_global_index_map =
122 std::make_unique<NumLib::LocalToGlobalIndexMap>(
123 std::move(all_mesh_subsets), vec_n_components,
125 assert(_local_to_global_index_map);
130 const int process_id = 1;
131 std::vector<MeshLib::MeshSubset> all_mesh_subsets;
132 std::generate_n(std::back_inserter(all_mesh_subsets),
133 getProcessVariables(process_id)[0]
135 .getNumberOfGlobalComponents(),
136 [&]() {
return *_mesh_subset_all_nodes; });
138 std::vector<int>
const vec_n_components{DisplacementDim};
139 _local_to_global_index_map =
140 std::make_unique<NumLib::LocalToGlobalIndexMap>(
141 std::move(all_mesh_subsets), vec_n_components,
146 std::vector<MeshLib::MeshSubset> all_mesh_subsets_base_nodes{
147 *_mesh_subset_base_nodes};
148 _local_to_global_index_map_with_base_nodes =
149 std::make_unique<NumLib::LocalToGlobalIndexMap>(
150 std::move(all_mesh_subsets_base_nodes),
155 *_local_to_global_index_map_with_base_nodes, _mesh);
157 assert(_local_to_global_index_map);
158 assert(_local_to_global_index_map_with_base_nodes);
162template <
int DisplacementDim>
166 unsigned const integration_order)
175 LocalAssemblerIF::getReflectionDataForOutput(), _secondary_variables,
176 getExtrapolator(), _local_assemblers);
178 auto add_secondary_variable = [&](std::string
const& name,
179 int const num_components,
180 auto get_ip_values_function)
182 _secondary_variables.addSecondaryVariable(
186 std::move(get_ip_values_function)));
194 add_secondary_variable);
198 _process_data.solid_materials, _local_assemblers,
199 _integration_point_writer, integration_order);
213 DisplacementDim>::RowsAtCompileTime);
215 _process_data.pressure_interpolated =
226 *_local_to_global_index_map);
229template <
int DisplacementDim>
231 std::map<
int, std::shared_ptr<MaterialPropertyLib::Medium>>
const& media)
233 if (_use_monolithic_scheme)
235 const int monolithic_process_id = 0;
236 initializeProcessBoundaryConditionsAndSourceTerms(
237 *_local_to_global_index_map, monolithic_process_id, media);
243 const int hydraulic_process_id = 0;
244 initializeProcessBoundaryConditionsAndSourceTerms(
245 *_local_to_global_index_map_with_base_nodes, hydraulic_process_id,
249 const int mechanical_process_id = 1;
250 initializeProcessBoundaryConditionsAndSourceTerms(
251 *_local_to_global_index_map, mechanical_process_id, media);
254template <
int DisplacementDim>
258 int const process_id)
265 DBUG(
"SetInitialConditions RichardsMechanicsProcess.");
268 &LocalAssemblerIF::setInitialConditions, _local_assemblers,
269 getActiveElementIDs(), getDOFTables(x.size()), x, t, process_id);
272template <
int DisplacementDim>
274 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
275 std::vector<GlobalVector*>
const& x_prev,
int const process_id,
278 DBUG(
"Assemble the equations for RichardsMechanics");
280 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
281 _local_to_global_index_map.get()};
286 getActiveElementIDs(), dof_table, t, dt, x, x_prev, process_id, &M, &K,
290template <
int DisplacementDim>
293 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
294 std::vector<GlobalVector*>
const& x_prev,
int const process_id,
298 if (_use_monolithic_scheme)
301 "Assemble the Jacobian of RichardsMechanics for the monolithic"
310 "Assemble the Jacobian equations of liquid fluid process in "
311 "RichardsMechanics for the staggered scheme.");
316 "Assemble the Jacobian equations of mechanical process in "
317 "RichardsMechanics for the staggered scheme.");
321 auto const dof_tables = getDOFTables(x.size());
324 _local_assemblers, getActiveElementIDs(), dof_tables, t, dt, x, x_prev,
325 process_id, &b, &Jac);
327 auto copyRhs = [&](
int const variable_id,
auto& output_vector)
329 if (_use_monolithic_scheme)
331 transformVariableFromGlobalVector(b, variable_id, *dof_tables[0],
333 std::negate<double>());
337 transformVariableFromGlobalVector(b, 0, *dof_tables[process_id],
339 std::negate<double>());
342 if (_use_monolithic_scheme || process_id == 0)
344 copyRhs(0, *_hydraulic_flow);
346 if (_use_monolithic_scheme || process_id == 1)
348 copyRhs(1, *_nodal_forces);
352template <
int DisplacementDim>
354 std::vector<GlobalVector*>
const& x,
355 std::vector<GlobalVector*>
const& x_prev,
double const t,
double const dt,
356 const int process_id)
358 if (hasMechanicalProcess(process_id))
360 DBUG(
"PostTimestep RichardsMechanicsProcess.");
363 &LocalAssemblerIF::postTimestep, _local_assemblers,
364 getActiveElementIDs(), getDOFTables(x.size()), x, x_prev, t, dt,
369template <
int DisplacementDim>
372 std::vector<GlobalVector*>
const& x,
374 int const process_id)
381 DBUG(
"Compute the secondary variables for RichardsMechanicsProcess.");
384 &LocalAssemblerIF::computeSecondaryVariable, _local_assemblers,
385 getActiveElementIDs(), getDOFTables(x.size()), t, dt, x, x_prev,
389template <
int DisplacementDim>
391 DisplacementDim>::getDOFTableForExtrapolatorData()
const
393 const bool manage_storage =
false;
394 return std::make_tuple(_local_to_global_index_map_single_component.get(),
398template <
int DisplacementDim>
401 const int process_id)
const
403 if (hasMechanicalProcess(process_id))
405 return *_local_to_global_index_map;
409 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.
Properties & getProperties()
std::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > _integration_point_writer
std::vector< std::unique_ptr< LocalAssemblerIF > > _local_assemblers
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
MathLib::MatrixSpecifications getMatrixSpecifications(const int process_id) const override
void constructDofTable() override
void initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
Process specific initialization called by initialize().
void computeSecondaryVariableConcrete(double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_prev, int const process_id) override
MeshLib::PropertyVector< double > * _hydraulic_flow
RichardsMechanicsProcess(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, RichardsMechanicsProcessData< DisplacementDim > &&process_data, SecondaryVariableCollection &&secondary_variables, bool const use_monolithic_scheme)
bool isLinear() const override
void setInitialConditionsConcreteProcess(std::vector< GlobalVector * > &x, double const t, 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
MeshLib::PropertyVector< double > * _nodal_forces
void initializeBoundaryConditions(std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media) override
void postTimestepConcreteProcess(std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, double const t, double const dt, const int process_id) override
NumLib::LocalToGlobalIndexMap const & getDOFTable(const int process_id) const override
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)
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.
void addReflectedSecondaryVariables(ReflData const &reflection_data, SecondaryVariableCollection &secondary_variables, NumLib::Extrapolator &extrapolator, std::vector< std::unique_ptr< LocAsmIF > > const &local_assemblers)
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)
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)
static auto getReflectionDataForOutput()