Skip to content
Snippets Groups Projects
Commit 928801b7 authored by Timo Koch's avatar Timo Koch
Browse files

[gridvars] Unify for stationary and instationary problems

parent 7aa755c3
No related branches found
No related tags found
2 merge requests!1337WIP Fix/dirichlet caching v2,!1306[gridvars] Unify for stationary and instationary problems
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include <memory> #include <memory>
#include <cassert> #include <cassert>
#include <dune/common/deprecated.hh>
namespace Dumux { namespace Dumux {
/*! /*!
...@@ -68,53 +70,53 @@ public: ...@@ -68,53 +70,53 @@ public:
, gridFluxVarsCache_(*problem) , gridFluxVarsCache_(*problem)
{} {}
//! update all variables //! initialize all variables (stationary case)
template<class SolutionVector> template<class SolutionVector>
void update(const SolutionVector& curSol, bool forceFluxCacheUpdate = false) void init(const SolutionVector& curSol)
{ {
// resize and update the volVars with the initial solution // resize and update the volVars with the initial solution
curGridVolVars_.update(*fvGridGeometry_, curSol); curGridVolVars_.update(*fvGridGeometry_, curSol);
// update the flux variables caches // update the flux variables caches (always force flux cache update on initialization)
gridFluxVarsCache_.update(*fvGridGeometry_, curGridVolVars_, curSol, forceFluxCacheUpdate); gridFluxVarsCache_.update(*fvGridGeometry_, curGridVolVars_, curSol, true);
// set the volvars of the previous time step in case we have an instationary problem
// note that this means some memory overhead in the case of enabled caching, however
// this it outweighted by the advantage of having a single grid variables object for
// stationary and instationary problems
prevGridVolVars_ = curGridVolVars_;
} }
//! update all variables after grid adaption //! initialize all variables (instationary case)
template<class SolutionVector> template<class SolutionVector>
void updateAfterGridAdaption(const SolutionVector& curSol) DUNE_DEPRECATED_MSG("Use init(sol) instead. The class now works without modification for stationary and instationary cases.")
void init(const SolutionVector& curSol, const SolutionVector& initSol)
{ {
// update (always force flux cache update as the grid changed) // initialize current volvars and the flux var cache
update(curSol, true); init(initSol);
// for instationary problems also update the variables
// for the previous time step to the new grid
if (!problemIsStationary_)
prevGridVolVars_ = curGridVolVars_;
} }
//! initialize all variables (stationary case) //! update all variables
template<class SolutionVector> template<class SolutionVector>
void init(const SolutionVector& curSol) void update(const SolutionVector& curSol, bool forceFluxCacheUpdate = false)
{ {
// resize and update the volVars with the initial solution // resize and update the volVars with the initial solution
curGridVolVars_.update(*fvGridGeometry_, curSol); curGridVolVars_.update(*fvGridGeometry_, curSol);
// update the flux variables caches (always force flux cache update on initialization) // update the flux variables caches
gridFluxVarsCache_.update(*fvGridGeometry_, curGridVolVars_, curSol, true); gridFluxVarsCache_.update(*fvGridGeometry_, curGridVolVars_, curSol, forceFluxCacheUpdate);
} }
//! initialize all variables (instationary case) //! update all variables after grid adaption
template<class SolutionVector> template<class SolutionVector>
void init(const SolutionVector& curSol, const SolutionVector& initSol) void updateAfterGridAdaption(const SolutionVector& curSol)
{ {
// remember that we have a stationary problem // update (always force flux cache update as the grid changed)
problemIsStationary_ = false; update(curSol, true);
// initialize current volvars and the flux var cache
init(curSol);
// update the old time step vol vars with the initial solution // for instationary problems also update the variables
prevGridVolVars_.update(*fvGridGeometry_, initSol); // for the previous time step to the new grid
prevGridVolVars_ = curGridVolVars_;
} }
/*! /*!
...@@ -123,7 +125,6 @@ public: ...@@ -123,7 +125,6 @@ public:
*/ */
void advanceTimeStep() void advanceTimeStep()
{ {
assert(!problemIsStationary_);
prevGridVolVars_ = curGridVolVars_; prevGridVolVars_ = curGridVolVars_;
} }
...@@ -131,8 +132,6 @@ public: ...@@ -131,8 +132,6 @@ public:
template<class SolutionVector> template<class SolutionVector>
void resetTimeStep(const SolutionVector& solution) void resetTimeStep(const SolutionVector& solution)
{ {
assert(!problemIsStationary_);
// set the new time step vol vars to old vol vars // set the new time step vol vars to old vol vars
curGridVolVars_ = prevGridVolVars_; curGridVolVars_ = prevGridVolVars_;
...@@ -177,8 +176,6 @@ private: ...@@ -177,8 +176,6 @@ private:
GridVolumeVariables prevGridVolVars_; //!< the previous time step's volume variables (primary and secondary variables) GridVolumeVariables prevGridVolVars_; //!< the previous time step's volume variables (primary and secondary variables)
GridFluxVariablesCache gridFluxVarsCache_; //!< the flux variables cache GridFluxVariablesCache gridFluxVarsCache_; //!< the flux variables cache
bool problemIsStationary_ = true;
}; };
} // end namespace Dumux } // end namespace Dumux
......
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