Newer
Older
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:

Bernd Flemisch
committed
/*****************************************************************************
* See the file COPYING for full copying permissions. *

Bernd Flemisch
committed
* *
* This program is free software: you can redistribute it and/or modify *

Bernd Flemisch
committed
* 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. *

Bernd Flemisch
committed
* *
* 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 <http://www.gnu.org/licenses/>. *

Bernd Flemisch
committed
*****************************************************************************/
/*!
* \file
*
* \brief Tutorial problem for a fully coupled twophase box model.
*/

Andreas Lauser
committed
#ifndef DUMUX_TUTORIAL_PROBLEM_COUPLED_HH // guardian macro /*@\label{tutorial-coupled:guardian1}@*/
#define DUMUX_TUTORIAL_PROBLEM_COUPLED_HH // guardian macro /*@\label{tutorial-coupled:guardian2}@*/

Bernd Flemisch
committed

Bernd Flemisch
committed
#include <dumux/implicit/2p/2pmodel.hh>

Bernd Flemisch
committed
// The base prous media box problem

Bernd Flemisch
committed
#include <dumux/implicit/box/porousmediaboxproblem.hh>
#include <dune/grid/alugrid.hh>
#else
#include <dune/grid/yaspgrid.hh>
#endif // HAVE_ALUGRID

Bernd Flemisch
committed
// Spatially dependent parameters
#include "tutorialspatialparams_coupled.hh"

Bernd Flemisch
committed
// The components that are used

Klaus Mosthaf
committed
#include <dumux/material/components/h2o.hh>
#include <dumux/material/components/lnapl.hh>

Andreas Lauser
committed
#include <dumux/common/cubegridcreator.hh>

Klaus Mosthaf
committed
namespace Dumux{
// Forward declaration of the problem class

Bernd Flemisch
committed
template <class TypeTag>
class TutorialProblemCoupled;
namespace Properties {
// Create a new type tag for the problem
NEW_TYPE_TAG(TutorialProblemCoupled, INHERITS_FROM(BoxTwoP, TutorialSpatialParamsCoupled)); /*@\label{tutorial-coupled:create-type-tag}@*/

Bernd Flemisch
committed
// Set the "Problem" property
SET_PROP(TutorialProblemCoupled, Problem) /*@\label{tutorial-coupled:set-problem}@*/
{ typedef Dumux::TutorialProblemCoupled<TypeTag> type;};

Bernd Flemisch
committed
// Set grid and the grid creator to be used

Christoph Grüninger
committed
SET_TYPE_PROP(TutorialProblemCoupled, Grid, Dune::ALUGrid</*dim=*/2, 2, Dune::cube, Dune::nonconforming>); /*@\label{tutorial-coupled:set-grid}@*/
#else
SET_TYPE_PROP(TutorialProblemCoupled, Grid, Dune::YaspGrid<2>);
#warning If you want to use adaptivity, install and use ALUGrid.
#endif // HAVE_ALUGRID
SET_TYPE_PROP(TutorialProblemCoupled, GridCreator, Dumux::CubeGridCreator<TypeTag>); /*@\label{tutorial-coupled:set-gridcreator}@*/

Bernd Flemisch
committed
// Set the wetting phase
SET_PROP(TutorialProblemCoupled, WettingPhase) /*@\label{tutorial-coupled:2p-system-start}@*/

Bernd Flemisch
committed
{
private: typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
public: typedef Dumux::LiquidPhase<Scalar, Dumux::H2O<Scalar> > type; /*@\label{tutorial-coupled:wettingPhase}@*/

Bernd Flemisch
committed
};
SET_PROP(TutorialProblemCoupled, NonwettingPhase)
private: typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
public: typedef Dumux::LiquidPhase<Scalar, Dumux::LNAPL<Scalar> > type; /*@\label{tutorial-coupled:nonwettingPhase}@*/
}; /*@\label{tutorial-coupled:2p-system-end}@*/
SET_TYPE_PROP(TutorialProblemCoupled, FluidSystem, Dumux::TwoPImmiscibleFluidSystem<TypeTag>);/*@\label{tutorial-coupled:set-fluidsystem}@*/

Bernd Flemisch
committed
// Disable gravity
SET_BOOL_PROP(TutorialProblemCoupled, ProblemEnableGravity, false); /*@\label{tutorial-coupled:gravity}@*/

Bernd Flemisch
committed
}
* \ingroup TwoPBoxModel
*
* \brief Tutorial problem for a fully coupled twophase box model.
*/
template <class TypeTag>
class TutorialProblemCoupled : public PorousMediaBoxProblem<TypeTag> /*@\label{tutorial-coupled:def-problem}@*/

Bernd Flemisch
committed
{
typedef PorousMediaBoxProblem<TypeTag> ParentType;
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;

Bernd Flemisch
committed
// Grid dimension
enum { dim = GridView::dimension };

Bernd Flemisch
committed
// Types from DUNE-Grid
typedef typename GridView::template Codim<0>::Entity Element;
typedef typename GridView::template Codim<dim>::Entity Vertex;
typedef typename GridView::Intersection Intersection;
typedef Dune::FieldVector<Scalar, dim> GlobalPosition;
// Dumux specific types
typedef typename GET_PROP_TYPE(TypeTag, TimeManager) TimeManager;
typedef typename GET_PROP_TYPE(TypeTag, Indices) Indices;
typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
typedef typename GET_PROP_TYPE(TypeTag, BoundaryTypes) BoundaryTypes;
typedef typename GET_PROP_TYPE(TypeTag, FVElementGeometry) FVElementGeometry;

Bernd Flemisch
committed
public:
TutorialProblemCoupled(TimeManager &timeManager,
const GridView &gridView)
: ParentType(timeManager, gridView)
//! Specifies the problem name. This is used as a prefix for files
//! generated by the simulation.
const char *name() const
{ return "tutorial_coupled"; }

Bernd Flemisch
committed
//! Returns true if a restart file should be written.
bool shouldWriteRestartFile() const /*@\label{tutorial-coupled:restart}@*/
//! Returns true if the current solution should be written to disk
//! as a VTK file
bool shouldWriteOutput() const /*@\label{tutorial-coupled:output}@*/
{
this->timeManager().timeStepIndex() > 0 &&
(this->timeManager().timeStepIndex() % 1 == 0);
//! Returns the temperature within a finite volume. We use constant
Scalar temperature() const

Bernd Flemisch
committed
{ return 283.15; };
//! Specifies which kind of boundary condition should be used for
//! which equation for a finite volume on the boundary.
void boundaryTypes(BoundaryTypes &bcTypes, const Vertex &vertex) const

Bernd Flemisch
committed
{
const GlobalPosition &globalPos = vertex.geometry().center();
if (globalPos[0] < eps_) // Dirichlet conditions on left boundary
bcTypes.setAllDirichlet();

Bernd Flemisch
committed
else // neuman for the remaining boundaries

Bernd Flemisch
committed
}
//! Evaluates the Dirichlet boundary conditions for a finite volume
//! on the grid boundary. Here, the 'values' parameter stores
//! primary variables.
void dirichlet(PrimaryVariables &values, const Vertex &vertex) const

Bernd Flemisch
committed
{
values[Indices::pwIdx] = 200.0e3; // 200 kPa = 2 bar
values[Indices::SnIdx] = 0.0; // 0 % oil saturation on left boundary
}
//! Evaluates the boundary conditions for a Neumann boundary
//! segment. Here, the 'values' parameter stores the mass flux in
//! [kg/(m^2 * s)] in normal direction of each phase. Negative
//! values mean influx.
void neumann(PrimaryVariables &values,
const FVElementGeometry &fvGeometry,
const Intersection &is,
int scvIdx,
int boundaryFaceIdx) const

Bernd Flemisch
committed
{
const GlobalPosition &globalPos =
fvGeometry.boundaryFace[boundaryFaceIdx].ipGlobal;

Bernd Flemisch
committed
Scalar right = this->bboxMax()[0];
// extraction of oil on the right boundary for approx. 1.e6 seconds
// oil outflux of 30 g/(m * s) on the right boundary.

Bernd Flemisch
committed
values[Indices::contiWEqIdx] = 0;
values[Indices::contiNEqIdx] = 3e-2;

Bernd Flemisch
committed
} else {
// no-flow on the remaining Neumann-boundaries.

Bernd Flemisch
committed
values[Indices::contiWEqIdx] = 0;
values[Indices::contiNEqIdx] = 0;
}
}
//! Evaluates the initial value for a control volume. For this
//! method, the 'values' parameter stores primary variables.
void initial(PrimaryVariables &values,

Bernd Flemisch
committed
{
values[Indices::pwIdx] = 200.0e3; // 200 kPa = 2 bar
values[Indices::SnIdx] = 1.0;
}
//! Evaluates the source term for all phases within a given
//! sub-control-volume. In this case, the 'values' parameter
//! stores the rate mass generated or annihilated per volume unit
//! in [kg / (m^3 * s)]. Positive values mean that mass is created.
void source(PrimaryVariables &values,

Bernd Flemisch
committed
{
values[Indices::contiWEqIdx] = 0.0;
values[Indices::contiNEqIdx]= 0.0;
}
private:
// small epsilon value

Bernd Flemisch
committed
};
}
#endif