Loading [MathJax]/extensions/tex2jax.js
OGS
CreateCurve.cpp
Go to the documentation of this file.
1
11#include "CreateCurve.h"
12
13#include <unordered_set>
14
15#include "BaseLib/Algorithm.h"
16#include "BaseLib/ConfigTree.h"
17#include "Curve.h"
20
21namespace MaterialPropertyLib
22{
23std::unique_ptr<Curve> createCurve(
24 BaseLib::ConfigTree const& config,
25 std::map<std::string,
26 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
27 curves)
28{
30 config.checkConfigParameter("type", "Curve");
31
32 // Second access for storage.
34 auto property_name = config.peekConfigParameter<std::string>("name");
35
36 DBUG("Create Curve {:s}.", property_name);
37
39 auto curve_name = config.getConfigParameter<std::string>("curve");
40 DBUG("Using curve '{:s}'", curve_name);
41
42 auto const& curve =
43 *BaseLib::getOrError(curves, curve_name, "Could not find curve.");
44
45 auto const independent_variable_string =
47 config.getConfigParameter<std::string>("independent_variable");
48 DBUG("Using independent_variable '{:s}'", independent_variable_string);
49
50 static const std::unordered_set<std::string> filter_not_variables = {
51 "t", "x", "y", "z"};
52 MaterialPropertyLib::StringOrVariable independent_variable;
53 if (filter_not_variables.contains(independent_variable_string))
54 {
55 independent_variable = independent_variable_string;
56 }
57 else
58 {
60 independent_variable_string);
61 }
62
63 return std::make_unique<Curve>(
64 std::move(property_name), independent_variable, curve);
65}
66
67} // namespace MaterialPropertyLib
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
Definition of the PiecewiseLinearInterpolation class.
T peekConfigParameter(std::string const &param) const
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
OGS_NO_DANGLING Map::mapped_type & getOrError(Map &map, Key const &key, std::string const &error_message)
Definition Algorithm.h:118
std::unique_ptr< Curve > createCurve(BaseLib::ConfigTree const &config, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
std::variant< std::string, Variable > StringOrVariable
Definition Curve.h:18
Variable convertStringToVariable(std::string const &string)