OGS
CreateLinear.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
4#include <unordered_set>
5
7#include "Linear.h"
8
10{
11std::unique_ptr<Linear> createLinear(BaseLib::ConfigTree const& config)
12{
14 config.checkConfigParameter("type", "Linear");
15
16 // Second access for storage.
18 auto property_name = config.peekConfigParameter<std::string>("name");
19
20 DBUG("Create Linear property {:s}.", property_name);
21 auto const reference_value =
23 config.getConfigParameter<double>("reference_value");
24
25 std::vector<MaterialPropertyLib::IndependentVariable> ivs;
26 for (auto const& independent_variable_config :
28 config.getConfigSubtreeList("independent_variable"))
29 {
30 auto const& variable_name =
32 independent_variable_config.getConfigParameter<std::string>(
33 "variable_name");
34 auto const reference_condition =
36 independent_variable_config.getConfigParameter<double>(
37 "reference_condition");
38 auto const slope =
40 independent_variable_config.getConfigParameter<double>("slope");
41
42 auto const min =
44 independent_variable_config.getConfigParameterOptional<double>(
45 "min");
46
47 auto const max =
49 independent_variable_config.getConfigParameterOptional<double>(
50 "max");
51
52 static const std::unordered_set<std::string> filter_not_variables = {
53 "t", "x", "y", "z"};
55 if (!filter_not_variables.contains(variable_name))
56 {
58 }
59 else
60 {
61 ivt = variable_name;
62 }
63
64 MaterialPropertyLib::IndependentVariable iv{ivt, reference_condition,
65 slope, min, max};
66
67 ivs.push_back(std::move(iv));
68 }
69
70 return std::make_unique<MaterialPropertyLib::Linear>(
71 std::move(property_name), reference_value, ivs);
72}
73} // namespace MaterialPropertyLib
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
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:12
Variable convertStringToVariable(std::string const &string)
std::unique_ptr< Linear > createLinear(BaseLib::ConfigTree const &config)