diff --git a/MathLib/ODE/CVodeSolver.cpp b/MathLib/ODE/CVodeSolver.cpp index b5a29582cbc4358b79845e3f983728502b9f7bbd..55e0c68a7d2d6dfb5d362200e3417be81c7fd494 100644 --- a/MathLib/ODE/CVodeSolver.cpp +++ b/MathLib/ODE/CVodeSolver.cpp @@ -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, diff --git a/MathLib/ODE/CVodeSolver.h b/MathLib/ODE/CVodeSolver.h index 1b0252d331f363818d2df103358885a4b004a1e2..81e9418d0472fb5a85dc15203dc65cab2d0fc13e 100644 --- a/MathLib/ODE/CVodeSolver.h +++ b/MathLib/ODE/CVodeSolver.h @@ -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); diff --git a/MathLib/ODE/OdeSolverFactory.h b/MathLib/ODE/OdeSolverFactory.h index eccace280338fcd62cc5bffc10c46aa1b5ef39bb..de5fba09734a4b4e1f72f4203e95e6f9956a18bc 100644 --- a/MathLib/ODE/OdeSolverFactory.h +++ b/MathLib/ODE/OdeSolverFactory.h @@ -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} { }