OGS 6.1.0-1699-ge946d4c5f
CreatePiecewiseLinearCurve-impl.h
Go to the documentation of this file.
1 
14 
15 #include "BaseLib/Error.h"
16 #include "BaseLib/ConfigTree.h"
17 
18 namespace MathLib
19 {
20 template <typename CurveType>
21 std::unique_ptr<CurveType> createPiecewiseLinearCurve(
22  BaseLib::ConfigTree const& config)
23 {
24  auto x =
26  config.getConfigParameter<std::vector<double>>("coords");
27  auto y =
29  config.getConfigParameter<std::vector<double>>("values");
30 
31  if (x.empty() || y.empty())
32  {
33  OGS_FATAL("The given coordinates or values vector is empty.");
34  }
35  if (x.size() != y.size())
36  {
37  OGS_FATAL(
38  "The given coordinates and values vector sizes are "
39  "different.");
40  }
41  return std::make_unique<CurveType>(std::move(x), std::move(y));
42 }
43 }
T getConfigParameter(std::string const &param) const
#define OGS_FATAL(fmt,...)
Definition: Error.h:71
std::unique_ptr< CurveType > createPiecewiseLinearCurve(BaseLib::ConfigTree const &config)