OGS
DeactivatedSubdomainDirichlet.cpp
Go to the documentation of this file.
1 
10 
15 #include "ParameterLib/Parameter.h"
17 
18 namespace ProcessLib
19 {
21  std::vector<std::size_t> const* const active_element_ids,
23  ParameterLib::Parameter<double> const& parameter,
24  bool const set_outer_nodes_dirichlet_values,
25  DeactivatedSubdomainMesh const& subdomain,
26  NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id,
27  int const component_id)
28  : _parameter(parameter),
29  _subdomain(subdomain),
30  _variable_id(variable_id),
31  _component_id(component_id),
32  _time_interval(std::move(time_interval)),
33  _active_element_ids(active_element_ids),
34  _set_outer_nodes_dirichlet_values(set_outer_nodes_dirichlet_values)
35 {
36  config(dof_table_bulk);
37 }
38 
40  NumLib::LocalToGlobalIndexMap const& dof_table_bulk)
41 {
43  *_subdomain.mesh, dof_table_bulk, _variable_id, _component_id);
44 
45  std::vector<MeshLib::Node*> const& bc_nodes = _subdomain.mesh->getNodes();
46  MeshLib::MeshSubset subdomain_mesh_subset(*_subdomain.mesh, bc_nodes);
47 
48  // Create local DOF table from the BC mesh subset for the given variable
49  // and component id.
51  _variable_id, {_component_id}, std::move(subdomain_mesh_subset)));
52 }
53 
55  const double t, GlobalVector const& x,
57 {
58  auto const& bulk_element_ids =
59  *_subdomain.mesh->getProperties()
60  .template getPropertyVector<std::size_t>(
61  "bulk_element_ids", MeshLib::MeshItemType::Cell, 1);
62 
63  auto is_inactive = [&](MeshLib::Element const* const e)
64  {
65  return none_of(begin(*_active_element_ids), end(*_active_element_ids),
66  [&](auto const id)
67  { return id == bulk_element_ids[e->getID()]; });
68  };
69 
70  std::vector<MeshLib::Node*> inactive_nodes_in_bc_mesh;
71  std::copy_if(begin(_subdomain.inner_nodes), end(_subdomain.inner_nodes),
72  back_inserter(inactive_nodes_in_bc_mesh),
73  [&](MeshLib::Node* const n)
74  {
75  const auto& connected_elements =
76  _subdomain.mesh->getElementsConnectedToNode(*n);
77 
78  return std::all_of(begin(connected_elements),
79  end(connected_elements), is_inactive);
80  });
81 
83  {
84  std::copy_if(begin(_subdomain.outer_nodes), end(_subdomain.outer_nodes),
85  back_inserter(inactive_nodes_in_bc_mesh),
86  [&](MeshLib::Node* const n)
87  {
88  const auto& connected_elements =
89  _subdomain.mesh->getElementsConnectedToNode(*n);
90 
91  return std::all_of(begin(connected_elements),
92  end(connected_elements),
93  is_inactive);
94  });
95  }
96 
97  auto time_interval_contains = [&](double const t)
98  {
99  return _time_interval.getSupportMin() <= t &&
101  };
102  if (time_interval_contains(t))
103  {
105  _parameter, *_subdomain.mesh, inactive_nodes_in_bc_mesh,
106  *_dof_table_boundary, _variable_id, _component_id, t, x, bc_values);
107  return;
108  }
109 
110  bc_values.ids.clear();
111  bc_values.values.clear();
112 }
113 } // namespace ProcessLib
Defines functions that are shared by DirichletBoundaryCondition and DirichletBoundaryConditionWithinT...
Global vector based on Eigen vector.
Definition: EigenVector.h:26
A subset of nodes on a single mesh.
Definition: MeshSubset.h:27
LocalToGlobalIndexMap * deriveBoundaryConstrainedMap(int const variable_id, std::vector< int > const &component_ids, MeshLib::MeshSubset &&new_mesh_subset) const
MathLib::PiecewiseLinearInterpolation const _time_interval
std::vector< std::size_t > const * _active_element_ids
void getEssentialBCValues(const double t, GlobalVector const &x, NumLib::IndexValueVector< GlobalIndexType > &bc_values) const override
Writes the values of essential BCs to bc_values.
DeactivatedSubdomainDirichlet(std::vector< std::size_t > const *active_element_ids, 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)
ParameterLib::Parameter< double > const & _parameter
void config(NumLib::LocalToGlobalIndexMap const &dof_table_bulk)
std::unique_ptr< NumLib::LocalToGlobalIndexMap const > _dof_table_boundary
void getEssentialBCValuesLocal(ParameterLib::Parameter< double > const &parameter, MeshLib::Mesh const &bc_mesh, std::vector< MeshLib::Node * > 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
std::vector< MeshLib::Node * > const outer_nodes
std::vector< MeshLib::Node * > const inner_nodes
std::unique_ptr< MeshLib::Mesh > const mesh