Skip to content
Snippets Groups Projects
Commit 8ea736c2 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

Merge branch 'feature/update-gridvariables-aftergridadaption' into 'master'

Feature/update gridvariables aftergridadaption

See merge request !971
parents 0e165057 9d642684
No related branches found
No related tags found
1 merge request!971Feature/update gridvariables aftergridadaption
...@@ -69,13 +69,26 @@ public: ...@@ -69,13 +69,26 @@ public:
//! update all variables //! update all variables
template<class SolutionVector> template<class SolutionVector>
void update(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 // update the flux variables caches
gridFluxVarsCache_.update(*fvGridGeometry_, curGridVolVars_, curSol); gridFluxVarsCache_.update(*fvGridGeometry_, curGridVolVars_, curSol, forceFluxCacheUpdate);
}
//! update all variables after grid adaption
template<class SolutionVector>
void updateAfterGridAdaption(const SolutionVector& curSol)
{
// update (always force flux cache update as the grid changed)
update(curSol, true);
// 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) //! initialize all variables (stationary case)
...@@ -85,7 +98,7 @@ public: ...@@ -85,7 +98,7 @@ public:
// 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, true); gridFluxVarsCache_.update(*fvGridGeometry_, curGridVolVars_, curSol, true);
} }
...@@ -93,11 +106,11 @@ public: ...@@ -93,11 +106,11 @@ public:
template<class SolutionVector> template<class SolutionVector>
void init(const SolutionVector& curSol, const SolutionVector& initSol) void init(const SolutionVector& curSol, const SolutionVector& initSol)
{ {
// resize and update the volVars with the initial solution // remember that we have a stationary problem
curGridVolVars_.update(*fvGridGeometry_, curSol); problemIsStationary_ = false;
// update the flux variables caches // initialize current volvars and the flux var cache
gridFluxVarsCache_.update(*fvGridGeometry_, curGridVolVars_, curSol, true); init(curSol);
// update the old time step vol vars with the initial solution // update the old time step vol vars with the initial solution
prevGridVolVars_.update(*fvGridGeometry_, initSol); prevGridVolVars_.update(*fvGridGeometry_, initSol);
...@@ -109,6 +122,7 @@ public: ...@@ -109,6 +122,7 @@ public:
*/ */
void advanceTimeStep() void advanceTimeStep()
{ {
assert(!problemIsStationary_);
prevGridVolVars_ = curGridVolVars_; prevGridVolVars_ = curGridVolVars_;
} }
...@@ -116,6 +130,8 @@ public: ...@@ -116,6 +130,8 @@ 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_;
...@@ -141,11 +157,17 @@ public: ...@@ -141,11 +157,17 @@ public:
//! return the volume variables of the previous time step (for instationary problems) //! return the volume variables of the previous time step (for instationary problems)
const GridVolumeVariables& prevGridVolVars() const const GridVolumeVariables& prevGridVolVars() const
{ return prevGridVolVars_; } {
assert(!problemIsStationary_);
return prevGridVolVars_;
}
//! return the volume variables of the previous time step (for instationary problems) //! return the volume variables of the previous time step (for instationary problems)
GridVolumeVariables& prevGridVolVars() GridVolumeVariables& prevGridVolVars()
{ return prevGridVolVars_; } {
assert(!problemIsStationary_);
return prevGridVolVars_;
}
protected: protected:
...@@ -156,6 +178,8 @@ private: ...@@ -156,6 +178,8 @@ 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
......
...@@ -155,8 +155,8 @@ int main(int argc, char** argv) try ...@@ -155,8 +155,8 @@ int main(int argc, char** argv) try
// update grid data after adaption // update grid data after adaption
if (wasAdapted) if (wasAdapted)
{ {
xOld = x; //!< Overwrite the old solution with the new (resized & interpolated) one xOld = x; //!< Overwrite the old solution with the new (resized & interpolated) one
gridVariables->init(x, xOld); //!< Initialize the secondary variables to the new (and "new old") solution gridVariables->updateAfterGridAdaption(x); //!< Initialize the secondary variables to the new (and "new old") solution
problem->computePointSourceMap(); //!< Update the point source map problem->computePointSourceMap(); //!< Update the point source map
} }
} }
...@@ -171,8 +171,8 @@ int main(int argc, char** argv) try ...@@ -171,8 +171,8 @@ int main(int argc, char** argv) try
// update grid data after adaption // update grid data after adaption
if (wasAdapted) if (wasAdapted)
{ {
xOld = x; //!< Overwrite the old solution with the new (resized & interpolated) one xOld = x; //!< Overwrite the old solution with the new (resized & interpolated) one
gridVariables->init(x, xOld); //!< Initialize the secondary variables to the new (and "new old") solution gridVariables->updateAfterGridAdaption(x); //!< Initialize the secondary variables to the new (and "new old") solution
problem->computePointSourceMap(); //!< Update the point source map problem->computePointSourceMap(); //!< Update the point source map
} }
...@@ -226,10 +226,10 @@ int main(int argc, char** argv) try ...@@ -226,10 +226,10 @@ int main(int argc, char** argv) try
if (wasAdapted) if (wasAdapted)
{ {
// Note that if we were using point sources, we would have to update the map here as well // Note that if we were using point sources, we would have to update the map here as well
xOld = x; //!< Overwrite the old solution with the new (resized & interpolated) one xOld = x; //!< Overwrite the old solution with the new (resized & interpolated) one
assembler->setJacobianPattern(); //!< Tell the assembler to resize the matrix and set pattern assembler->setJacobianPattern(); //!< Tell the assembler to resize the matrix and set pattern
assembler->setResidualSize(); //!< Tell the assembler to resize the residual assembler->setResidualSize(); //!< Tell the assembler to resize the residual
gridVariables->init(x, xOld); //!< Initialize the secondary variables to the new (and "new old") solution gridVariables->updateAfterGridAdaption(x); //!< Initialize the secondary variables to the new (and "new old") solution
problem->computePointSourceMap(); //!< Update the point source map problem->computePointSourceMap(); //!< Update the point source map
} }
} }
......
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