From 16a3f34115c2a0f4580fa7c454dbf23ce7eb9bbf Mon Sep 17 00:00:00 2001 From: Benjamin Faigle <benjamin.faigle@posteo.de> Date: Wed, 30 May 2012 10:17:02 +0000 Subject: [PATCH] -removed minor output bug in transport module for non-upwind -seperated updateMaterial at the end of time step with that done after grid adaptation by introducing distinguishing bool. Compositional problem base class does that distinction. Reviewd by Markus git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@8404 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- dumux/decoupled/2p2c/2p2cproblem.hh | 39 ++++++++++++++++++- dumux/decoupled/2p2c/fvpressure2p2c.hh | 18 ++++----- .../2p2c/fvpressure2p2cmultiphysics.hh | 18 +++++---- dumux/decoupled/2p2c/fvtransport2p2c.hh | 4 +- 4 files changed, 60 insertions(+), 19 deletions(-) diff --git a/dumux/decoupled/2p2c/2p2cproblem.hh b/dumux/decoupled/2p2c/2p2cproblem.hh index 692681ee03..417dedd831 100644 --- a/dumux/decoupled/2p2c/2p2cproblem.hh +++ b/dumux/decoupled/2p2c/2p2cproblem.hh @@ -59,7 +59,10 @@ class IMPETProblem2P2C : public IMPESProblem2P<TypeTag> // material properties typedef typename GET_PROP_TYPE(TypeTag, SpatialParams) SpatialParams; - + enum + { + adaptiveGrid = GET_PROP_VALUE(TypeTag, AdaptiveGrid) + }; enum { dim = Grid::dimension, dimWorld = Grid::dimensionworld @@ -93,6 +96,40 @@ public: virtual ~IMPETProblem2P2C() { } + + /*! + * \brief Called by Dumux::TimeManager just before the time + * integration. + * + * In compositional/compressible models, the secondary variables + * should be updated after each time step. Hence, another update + * is only necessary if the grid is adapted. + */ + void preTimeStep() + { + // if adaptivity is used, this method adapts the grid. + // if it is not used, this method does nothing. + if (this->adaptiveGrid) + { + this->gridAdapt().adaptGrid(); + asImp_().pressureModel().updateMaterialLaws(false); + } + } + /*! + * \brief Called by the time manager after everything which can be + * done about the current time step is finished and the + * model should be prepared to do the next time integration. + * + * In compositional/compressible models, the secondary variables + * should be updated for output and the next time step via + * updateMaterialLaws. The boolean indicates that it is + * a call from postTimeStep(). + */ + void postTimeStep() + { + ParentType::postTimeStep(); + asImp_().pressureModel().updateMaterialLaws(true); + }; /*! * \name Problem parameters */ diff --git a/dumux/decoupled/2p2c/fvpressure2p2c.hh b/dumux/decoupled/2p2c/fvpressure2p2c.hh index 5612c0de8f..6a9fdba3b0 100644 --- a/dumux/decoupled/2p2c/fvpressure2p2c.hh +++ b/dumux/decoupled/2p2c/fvpressure2p2c.hh @@ -158,9 +158,9 @@ public: const Intersection&, const CellData&, const bool); //constitutive functions are initialized and stored in the variables object - void updateMaterialLaws(); + void updateMaterialLaws(bool); //updates secondary variables for one cell and stores in the variables object - void updateMaterialLawsInElement(const Element&); + void updateMaterialLawsInElement(const Element&, bool); //! Constructs a FVPressure2P2C object /** @@ -881,7 +881,7 @@ void FVPressure2P2C<TypeTag>::getFluxOnBoundary(Dune::FieldVector<Scalar, 2>& en * by using the updated primary variables. */ template<class TypeTag> -void FVPressure2P2C<TypeTag>::updateMaterialLaws() +void FVPressure2P2C<TypeTag>::updateMaterialLaws(bool postTimeStep = false) { Scalar maxError = 0.; // iterate through leaf grid an evaluate c0 at cell center @@ -892,7 +892,7 @@ void FVPressure2P2C<TypeTag>::updateMaterialLaws() CellData& cellData = problem().variables().cellData(globalIdx); - problem().pressureModel().updateMaterialLawsInElement(*eIt); + problem().pressureModel().updateMaterialLawsInElement(*eIt, postTimeStep); maxError = std::max(maxError, fabs(cellData.volumeError())); } @@ -905,7 +905,7 @@ void FVPressure2P2C<TypeTag>::updateMaterialLaws() * \param elementI The element */ template<class TypeTag> -void FVPressure2P2C<TypeTag>::updateMaterialLawsInElement(const Element& elementI) +void FVPressure2P2C<TypeTag>::updateMaterialLawsInElement(const Element& elementI, bool postTimeStep) { // get global coordinate of cell center GlobalPosition globalPos = elementI.geometry().center(); @@ -918,8 +918,10 @@ void FVPressure2P2C<TypeTag>::updateMaterialLawsInElement(const Element& element FluidState& fluidState = cellData.manipulateFluidState(); Scalar temperature_ = problem().temperatureAtPos(globalPos); - // reset - cellData.reset(); + + // reset to calculate new timeStep if we are at the end of a time step + if(postTimeStep) + cellData.reset(); // // make shure total concentrations from solution vector are exact in fluidstate // fluidState.setMassConcentration(wCompIdx, @@ -1062,8 +1064,6 @@ void FVPressure2P2C<TypeTag>::updateMaterialLawsInElement(const Element& element else cellData.volumeError()=0.; - cellData.reset(); - return; } diff --git a/dumux/decoupled/2p2c/fvpressure2p2cmultiphysics.hh b/dumux/decoupled/2p2c/fvpressure2p2cmultiphysics.hh index 308f5b3e2c..f1a692987d 100644 --- a/dumux/decoupled/2p2c/fvpressure2p2cmultiphysics.hh +++ b/dumux/decoupled/2p2c/fvpressure2p2cmultiphysics.hh @@ -156,9 +156,9 @@ public: //constitutive functions are initialized and stored in the variables object - void updateMaterialLaws(); + void updateMaterialLaws(bool); //updates singlephase secondary variables for one cell and stores in the variables object - void update1pMaterialLawsInElement(const Element&, CellData&); + void update1pMaterialLawsInElement(const Element&, CellData&, bool); //! \brief Write data files /* \param name file name */ @@ -659,7 +659,7 @@ void FVPressure2P2CMultiPhysics<TypeTag>::get1pFluxOnBoundary(Dune::FieldVector< * or in the two phase subdomain (value = 2). */ template<class TypeTag> -void FVPressure2P2CMultiPhysics<TypeTag>::updateMaterialLaws() +void FVPressure2P2CMultiPhysics<TypeTag>::updateMaterialLaws(bool postTimeStep = false) { //get timestep for error term Scalar maxError = 0.; @@ -680,7 +680,7 @@ void FVPressure2P2CMultiPhysics<TypeTag>::updateMaterialLaws() if(cellData.subdomain() == 2) // complex { - this->updateMaterialLawsInElement(*eIt); + this->updateMaterialLawsInElement(*eIt, postTimeStep); // check subdomain consistency timer_.start(); @@ -735,7 +735,7 @@ void FVPressure2P2CMultiPhysics<TypeTag>::updateMaterialLaws() // assure correct PV if subdomain used to be simple if(cellData.fluidStateType() != 0); // i.e. it was simple timer_.stop(); - this->updateMaterialLawsInElement(*eIt); + this->updateMaterialLawsInElement(*eIt, postTimeStep); timer_.start(); } else if(oldSubdomainI != 2 @@ -745,7 +745,7 @@ void FVPressure2P2CMultiPhysics<TypeTag>::updateMaterialLaws() // int presentPhaseIdx = cellData.subdomain(); // this is already =nextSubomainIdx // perform simple update - this->update1pMaterialLawsInElement(*eIt, cellData); + this->update1pMaterialLawsInElement(*eIt, cellData, postTimeStep); timer_.stop(); } //else @@ -763,7 +763,7 @@ void FVPressure2P2CMultiPhysics<TypeTag>::updateMaterialLaws() return; } template<class TypeTag> -void FVPressure2P2CMultiPhysics<TypeTag>::update1pMaterialLawsInElement(const Element& elementI, CellData& cellData) +void FVPressure2P2CMultiPhysics<TypeTag>::update1pMaterialLawsInElement(const Element& elementI, CellData& cellData, bool postTimeStep) { // get global coordinate of cell center GlobalPosition globalPos = elementI.geometry().center(); @@ -772,6 +772,10 @@ void FVPressure2P2CMultiPhysics<TypeTag>::update1pMaterialLawsInElement(const El // determine which phase should be present int presentPhaseIdx = cellData.subdomain(); // this is already =nextSubomainIdx + // reset to calculate new timeStep if we are at the end of a time step + if(postTimeStep) + cellData.reset(); + // acess the simple fluid state and prepare for manipulation PseudoOnePTwoCFluidState<TypeTag>& pseudoFluidState = cellData.manipulateSimpleFluidState(); diff --git a/dumux/decoupled/2p2c/fvtransport2p2c.hh b/dumux/decoupled/2p2c/fvtransport2p2c.hh index 9280795e03..a7bc2d976d 100644 --- a/dumux/decoupled/2p2c/fvtransport2p2c.hh +++ b/dumux/decoupled/2p2c/fvtransport2p2c.hh @@ -539,7 +539,7 @@ void FVTransport2P2C<TypeTag>::getFlux(Dune::FieldVector<Scalar, 2>& fluxEntries potential[wPhaseIdx] = 0; //d) output (only for one side) - if(potential[wPhaseIdx] >= 0.) + if(globalIdxI > globalIdxJ) Dune::dinfo << "harmonicMean flux of phase w used from cell" << globalIdxI<< " into " << globalIdxJ <<"\n"; } if(!doUpwinding[nPhaseIdx]) @@ -563,7 +563,7 @@ void FVTransport2P2C<TypeTag>::getFlux(Dune::FieldVector<Scalar, 2>& fluxEntries potential[nPhaseIdx] = 0; //d) output (only for one side) - if(potential[nPhaseIdx] >= 0.) + if(globalIdxI > globalIdxJ) Dune::dinfo << "harmonicMean flux of phase n used from cell" << globalIdxI<< " into " << globalIdxJ <<"\n"; } -- GitLab