Skip to content
Snippets Groups Projects
Commit 034e434b authored by Christoph Lehmann's avatar Christoph Lehmann Committed by Dmitri Naumov
Browse files

[MaL] solve returns success code

parent 02dd458b
No related branches found
No related tags found
No related merge requests found
...@@ -93,7 +93,7 @@ private: ...@@ -93,7 +93,7 @@ private:
void setFunction(std::unique_ptr<detail::FunctionHandles>&& f); void setFunction(std::unique_ptr<detail::FunctionHandles>&& f);
void preSolve(); void preSolve();
void solve(const double t_end); bool solve(const double t_end);
double const* getSolution() const { return NV_DATA_S(_y); } double const* getSolution() const { return NV_DATA_S(_y); }
double getTime() const { return _t; } double getTime() const { return _t; }
...@@ -263,12 +263,17 @@ void CVodeSolverImpl::preSolve() ...@@ -263,12 +263,17 @@ void CVodeSolverImpl::preSolve()
} }
} }
void CVodeSolverImpl::solve(const double t_end) bool CVodeSolverImpl::solve(const double t_end)
{ {
realtype t_reached; realtype t_reached;
check_error("CVode solve", check_error("CVode solve",
CVode(_cvode_mem, t_end, _y, &t_reached, CV_NORMAL)); CVode(_cvode_mem, t_end, _y, &t_reached, CV_NORMAL));
_t = t_reached; _t = t_reached;
// check_error asserts that t_end == t_reached and that solving the ODE
// went fine. Otherwise the program will be aborted. Therefore, we don't
// have to check manually for errors here and can always savely return true.
return true;
} }
void CVodeSolverImpl::getYDot(const double t, double const* const y, void CVodeSolverImpl::getYDot(const double t, double const* const y,
...@@ -325,9 +330,9 @@ void CVodeSolver::preSolve() ...@@ -325,9 +330,9 @@ void CVodeSolver::preSolve()
_impl->preSolve(); _impl->preSolve();
} }
void CVodeSolver::solve(const double t_end) bool CVodeSolver::solve(const double t_end)
{ {
_impl->solve(t_end); return _impl->solve(t_end);
} }
double const* CVodeSolver::getSolution() const double const* CVodeSolver::getSolution() const
......
...@@ -39,7 +39,7 @@ protected: ...@@ -39,7 +39,7 @@ protected:
void setIC(const double t0, double const* const y0); void setIC(const double t0, double const* const y0);
void preSolve(); void preSolve();
void solve(const double t_end); bool solve(const double t_end);
double const* getSolution() const; double const* getSolution() const;
double getTime() const; double getTime() const;
......
...@@ -83,7 +83,7 @@ public: ...@@ -83,7 +83,7 @@ public:
} }
void preSolve() override { Implementation::preSolve(); } void preSolve() override { Implementation::preSolve(); }
void solve(const double t) override { Implementation::solve(t); } bool solve(const double t) override { return Implementation::solve(t); }
MappedConstVector<NumEquations> getSolution() const override MappedConstVector<NumEquations> getSolution() const override
{ {
return MappedConstVector<NumEquations>{Implementation::getSolution()}; return MappedConstVector<NumEquations>{Implementation::getSolution()};
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
Eigen::Matrix<double, NumEquations, 1, Eigen::ColMajor> const& y0) = 0; Eigen::Matrix<double, NumEquations, 1, Eigen::ColMajor> const& y0) = 0;
virtual void preSolve() = 0; virtual void preSolve() = 0;
virtual void solve(const double t) = 0; virtual bool solve(const double t) = 0;
virtual unsigned getNumEquations() const { return NumEquations; } virtual unsigned getNumEquations() const { return NumEquations; }
virtual MappedConstVector<NumEquations> getSolution() const = 0; virtual MappedConstVector<NumEquations> getSolution() const = 0;
......
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