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"
22#include "ParameterLib/Utils.h"
23
24namespace 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
55
56std::unique_ptr<DirichletBoundaryCondition> createDirichletBoundaryCondition(
57 BaseLib::ConfigTree const& config, MeshLib::Mesh const& bc_mesh,
58 NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id,
59 int const component_id,
60 const std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters)
61{
62 DBUG("Constructing DirichletBoundaryCondition from config.");
64 config.checkConfigParameter("type", "Dirichlet");
65
67 auto const param_name = config.getConfigParameter<std::string>("parameter");
68 DBUG("Using parameter {:s}", param_name);
69
71 param_name, parameters, 1, &bc_mesh);
72
73// In case of partitioned mesh the boundary could be empty, i.e. there is no
74// boundary condition.
75#ifdef USE_PETSC
76 // This can be extracted to createBoundaryCondition() but then the config
77 // parameters are not read and will cause an error.
78 // TODO (naumov): Add a function to ConfigTree for skipping the tags of the
79 // subtree and move the code up in createBoundaryCondition().
80 if (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 &&
81 bc_mesh.getNumberOfElements() == 0)
82 {
83 return nullptr;
84 }
85#endif // USE_PETSC
86
87 return std::make_unique<DirichletBoundaryCondition>(
88 parameter, bc_mesh, dof_table_bulk, variable_id, component_id);
89}
90
91} // namespace ProcessLib
Defines functions that are shared by DirichletBoundaryCondition and DirichletBoundaryConditionWithinT...
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
Global vector based on Eigen vector.
Definition EigenVector.h:25
A subset of nodes on a single mesh.
Definition MeshSubset.h:26
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:106
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:88
std::size_t getNumberOfNodes() const
Get the number of nodes.
Definition Mesh.h:100
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:97
std::unique_ptr< 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
OGS_NO_DANGLING Parameter< ParameterDataType > & findParameter(std::string const &parameter_name, std::vector< std::unique_ptr< ParameterBase > > const &parameters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
Definition Utils.h:102
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)
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)