From 56f1822dea3044abb18de499c869112bc4137ea2 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Sun, 21 May 2017 11:42:25 +0200 Subject: [PATCH] [NL] Use make_unique in TimeDiscretizationBuilder. Call make_unique for specific type. Add documentation for the CrankNicolson and BDF. --- NumLib/ODESolver/TimeDiscretizationBuilder.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/NumLib/ODESolver/TimeDiscretizationBuilder.cpp b/NumLib/ODESolver/TimeDiscretizationBuilder.cpp index 5fede6cd827..f07187b6ca6 100644 --- a/NumLib/ODESolver/TimeDiscretizationBuilder.cpp +++ b/NumLib/ODESolver/TimeDiscretizationBuilder.cpp @@ -16,36 +16,32 @@ namespace NumLib std::unique_ptr<TimeDiscretization> createTimeDiscretization( BaseLib::ConfigTree const& config) { - using T = std::unique_ptr<TimeDiscretization>; - //! \ogs_file_param{prj__time_loop__processes__process__time_discretization__type} auto const type = config.getConfigParameter<std::string>("type"); if (type == "BackwardEuler") { //! \ogs_file_param_special{prj__time_loop__processes__process__time_discretization__BackwardEuler} - using ConcreteTD = BackwardEuler; - return T(new ConcreteTD); + return std::make_unique<BackwardEuler>(); } else if (type == "ForwardEuler") { //! \ogs_file_param_special{prj__time_loop__processes__process__time_discretization__ForwardEuler} - using ConcreteTD = ForwardEuler; - return T(new ConcreteTD); + return std::make_unique<ForwardEuler>(); } else if (type == "CrankNicolson") { //! \ogs_file_param{prj__time_loop__processes__process__time_discretization__CrankNicolson__theta} auto const theta = config.getConfigParameter<double>("theta"); - using ConcreteTD = CrankNicolson; - return T(new ConcreteTD(theta)); + //! \ogs_file_param_special{prj__time_loop__processes__process__time_discretization__CrankNicolson} + return std::make_unique<CrankNicolson>(theta); } else if (type == "BackwardDifferentiationFormula") { //! \ogs_file_param{prj__time_loop__processes__process__time_discretization__BackwardDifferentiationFormula__order} auto const order = config.getConfigParameter<unsigned>("order"); - using ConcreteTD = BackwardDifferentiationFormula; - return T(new ConcreteTD(order)); + //! \ogs_file_param_special{prj__time_loop__processes__process__time_discretization__BackwardDifferentiationFormula} + return std::make_unique<BackwardDifferentiationFormula>(order); } else { -- GitLab