OGS
VariableDependentNeumannBoundaryCondition.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", "VariableDependentNeumann");
15
16 auto const constant_name =
18 config.getConfigParameter<std::string>("constant_name");
19
20 auto const coefficient_current_variable_name =
22 config.getConfigParameter<std::string>(
23 "coefficient_current_variable_name");
24
25 auto const coefficient_other_variable_name =
27 config.getConfigParameter<std::string>(
28 "coefficient_other_variable_name");
29
30 auto const coefficient_mixed_variables_name =
32 config.getConfigParameter<std::string>(
33 "coefficient_mixed_variables_name");
34
35 return {constant_name, coefficient_current_variable_name,
36 coefficient_other_variable_name, coefficient_mixed_variables_name};
37}
38
39std::unique_ptr<VariableDependentNeumannBoundaryCondition>
41 VariableDependentNeumannConfig const& coefficients,
42 MeshLib::Mesh const& bc_mesh,
43 NumLib::LocalToGlobalIndexMap const& dof_table, int const variable_id,
44 int const component_id, unsigned const integration_order,
45 unsigned const shapefunction_order, unsigned const global_dim,
46 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
47{
48 DBUG("Constructing VariableDependentNeumann BC.");
49 if (dof_table.getNumberOfVariables() != 2)
50 {
52 "VariableDependentNeumann BC only implemented for 2 variable "
53 "processes.");
54 }
55 assert(variable_id == 0 || variable_id == 1);
56
57 if (bc_mesh.getDimension() + 1 != global_dim)
58 {
60 "The dimension ({:d}) of the given boundary mesh '{:s}' is not by "
61 "one lower than the bulk dimension ({:d}).",
62 bc_mesh.getDimension(), bc_mesh.getName(), global_dim);
63 }
64
65 auto const& constant = ParameterLib::findParameter<double>(
66 coefficients.constant_name, parameters, 1, &bc_mesh);
67
68 auto const& coefficient_current_variable =
70 parameters, 1, &bc_mesh);
71
72 auto const& coefficient_other_variable =
74 parameters, 1, &bc_mesh);
75
76 auto const& coefficient_mixed_variables =
78 parameters, 1, &bc_mesh);
79
80 std::vector<MeshLib::Node*> const& bc_nodes = bc_mesh.getNodes();
81 MeshLib::MeshSubset bc_mesh_subset(bc_mesh, bc_nodes);
82 auto dof_table_boundary_other_variable =
84 (variable_id + 1) % 2, {component_id}, std::move(bc_mesh_subset));
85
86 // In case of partitioned mesh the boundary could be empty, i.e. there is no
87 // boundary condition.
88#ifdef USE_PETSC
89 // This can be extracted to createBoundaryCondition() but then the config
90 // parameters are not read and will cause an error.
91 // TODO (naumov): Add a function to ConfigTree for skipping the tags of the
92 // subtree and move the code up in createBoundaryCondition().
93 if (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 &&
94 bc_mesh.getNumberOfElements() == 0)
95 {
96 return nullptr;
97 }
98#endif // USE_PETSC
99
100 return std::make_unique<VariableDependentNeumannBoundaryCondition>(
101 integration_order, shapefunction_order, dof_table, variable_id,
102 component_id, global_dim, bc_mesh,
104 constant, coefficient_current_variable, coefficient_other_variable,
105 coefficient_mixed_variables,
106 std::move(dof_table_boundary_other_variable)});
107}
108
109} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:19
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
A subset of nodes on a single mesh.
Definition MeshSubset.h:17
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:97
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
std::unique_ptr< LocalToGlobalIndexMap > deriveBoundaryConstrainedMap(int const variable_id, std::vector< int > const &component_ids, MeshLib::MeshSubset &&new_mesh_subset) const
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)
VariableDependentNeumannConfig parseVariableDependentNeumannBoundaryCondition(BaseLib::ConfigTree const &config)
std::unique_ptr< VariableDependentNeumannBoundaryCondition > createVariableDependentNeumannBoundaryCondition(VariableDependentNeumannConfig const &coefficients, 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)