OGS
CreateLinear.cpp
Go to the documentation of this file.
1
12
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 auto const min =
53 independent_variable_config.getConfigParameterOptional<double>(
54 "min");
55
56 auto const max =
58 independent_variable_config.getConfigParameterOptional<double>(
59 "max");
60
61 static const std::unordered_set<std::string> filter_not_variables = {
62 "t", "x", "y", "z"};
64 if (!filter_not_variables.contains(variable_name))
65 {
67 }
68 else
69 {
70 ivt = variable_name;
71 }
72
73 MaterialPropertyLib::IndependentVariable iv{ivt, reference_condition,
74 slope, min, max};
75
76 ivs.push_back(std::move(iv));
77 }
78
79 return std::make_unique<MaterialPropertyLib::Linear>(
80 std::move(property_name), reference_value, ivs);
81}
82} // 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)