OGS
VariableDependentNeumannBoundaryCondition.cpp
Go to the documentation of this file.
1 
12 
13 #include "ParameterLib/Utils.h"
14 
15 namespace ProcessLib
16 {
17 std::unique_ptr<VariableDependentNeumannBoundaryCondition>
19  BaseLib::ConfigTree const& config, MeshLib::Mesh const& bc_mesh,
20  NumLib::LocalToGlobalIndexMap const& dof_table, int const variable_id,
21  int const component_id, unsigned const integration_order,
22  unsigned const shapefunction_order, unsigned const global_dim,
23  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
24 {
25  DBUG("Constructing VariableDependentNeumann BC from config.");
27  config.checkConfigParameter("type", "VariableDependentNeumann");
28  if (dof_table.getNumberOfVariables() != 2)
29  {
30  OGS_FATAL(
31  "VariableDependentNeumann BC only implemented for 2 variable "
32  "processes.");
33  }
34  assert(variable_id == 0 || variable_id == 1);
35 
36  if (bc_mesh.getDimension() + 1 != global_dim)
37  {
38  OGS_FATAL(
39  "The dimension ({:d}) of the given boundary mesh '{:s}' is not by "
40  "one "
41  "lower than the bulk dimension ({:d}).",
42  bc_mesh.getDimension(), bc_mesh.getName(), global_dim);
43  }
44 
45  auto const constant_name =
47  config.getConfigParameter<std::string>("constant_name");
48  auto const& constant = ParameterLib::findParameter<double>(
49  constant_name, parameters, 1, &bc_mesh);
50 
51  auto const coefficient_current_variable_name =
53  config.getConfigParameter<std::string>(
54  "coefficient_current_variable_name");
55  auto const& coefficient_current_variable =
56  ParameterLib::findParameter<double>(coefficient_current_variable_name,
57  parameters, 1, &bc_mesh);
58 
59  auto const coefficient_other_variable_name =
61  config.getConfigParameter<std::string>(
62  "coefficient_other_variable_name");
63  auto const& coefficient_other_variable =
64  ParameterLib::findParameter<double>(coefficient_other_variable_name,
65  parameters, 1, &bc_mesh);
66 
67  auto const coefficient_mixed_variables_name =
69  config.getConfigParameter<std::string>(
70  "coefficient_mixed_variables_name");
71  auto const& coefficient_mixed_variables =
72  ParameterLib::findParameter<double>(coefficient_mixed_variables_name,
73  parameters, 1, &bc_mesh);
74 
75  std::vector<MeshLib::Node*> const& bc_nodes = bc_mesh.getNodes();
76  MeshLib::MeshSubset bc_mesh_subset(bc_mesh, bc_nodes);
77  auto const& dof_table_boundary_other_variable =
79  (variable_id + 1) % 2, {component_id}, std::move(bc_mesh_subset));
80 
81  // In case of partitioned mesh the boundary could be empty, i.e. there is no
82  // boundary condition.
83 #ifdef USE_PETSC
84  // This can be extracted to createBoundaryCondition() but then the config
85  // parameters are not read and will cause an error.
86  // TODO (naumov): Add a function to ConfigTree for skipping the tags of the
87  // subtree and move the code up in createBoundaryCondition().
88  if (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 &&
89  bc_mesh.getNumberOfElements() == 0)
90  {
91  return nullptr;
92  }
93 #endif // USE_PETSC
94 
95  return std::make_unique<VariableDependentNeumannBoundaryCondition>(
96  integration_order, shapefunction_order, dof_table, variable_id,
97  component_id, global_dim, bc_mesh,
99  constant, coefficient_current_variable, coefficient_other_variable,
100  coefficient_mixed_variables, dof_table_boundary_other_variable});
101 }
102 
103 } // namespace ProcessLib
#define OGS_FATAL(...)
Definition: Error.h:26
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
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
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:92
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
std::unique_ptr< VariableDependentNeumannBoundaryCondition > createVariableDependentNeumannBoundaryCondition(BaseLib::ConfigTree 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)