OGS
CreateDirichletBoundaryConditionWithinTimeInterval.cpp
Go to the documentation of this file.
1
10#include "BaseLib/ConfigTree.h"
15#include "ParameterLib/Utils.h"
16
17namespace ProcessLib
18{
19std::unique_ptr<BoundaryCondition>
21 BaseLib::ConfigTree const& config, MeshLib::Mesh const& bc_mesh,
22 NumLib::LocalToGlobalIndexMap const& dof_table_bulk, int const variable_id,
23 int const component_id,
24 const std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters)
25{
26 DBUG(
27 "Constructing DirichletBoundaryConditionWithinTimeInterval from "
28 "config.");
29
31 config.checkConfigParameter("type", "DirichletWithinTimeInterval");
32
34 auto const param_name = config.getConfigParameter<std::string>("parameter");
35 DBUG("Using parameter {:s}", param_name);
36
37 auto& param = ParameterLib::findParameter<double>(param_name, parameters, 1,
38 &bc_mesh);
39
41 config.peekConfigParameter<std::string>("time_interval");
42 auto time_interval = BaseLib::createTimeInterval(config);
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 (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 &&
52 bc_mesh.getNumberOfElements() == 0)
53 {
54 return nullptr;
55 }
56#endif // USE_PETSC
57
58 return std::make_unique<DirichletBoundaryConditionWithinTimeInterval>(
59 std::move(time_interval), param, bc_mesh, dof_table_bulk, variable_id,
60 component_id);
61}
62} // namespace ProcessLib
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
T peekConfigParameter(std::string const &param) const
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:88
std::size_t getNumberOfNodes() const
Get the number of nodes.
Definition Mesh.h:100
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:97
TimeInterval createTimeInterval(ConfigTree const &config)
std::unique_ptr< BoundaryCondition > createDirichletBoundaryConditionWithinTimeInterval(BaseLib::ConfigTree const &config, MeshLib::Mesh const &bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, int const variable_id, int const component_id, const std::vector< std::unique_ptr< ParameterLib::ParameterBase > > &parameters)