Skip to content

Commit

Permalink
[NL] Rename computeRelativeChangeFromPreviousTimestep() to computeRel…
Browse files Browse the repository at this point in the history
…ativeNorm()
  • Loading branch information
TomFischer committed Nov 28, 2023
1 parent e4e449c commit 9b058af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
10 changes: 5 additions & 5 deletions NumLib/ODESolver/TimeDiscretization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

namespace NumLib
{
double computeRelativeChangeFromPreviousTimestep(GlobalVector const& x,
GlobalVector const& x_old,
MathLib::VecNormType norm_type)
double computeRelativeNorm(GlobalVector const& x,
GlobalVector const& x_prev,
MathLib::VecNormType norm_type)
{
if (norm_type == MathLib::VecNormType::INVALID)
{
Expand All @@ -28,8 +28,8 @@ double computeRelativeChangeFromPreviousTimestep(GlobalVector const& x,
GlobalVector dx;
MathLib::LinAlg::copy(x, dx); // copy x to dx.

// dx = x - x_old --> x - dx --> dx
MathLib::LinAlg::axpy(dx, -1.0, x_old);
// dx = x - x_prev --> x - dx --> dx
MathLib::LinAlg::axpy(dx, -1.0, x_prev);
const double norm_dx = MathLib::LinAlg::norm(dx, norm_type);

const double norm_x = MathLib::LinAlg::norm(x, norm_type);
Expand Down
16 changes: 7 additions & 9 deletions NumLib/ODESolver/TimeDiscretization.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@
namespace NumLib
{
/**
* Compute and return the relative change of solutions between two
* successive time steps by \f$ e_n = \|u^{n+1}-u^{n}\|/\|u^{n+1}\| \f$.
* Compute and return the relative norm of solutions between two
* successive time steps by \f$ \|u^{n+1}-u^{n}\|/\|u^{n+1}\| \f$.
*
* \param x The current solution
* \param x_old The previous solution
* \param x_prev The previous solution
* \param norm_type The norm type of global vector
* \return \f$ e_n = \|u^{n+1}-u^{n}\|/\|u^{n+1}\| \f$.
*
* \return \f$ \|u^{n+1}-u^{n}\|/\|u^{n+1}\| \f$.
*/
double computeRelativeChangeFromPreviousTimestep(
GlobalVector const& x,
GlobalVector const& x_old,
MathLib::VecNormType norm_type);
double computeRelativeNorm(GlobalVector const& x,
GlobalVector const& x_prev,
MathLib::VecNormType norm_type);

//! \addtogroup ODESolver
//! @{
Expand Down
2 changes: 1 addition & 1 deletion ProcessLib/TimeLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ double TimeLoop::computeRelativeSolutionChangeFromPreviousTimestep(
: MathLib::VecNormType::NORM2;

const double solution_error =
NumLib::computeRelativeChangeFromPreviousTimestep(x, x_prev, norm_type);
NumLib::computeRelativeNorm(x, x_prev, norm_type);
return solution_error;
}

Expand Down

0 comments on commit 9b058af

Please sign in to comment.