Commit 70b9f25c authored by Santiago Ospina's avatar Santiago Ospina

[Common] Fix methods 'back' and 'front' in grid function containers

parent ce47ce48
......@@ -254,34 +254,35 @@ public:
/*-----------------------------------------------------------------------*//**
* @brief Front of the queue.
*
* @return Reference the most resent pair (grid function,time) on the
* @return Reference the oldest pair (grid function,time) on the
* container.
*
*/
reference front() {return _list.back();}
reference front() {return _list.front();}
/*-----------------------------------------------------------------------*//**
* @brief Front of the queue.
*
* @return Constant reference the most resent pair (grid function,time) on
* the container.
* @return Reference the oldest pair (grid function,time) on the
* container.
*/
const_reference front() const {return _list.back();}
const_reference front() const {return _list.front();}
/*-----------------------------------------------------------------------*//**
* @brief Back of the queue.
*
* @return Reference the oldest pair (grid function,time) on the
* @return Reference the most recent pair (grid function,time) on the
* container.
*/
reference back() {return _list.front();}
reference back() {return _list.back();}
/*-----------------------------------------------------------------------*//**
* @brief Back of the queue.
*
* @return Constant reference the oldest pair (grid function,time) on the
*
* @return Reference the most recent pair (grid function,time) on the
* container.
*/
const_reference back() const {return _list.front();}
const_reference back() const {return _list.back();}
/*-----------------------------------------------------------------------*//**
* @brief Push a new pair to the container.
......@@ -418,7 +419,7 @@ protected:
void check_new_time(const TF& time ) const
{
if (not _list.empty()){
const auto& last_time = front().second;
const auto& last_time = back().second;
if (not Dune::FloatCmp::gt(time,last_time))
DUNE_THROW(Dune::InvalidStateException,
"New time " << time << " value is invalid!");
......@@ -433,8 +434,8 @@ protected:
*/
void check_in_range_time(const TF& time ) const
{
const auto& first_time = back().second;
const auto& last_time = front().second;
const auto& first_time = front().second;
const auto& last_time = back().second;
if (Dune::FloatCmp::lt(time,first_time))
DUNE_THROW(Dune::InvalidStateException,
"time below the range ("
......
......@@ -47,18 +47,26 @@ bool test_container(GV& gv)
} catch (...) {}
gf_container.pop();
if (Dune::FloatCmp::ne(gf_container.back().second,1.0))
if (Dune::FloatCmp::ne(gf_container.front().second,1.0))
failed |= true;
if (Dune::FloatCmp::ne(gf_container.back().second,4.0))
failed |= true;
gf_container.pop();
if (Dune::FloatCmp::ne(gf_container.back().second,2.0))
if (Dune::FloatCmp::ne(gf_container.front().second,2.0))
failed |= true;
if (Dune::FloatCmp::ne(gf_container.back().second,4.0))
failed |= true;
gf_container.pop();
if (Dune::FloatCmp::ne(gf_container.back().second,3.0))
if (Dune::FloatCmp::ne(gf_container.front().second,3.0))
failed |= true;
if (Dune::FloatCmp::ne(gf_container.back().second,4.0))
failed |= true;
gf_container.pop();
if (Dune::FloatCmp::ne(gf_container.front().second,4.0))
failed |= true;
if (Dune::FloatCmp::ne(gf_container.back().second,4.0))
failed |= true;
......@@ -66,6 +74,8 @@ bool test_container(GV& gv)
if (not gf_container.empty())
failed |= true;
// gf_container.front(); // undefined behavior
// gf_container.back(); // undefined behavior
// check instationary grid function capabilities
gf_container.push(gf0,0.0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment