OGS
CreateTimeDecayDirichletBoundaryCondition.cpp
Go to the documentation of this file.
1
13
14#include <numeric>
15
16#include "BaseLib/ConfigTree.h"
17#include "BoundaryCondition.h"
18#include "MeshLib/Mesh.h"
21#include "ParameterLib/Utils.h"
23
24namespace ProcessLib
25{
26std::unique_ptr<BoundaryCondition> createTimeDecayDirichletBoundaryCondition(
27 int const variable_id, int const component_id,
28 BaseLib::ConfigTree const& config, MeshLib::Mesh const& bc_mesh,
29 NumLib::LocalToGlobalIndexMap const& dof_table_bulk,
30 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
31{
32 DBUG("Create TimeDecayDirichlet.");
34 config.checkConfigParameter("type", "TimeDecayDirichlet");
35
36 auto const parameter_name =
38 config.getConfigParameter<std::string>("time_decay_parameter");
39 DBUG("Using parameter {:s}", parameter_name);
40
41 auto const& time_decay_parameter = ParameterLib::findParameter<double>(
42 parameter_name, parameters, 1, &bc_mesh);
43
44 auto const lower_limit =
46 config.getConfigParameter<double>("lower_limit");
47
48 // In case of partitioned mesh the boundary could be empty, i.e. there
49 // is no boundary condition.
50#ifdef USE_PETSC
51 // This can be extracted to createBoundaryCondition() but then the config
52 // parameters are not read and will cause an error.
53 // TODO (naumov): Add a function to ConfigTree for skipping the tags of the
54 // subtree and move the code up in createBoundaryCondition().
55 if (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 &&
56 bc_mesh.getNumberOfElements() == 0)
57 {
58 return nullptr;
59 }
60#endif // USE_PETSC
61
62 return std::make_unique<TimeDecayDirichletBoundaryCondition>(
63 variable_id, component_id, bc_mesh, dof_table_bulk,
64 time_decay_parameter, lower_limit);
65}
66
67} // namespace ProcessLib
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
Definition of the Mesh class.
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:90
std::size_t getNumberOfNodes() const
Get the number of nodes.
Definition Mesh.h:102
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:99
OGS_NO_DANGLING Parameter< ParameterDataType > & findParameter(std::string const &parameter_name, std::vector< std::unique_ptr< ParameterBase > > const &parameters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
Definition Utils.h:102
std::unique_ptr< BoundaryCondition > createTimeDecayDirichletBoundaryCondition(int const variable_id, int const component_id, BaseLib::ConfigTree const &config, MeshLib::Mesh const &bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters)