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