OGS
CreateCurve.cpp
Go to the documentation of this file.
1
11#include "CreateCurve.h"
12
13#include "BaseLib/Algorithm.h"
14#include "BaseLib/ConfigTree.h"
15#include "Curve.h"
18
19namespace MaterialPropertyLib
20{
21std::unique_ptr<Curve> createCurve(
22 BaseLib::ConfigTree const& config,
23 std::map<std::string,
24 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
25 curves)
26{
28 config.checkConfigParameter("type", "Curve");
29
30 // Second access for storage.
32 auto property_name = config.peekConfigParameter<std::string>("name");
33
34 DBUG("Create Curve {:s}.", property_name);
35
37 auto curve_name = config.getConfigParameter<std::string>("curve");
38 DBUG("Using curve '{:s}'", curve_name);
39
40 auto const& curve =
41 *BaseLib::getOrError(curves, curve_name, "Could not find curve.");
42
43 auto const independent_variable_string =
45 config.getConfigParameter<std::string>("independent_variable");
46 DBUG("Using independent_variable '{:s}'", independent_variable_string);
47 auto const independent_variable =
49 independent_variable_string);
50
51 return std::make_unique<Curve>(
52 std::move(property_name), independent_variable, curve);
53}
54
55} // 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
Map::mapped_type & getOrError(Map &map, Key const &key, std::string const &error_message)
Definition Algorithm.h:113
std::unique_ptr< Curve > createCurve(BaseLib::ConfigTree const &config, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
Variable convertStringToVariable(std::string const &string)