OGS 6.1.0-1699-ge946d4c5f
NonuniformDirichletBoundaryCondition.cpp
Go to the documentation of this file.
1 
13 
16 
17 namespace ProcessLib
18 {
19 std::unique_ptr<NonuniformDirichletBoundaryCondition>
21  BaseLib::ConfigTree const& config, MeshLib::Mesh const& boundary_mesh,
22  NumLib::LocalToGlobalIndexMap const& dof_table, int const variable_id,
23  int const component_id)
24 {
25  DBUG("Constructing NonuniformDirichlet BC from config.");
27  config.checkConfigParameter("type", "NonuniformDirichlet");
28 
29  // TODO finally use ProcessLib::Parameter here
30  auto const field_name =
32  config.getConfigParameter<std::string>("field_name");
33 
34  auto const* const property =
35  boundary_mesh.getProperties().getPropertyVector<double>(
36  field_name, MeshLib::MeshItemType::Node, 1);
37 
38  if (!property)
39  {
40  OGS_FATAL("A property with name `%s' does not exist in `%s'.",
41  field_name.c_str(), boundary_mesh.getName().c_str());
42  }
43 
44  // In case of partitioned mesh the boundary could be empty, i.e. there is no
45  // 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 (boundary_mesh.getDimension() == 0 &&
52  boundary_mesh.getNumberOfNodes() == 0 &&
53  boundary_mesh.getNumberOfElements() == 0)
54  {
55  return nullptr;
56  }
57 #endif // USE_PETSC
58 
59  return std::make_unique<NonuniformDirichletBoundaryCondition>(
60  boundary_mesh, *property, dof_table, variable_id, component_id);
61 }
62 
63 } // ProcessLib
std::size_t getNumberOfNodes() const
Get the number of nodes.
Definition: Mesh.h:99
MeshLib::Properties & getProperties()
Definition: Mesh.h:131
T getConfigParameter(std::string const &param) const
std::unique_ptr< NonuniformDirichletBoundaryCondition > createNonuniformDirichletBoundaryCondition(BaseLib::ConfigTree const &config, MeshLib::Mesh const &boundary_mesh, NumLib::LocalToGlobalIndexMap const &dof_table, int const variable_id, int const component_id)
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:102
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