OGS 6.1.0-1699-ge946d4c5f
NonuniformNeumannBoundaryCondition.cpp
Go to the documentation of this file.
1 
11 
14 
15 namespace ProcessLib
16 {
17 std::unique_ptr<NonuniformNeumannBoundaryCondition>
19  BaseLib::ConfigTree const& config, MeshLib::Mesh const& boundary_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, MeshLib::Mesh const& bulk_mesh)
23 {
24  DBUG("Constructing NonuniformNeumann BC from config.");
26  config.checkConfigParameter("type", "NonuniformNeumann");
27 
28  // TODO finally use ProcessLib::Parameter here
29  auto const field_name =
31  config.getConfigParameter<std::string>("field_name");
32 
33  auto const* const property =
34  boundary_mesh.getProperties().getPropertyVector<double>(field_name);
35 
36  if (!property)
37  {
38  OGS_FATAL("A property with name `%s' does not exist in `%s'.",
39  field_name.c_str(), boundary_mesh.getName().c_str());
40  }
41 
42  if (property->getMeshItemType() != MeshLib::MeshItemType::Node)
43  {
44  OGS_FATAL(
45  "Only nodal fields are supported for non-uniform fields. Field "
46  "`%s' is not nodal.",
47  field_name.c_str());
48  }
49 
50  if (property->getNumberOfComponents() != 1)
51  {
52  OGS_FATAL("`%s' is not a one-component field.", field_name.c_str());
53  }
54 
55  std::string const mapping_to_bulk_nodes_property = "bulk_node_ids";
56  auto const* const mapping_to_bulk_nodes =
57  boundary_mesh.getProperties().getPropertyVector<std::size_t>(
58  mapping_to_bulk_nodes_property);
59 
60  if (mapping_to_bulk_nodes == nullptr ||
61  mapping_to_bulk_nodes->getMeshItemType() !=
63  mapping_to_bulk_nodes->getNumberOfComponents() != 1)
64  {
65  OGS_FATAL("Field `%s' is not set up properly.",
66  mapping_to_bulk_nodes_property.c_str());
67  }
68 
69  // In case of partitioned mesh the boundary could be empty, i.e. there is no
70  // boundary condition.
71 #ifdef USE_PETSC
72  // This can be extracted to createBoundaryCondition() but then the config
73  // parameters are not read and will cause an error.
74  // TODO (naumov): Add a function to ConfigTree for skipping the tags of the
75  // subtree and move the code up in createBoundaryCondition().
76  if (boundary_mesh.getDimension() == 0 &&
77  boundary_mesh.getNumberOfNodes() == 0 &&
78  boundary_mesh.getNumberOfElements() == 0)
79  {
80  return nullptr;
81  }
82 #endif // USE_PETSC
83 
84  return std::make_unique<NonuniformNeumannBoundaryCondition>(
85  integration_order, shapefunction_order, dof_table, variable_id,
86  component_id, bulk_mesh.getDimension(), boundary_mesh,
88  *property, bulk_mesh.getID(), *mapping_to_bulk_nodes, dof_table,
89  variable_id, component_id});
90 }
91 
92 } // ProcessLib
std::size_t getNumberOfNodes() const
Get the number of nodes.
Definition: Mesh.h:99
std::size_t getID() const
Get id of the mesh.
Definition: Mesh.h:120
MeshLib::Properties & getProperties()
Definition: Mesh.h:131
T getConfigParameter(std::string const &param) const
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:102
std::unique_ptr< NonuniformNeumannBoundaryCondition > createNonuniformNeumannBoundaryCondition(BaseLib::ConfigTree const &config, MeshLib::Mesh const &boundary_mesh, NumLib::LocalToGlobalIndexMap const &dof_table, int const variable_id, int const component_id, unsigned const integration_order, unsigned const shapefunction_order, MeshLib::Mesh const &bulk_mesh)
Definition of readMeshFromFile function.
void checkConfigParameter(std::string const &param, T const &value) const
PropertyVector< T > const * getPropertyVector(std::string const &name) const
Definition: Properties.h:119
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:81
std::size_t getNumberOfElements() const
Get the number of elements.
Definition: Mesh.h:96
#define OGS_FATAL(fmt,...)
Definition: Error.h:71