35namespace HydroMechanics
37template <
int GlobalDim>
41 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
42 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>
const& parameters,
43 unsigned const integration_order,
44 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>&&
48 bool const use_monolithic_scheme)
49 :
Process(std::move(name), mesh, std::move(jacobian_assembler), parameters,
50 integration_order, std::move(process_variables),
51 std::move(secondary_variables), use_monolithic_scheme),
52 _process_data(std::move(process_data))
54 INFO(
"[LIE/HM] looking for fracture elements in the given mesh");
55 std::vector<int> vec_fracture_mat_IDs;
56 std::vector<std::vector<MeshLib::Element*>> vec_vec_fracture_elements;
57 std::vector<std::vector<MeshLib::Element*>>
58 vec_vec_fracture_matrix_elements;
59 std::vector<std::vector<MeshLib::Node*>> vec_vec_fracture_nodes;
60 std::vector<std::pair<std::size_t, std::vector<int>>>
61 vec_branch_nodeID_matIDs;
62 std::vector<std::pair<std::size_t, std::vector<int>>>
63 vec_junction_nodeID_matIDs;
66 vec_vec_fracture_elements, vec_vec_fracture_matrix_elements,
67 vec_vec_fracture_nodes, vec_branch_nodeID_matIDs,
68 vec_junction_nodeID_matIDs);
70 vec_vec_fracture_elements[0].begin(),
71 vec_vec_fracture_elements[0].end());
74 vec_vec_fracture_matrix_elements[0].begin(),
75 vec_vec_fracture_matrix_elements[0].end());
77 vec_vec_fracture_nodes[0].begin(),
78 vec_vec_fracture_nodes[0].end());
98 std::make_unique<MeshLib::ElementStatus>(&mesh);
107 "Could not get minimum/maximum ranges values for the "
108 "MaterialIDs property in the mesh '{:s}'.",
112 std::vector<int> vec_p_inactive_matIDs;
113 for (
int matID = range->first; matID <= range->second; matID++)
115 if (std::find(vec_fracture_mat_IDs.begin(),
116 vec_fracture_mat_IDs.end(),
117 matID) == vec_fracture_mat_IDs.end())
119 vec_p_inactive_matIDs.push_back(matID);
123 std::make_unique<MeshLib::ElementStatus>(&mesh,
124 vec_p_inactive_matIDs);
126 const int monolithic_process_id = 0;
133template <
int GlobalDim>
140 _mesh_subset_all_nodes =
141 std::make_unique<MeshLib::MeshSubset>(_mesh, _mesh.getNodes());
144 _process_data.p_element_status->getActiveElements());
145 _mesh_subset_nodes_p =
146 std::make_unique<MeshLib::MeshSubset>(_mesh, _mesh_nodes_p);
148 _mesh_subset_matrix_nodes =
149 std::make_unique<MeshLib::MeshSubset>(_mesh, _mesh.getNodes());
150 if (!_vec_fracture_nodes.empty())
153 _mesh_subset_fracture_nodes =
154 std::make_unique<MeshLib::MeshSubset>(_mesh, _vec_fracture_nodes);
158 std::vector<MeshLib::MeshSubset> all_mesh_subsets;
159 std::vector<int> vec_n_components;
160 std::vector<std::vector<MeshLib::Element*>
const*> vec_var_elements;
162 vec_n_components.push_back(1);
163 all_mesh_subsets.emplace_back(*_mesh_subset_nodes_p);
164 if (!_process_data.deactivate_matrix_in_flow)
166 vec_var_elements.push_back(&_mesh.getElements());
172 vec_var_elements.push_back(&_vec_fracture_matrix_elements);
175 vec_n_components.push_back(GlobalDim);
176 std::generate_n(std::back_inserter(all_mesh_subsets), GlobalDim,
177 [&]() {
return *_mesh_subset_matrix_nodes; });
178 vec_var_elements.push_back(&_vec_matrix_elements);
179 if (!_vec_fracture_nodes.empty())
182 vec_n_components.push_back(GlobalDim);
183 std::generate_n(std::back_inserter(all_mesh_subsets), GlobalDim,
184 [&]() {
return *_mesh_subset_fracture_nodes; });
185 vec_var_elements.push_back(&_vec_fracture_matrix_elements);
188 INFO(
"[LIE/HM] creating a DoF table");
189 _local_to_global_index_map =
190 std::make_unique<NumLib::LocalToGlobalIndexMap>(
191 std::move(all_mesh_subsets),
196 DBUG(
"created {:d} DoF", _local_to_global_index_map->size());
199template <
int GlobalDim>
203 unsigned const integration_order)
206 INFO(
"[LIE/HM] creating local assemblers");
215 auto add_secondary_variable = [&](std::string
const& name,
216 int const num_components,
217 auto get_ip_values_function)
219 _secondary_variables.addSecondaryVariable(
223 std::move(get_ip_values_function)));
226 add_secondary_variable(
229 &LocalAssemblerInterface::getIntPtSigma);
231 add_secondary_variable(
234 &LocalAssemblerInterface::getIntPtEpsilon);
236 add_secondary_variable(
"velocity", GlobalDim,
237 &LocalAssemblerInterface::getIntPtDarcyVelocity);
239 add_secondary_variable(
"fracture_velocity", GlobalDim,
240 &LocalAssemblerInterface::getIntPtFractureVelocity);
242 add_secondary_variable(
"fracture_stress", GlobalDim,
243 &LocalAssemblerInterface::getIntPtFractureStress);
245 add_secondary_variable(
"fracture_aperture", 1,
246 &LocalAssemblerInterface::getIntPtFractureAperture);
248 add_secondary_variable(
249 "fracture_permeability", 1,
250 &LocalAssemblerInterface::getIntPtFracturePermeability);
261 if (!_vec_fracture_elements.empty())
269 if (e->getDimension() < GlobalDim)
274 std::vector<FractureProperty*> fracture_props(
275 {_process_data.fracture_property.get()});
276 std::vector<JunctionProperty*> junction_props;
277 std::unordered_map<int, int> fracID_to_local({{0, 0}});
279 fracture_props, junction_props, fracID_to_local,
281 (*mesh_prop_levelset)[e->getID()] = levelsets[0];
284 _process_data.element_local_jumps =
289 _process_data.element_fracture_stresses =
294 _process_data.element_fracture_velocities =
304 auto const mesh_prop_matid = materialIDs(mesh);
305 if (!mesh_prop_matid)
307 OGS_FATAL(
"Could not access MaterialIDs property from mesh.");
309 auto const& frac = _process_data.fracture_property;
312 if (e->getDimension() == GlobalDim)
316 if ((*mesh_prop_matid)[e->getID()] != frac->mat_id)
322 (*mesh_prop_b)[e->getID()] =
324 .getNodalValuesOnElement(*e, 0)
327 _process_data.mesh_prop_b = mesh_prop_b;
330 const_cast<MeshLib::Mesh&
>(mesh),
"fracture_permeability_avg",
333 _process_data.mesh_prop_k_f = mesh_prop_k_f;
335 auto mesh_prop_fracture_shear_failure =
340 _process_data.mesh_prop_fracture_shear_failure =
341 mesh_prop_fracture_shear_failure;
347 _process_data.mesh_prop_nodal_p = mesh_prop_nodal_p;
349 _process_data.mesh_prop_nodal_forces =
353 assert(_process_data.mesh_prop_nodal_forces->size() ==
356 _process_data.mesh_prop_nodal_forces_jump =
360 assert(_process_data.mesh_prop_nodal_forces_jump->size() ==
363 _process_data.mesh_prop_hydraulic_flow =
367 assert(_process_data.mesh_prop_hydraulic_flow->size() ==
372template <
int GlobalDim>
374 std::vector<GlobalVector*>
const& x,
375 std::vector<GlobalVector*>
const& x_prev,
const double t,
double const dt,
376 int const process_id)
380 DBUG(
"PostTimestep HydroMechanicsProcess.");
384 _local_assemblers, getActiveElementIDs(), getDOFTables(x.size()), x,
385 x_prev, t, dt, process_id);
388 DBUG(
"Compute the secondary variables for HydroMechanicsProcess.");
390 const auto& dof_table = getDOFTable(process_id);
396 int g_variable_id = 0;
398 const int monolithic_process_id = 0;
399 auto const& pvs = getProcessVariables(monolithic_process_id);
401 std::find_if(pvs.begin(), pvs.end(),
403 { return pv.getName() ==
"displacement_jump1"; });
407 "Didn't find expected 'displacement_jump1' process variable.");
409 g_variable_id =
static_cast<int>(std::distance(pvs.begin(), it));
414 const int monolithic_process_id = 0;
416 this->getProcessVariables(monolithic_process_id)[g_variable_id];
420 for (
int component_id = 0; component_id < num_comp; ++component_id)
422 auto const& mesh_subset =
423 dof_table.getMeshSubset(g_variable_id, component_id);
424 auto const mesh_id = mesh_subset.getMeshID();
425 for (
auto const* node : mesh_subset.getNodes())
430 auto const global_index =
431 dof_table.getGlobalIndex(l, g_variable_id, component_id);
432 mesh_prop_g[node->getID() * num_comp + component_id] =
433 (*x[process_id])[global_index];
438template <
int GlobalDim>
444template <
int GlobalDim>
446 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
447 std::vector<GlobalVector*>
const& x_prev,
int const process_id,
450 DBUG(
"Assemble HydroMechanicsProcess.");
452 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
453 _local_to_global_index_map.get()};
457 dof_table, t, dt, x, x_prev, process_id, &M, &K, &b);
460template <
int GlobalDim>
462 const double t,
double const dt, std::vector<GlobalVector*>
const& x,
463 std::vector<GlobalVector*>
const& x_prev,
int const process_id,
466 DBUG(
"AssembleWithJacobian HydroMechanicsProcess.");
469 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
470 _local_to_global_index_map.get()};
473 _local_assemblers, getActiveElementIDs(), dof_table, t, dt, x, x_prev,
474 process_id, &b, &Jac);
476 auto copyRhs = [&](
int const variable_id,
auto& output_vector)
478 transformVariableFromGlobalVector(b, variable_id,
479 *_local_to_global_index_map,
480 output_vector, std::negate<double>());
482 copyRhs(0, *_process_data.mesh_prop_hydraulic_flow);
483 copyRhs(1, *_process_data.mesh_prop_nodal_forces);
484 copyRhs(2, *_process_data.mesh_prop_nodal_forces_jump);
487template <
int GlobalDim>
489 std::vector<GlobalVector*>
const& x,
double const t,
double const dt,
490 int const process_id)
492 DBUG(
"PreTimestep HydroMechanicsProcess.");
496 getActiveElementIDs(), *_local_to_global_index_map, *x[process_id], t,
Definition of the ElementStatus class.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the class Properties that implements a container of properties.
Definition of the Mesh class.
Global vector based on Eigen vector.
const double * data() const
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).
const std::string getName() const
Get name of the mesh.
std::size_t getNumberOfNodes() const
Get the number of nodes.
std::size_t getNumberOfElements() const
Get the number of elements.
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
void preTimestepConcreteProcess(std::vector< GlobalVector * > const &x, double const t, double const dt, int const process_id) override
std::vector< MeshLib::Node * > _vec_fracture_nodes
std::vector< MeshLib::Element * > _vec_matrix_elements
bool isLinear() const override
std::vector< MeshLib::Element * > _vec_fracture_matrix_elements
std::vector< MeshLib::Element * > _vec_fracture_elements
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< GlobalDim > &&process_data, SecondaryVariableCollection &&secondary_variables, bool const use_monolithic_scheme)
HydroMechanicsProcessData< GlobalDim > _process_data
void initializeConcreteProcess(NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
Process specific initialization called by initialize().
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, double const t, double const dt, int const process_id) override
void constructDofTable() override
virtual void postTimestep(std::size_t const mesh_item_id, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, double const t, double const dt, int const process_id)
virtual void preTimestep(std::size_t const mesh_item_id, NumLib::LocalToGlobalIndexMap const &dof_table, GlobalVector const &x, double const t, double const delta_t)
ParameterLib::Parameter< double > const & getInitialCondition() const
std::string const & getName() const
int getNumberOfGlobalComponents() const
Returns the number of components of the process variable.
std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > const & getProcessVariables() const
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
void setLocalAccessibleVector(PETScVector const &x)
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)
MathLib::Point3d getCenterOfGravity(Element const &element)
Calculates the center of gravity for the mesh element.
@ BY_COMPONENT
Ordering data by component type.
void createLocalAssemblers(std::vector< MeshLib::Element * > const &mesh_elements, NumLib::LocalToGlobalIndexMap const &dof_table, std::vector< std::unique_ptr< LocalAssemblerInterface > > &local_assemblers, NumLib::IntegrationOrder const integration_order, ExtraCtorArgs &&... extra_ctor_args)
void setFractureProperty(int const dim, MeshLib::Element const &e, FractureProperty &frac_prop)
void getFractureMatrixDataInMesh(MeshLib::Mesh const &mesh, std::vector< MeshLib::Element * > &vec_matrix_elements, std::vector< int > &vec_fracture_mat_IDs, std::vector< std::vector< MeshLib::Element * > > &vec_fracture_elements, std::vector< std::vector< MeshLib::Element * > > &vec_fracture_matrix_elements, std::vector< std::vector< MeshLib::Node * > > &vec_fracture_nodes, std::vector< std::pair< std::size_t, std::vector< int > > > &vec_branch_nodeID_matIDs, std::vector< std::pair< std::size_t, std::vector< int > > > &vec_junction_nodeID_matIDs)
std::vector< double > uGlobalEnrichments(std::vector< FractureProperty * > const &frac_props, std::vector< JunctionProperty * > const &junction_props, std::unordered_map< int, int > const &fracID_to_local, Eigen::Vector3d const &x)
SecondaryVariableFunctions makeExtrapolator(const unsigned num_components, NumLib::Extrapolator &extrapolator, LocalAssemblerCollection const &local_assemblers, typename NumLib::ExtrapolatableLocalAssemblerCollection< LocalAssemblerCollection >::IntegrationPointValuesMethod integration_point_values_method)
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 executeMemberDereferenced(Object &object, Method method, Container const &container, Args &&... args)