OGS
RobinBoundaryCondition.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
7
8namespace ProcessLib
9{
11 BaseLib::ConfigTree const& config)
12{
13 DBUG("parsing RobinBoundaryConditionConfig.");
15 config.checkConfigParameter("type", "Robin");
16
18 auto const alpha_name = config.getConfigParameter<std::string>("alpha");
20 auto const u_0_name = config.getConfigParameter<std::string>("u_0");
21
22 auto const area_parameter_name =
24 config.getConfigParameterOptional<std::string>("area_parameter");
25 if (area_parameter_name.has_value())
26 {
27 DBUG("area parameter name '{:s}'", __FUNCTION__,
28 area_parameter_name.value());
29 }
30
31 return {alpha_name, u_0_name, area_parameter_name};
32}
33
34std::unique_ptr<RobinBoundaryCondition> createRobinBoundaryCondition(
35 RobinBoundaryConditionConfig const& config, MeshLib::Mesh const& bc_mesh,
36 NumLib::LocalToGlobalIndexMap const& dof_table, int const variable_id,
37 int const component_id, unsigned const integration_order,
38 unsigned const shapefunction_order, unsigned const global_dim,
39 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
40{
41 DBUG("Constructing RobinBcConfig.");
42
43 if (bc_mesh.getDimension() >= global_dim)
44 {
46 "The dimension ({:d}) of the given boundary mesh '{:s}' is not "
47 "lower than the bulk dimension ({:d}).",
48 bc_mesh.getDimension(), bc_mesh.getName(), global_dim);
49 }
50
51 auto const& alpha = ParameterLib::findParameter<double>(
52 config.alpha_name, parameters, 1, &bc_mesh);
54 config.u_0_name, parameters, 1, &bc_mesh);
55
56 ParameterLib::Parameter<double> const* integral_measure(nullptr);
57 if (global_dim - bc_mesh.getDimension() != 1)
58 {
59 if (!config.area_parameter_name)
60 {
61 OGS_FATAL("{}: tag <area_parameter> required in Robin BC.",
62 __FUNCTION__);
63 }
64 integral_measure = &ParameterLib::findParameter<double>(
65 config.area_parameter_name.value(), parameters, 1, &bc_mesh);
66 }
67
68 // In case of partitioned mesh the boundary could be empty, i.e. there is no
69 // boundary condition.
70#ifdef USE_PETSC
71 // This can be extracted to createBoundaryCondition() but then the config
72 // parameters are not read and will cause an error.
73 // TODO (naumov): Add a function to ConfigTree for skipping the tags of the
74 // subtree and move the code up in createBoundaryCondition().
75 if (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 &&
76 bc_mesh.getNumberOfElements() == 0)
77 {
78 return nullptr;
79 }
80#endif // USE_PETSC
81
82 return std::make_unique<RobinBoundaryCondition>(
83 integration_order, shapefunction_order, dof_table, variable_id,
84 component_id, global_dim, bc_mesh,
85 RobinBoundaryConditionData{alpha, u_0, integral_measure});
86}
87
88} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
std::optional< T > getConfigParameterOptional(std::string const &param) const
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:79
const std::string getName() const
Get name of the mesh.
Definition Mesh.h:94
std::size_t getNumberOfNodes() const
Get the number of nodes.
Definition Mesh.h:91
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:88
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)
std::unique_ptr< RobinBoundaryCondition > createRobinBoundaryCondition(RobinBoundaryConditionConfig const &config, MeshLib::Mesh const &bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table, int const variable_id, int const component_id, unsigned const integration_order, unsigned const shapefunction_order, unsigned const global_dim, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters)
RobinBoundaryConditionConfig parseRobinBoundaryCondition(BaseLib::ConfigTree const &config)
std::optional< std::string > area_parameter_name