OGS 6.2.0-97-g4a610c866
TimeDiscretizationBuilder.cpp
Go to the documentation of this file.
1 
11 
12 #include "BaseLib/Error.h"
13 
14 namespace NumLib
15 {
16 std::unique_ptr<TimeDiscretization> createTimeDiscretization(
17  BaseLib::ConfigTree const& config)
18 {
20  auto const type = config.getConfigParameter<std::string>("type");
21 
23  if (type == "BackwardEuler")
24  {
25  return std::make_unique<BackwardEuler>();
26  }
28  if (type == "ForwardEuler")
29  {
30  return std::make_unique<ForwardEuler>();
31  }
33  if (type == "CrankNicolson")
34  {
36  auto const theta = config.getConfigParameter<double>("theta");
37  return std::make_unique<CrankNicolson>(theta);
38  }
40  if (type == "BackwardDifferentiationFormula")
41  {
43  auto const order = config.getConfigParameter<unsigned>("order");
44  return std::make_unique<BackwardDifferentiationFormula>(order);
45  }
46 
47  OGS_FATAL("Unrecognized time discretization type `%s'", type.c_str());
48 }
49 } // namespace NumLib
T getConfigParameter(std::string const &param) const
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
std::unique_ptr< TimeDiscretization > createTimeDiscretization(BaseLib::ConfigTree const &config)