From d7db90476e62762c29e8ec4549acd38e57522ffa Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Fri, 18 Nov 2011 18:20:31 +0100 Subject: [PATCH] box models: fold the spatial parameters directly into the problems --- doc/handbook/tutorial-coupled.tex | 6 +- examples/Makefile.am | 5 +- examples/tutorialproblem_coupled.hh | 104 ++++++++++- examples/tutorialspatialparameters_coupled.hh | 173 ------------------ 4 files changed, 100 insertions(+), 188 deletions(-) delete mode 100644 examples/tutorialspatialparameters_coupled.hh diff --git a/doc/handbook/tutorial-coupled.tex b/doc/handbook/tutorial-coupled.tex index 464a1f0d5..3365fb01d 100644 --- a/doc/handbook/tutorial-coupled.tex +++ b/doc/handbook/tutorial-coupled.tex @@ -259,9 +259,9 @@ should be derived from the base class \ref{tutorial-coupled:spatialparametersfile} shows the file \\ \verb+tutorialspatialparameters_coupled.hh+: -\begin{lst}[File tutorial/tutorialspatialparameters\_coupled.hh]\label{tutorial-coupled:spatialparametersfile} \mbox{} -\lstinputlisting[style=DumuxCode, numbersep=5pt, firstline=28]{../../tutorial/tutorialspatialparameters_coupled.hh} -\end{lst} +%\begin{lst}[File tutorial/tutorialspatialparameters\_coupled.hh]\label{tutorial-coupled:spatialparametersfile} \mbox{} +%\lstinputlisting[style=DumuxCode, numbersep=5pt, firstline=28]{../../tutorial/tutorialspatialparameters_coupled.hh} +%\end{lst} First, the spatial parameters type tag is created on line \ref{tutorial-coupled:define-spatialparameters-typetag}. The type tag diff --git a/examples/Makefile.am b/examples/Makefile.am index a55626101..a4ca0b6b3 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,7 +1,7 @@ # programs just to build when "make check" is used check_PROGRAMS = tutorial_decoupled tutorial_coupled -noinst_HEADERS= tutorialspatialparameters_decoupled.hh tutorialproblem_decoupled.hh tutorialspatialparameters_coupled.hh tutorialproblem_coupled.hh +noinst_HEADERS= tutorialspatialparameters_decoupled.hh tutorialproblem_decoupled.hh tutorialproblem_coupled.hh EXTRA_DIST = CMakeLists.txt *.input tutorial_decoupleddir = $(datadir)/dumux/tutorial @@ -10,8 +10,7 @@ tutorial_decoupled_HEADERS = tutorialspatialparameters_decoupled.hh \ tutorial_decoupled_SOURCES = tutorial_decoupled.cc tutorial_decoupled_DATA = $(tutorial_decoupled_SOURCES) tutorial_coupleddir = $(datadir)/dumux/tutorial -tutorial_coupled_HEADERS = tutorialspatialparameters_coupled.hh \ - tutorialproblem_coupled.hh +tutorial_coupled_HEADERS = tutorialproblem_coupled.hh tutorial_coupled_SOURCES = tutorial_coupled.cc tutorial_coupled_DATA = $(tutorial_coupled_SOURCES) diff --git a/examples/tutorialproblem_coupled.hh b/examples/tutorialproblem_coupled.hh index c9f611cac..88ffc9106 100644 --- a/examples/tutorialproblem_coupled.hh +++ b/examples/tutorialproblem_coupled.hh @@ -35,21 +35,25 @@ #include // Spatially dependent parameters -#include "tutorialspatialparameters_coupled.hh" - // The components that are used #include #include #include -namespace Dumux{ -// Forward declaration of the problem class +// include material laws +#include /*@\label{tutorial-coupled:rawLawInclude}@*/ +#include +#include + +namespace Dumux { + +// forward declaration of the problem class template class TutorialProblemCoupled; namespace Properties { // Create a new type tag for the problem -NEW_TYPE_TAG(TutorialProblemCoupled, INHERITS_FROM(BoxTwoP, TutorialSpatialParametersCoupled)); /*@\label{tutorial-coupled:create-type-tag}@*/ +NEW_TYPE_TAG(TutorialProblemCoupled, INHERITS_FROM(BoxTwoP)); /*@\label{tutorial-coupled:create-type-tag}@*/ // Set the "Problem" property SET_PROP(TutorialProblemCoupled, Problem) /*@\label{tutorial-coupled:set-problem}@*/ @@ -73,7 +77,24 @@ private: typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar; public: typedef Dumux::LiquidPhase > type; /*@\label{tutorial-coupled:nonwettingPhase}@*/ }; /*@\label{tutorial-coupled:2p-system-end}@*/ -SET_TYPE_PROP(TutorialProblemCoupled, FluidSystem, Dumux::TwoPImmiscibleFluidSystem); +// Set the material law +SET_PROP(TutorialProblemCoupled, MaterialLaw) +{ +private: + // material law typedefs + typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar; + // select material law to be used + typedef RegularizedBrooksCorey RawMaterialLaw; /*@\label{tutorial-coupled:rawlaw}@*/ + // adapter for absolute law + typedef EffToAbsLaw TwoPMaterialLaw; /*@\label{tutorial-coupled:eff2abs}@*/ + + typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem; + enum { wPhaseIdx = FluidSystem::wPhaseIdx }; + +public: + typedef TwoPAdapter type; +}; + // Disable gravity SET_BOOL_PROP(TutorialProblemCoupled, EnableGravity, false); /*@\label{tutorial-coupled:gravity}@*/ @@ -93,7 +114,8 @@ SET_INT_PROP(TutorialProblemCoupled, GridCellsZ, 0); * \brief Tutorial problem for a fully coupled twophase box model. */ template -class TutorialProblemCoupled : public GET_PROP_TYPE(TypeTag, BaseProblem) /*@\label{tutorial-coupled:def-problem}@*/ +class TutorialProblemCoupled + : public GET_PROP_TYPE(TypeTag, BaseProblem) /*@\label{tutorial-coupled:def-problem}@*/ { typedef typename GET_PROP_TYPE(TypeTag, BaseProblem) ParentType; typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar; @@ -106,7 +128,9 @@ class TutorialProblemCoupled : public GET_PROP_TYPE(TypeTag, BaseProblem) /*@\la typedef typename GridView::template Codim<0>::Entity Element; typedef typename GridView::template Codim::Entity Vertex; typedef typename GridView::Intersection Intersection; + typedef Dune::FieldVector GlobalPosition; + typedef Dune::FieldMatrix Tensor; // Dumux specific types typedef typename GET_PROP_TYPE(TypeTag, TimeManager) TimeManager; @@ -115,6 +139,11 @@ class TutorialProblemCoupled : public GET_PROP_TYPE(TypeTag, BaseProblem) /*@\la typedef typename GET_PROP_TYPE(TypeTag, BoundaryTypes) BoundaryTypes; typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem; typedef typename GET_PROP_TYPE(TypeTag, TwoPIndices) Indices; + + // get material law from property system + typedef typename GET_PROP_TYPE(TypeTag, MaterialLaw) MaterialLaw; + // determine type of the parameter objects depening on selected material law + typedef typename GET_PROP_TYPE(TypeTag, MaterialLawParams) MaterialLawParams; /*@\label{tutorial-coupled:matLawObjectType}@*/ // indices of the conservation equations enum { contiWEqIdx = Indices::conti0EqIdx + FluidSystem::wPhaseIdx }; @@ -129,6 +158,19 @@ public: : ParentType(timeManager, GET_PROP_TYPE(TypeTag, GridCreator)::grid().leafView()) , eps_(3e-6) { + //set main diagonal entries of the permeability tensor to a value + //setting to one value means: isotropic, homogeneous + K_ = 0; + for (int i = 0; i < dim; i++) + K_[i][i] = 1e-7; + + //set residual saturations + materialParams_.setSwr(0.0); /*@\label{tutorial-coupled:setLawParams}@*/ + materialParams_.setSnr(0.0); + + //parameters of Brooks & Corey Law + materialParams_.setPe(500.0); + materialParams_.setLambda(2); } //! Specifies the problem name. This is used as a prefix for files @@ -155,8 +197,48 @@ public: Scalar temperature(const Context &context, int spaceIdx, int timeIdx) const { return 283.15; }; - //! Specifies which kind of boundary condition should be used for - //! which equation for a finite volume on the boundary. + /*! Intrinsic permeability tensor K \f$[m^2]\f$ depending + * on the position in the domain + * + * \param context The execution context + * \param scvIdx The local index of the degree of freedom + * + * Alternatively, the function intrinsicPermeabilityAtPos(const GlobalPosition& globalPos) could be defined, where globalPos + * is the vector including the global coordinates of the finite volume. + */ + template + const Tensor &intrinsicPermeability(const Context &context, /*@\label{tutorial-coupled:permeability}@*/ + int spaceIdx, int timeIdx) const + { return K_; } + + /*! Define the porosity \f$[-]\f$ of the porous medium depending + * on the position in the domain + * + * \param context The execution context + * \param scvIdx The local index of the degree of freedom + * + * Alternatively, the function porosityAtPos(const GlobalPosition& globalPos) could be defined, where globalPos + * is the vector including the global coordinates of the finite volume. + */ + template + Scalar porosity(const Context &context, /*@\label{tutorial-coupled:porosity}@*/ + int spaceIdx, int timeIdx) const + { return 0.2; } + + /*! Return the parameter object for the material law (i.e. Brooks-Corey) + * depending on the position in the domain + * + * \param context The execution context + * \param scvIdx The local index of the degree of freedom + * + * Alternatively, the function materialLawParamsAtPos(const GlobalPosition& globalPos) could be defined, where globalPos + * is the vector including the global coordinates of the finite volume. + */ + template + const MaterialLawParams& materialLawParams(const Context &context, /*@\label{tutorial-coupled:matLawParams}@*/ + int spaceIdx, int timeIdx) const + { return materialParams_; } + template void boundaryTypes(BoundaryTypes &bcTypes, const Context &context, int spaceIdx, int timeIdx) const { @@ -219,6 +301,10 @@ public: } private: + Tensor K_; + // Object that holds the values/parameters of the selected material law. + MaterialLawParams materialParams_; /*@\label{tutorial-coupled:matParamsObject}@*/ + // small epsilon value Scalar eps_; }; diff --git a/examples/tutorialspatialparameters_coupled.hh b/examples/tutorialspatialparameters_coupled.hh deleted file mode 100644 index b16d552f2..000000000 --- a/examples/tutorialspatialparameters_coupled.hh +++ /dev/null @@ -1,173 +0,0 @@ -// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set et ts=4 sw=4 sts=4: -/***************************************************************************** - * Copyright (C) 2008-2009 by Melanie Darcis * - * Institute for Modelling Hydraulic and Environmental Systems * - * University of Stuttgart, Germany * - * email: .@iws.uni-stuttgart.de * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - *****************************************************************************/ -/*! - * \file - * - * \brief The spatial parameters for the fully coupled tutorial problem - * which uses the twophase box model. - */ -#ifndef DUMUX_TUTORIAL_SPATIAL_PARAMETERS_COUPLED_HH -#define DUMUX_TUTORIAL_SPATIAL_PARAMETERS_COUPLED_HH - -// include parent spatialparameters -#include - -// include material laws -#include /*@\label{tutorial-coupled:rawLawInclude}@*/ -#include -#include - -namespace Dumux { -//forward declaration -template -class TutorialSpatialParametersCoupled; - -namespace Properties -{ -// The spatial parameters TypeTag -NEW_TYPE_TAG(TutorialSpatialParametersCoupled);/*@\label{tutorial-coupled:define-spatialparameters-typetag}@*/ - -// Set the spatial parameters -SET_TYPE_PROP(TutorialSpatialParametersCoupled, SpatialParameters, - Dumux::TutorialSpatialParametersCoupled); /*@\label{tutorial-coupled:set-spatialparameters}@*/ - -// Set the material law -SET_PROP(TutorialSpatialParametersCoupled, MaterialLaw) -{ -private: - // material law typedefs - typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar; - // select material law to be used - typedef RegularizedBrooksCorey RawMaterialLaw; /*@\label{tutorial-coupled:rawlaw}@*/ - // adapter for absolute law - typedef EffToAbsLaw TwoPMaterialLaw; /*@\label{tutorial-coupled:eff2abs}@*/ - - typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem; - enum { wPhaseIdx = FluidSystem::wPhaseIdx }; - -public: - typedef TwoPAdapter type; - -}; -} - -/*! - * \ingroup TwoPBoxModel - * - * \brief The spatial parameters for the fully coupled tutorial problem - * which uses the twophase box model. - */ -template -class TutorialSpatialParametersCoupled: public BoxSpatialParameters /*@\label{tutorial-coupled:tutorialSpatialParameters}@*/ -{ - // Get informations for current implementation via property system - typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid; - typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView; - typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar; - enum - { - dim = Grid::dimension, - dimWorld = Grid::dimensionworld - }; - typedef Dune::FieldMatrix Tensor; - - // Get object types for function arguments - typedef typename GET_PROP_TYPE(TypeTag, FVElementGeometry) FVElementGeometry; - typedef typename Grid::Traits::template Codim<0>::Entity Element; - -public: - // get material law from property system - typedef typename GET_PROP_TYPE(TypeTag, MaterialLaw) MaterialLaw; - // determine appropriate parameters depending on selected materialLaw - typedef typename MaterialLaw::Params MaterialLawParams; /*@\label{tutorial-coupled:matLawObjectType}@*/ - - /*! Intrinsic permeability tensor K \f$[m^2]\f$ depending - * on the position in the domain - * - * \param context The execution context - * \param scvIdx The local index of the degree of freedom - * - * Alternatively, the function intrinsicPermeabilityAtPos(const GlobalPosition& globalPos) - * could be defined, where globalPos is the vector including the global coordinates - * of the finite volume. - */ - template - const Tensor &intrinsicPermeability(const Context &context, /*@\label{tutorial-coupled:permeability}@*/ - int spaceIdx, int timeIdx) const - { return K_; } - - /*! Defines the porosity \f$[-]\f$ of the porous medium depending - * on the position in the domain - * - * \param context The execution context - * \param scvIdx The local index of the degree of freedom - * - * Alternatively, the function porosityAtPos(const GlobalPosition& globalPos) - * could be defined, where globalPos is the vector including the global coordinates - * of the finite volume. - */ - template - Scalar porosity(const Context &context, /*@\label{tutorial-coupled:porosity}@*/ - int spaceIdx, int timeIdx) const - { return 0.2; } - - /*! Returns the parameter object for the material law (i.e. Brooks-Corey) - * depending on the position in the domain - * - * \param context The execution context - * \param scvIdx The local index of the degree of freedom - * - * Alternatively, the function materialLawParamsAtPos(const GlobalPosition& globalPos) - * could be defined, where globalPos is the vector including the global coordinates - * of the finite volume. - */ - template - const MaterialLawParams& materialLawParams(const Context &context, /*@\label{tutorial-coupled:matLawParams}@*/ - int spaceIdx, int timeIdx) const - { return materialParams_; } - - // constructor - TutorialSpatialParametersCoupled(const GridView& gridView) : - BoxSpatialParameters(gridView), - K_(0) - { - //set main diagonal entries of the permeability tensor to a value - //setting to one value means: isotropic, homogeneous - for (int i = 0; i < dim; i++) - K_[i][i] = 1e-7; - - //set residual saturations - materialParams_.setSwr(0.0); /*@\label{tutorial-coupled:setLawParams}@*/ - materialParams_.setSnr(0.0); - - //parameters of Brooks & Corey Law - materialParams_.setPe(500.0); - materialParams_.setLambda(2); - } - -private: - Tensor K_; - // Object that holds the values/parameters of the selected material law. - MaterialLawParams materialParams_; /*@\label{tutorial-coupled:matParamsObject}@*/ -}; -} // end namespace -#endif