From e4a5d9420c4b5cdab57994d04f2f72a6150cfa64 Mon Sep 17 00:00:00 2001 From: Markus Wolff <markus.wolff@twt-gmbh.de> Date: Wed, 5 Jun 2013 06:42:31 +0000 Subject: [PATCH] Decoupled 2p models can now use local sub-time-stepping also in parallel. Additionally, model-specific stuff is removed from the functions needed for the local sub-time-stepping in the more general decoupled part. git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@10814 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- .../decoupled/2p/diffusion/fv/fvpressure2p.hh | 13 +++++++ .../2p/diffusion/fv/fvpressure2padaptive.hh | 7 ++++ .../lmethod/fvmpfal2pfaboundvelocity2p.hh | 13 +++++++ .../fvmpfal2pfaboundvelocity2padaptive.hh | 13 +++++++ .../omethod/fvmpfao2pfaboundvelocity2p.hh | 13 +++++++ .../fvmpfa/omethod/fvmpfaovelocity2p.hh | 15 ++++++++ dumux/decoupled/common/fv/fvpressure.hh | 5 +++ dumux/decoupled/common/fv/fvtransport.hh | 36 ++++++++++++++++++- dumux/decoupled/common/fv/fvvelocity.hh | 2 -- dumux/decoupled/common/impet.hh | 14 +------- 10 files changed, 115 insertions(+), 16 deletions(-) diff --git a/dumux/decoupled/2p/diffusion/fv/fvpressure2p.hh b/dumux/decoupled/2p/diffusion/fv/fvpressure2p.hh index 3ad346202d..a6b88de2da 100644 --- a/dumux/decoupled/2p/diffusion/fv/fvpressure2p.hh +++ b/dumux/decoupled/2p/diffusion/fv/fvpressure2p.hh @@ -268,6 +268,19 @@ public: return; } + void updateVelocity() + { + updateMaterialLaws(); + + //reset velocities + int size = problem_.gridView().size(0); + for (int i = 0; i < size; i++) + { + CellData& cellData = problem_.variables().cellData(i); + cellData.fluxData().resetVelocity(); + } + } + /*! \brief Globally stores the pressure solution * */ diff --git a/dumux/decoupled/2p/diffusion/fv/fvpressure2padaptive.hh b/dumux/decoupled/2p/diffusion/fv/fvpressure2padaptive.hh index 96ac7b5219..4b7970b4f3 100644 --- a/dumux/decoupled/2p/diffusion/fv/fvpressure2padaptive.hh +++ b/dumux/decoupled/2p/diffusion/fv/fvpressure2padaptive.hh @@ -175,6 +175,13 @@ public: velocity_.calculateVelocity(); } + void updateVelocity() + { + ParentType::updateVelocity(); + + calculateVelocity(); + } + /*! \brief Adds pressure output to the output file * * \copydetails FVPressure2P::addOutputVtkFields(MultiWriter&) diff --git a/dumux/decoupled/2p/diffusion/fvmpfa/lmethod/fvmpfal2pfaboundvelocity2p.hh b/dumux/decoupled/2p/diffusion/fvmpfa/lmethod/fvmpfal2pfaboundvelocity2p.hh index f48086e364..1c0a0076a5 100644 --- a/dumux/decoupled/2p/diffusion/fvmpfa/lmethod/fvmpfal2pfaboundvelocity2p.hh +++ b/dumux/decoupled/2p/diffusion/fvmpfa/lmethod/fvmpfal2pfaboundvelocity2p.hh @@ -146,6 +146,19 @@ public: //Calculates the velocities at all cell-cell interfaces. void calculateVelocity(); + void updateVelocity() + { + this->updateMaterialLaws(); + + //reset velocities + int size = problem_.gridView().size(0); + for (int i = 0; i < size; i++) + { + CellData& cellData = problem_.variables().cellData(i); + cellData.fluxData().resetVelocity(); + } + } + /*! \brief Initializes pressure and velocity * * \copydetails ParentType::initialize() diff --git a/dumux/decoupled/2p/diffusion/fvmpfa/lmethod/fvmpfal2pfaboundvelocity2padaptive.hh b/dumux/decoupled/2p/diffusion/fvmpfa/lmethod/fvmpfal2pfaboundvelocity2padaptive.hh index 0683b552cb..55bff3c3ea 100644 --- a/dumux/decoupled/2p/diffusion/fvmpfa/lmethod/fvmpfal2pfaboundvelocity2padaptive.hh +++ b/dumux/decoupled/2p/diffusion/fvmpfa/lmethod/fvmpfal2pfaboundvelocity2padaptive.hh @@ -154,6 +154,19 @@ public: //Calculates the velocities at all cell-cell interfaces. void calculateVelocity(); + void updateVelocity() + { + this->updateMaterialLaws(); + + //reset velocities + int size = problem_.gridView().size(0); + for (int i = 0; i < size; i++) + { + CellData& cellData = problem_.variables().cellData(i); + cellData.fluxData().resetVelocity(); + } + } + /*! \brief Initializes pressure and velocity * * \copydetails ParentType::initialize() diff --git a/dumux/decoupled/2p/diffusion/fvmpfa/omethod/fvmpfao2pfaboundvelocity2p.hh b/dumux/decoupled/2p/diffusion/fvmpfa/omethod/fvmpfao2pfaboundvelocity2p.hh index 3c7c415d4d..50e67cb099 100644 --- a/dumux/decoupled/2p/diffusion/fvmpfa/omethod/fvmpfao2pfaboundvelocity2p.hh +++ b/dumux/decoupled/2p/diffusion/fvmpfa/omethod/fvmpfao2pfaboundvelocity2p.hh @@ -147,6 +147,19 @@ public: //Calculates the velocities at all cell-cell interfaces. void calculateVelocity(); + void updateVelocity() + { + this->updateMaterialLaws(); + + //reset velocities + int size = problem_.gridView().size(0); + for (int i = 0; i < size; i++) + { + CellData& cellData = problem_.variables().cellData(i); + cellData.fluxData().resetVelocity(); + } + } + /*! \brief Initializes pressure and velocity * * \copydetails ParentType::initialize() diff --git a/dumux/decoupled/2p/diffusion/fvmpfa/omethod/fvmpfaovelocity2p.hh b/dumux/decoupled/2p/diffusion/fvmpfa/omethod/fvmpfaovelocity2p.hh index 2416a86be7..1f1452d3e4 100644 --- a/dumux/decoupled/2p/diffusion/fvmpfa/omethod/fvmpfaovelocity2p.hh +++ b/dumux/decoupled/2p/diffusion/fvmpfa/omethod/fvmpfaovelocity2p.hh @@ -125,6 +125,21 @@ public: //Calculates the velocities at all cell-cell interfaces. void calculateVelocity(); + void updateVelocity() + { + this->updateMaterialLaws(); + + //reset velocities + int size = problem_.gridView().size(0); + for (int i = 0; i < size; i++) + { + CellData& cellData = problem_.variables().cellData(i); + cellData.fluxData().resetVelocity(); + } + + calculateVelocity(); + } + /*! \brief Initializes pressure and velocity * * \copydetails ParentType::initialize() diff --git a/dumux/decoupled/common/fv/fvpressure.hh b/dumux/decoupled/common/fv/fvpressure.hh index d3948660b1..d4d5b77154 100644 --- a/dumux/decoupled/common/fv/fvpressure.hh +++ b/dumux/decoupled/common/fv/fvpressure.hh @@ -236,6 +236,11 @@ public: DUNE_THROW(Dune::NotImplemented,"Velocity calculation not implemented in pressure model!"); } + void updateVelocity() + { + DUNE_THROW(Dune::NotImplemented,"Velocity update not implemented in pressure model!"); + } + /*! \brief Function for serialization of the pressure field. * * Function needed for restart option. Writes the pressure of a grid element to a restart file. diff --git a/dumux/decoupled/common/fv/fvtransport.hh b/dumux/decoupled/common/fv/fvtransport.hh index 70438f1360..0deb5dde2a 100644 --- a/dumux/decoupled/common/fv/fvtransport.hh +++ b/dumux/decoupled/common/fv/fvtransport.hh @@ -421,10 +421,18 @@ void FVTransport<TypeTag>::update(const Scalar t, Scalar& dt, TransportSolutionT typedef typename GET_PROP(TypeTag, SolutionTypes) SolutionTypes; typedef typename SolutionTypes::ElementMapper ElementMapper; typedef VectorExchange<ElementMapper, Dune::BlockVector<Dune::FieldVector<Scalar, 1> > > DataHandle; - DataHandle dataHandle(problem_.variables().elementMapper(), updateVec); + DataHandle dataHandle(problem_.elementMapper(), updateVec); problem_.gridView().template communicate<DataHandle>(dataHandle, Dune::InteriorBorder_All_Interface, Dune::ForwardCommunication); + + typedef VectorExchange<ElementMapper, std::vector<LocalTimesteppingData> > TimeDataHandle; + + TimeDataHandle timeDataHandle(problem_.elementMapper(), timeStepData_); + problem_.gridView().template communicate<TimeDataHandle>(timeDataHandle, + Dune::InteriorBorder_All_Interface, + Dune::ForwardCommunication); + dt = problem_.gridView().comm().min(dt); #endif } @@ -540,6 +548,20 @@ void FVTransport<TypeTag>::updatedTargetDt_(Scalar &dt) } } } + +#if HAVE_MPI + // communicate updated values + typedef typename GET_PROP(TypeTag, SolutionTypes) SolutionTypes; + typedef typename SolutionTypes::ElementMapper ElementMapper; + typedef VectorExchange<ElementMapper, std::vector<LocalTimesteppingData> > TimeDataHandle; + + TimeDataHandle timeDataHandle(problem_.elementMapper(), timeStepData_); + problem_.gridView().template communicate<TimeDataHandle>(timeDataHandle, + Dune::InteriorBorder_All_Interface, + Dune::ForwardCommunication); + + dt = problem_.gridView().comm().min(dt); +#endif } template<class TypeTag> @@ -550,6 +572,7 @@ void FVTransport<TypeTag>::innerUpdate(TransportSolutionType& updateVec) Scalar realDt = problem_.timeManager().timeStepSize(); Scalar subDt = realDt; + updatedTargetDt_(subDt); Scalar accumulatedDtOld = accumulatedDt_; @@ -578,10 +601,21 @@ void FVTransport<TypeTag>::innerUpdate(TransportSolutionType& updateVec) if (!asImp_().inPhysicalRange(newVal)) { stopTimeStep = true; + break; } } +#if HAVE_MPI + int rank = 0; + if (stopTimeStep) + rank = problem_.gridView().comm().rank(); + + rank = problem_.gridView().comm().max(rank); + problem_.gridView().comm().broadcast(&stopTimeStep,1,rank); +#endif + + if (stopTimeStep && accumulatedDtOld > dtThreshold_) { problem_.timeManager().setTimeStepSize(accumulatedDtOld); diff --git a/dumux/decoupled/common/fv/fvvelocity.hh b/dumux/decoupled/common/fv/fvvelocity.hh index 15c0bf6f27..13cddab299 100644 --- a/dumux/decoupled/common/fv/fvvelocity.hh +++ b/dumux/decoupled/common/fv/fvvelocity.hh @@ -107,8 +107,6 @@ private: template<class TypeTag, class Velocity> void FVVelocity<TypeTag, Velocity>::calculateVelocity() { - Dune::FieldVector<Scalar, dim> vel(0.); - ElementIterator eItEnd = problem_.gridView().template end<0> (); for (ElementIterator eIt = problem_.gridView().template begin<0> (); eIt != eItEnd; ++eIt) { diff --git a/dumux/decoupled/common/impet.hh b/dumux/decoupled/common/impet.hh index 2d5d529518..88cf1da787 100644 --- a/dumux/decoupled/common/impet.hh +++ b/dumux/decoupled/common/impet.hh @@ -189,19 +189,7 @@ public: void updateTransport(const Scalar t, Scalar& dt, TransportSolutionType& updateVec) { - problem_.pressureModel().updateMaterialLaws(); - - //reset velocities - int size = problem_.gridView().size(0); - for (int i = 0; i < size; i++) - { - CellData& cellData = problem_.variables().cellData(i); - cellData.fluxData().resetVelocity(); - } - if (!problem_.transportModel().velocity().calculateVelocityInTransport()) - { - problem_.pressureModel().calculateVelocity(); - } + problem_.pressureModel().updateVelocity(); problem_.transportModel().update(t, dt, updateVec, true); } -- GitLab