OGS
DeactivatedSubdomainDirichlet.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
12
13namespace ProcessLib
14{
18 ParameterLib::Parameter<double> const& parameter,
19 bool const set_outer_nodes_dirichlet_values,
20 DeactivatedSubdomainMesh const& subdomain,
21 NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id,
22 int const component_id)
23 : _parameter(parameter),
24 _subdomain(subdomain),
25 _variable_id(variable_id),
26 _component_id(component_id),
27 _time_interval(std::move(time_interval)),
28 _is_active(is_active),
29 _set_outer_nodes_dirichlet_values(set_outer_nodes_dirichlet_values)
30{
31 config(dof_table_bulk);
32}
33
35 NumLib::LocalToGlobalIndexMap const& dof_table_bulk)
36{
39
40 std::vector<MeshLib::Node*> const& bc_nodes = _subdomain.mesh.getNodes();
41 MeshLib::MeshSubset subdomain_mesh_subset(_subdomain.mesh, bc_nodes);
42
43 // Create local DOF table from the BC mesh subset for the given variable
44 // and component id.
46 _variable_id, {_component_id}, std::move(subdomain_mesh_subset));
47}
48
50 const double t, GlobalVector const& x,
52{
53 [[maybe_unused]] auto const& bulk_node_ids =
55 [[maybe_unused]] auto const& bulk_element_ids =
57
58 auto is_inactive_id = [&](std::size_t const bulk_element_id)
59 { return _is_active[bulk_element_id] == 0; };
60
61 auto is_inactive_element = [&](MeshLib::Element const* const e)
62 { return is_inactive_id(bulk_element_ids[e->getID()]); };
63
64 std::vector<std::size_t> inactive_nodes_in_bc_mesh;
65 std::copy_if(begin(_subdomain.inner_nodes), end(_subdomain.inner_nodes),
66 back_inserter(inactive_nodes_in_bc_mesh),
67 [&](std::size_t const n)
68 {
69 const auto& connected_elements =
70 _subdomain.mesh.getElementsConnectedToNode(n);
71
72 return std::all_of(begin(connected_elements),
73 end(connected_elements),
74 is_inactive_element);
75 });
76
78 {
79 std::copy_if(begin(_subdomain.outer_nodes), end(_subdomain.outer_nodes),
80 back_inserter(inactive_nodes_in_bc_mesh),
81 [&](std::size_t const n)
82 {
83 const auto& connected_elements =
84 _subdomain.mesh.getElementsConnectedToNode(n);
85
86 return std::all_of(begin(connected_elements),
87 end(connected_elements),
88 is_inactive_element);
89 });
90 }
91 else
92 {
93 for (std::size_t i = 0; i < _subdomain.outer_nodes.size(); ++i)
94 {
95 auto const& connected_elements = _subdomain.outer_nodes_elements[i];
96 if (std::all_of(begin(connected_elements), end(connected_elements),
97 is_inactive_id))
98 {
99 inactive_nodes_in_bc_mesh.push_back(_subdomain.outer_nodes[i]);
100 }
101 }
102 }
103
104 auto time_interval_contains = [&](double const t)
105 {
106 return _time_interval.getSupportMin() <= t &&
107 t <= _time_interval.getSupportMax();
108 };
109 if (time_interval_contains(t))
110 {
112 _parameter, _subdomain.mesh, inactive_nodes_in_bc_mesh,
114 return;
115 }
116
117 bc_values.ids.clear();
118 bc_values.values.clear();
119}
120} // namespace ProcessLib
MathLib::EigenVector GlobalVector
A subset of nodes on a single mesh.
Definition MeshSubset.h:17
std::unique_ptr< LocalToGlobalIndexMap > deriveBoundaryConstrainedMap(int const variable_id, std::vector< int > const &component_ids, MeshLib::MeshSubset &&new_mesh_subset) const
DeactivatedSubdomainDirichlet(MeshLib::PropertyVector< unsigned char > const &is_active, MathLib::PiecewiseLinearInterpolation time_interval, ParameterLib::Parameter< double > const &parameter, bool const set_outer_nodes_dirichlet_values, DeactivatedSubdomainMesh const &subdomain, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, int const variable_id, int const component_id)
MathLib::PiecewiseLinearInterpolation const _time_interval
void getEssentialBCValues(const double t, GlobalVector const &x, NumLib::IndexValueVector< GlobalIndexType > &bc_values) const override
Writes the values of essential BCs to bc_values.
ParameterLib::Parameter< double > const & _parameter
MeshLib::PropertyVector< unsigned char > const & _is_active
void config(NumLib::LocalToGlobalIndexMap const &dof_table_bulk)
std::unique_ptr< NumLib::LocalToGlobalIndexMap const > _dof_table_boundary
PropertyVector< std::size_t > const * bulkElementIDs(Mesh const &mesh)
Definition Mesh.cpp:290
PropertyVector< std::size_t > const * bulkNodeIDs(Mesh const &mesh)
Definition Mesh.cpp:282
void getEssentialBCValuesLocal(ParameterLib::Parameter< double > const &parameter, MeshLib::Mesh const &bc_mesh, std::vector< std::size_t > const &nodes_in_bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_boundary, int const variable_id, int const component_id, const double t, GlobalVector const &, NumLib::IndexValueVector< GlobalIndexType > &bc_values)
void checkParametersOfDirichletBoundaryCondition(MeshLib::Mesh const &bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, int const variable_id, int const component_id)
std::vector< IndexType > ids
std::vector< double > values