OGS
DirichletBoundaryCondition.cpp
Go to the documentation of this file.
1 
12 
13 #include <algorithm>
14 #include <vector>
15 
16 #include "BaseLib/ConfigTree.h"
17 #include "BaseLib/Logging.h"
21 #include "ParameterLib/Parameter.h"
22 #include "ParameterLib/Utils.h"
23 
24 namespace ProcessLib
25 {
27  ParameterLib::Parameter<double> const& parameter,
28  MeshLib::Mesh const& bc_mesh,
29  NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id,
30  int const component_id)
31  : _parameter(parameter),
32  _bc_mesh(bc_mesh),
33  _variable_id(variable_id),
34  _component_id(component_id)
35 {
38 
39  std::vector<MeshLib::Node*> const& bc_nodes = bc_mesh.getNodes();
40  MeshLib::MeshSubset bc_mesh_subset(_bc_mesh, bc_nodes);
41 
42  // Create local DOF table from the BC mesh subset for the given variable
43  // and component id.
45  variable_id, {component_id}, std::move(bc_mesh_subset)));
46 }
47 
49  const double t, GlobalVector const& x,
51 {
54  t, x, bc_values);
55 }
56 
57 std::unique_ptr<DirichletBoundaryCondition> createDirichletBoundaryCondition(
58  BaseLib::ConfigTree const& config, MeshLib::Mesh const& bc_mesh,
59  NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id,
60  int const component_id,
61  const std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters)
62 {
63  DBUG("Constructing DirichletBoundaryCondition from config.");
65  config.checkConfigParameter("type", "Dirichlet");
66 
68  auto const param_name = config.getConfigParameter<std::string>("parameter");
69  DBUG("Using parameter {:s}", param_name);
70 
71  auto& parameter = ParameterLib::findParameter<double>(
72  param_name, parameters, 1, &bc_mesh);
73 
74 // In case of partitioned mesh the boundary could be empty, i.e. there is no
75 // boundary condition.
76 #ifdef USE_PETSC
77  // This can be extracted to createBoundaryCondition() but then the config
78  // parameters are not read and will cause an error.
79  // TODO (naumov): Add a function to ConfigTree for skipping the tags of the
80  // subtree and move the code up in createBoundaryCondition().
81  if (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 &&
82  bc_mesh.getNumberOfElements() == 0)
83  {
84  return nullptr;
85  }
86 #endif // USE_PETSC
87 
88  return std::make_unique<DirichletBoundaryCondition>(
89  parameter, bc_mesh, dof_table_bulk, variable_id, component_id);
90 }
91 
92 } // namespace ProcessLib
Defines functions that are shared by DirichletBoundaryCondition and DirichletBoundaryConditionWithinT...
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
void checkConfigParameter(std::string const &param, T const &value) const
T getConfigParameter(std::string const &param) const
Global vector based on Eigen vector.
Definition: EigenVector.h:26
A subset of nodes on a single mesh.
Definition: MeshSubset.h:27
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition: Mesh.h:95
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:71
std::size_t getNumberOfNodes() const
Get the number of nodes.
Definition: Mesh.h:89
std::size_t getNumberOfElements() const
Get the number of elements.
Definition: Mesh.h:86
LocalToGlobalIndexMap * deriveBoundaryConstrainedMap(int const variable_id, std::vector< int > const &component_ids, MeshLib::MeshSubset &&new_mesh_subset) const
void getEssentialBCValues(const double t, GlobalVector const &x, NumLib::IndexValueVector< GlobalIndexType > &bc_values) const override
Writes the values of essential BCs to bc_values.
DirichletBoundaryCondition(ParameterLib::Parameter< double > const &parameter, MeshLib::Mesh const &bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, int const variable_id, int const component_id)
ParameterLib::Parameter< double > const & _parameter
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)
std::unique_ptr< DirichletBoundaryCondition > createDirichletBoundaryCondition(BaseLib::ConfigTree const &config, MeshLib::Mesh const &bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, int const variable_id, int const component_id, const std::vector< std::unique_ptr< ParameterLib::ParameterBase >> &parameters)
void checkParametersOfDirichletBoundaryCondition(MeshLib::Mesh const &bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, int const variable_id, int const component_id)