OGS
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
CreateLinear.cpp
Go to the documentation of this file.
1
13#include <unordered_set>
14
15#include "BaseLib/ConfigTree.h"
16#include "Linear.h"
17
18namespace MaterialPropertyLib
19{
20std::unique_ptr<Linear> createLinear(BaseLib::ConfigTree const& config)
21{
23 config.checkConfigParameter("type", "Linear");
24
25 // Second access for storage.
27 auto property_name = config.peekConfigParameter<std::string>("name");
28
29 DBUG("Create Linear property {:s}.", property_name);
30 auto const reference_value =
32 config.getConfigParameter<double>("reference_value");
33
34 std::vector<MaterialPropertyLib::IndependentVariable> ivs;
35 for (auto const& independent_variable_config :
37 config.getConfigSubtreeList("independent_variable"))
38 {
39 auto const& variable_name =
41 independent_variable_config.getConfigParameter<std::string>(
42 "variable_name");
43 auto const reference_condition =
45 independent_variable_config.getConfigParameter<double>(
46 "reference_condition");
47 auto const slope =
49 independent_variable_config.getConfigParameter<double>("slope");
50
51 static const std::unordered_set<std::string> filter_not_variables = {
52 "t", "x", "y", "z"};
54 if (!filter_not_variables.contains(variable_name))
55 {
57 }
58 else
59 {
60 ivt = variable_name;
61 }
62 MaterialPropertyLib::IndependentVariable iv{ivt, reference_condition,
63 slope};
64
65 ivs.push_back(std::move(iv));
66 }
67
68 return std::make_unique<MaterialPropertyLib::Linear>(
69 std::move(property_name), reference_value, ivs);
70}
71} // namespace MaterialPropertyLib
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
Range< SubtreeIterator > getConfigSubtreeList(std::string const &root) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
std::variant< std::string, Variable > StringOrVariable
Definition Curve.h:18
Variable convertStringToVariable(std::string const &string)
std::unique_ptr< Linear > createLinear(BaseLib::ConfigTree const &config)