OGS
NeumannBoundaryCondition.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{
14 config.checkConfigParameter("type", "Neumann");
15
17 auto const name = config.getConfigParameter<std::string>("parameter");
18 DBUG("{}: parameter {:s}", __FUNCTION__, name);
19
20 auto const area_parameter_name =
22 config.getConfigParameterOptional<std::string>("area_parameter");
23 if (area_parameter_name.has_value())
24 {
25 DBUG("{}: area parameter name '{:s}'", __FUNCTION__,
26 area_parameter_name.value());
27 }
28
29 return {name, area_parameter_name};
30}
31
32std::unique_ptr<NeumannBoundaryCondition> createNeumannBoundaryCondition(
33 NeumannBoundaryConditionConfig const& config, MeshLib::Mesh const& bc_mesh,
34 NumLib::LocalToGlobalIndexMap const& dof_table, int const variable_id,
35 int const component_id, unsigned const integration_order,
36 unsigned const shapefunction_order, unsigned const global_dim,
37 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
38{
39 DBUG("Constructing Neumann BC.");
40
41 auto const& param = ParameterLib::findParameter<double>(
42 config.parameter_name, parameters, 1, &bc_mesh);
43
44 // In case of partitioned mesh the boundary could be empty, i.e. there
45 // is no boundary condition.
46#ifdef USE_PETSC
47 // This can be extracted to createBoundaryCondition() but then the config
48 // parameters are not read and will cause an error.
49 // TODO (naumov): Add a function to ConfigTree for skipping the tags of the
50 // subtree and move the code up in createBoundaryCondition().
51 if (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 &&
52 bc_mesh.getNumberOfElements() == 0)
53 {
54 return nullptr;
55 }
56#endif // USE_PETSC
57
58 ParameterLib::Parameter<double> const* integral_measure(nullptr);
59 if (global_dim - bc_mesh.getDimension() != 1)
60 {
61 if (!config.area_parameter_name)
62 {
63 OGS_FATAL("{}: tag <area_parameter> required in Neumann BC.",
64 __FUNCTION__);
65 }
66 integral_measure = &ParameterLib::findParameter<double>(
67 config.area_parameter_name.value(), parameters, 1, &bc_mesh);
68 }
69
70 if (bc_mesh.getDimension() >= global_dim)
71 {
73 "The dimension ({:d}) of the given boundary mesh '{:s}' is not "
74 "lower than the bulk dimension ({:d}).",
75 bc_mesh.getDimension(), bc_mesh.getName(), global_dim);
76 }
77
78 return std::make_unique<NeumannBoundaryCondition>(
79 integration_order, shapefunction_order, dof_table, variable_id,
80 component_id, global_dim, bc_mesh,
81 NeumannBoundaryConditionData{param, integral_measure});
82}
83
84} // 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< NeumannBoundaryCondition > createNeumannBoundaryCondition(NeumannBoundaryConditionConfig 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)
NeumannBoundaryConditionConfig parseNeumannBoundaryCondition(BaseLib::ConfigTree const &config)