diff --git a/dumux/decoupled/2p/diffusion/fv/fvpressure2p.hh b/dumux/decoupled/2p/diffusion/fv/fvpressure2p.hh index 3ad346202dc43c06e2ceff0b7d593944968b657d..a6b88de2da516d86f016edf69f4f435ed302b0f8 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 96ac7b52191d0d84c3142b3d04eff9a6cdea1879..4b7970b4f35ccb7201e64fc638ca65df7b2895c8 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 f48086e3647ffa1c0a0643d845d7879e6e098e8d..1c0a0076a5904440e5f9ea3110133329ba6e62eb 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 0683b552cb094ae8990e7ebf101742c3bd34039c..55bff3c3ea42184482de2db36898b6c407ec4a60 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 3c7c415d4d677154288295fbe31094f55858e572..50e67cb0990264482ece70b92bf51800696d7646 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 2416a86be7effbaa689e64a82c2adedb9b3abc92..1f1452d3e4b932c8b6299abe27544c4c676d1e72 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 d3948660b12af4bb10e8eb7e681225d714da3737..d4d5b77154f009c68549114152a28841e8f19d4f 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 70438f136090e81f656180ad434bb03d4524c641..0deb5dde2a9b28754cd17167678aa8f390d2371f 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 15c0bf6f275ed030ebcc9eb99d0214d2fcbe33de..13cddab299ac1c6b2606290837ede6b602296205 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 2d5d5295181ccb4bdab5552c5e6fcd7c7d2c34f2..88cf1da7879f9e12065386a5f87f400b3bc04edf 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); }