diff --git a/dumux/decoupled/2p/diffusion/fvmpfa/fvmpfaopressure2p_new.hh b/dumux/decoupled/2p/diffusion/fvmpfa/fvmpfaopressure2p_new.hh index 75343363bb6c34b7de0323973b9d5bde43074e26..615ab156b4ceff4df6e645e8eeae58811837dad6 100644 --- a/dumux/decoupled/2p/diffusion/fvmpfa/fvmpfaopressure2p_new.hh +++ b/dumux/decoupled/2p/diffusion/fvmpfa/fvmpfaopressure2p_new.hh @@ -598,7 +598,8 @@ void FVMPFAOPressure2P<TypeTag>::storeInteractionVolumeInfo() } //store pointer 1 - interactionVolumes_[globalVertIdx1234].setSubVolumeElement(eIt, 0); + ElementPointer ePtr(*eIt); + interactionVolumes_[globalVertIdx1234].setSubVolumeElement(ePtr, 0); interactionVolumes_[globalVertIdx1234].setIndexOnElement(isIt12->indexInInside(), 0, 0); interactionVolumes_[globalVertIdx1234].setIndexOnElement(isIt14->indexInInside(), 0, 1); diff --git a/dumux/decoupled/2p/diffusion/mimetic/croperator.hh b/dumux/decoupled/2p/diffusion/mimetic/croperator.hh index 6b81d177840e92c27e2fed431bd6224852162e0f..3b025525768d2763019376bae4c4f1ae7db2a4c5 100644 --- a/dumux/decoupled/2p/diffusion/mimetic/croperator.hh +++ b/dumux/decoupled/2p/diffusion/mimetic/croperator.hh @@ -31,7 +31,6 @@ #include<dune/common/geometrytype.hh> #include<dune/grid/common/grid.hh> #include<dune/grid/common/mcmgmapper.hh> -#include<dune/grid/common/referenceelements.hh> #include<dune/istl/bvector.hh> #include<dune/istl/operators.hh> @@ -111,7 +110,6 @@ class CROperatorAssembler typedef typename Grid::template Codim<0>::Entity Entity; typedef typename GridView::template Codim<0>::Iterator Iterator; typedef typename GridView::IndexSet IS; - typedef typename Grid::template Codim<0>::HierarchicIterator HierarchicIterator; typedef typename Grid::template Codim<0>::EntityPointer EEntityPointer; typedef Dune::FieldMatrix<Scalar,1,1> BlockType; typedef Dune::BCRSMatrix<BlockType> MatrixType; @@ -158,8 +156,8 @@ public: for (Iterator it = gridView_.template begin<0>(); it != eendit; ++it) { Dune::GeometryType gt = it->geometry().type(); - const typename Dune::ReferenceElementContainer<Scalar,dim>::value_type& - refelem = Dune::ReferenceElements<Scalar,dim>::general(gt); + const typename Dune::GenericReferenceElementContainer<Scalar,dim>::value_type& + refelem = Dune::GenericReferenceElements<Scalar,dim>::general(gt); // faces, c=1 for (int i = 0; i < refelem.size(1); i++) @@ -193,8 +191,8 @@ public: for (Iterator it = gridView_.template begin<0>(); it!=eendit; ++it) { Dune::GeometryType gt = it->geometry().type(); - const typename Dune::ReferenceElementContainer<Scalar,dim>::value_type& - refelem = Dune::ReferenceElements<Scalar,dim>::general(gt); + const typename Dune::GenericReferenceElementContainer<Scalar,dim>::value_type& + refelem = Dune::GenericReferenceElements<Scalar,dim>::general(gt); // std::cout << "ELEM " << GeometryName(gt) << std::endl; // faces, c=1 diff --git a/dumux/decoupled/2p/diffusion/mimetic/mimeticgroundwater.hh b/dumux/decoupled/2p/diffusion/mimetic/mimeticgroundwater.hh index 8431774f0fb249055d27150b4b168f0a7e43abd5..a040ec8701552bf8606d203aa1aed35e9785d5e6 100644 --- a/dumux/decoupled/2p/diffusion/mimetic/mimeticgroundwater.hh +++ b/dumux/decoupled/2p/diffusion/mimetic/mimeticgroundwater.hh @@ -26,7 +26,6 @@ #include<dune/common/exceptions.hh> #include<dune/grid/common/grid.hh> -#include<dune/grid/common/referenceelements.hh> #include<dune/common/geometrytype.hh> #include<dune/grid/common/quadraturerules.hh> diff --git a/dumux/decoupled/common/impesproblem.hh b/dumux/decoupled/common/impesproblem.hh index a4035250d5c862af2b0d1a75fd8a2d7c24088751..238f6bacc2ff057c4aab718a2a9e1ca2a22a61bf 100644 --- a/dumux/decoupled/common/impesproblem.hh +++ b/dumux/decoupled/common/impesproblem.hh @@ -13,7 +13,6 @@ * * * This program is distributed WITHOUT ANY WARRANTY. * *****************************************************************************/ - #ifndef DUMUX_IMPESPROBLEM_HH #define DUMUX_IMPESPROBLEM_HH @@ -55,9 +54,7 @@ class IMPESProblem { private: typedef typename GET_PROP_TYPE(TypeTag, PTAG(GridView)) GridView; - - enum Episode {}; // the type of an episode of the simulation - typedef Dumux::TimeManager<Episode> TimeManager; + typedef Dumux::TimeManager<TypeTag> TimeManager; typedef Dumux::VtkMultiWriter<GridView> VtkMultiWriter; @@ -96,13 +93,10 @@ public: : gridView_(gridView), bboxMin_(std::numeric_limits<double>::max()), bboxMax_(-std::numeric_limits<double>::max()), - timeManager_(0.0, verbose), + timeManager_(verbose), variables_(gridView), - dt_(0), - resultWriter_(asImp_()->name()) + dt_(0) { - wasRestarted_ = false; - // // calculate the bounding box of the grid view // VertexIterator vIt = gridView.template begin<dim>(); // const VertexIterator vEndIt = gridView.template end<dim>(); @@ -131,23 +125,6 @@ public: */ // \{ - /*! - * \brief Start the simulation procedure. - * - * This method is usually called by the main() function and simply - * uses Dumux::TimeManager::runSimulation() to do the actual - * work. - */ - bool simulate(Scalar dtInitial, Scalar tEnd) - { - // set the initial time step and the time where the simulation ends - timeManager_.setEndTime(tEnd); - timeManager_.setTimeStepSize(dtInitial); - timeManager_.runSimulation(*asImp_()); - return true; - }; - - /*! * \brief Called by the Dumux::TimeManager in order to * initialize the problem. @@ -156,15 +133,12 @@ public: { // set the initial condition of the model model().initial(); - - // write the inital solution to disk - writeCurrentResult_(); } /*! * \brief Called by the time manager before the time integration. */ - void timeStepBegin() + void preProcess() {} /*! @@ -206,10 +180,8 @@ public: * This is used to do some janitorial tasks like writing the * current solution to disk. */ - void timeStepEnd() + void postProcess() { - asImp_()->writeCurrentResult_(); - wasRestarted_ = false; }; /*! @@ -240,11 +212,11 @@ public: * steps. This file is intented to be overwritten by the * implementation. */ - bool shouldWriteRestartFile() const + bool doSerialize() const { - return !restarted() && - timeManager().stepNum() > 0 && - (timeManager().stepNum() % 5 == 0); + return + timeManager().timeStepIndex() > 0 && + (timeManager().timeStepIndex() % 5 == 0); } /*! @@ -255,8 +227,8 @@ public: * very time step. This file is intented to be overwritten by the * implementation. */ - bool shouldWriteOutputFile() const - { return !restarted(); } + bool doOutput() const + { return true; } // \} @@ -366,19 +338,6 @@ public: */ // \{ - /*! - * \brief Returns true, if the current state of the problem was - * loaded from a restart file. - */ - bool restarted() const - { return wasRestarted_; } - - void restarted(bool setRestarted) - { - wasRestarted_ = setRestarted; - return ; - } - /*! * \brief This method writes the complete state of the problem * to the harddisk. @@ -390,12 +349,10 @@ public: */ void serialize() { - typedef Dumux::Restart<GridView> Restarter; + typedef Dumux::Restart Restarter; Restarter res; - res.serializeBegin(gridView(), - asImp_()->name(), - timeManager_.time()); + res.serializeBegin(*asImp_()); std::cerr << "Serialize to file " << res.fileName() << "\n"; timeManager_.serialize(res); @@ -413,12 +370,10 @@ public: */ void deserialize(double t) { - typedef Dumux::Restart<GridView> Restarter; + typedef Dumux::Restart Restarter; Restarter res; - res.deserializeBegin(gridView(), - asImp_()->name(), - t); + res.deserializeBegin(*asImp_(), t); std::cerr << "Deserialize from file " << res.fileName() << "\n"; timeManager_.deserialize(res); @@ -426,10 +381,20 @@ public: model().deserialize(res); res.deserializeEnd(); - - wasRestarted_ = true; }; + //! Write the fields current solution into an VTK output file. + void writeOutput() + { + if (gridView().comm().rank() == 0) + std::cout << "Writing result file for current time step\n"; + + resultWriter_.beginTimestep(timeManager_.time() + timeManager_.timeStepSize(), + gridView()); + model().addOutputVtkFields(resultWriter_); + resultWriter_.endTimestep(); + } + // \} protected: @@ -441,26 +406,6 @@ protected: const Implementation *asImp_() const { return static_cast<const Implementation *>(this); } - //! Write the fields current solution into an VTK output file. - void writeCurrentResult_() - { - // write the current result to disk - if (asImp_()->shouldWriteOutputFile()) { - if (gridView().comm().rank() == 0) - std::cout << "Writing result file for current time step\n"; - - resultWriter_.beginTimestep(timeManager_.time(), - gridView()); - - model().addOutputVtkFields(resultWriter_); - resultWriter_.endTimestep(); - } - - // write restart file if necessary - if (asImp_()->shouldWriteRestartFile()) - serialize(); - } - VtkMultiWriter& resultWriter() { return resultWriter_; @@ -491,8 +436,6 @@ private: IMPESModel* model_; VtkMultiWriter resultWriter_; - - bool wasRestarted_; }; // definition of the static class member simname_, // which is necessary because it is of type string. diff --git a/dumux/decoupled/common/onemodelproblem.hh b/dumux/decoupled/common/onemodelproblem.hh index 104ba89ff33b72e776fa2867bb3e2213c4542884..2b681e802fa9ffcad68759c68dc26be47e2bbdd5 100644 --- a/dumux/decoupled/common/onemodelproblem.hh +++ b/dumux/decoupled/common/onemodelproblem.hh @@ -57,8 +57,7 @@ class OneModelProblem private: typedef typename GET_PROP_TYPE(TypeTag, PTAG(GridView)) GridView; - enum Episode {}; // the type of an episode of the simulation - typedef Dumux::TimeManager<Episode> TimeManager; + typedef Dumux::TimeManager<TypeTag> TimeManager; typedef Dumux::VtkMultiWriter<GridView> VtkMultiWriter; @@ -95,7 +94,7 @@ public: : gridView_(gridView), bboxMin_(std::numeric_limits<double>::max()), bboxMax_(-std::numeric_limits<double>::max()), - timeManager_(0.0, verbose), + timeManager_(verbose), variables_(gridView), dt_(0), resultWriter_(asImp_()->name()) @@ -360,12 +359,10 @@ public: */ void serialize() { - typedef Dumux::Restart<GridView> Restarter; + typedef Dumux::Restart Restarter; Restarter res; - res.serializeBegin(gridView(), - asImp_()->name(), - timeManager_.time()); + res.serializeBegin(*asImp_()); std::cerr << "Serialize to file " << res.fileName() << "\n"; timeManager_.serialize(res); @@ -383,7 +380,7 @@ public: */ void deserialize(double t) { - typedef Dumux::Restart<GridView> Restarter; + typedef Dumux::Restart Restarter; Restarter res; res.deserializeBegin(gridView(), diff --git a/test/decoupled/1p/benchmarkresult.hh b/test/decoupled/1p/benchmarkresult.hh index 04e12045244f51e32dd0b70cf075bc9cc4f7b28b..dd0476f9d5eab30606aaab7c4bb29f5222ee3bb3 100644 --- a/test/decoupled/1p/benchmarkresult.hh +++ b/test/decoupled/1p/benchmarkresult.hh @@ -132,7 +132,7 @@ struct BenchmarkResult // cell center in reference element const Dune::FieldVector<ct,dim>& - local = Dune::ReferenceElements<ct,dim>::general(gt).position(0,0); + local = Dune::GenericReferenceElements<ct,dim>::general(gt).position(0,0); // get global coordinate of cell center Dune::FieldVector<ct,dim> global = geometry.global(local); @@ -360,7 +360,7 @@ struct ResultEvaluation Dune::GeometryType geomType = geometry.type(); - const Dune::FieldVector<Scalar,dim>& local = Dune::ReferenceElements<Scalar,dim>::general(geomType).position(0, 0); + const Dune::FieldVector<Scalar,dim>& local = Dune::GenericReferenceElements<Scalar,dim>::general(geomType).position(0, 0); Dune::FieldVector<Scalar,dim> global = geometry.global(local); Scalar volume = geometry.volume(); @@ -537,11 +537,11 @@ struct ResultEvaluation Dune::GeometryType geomType = geometry.type(); - const Dune::FieldVector<Scalar,dim>& local = Dune::ReferenceElements<Scalar,dim>::general(geomType).position(0, 0); + const Dune::FieldVector<Scalar,dim>& local = Dune::GenericReferenceElements<Scalar,dim>::general(geomType).position(0, 0); Dune::FieldVector<Scalar,dim> global = geometry.global(local); Scalar volume = geometry.integrationElement(local) - *Dune::ReferenceElements<Scalar,dim>::general(geomType).volume(); + *Dune::GenericReferenceElements<Scalar,dim>::general(geomType).volume(); int eIdx = elementMapper.map(element); @@ -572,7 +572,7 @@ struct ResultEvaluation i++; // center in face's reference element - const Dune::FieldVector<Scalar,dim-1>& faceLocalNm1 = Dune::ReferenceElements<Scalar,dim-1>::general(gtf).position(0,0); + const Dune::FieldVector<Scalar,dim-1>& faceLocalNm1 = Dune::GenericReferenceElements<Scalar,dim-1>::general(gtf).position(0,0); // center of face in global coordinates Dune::FieldVector<Scalar,dim> faceGlobal = is->geometry().global(faceLocalNm1); diff --git a/test/decoupled/2p/test_2p.cc b/test/decoupled/2p/test_2p.cc index 070a70f5097120019307637e29722c1e8a8e54e2..14ca61e8fec3a7328bd098d5efe35cbb7fe559e2 100644 --- a/test/decoupled/2p/test_2p.cc +++ b/test/decoupled/2p/test_2p.cc @@ -95,10 +95,8 @@ int main(int argc, char** argv) if (restart) problem.deserialize(restartTime); - // run the simulation - if (!problem.simulate(dt, tEnd)) - return 2; - + problem.timeManager().init(problem, 0, dt, tEnd, !restart); + problem.timeManager().run(); return 0; } catch (Dune::Exception &e) {