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