Skip to content
Snippets Groups Projects
Commit 2058bb6f authored by wenqing's avatar wenqing Committed by Dmitri Naumov
Browse files

[NumLib] Moved the definitions of two member functions of TimeDiscretization to cpp file

parent 1ce8583f
No related branches found
No related tags found
No related merge requests found
...@@ -47,4 +47,28 @@ double computeRelativeChangeFromPreviousTimestep(GlobalVector const& x, ...@@ -47,4 +47,28 @@ double computeRelativeChangeFromPreviousTimestep(GlobalVector const& x,
// Only norm_x is close to zero // Only norm_x is close to zero
return norm_dx / std::numeric_limits<double>::epsilon(); return norm_dx / std::numeric_limits<double>::epsilon();
} }
void TimeDiscretization::getXdot(GlobalVector const& x_at_new_timestep,
GlobalVector const& x_old,
GlobalVector& xdot) const
{
namespace LinAlg = MathLib::LinAlg;
double const dt = getCurrentTimeIncrement();
// xdot = 1/dt * x_at_new_timestep - x_old
getWeightedOldX(xdot, x_old);
LinAlg::axpby(xdot, 1. / dt, -1.0, x_at_new_timestep);
}
void BackwardEuler::getWeightedOldX(GlobalVector& y,
GlobalVector const& x_old) const
{
namespace LinAlg = MathLib::LinAlg;
// y = x_old / delta_t
LinAlg::copy(x_old, y);
LinAlg::scale(y, 1.0 / _delta_t);
}
} // end of namespace NumLib } // end of namespace NumLib
...@@ -132,16 +132,7 @@ public: ...@@ -132,16 +132,7 @@ public:
//! \f$. //! \f$.
void getXdot(GlobalVector const& x_at_new_timestep, void getXdot(GlobalVector const& x_at_new_timestep,
GlobalVector const& x_old, GlobalVector const& x_old,
GlobalVector& xdot) const GlobalVector& xdot) const;
{
namespace LinAlg = MathLib::LinAlg;
double const dt = getCurrentTimeIncrement();
// xdot = 1/dt * x_at_new_timestep - x_old
getWeightedOldX(xdot, x_old);
LinAlg::axpby(xdot, 1. / dt, -1.0, x_at_new_timestep);
}
//! Returns \f$ x_O \f$. //! Returns \f$ x_O \f$.
virtual void getWeightedOldX( virtual void getWeightedOldX(
...@@ -155,7 +146,6 @@ class BackwardEuler final : public TimeDiscretization ...@@ -155,7 +146,6 @@ class BackwardEuler final : public TimeDiscretization
{ {
public: public:
void setInitialState(const double t0) override { _t = t0; } void setInitialState(const double t0) override { _t = t0; }
void nextTimestep(const double t, const double delta_t) override void nextTimestep(const double t, const double delta_t) override
{ {
_t = t; _t = t;
...@@ -165,14 +155,7 @@ public: ...@@ -165,14 +155,7 @@ public:
double getCurrentTime() const override { return _t; } double getCurrentTime() const override { return _t; }
double getCurrentTimeIncrement() const override { return _delta_t; } double getCurrentTimeIncrement() const override { return _delta_t; }
void getWeightedOldX(GlobalVector& y, void getWeightedOldX(GlobalVector& y,
GlobalVector const& x_old) const override GlobalVector const& x_old) const override;
{
namespace LinAlg = MathLib::LinAlg;
// y = x_old / delta_t
LinAlg::copy(x_old, y);
LinAlg::scale(y, 1.0 / _delta_t);
}
private: private:
double _t = std::numeric_limits<double>::quiet_NaN(); //!< \f$ t_C \f$ double _t = std::numeric_limits<double>::quiet_NaN(); //!< \f$ t_C \f$
......
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