Skip to content
Snippets Groups Projects
Commit 8f82fd28 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[MaL] Move init() into ctor of ode solver classes.

parent e875dd57
No related branches found
No related tags found
No related merge requests found
......@@ -83,8 +83,8 @@ class CVodeSolverImpl
"cvode's realtype is not the same as double");
public:
CVodeSolverImpl(BaseLib::ConfigTree const& config);
void init(const unsigned num_equations);
CVodeSolverImpl(BaseLib::ConfigTree const& config,
unsigned const num_equations);
friend class CVodeSolver;
~CVodeSolverImpl();
......@@ -119,7 +119,8 @@ private:
int _nonlinear_solver_iteration = CV_FUNCTIONAL;
};
CVodeSolverImpl::CVodeSolverImpl(const BaseLib::ConfigTree& config)
CVodeSolverImpl::CVodeSolverImpl(const BaseLib::ConfigTree& config,
const unsigned num_equations)
{
if (auto const param =
config.getConfParamOptional<std::string>("linear_multistep_method"))
......@@ -160,10 +161,7 @@ CVodeSolverImpl::CVodeSolverImpl(const BaseLib::ConfigTree& config)
std::abort();
}
}
}
void CVodeSolverImpl::init(const unsigned num_equations)
{
_y = N_VNew_Serial(num_equations);
_abstol = N_VNew_Serial(num_equations);
_num_equations = num_equations;
......@@ -306,14 +304,10 @@ CVodeSolverImpl::~CVodeSolverImpl()
}
}
CVodeSolverInternal::CVodeSolverInternal(BaseLib::ConfigTree const& config)
: _impl{new CVodeSolverImpl{config}}
{
}
void CVodeSolverInternal::init(const unsigned num_equations)
CVodeSolverInternal::CVodeSolverInternal(BaseLib::ConfigTree const& config,
unsigned const num_equations)
: _impl{new CVodeSolverImpl{config, num_equations}}
{
_impl->init(num_equations);
}
void CVodeSolverInternal::setTolerance(const double* abstol,
......
......@@ -27,8 +27,8 @@ class CVodeSolverImpl;
class CVodeSolverInternal
{
protected:
CVodeSolverInternal(BaseLib::ConfigTree const& config);
void init(const unsigned num_equations);
CVodeSolverInternal(BaseLib::ConfigTree const& config,
unsigned const num_equations);
void setTolerance(double const* const abstol, const double reltol);
void setTolerance(const double abstol, const double reltol);
......
......@@ -145,7 +145,6 @@ public:
void setFunction(Function f, JacobianFunction df,
FunctionArguments&... args) override
{
Implementation::init(NumEquations);
Implementation::setFunction(
std::unique_ptr<
detail::Handles<NumEquations, FunctionArguments...>>{
......@@ -187,7 +186,7 @@ private:
/// instances of this class shall only be constructed by
/// the friend function listed below
ConcreteOdeSolver(BaseLib::ConfigTree const& config)
: Implementation{config}
: Implementation{config, NumEquations}
{
}
......
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