Skip to content
Snippets Groups Projects
Commit 03fbcd1f authored by Norihiro Watanabe's avatar Norihiro Watanabe
Browse files

move to cpp: TimeDiscretizationBuilder

parent a90e906f
No related branches found
No related tags found
No related merge requests found
/**
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include "TimeDiscretizationBuilder.h"
#include "BaseLib/Error.h"
namespace NumLib
{
std::unique_ptr<TimeDiscretization> createTimeDiscretization(
BaseLib::ConfigTree const& config)
{
using T = std::unique_ptr<TimeDiscretization>;
//! \ogs_file_param{process__time_discretization__type}
auto const type = config.getConfigParameter<std::string>("type");
if (type == "BackwardEuler")
{
using ConcreteTD = BackwardEuler;
return T(new ConcreteTD);
}
else if (type == "ForwardEuler")
{
using ConcreteTD = ForwardEuler;
return T(new ConcreteTD);
}
else if (type == "CrankNicolson")
{
//! \ogs_file_param{process__time_discretization__CrankNicolson__theta}
auto const theta = config.getConfigParameter<double>("theta");
using ConcreteTD = CrankNicolson;
return T(new ConcreteTD(theta));
}
else if (type == "BackwardDifferentiationFormula")
{
//! \ogs_file_param{process__time_discretization__BackwardDifferentiationFormula__order}
auto const order = config.getConfigParameter<unsigned>("order");
using ConcreteTD = BackwardDifferentiationFormula;
return T(new ConcreteTD(order));
}
else
{
OGS_FATAL("Unrecognized time discretization type `%s'", type.c_str());
}
}
}
...@@ -19,42 +19,7 @@ namespace NumLib ...@@ -19,42 +19,7 @@ namespace NumLib
{ {
std::unique_ptr<TimeDiscretization> createTimeDiscretization( std::unique_ptr<TimeDiscretization> createTimeDiscretization(
BaseLib::ConfigTree const& config) BaseLib::ConfigTree const& config);
{
using T = std::unique_ptr<TimeDiscretization>;
//! \ogs_file_param{process__time_discretization__type}
auto const type = config.getConfigParameter<std::string>("type");
if (type == "BackwardEuler")
{
using ConcreteTD = BackwardEuler;
return T(new ConcreteTD);
}
else if (type == "ForwardEuler")
{
using ConcreteTD = ForwardEuler;
return T(new ConcreteTD);
}
else if (type == "CrankNicolson")
{
//! \ogs_file_param{process__time_discretization__CrankNicolson__theta}
auto const theta = config.getConfigParameter<double>("theta");
using ConcreteTD = CrankNicolson;
return T(new ConcreteTD(theta));
}
else if (type == "BackwardDifferentiationFormula")
{
//! \ogs_file_param{process__time_discretization__BackwardDifferentiationFormula__order}
auto const order = config.getConfigParameter<unsigned>("order");
using ConcreteTD = BackwardDifferentiationFormula;
return T(new ConcreteTD(order));
}
else
{
OGS_FATAL("Unrecognized time discretization type `%s'", type.c_str());
}
}
} }
#endif // NUMLIB_TIMEDISCRETIZATION_BUILDER_H #endif // NUMLIB_TIMEDISCRETIZATION_BUILDER_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment