### [example][1ptracer] edit docu

parent a38e8857
 ... ... @@ -3,8 +3,10 @@ "doc/intro.md", "spatialparams_1p.hh", "problem_1p.hh", "properties_1p.hh", "spatialparams_tracer.hh", "problem_tracer.hh", "properties_tracer.hh", "main.cc", "doc/results.md" ] ... ...
This diff is collapsed.
 ... ... @@ -21,22 +21,22 @@ with the darcy velocity $ \textbf v $, the permeability $ \textbf K$, the dy Darcy's law is inserted into the mass balance equation: math \phi \frac{\partial \varrho}{\partial t} + \text{div} \textbf v = 0 \phi \frac{\partial \varrho}{\partial t} + \text{div} \textbf v = 0,  where $\phi$ is the porosity. The equation is discretized using a cell-centered finite volume scheme as spatial discretization for the pressure as primary variable. For details on the discretization scheme, have a look at the dumux [handbook](https://dumux.org/handbook). The equation is discretized using cell-centered finite volumes with two-point flux approximation as spatial discretization scheme for the pressure as primary variable. For details on the discretization schemes available in DuMuX, have a look at the [handbook](https://dumux.org/handbook). ### Tracer Model The transport of the contaminant component $\kappa$ is based on the previously evaluated velocity field $\textbf v$ with the help of the following mass balance equation: The transport of the contaminant component $\kappa$ occurs with the velocity field $\textbf v$ that is computed with the __1p model__ (see above): math \phi \frac{ \partial \varrho X^\kappa}{\partial t} - \text{div} \left\lbrace \varrho X^\kappa {\textbf v} + \varrho D^\kappa_\text{pm} \textbf{grad} X^\kappa \right\rbrace = 0,  where $X^\kappa$ is the mass fraction of the contaminant component $\kappa$ and $ D^\kappa_\text{pm} $ is the effective diffusivity. The effective diffusivity is a function of the diffusion coefficient of the component $D^\kappa$ and the porosity and tortuosity $\tau$ of the porous medium (see [dumux/material/fluidmatrixinteractions/diffusivityconstanttortuosity.hh](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/-/blob/master/dumux/material/fluidmatrixinteractions/diffusivityconstanttortuosity.hh)): math ... ...
This diff is collapsed.
 ... ... @@ -22,94 +22,21 @@ // ## The file problem_1p.hh // // This file contains the __problem class__ which defines the initial and boundary // conditions for the single-phase flow simulation. // // Before we enter the problem class containing initial and boundary conditions, we include necessary files and introduce properties. // ### Include files // We use YaspGrid, an implementation of the dune grid interface for structured grids: #include // The cell centered, two-point-flux discretization scheme is included: #include // The one-phase flow model is included: #include // This is the porous medium problem class that this class is derived from: // This header contains the porous medium problem class that this class is derived from: #include // The fluid properties are specified in the following headers (we use liquid water as the fluid phase): #include #include // The local residual for incompressible flow is included: #include // We include the header that specifies all spatially variable parameters: // This header contains the class that specifies all spatially variable parameters // related to this problem. #include "spatialparams_1p.hh" // ### Define basic properties for our simulation // We enter the namespace Dumux in order to import the entire Dumux namespace for general use namespace Dumux { // The problem class is forward declared: template class OnePTestProblem; // We enter the namespace Properties, which is a sub-namespace of the namespace Dumux: namespace Properties { // A TypeTag for our simulation is created which inherits from the one-phase flow model and the cell centered, two-point-flux discretization scheme. namespace TTag { struct IncompressibleTest { using InheritsFrom = std::tuple; }; } // We use a structured 2D grid: template struct Grid { using type = Dune::YaspGrid<2>; }; // The problem class specifies initial and boundary conditions: template struct Problem { using type = OnePTestProblem; }; // We define the spatial parameters for our simulation: template struct SpatialParams { // We define convenient shortcuts to the properties GridGeometry and Scalar: using GridGeometry = GetPropType; using Scalar = GetPropType; // Finally, we set the spatial parameters: using type = OnePTestSpatialParams; }; // We use the local residual that contains analytic derivative methods for incompressible flow: template struct LocalResidual { using type = OnePIncompressibleLocalResidual; }; // In the following we define the fluid properties. template struct FluidSystem { // We define a convenient shortcut to the property Scalar: using Scalar = GetPropType; // We create a fluid system that consists of one liquid water phase. We use the simple // description of water, which means we do not use tabulated values but more general equations of state. using type = FluidSystems::OnePLiquid >; }; // We enable caching for the grid volume variables. template struct EnableGridVolumeVariablesCache { static constexpr bool value = true; }; // We enable caching for the grid flux variables. template struct EnableGridFluxVariablesCache { static constexpr bool value = true; }; // We enable caching for the FV grid geometry template struct EnableGridGeometryCache { static constexpr bool value = true; }; // The cache stores values that were already calculated for later usage. This increases the memory demand but makes the simulation faster. // We leave the namespace Properties. } // ### The problem class // We enter the problem class where all necessary boundary conditions and initial conditions are set for our simulation. // As this is a porous medium problem, we inherit from the base class PorousMediumFlowProblem. // As this is a porous medium flow problem, we inherit from the base class PorousMediumFlowProblem. namespace Dumux { template class OnePTestProblem : public PorousMediumFlowProblem { ... ...
 ... ... @@ -22,133 +22,21 @@ // ## The file problem_tracer.hh // // This file contains the __problem class__ which defines the initial and boundary // conditions for the tracer transport simulation. // //Before we enter the problem class containing initial and boundary conditions, we include necessary files and introduce properties. // ### Include files // Again, we use YaspGrid, the implementation of the dune grid interface for structured grids: #include // and the cell centered, two-point-flux discretization. #include // Here, we include the tracer model: #include // We include again the porous medium problem class that this class is derived from: // This header contains the porous medium problem class that this class is derived from: #include // and the base fluidsystem. We will define a custom fluid system that inherits from that class. #include // We include the header that specifies all spatially variable parameters for the tracer problem: // This header contains the class that specifies all spatially variable parameters // related to this problem. #include "spatialparams_tracer.hh" // ### Define basic properties for our simulation // We enter the namespace Dumux namespace Dumux { // The problem class is forward declared: template class TracerTestProblem; // We enter the namespace Properties, namespace Properties { // A TypeTag for our simulation is created which inherits from the tracer model and the // cell centered, two-point-flux discretization scheme. namespace TTag { struct TracerTest { using InheritsFrom = std::tuple; }; struct TracerTestCC { using InheritsFrom = std::tuple; }; } // We enable caching for the grid volume variables, the flux variables and the FV grid geometry. template struct EnableGridVolumeVariablesCache { static constexpr bool value = true; }; template struct EnableGridFluxVariablesCache { static constexpr bool value = true; }; template struct EnableGridGeometryCache { static constexpr bool value = true; }; // We use the same grid as in the stationary one-phase model, a structured 2D grid: template struct Grid { using type = Dune::YaspGrid<2>; }; // The problem class specifies initial and boundary conditions: template struct Problem { using type = TracerTestProblem; }; // We define the spatial parameters for our tracer simulation: template struct SpatialParams { private: using GridGeometry = GetPropType; using Scalar = GetPropType; public: using type = TracerTestSpatialParams; }; // One can choose between a formulation in terms of mass or mole fractions. Here, we are using mass fractions. template struct UseMoles { static constexpr bool value = false; }; // We use solution-independent molecular diffusion coefficients. Per default, solution-dependent // diffusion coefficients are assumed during the computation of the jacobian matrix entries. Specifying // solution-independent diffusion coefficients can speed up computations: template struct SolutionDependentMolecularDiffusion { static constexpr bool value = false; }; // In the following, we create a new tracer fluid system and derive from the base fluid system. template class TracerFluidSystem : public FluidSystems::Base, TracerFluidSystem> { // We define some convenience aliases: using Scalar = GetPropType; using Problem = GetPropType; using GridView = typename GetPropType::GridView; using Element = typename GridView::template Codim<0>::Entity; using FVElementGeometry = typename GetPropType::LocalView; using SubControlVolume = typename FVElementGeometry::SubControlVolume; public: // We specify that the fluid system only contains tracer components, static constexpr bool isTracerFluidSystem() { return true; } // We define the number of components of this fluid system (one single tracer component) static constexpr int numComponents = 1; // This interface is designed to define the names of the components of the fluid system. // Here, we only have a single component, so compIdx should always be 0. // The component name is used for the vtk output. static std::string componentName(int compIdx = 0) { return "tracer_" + std::to_string(compIdx); } // We set the phase name for the phase index (phaseIdx) for velocity vtk output: // Here, we only have a single phase, so phaseIdx should always be zero. static std::string phaseName(int phaseIdx = 0) { return "Groundwater"; } // We set the molar mass of the tracer component with index compIdx (should again always be zero here). static Scalar molarMass(unsigned int compIdx = 0) { return 0.300; } // We set the value for the binary diffusion coefficient. This // might depend on spatial parameters like pressure / temperature. // But, in this case we neglect diffusion and return 0.0: static Scalar binaryDiffusionCoefficient(unsigned int compIdx, const Problem& problem, const Element& element, const SubControlVolume& scv) { return 0.0; } }; // We set the above created tracer fluid system: template struct FluidSystem { using type = TracerFluidSystem; }; // We leave the namespace Properties. } // ### The problem class // We enter the problem class where all necessary boundary conditions and initial conditions are set for our simulation. // As this is a porous medium problem, we inherit from the base class PorousMediumFlowProblem. // As this is a porous medium flow problem, we inherit from the base class PorousMediumFlowProblem. namespace Dumux { template class TracerTestProblem : public PorousMediumFlowProblem { ... ... @@ -244,7 +132,7 @@ public: } private: // We assign a private global variable for the epsilon: // We assign a private global variable for the epsilon: static constexpr Scalar eps_ = 1e-6; // This is everything the tracer problem class contains. ... ...
 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- // vi: set et ts=4 sw=4 sts=4: /***************************************************************************** * See the file COPYING for full copying permissions. * * * * 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 3 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 . * *****************************************************************************/ // ### Header guard #ifndef DUMUX_ONEP_TEST_PROPERTIES_HH #define DUMUX_ONEP_TEST_PROPERTIES_HH // This file defines the TypeTag used for the single-phase simulation, for // which we then define the necessary properties. // // ### Include files // The TypeTag defined for this simulation will inherit all properties from the // OneP type tag, a convenience type tag that predefines most of the required // properties for single-phase flow simulations in DuMuX. The properties that will be // defined in this file are those that depend on user choices and no meaningful // default can be set. #include // We want to use YaspGrid, an implementation of the dune grid interface for structured grids: #include // In this example, we want to discretize the equations with the cell centered finite volume // scheme using two-point-flux approximation: #include // The fluid properties are specified in the following headers (we use liquid water as the fluid phase): #include #include // The local residual for incompressible flow is included. // The one-phase flow model (included above) uses a default implementation of the // local residual for single-phase flow. However, in this example we are using an // incompressible fluid phase. Therefore, we are including the specialized local // residual which contains functionality to analytically compute the entries of // the Jacobian matrix. We will use this in the main file. #include // We include the problem and spatial parameters headers used for this simulation. #include "problem_1p.hh" #include "spatialparams_1p.hh" // ### Basic property definitions for the 1p problem // We enter the namespace Dumux::Properties in order to import the entire Dumux namespace for general use: namespace Dumux:: Properties { // A TypeTag for our simulation is created which inherits from the one-phase flow model // and the cell centered finite volume scheme with two-point-flux discretization scheme: namespace TTag { struct IncompressibleTest { using InheritsFrom = std::tuple; }; } // We use a structured 2D grid: template struct Grid { using type = Dune::YaspGrid<2>; }; // The problem class specifies initial and boundary conditions: template struct Problem { using type = OnePTestProblem; }; // We define the spatial parameters for our simulation: template struct SpatialParams { private: using GridGeometry = GetPropType; using Scalar = GetPropType; public: using type = OnePTestSpatialParams; }; // We use the local residual that contains analytic derivative methods for incompressible flow: template struct LocalResidual { using type = OnePIncompressibleLocalResidual; }; // In the following we define the fluid system to be used: template struct FluidSystem { private: using Scalar = GetPropType; public: using type = FluidSystems::OnePLiquid >; }; // This enables grid-wide caching of the volume variables. template struct EnableGridVolumeVariablesCache { static constexpr bool value = true; }; //This enables grid wide caching for the flux variables. template struct EnableGridFluxVariablesCache { static constexpr bool value = true; }; // This enables grid-wide caching for the finite volume grid geometry template struct EnableGridGeometryCache { static constexpr bool value = true; }; // The caches store values that were already calculated for later usage. This increases the memory demand but makes the simulation faster. // We leave the namespace Dumux::Properties. } // end namespace Dumux::Properties #endif
 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- // vi: set et ts=4 sw=4 sts=4: /***************************************************************************** * See the file COPYING for full copying permissions. * * * * 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 3 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 . * *****************************************************************************/ // ### Header guard #ifndef DUMUX_TRACER_TEST_PROPERTIES_HH #define DUMUX_TRACER_TEST_PROPERTIES_HH // This file defines the TypeTag used for the tracer transport simulation, for // which we then define the necessary properties. // // ### Include files // As for the single-phase problem, aTypeTag is defined for this simulation. // Here, we inherit all properties from the Tracer type tag, a convenience type tag // that predefines most of the required properties for tracer transport flow simulations in DuMuX. #include // Again, we use YaspGrid, an implementation of the dune grid interface for structured grids: #include // and the cell centered, two-point-flux discretization. #include // This includes the base class for fluid systems. We will define a custom fluid // system that inherits from that class. #include // We include the problem and spatial parameters headers used for this simulation. #include "problem_tracer.hh" #include "spatialparams_tracer.hh" // ### Basic property definitions for the tracer transport problem // We enter the namespace Dumux namespace Dumux { // In the following, we create a new tracer fluid system and derive from the base fluid system. template class TracerFluidSystem : public FluidSystems::Base, TracerFluidSystem> { // We define some convenience aliases to be used inside this class. using Scalar = GetPropType; using Problem = GetPropType; using GridView = GetPropType; using Element = typename GridView::template Codim<0>::Entity; using FVElementGeometry = typename GetPropType::LocalView; using SubControlVolume = typename FVElementGeometry::SubControlVolume; public: // We specify that the fluid system only contains tracer components, static constexpr bool isTracerFluidSystem() { return true; } // and that no component is the main component static constexpr int getMainComponent(int phaseIdx) { return -1; } // We define the number of components of this fluid system (one single tracer component) static constexpr int numComponents = 1; // This interface is designed to define the names of the components of the fluid system. // Here, we only have a single component, so compIdx should always be 0. // The component name is used for the vtk output. static std::string componentName(int compIdx = 0) { return "tracer_" + std::to_string(compIdx); } // We set the phase name for the phase index (phaseIdx) for velocity vtk output: // Here, we only have a single phase, so phaseIdx should always be zero. static std::string phaseName(int phaseIdx = 0) { return "Groundwater"; } // We set the molar mass of the tracer component with index compIdx (should again always be zero here). static Scalar molarMass(unsigned int compIdx = 0) { return 0.300; } // We set the value for the binary diffusion coefficient. This // might depend on spatial parameters like pressure / temperature. // But, in this case we neglect diffusion and return 0.0: static Scalar binaryDiffusionCoefficient(unsigned int compIdx, const Problem& problem, const Element& element, const SubControlVolume& scv) { return 0.0; } }; // We enter the namespace Properties namespace Properties { // A TypeTag for our simulation is created which inherits from the tracer model and the // cell centered discretization scheme using two-point flux approximation. namespace TTag { struct TracerTest { using InheritsFrom = std::tuple; }; struct TracerTestCC { using InheritsFrom = std::tuple; }; } // We enable caching for the grid volume variables, the flux variables and the FV grid geometry. template struct EnableGridVolumeVariablesCache { static constexpr bool value = true; }; template struct EnableGridFluxVariablesCache { static constexpr bool value = true; }; template struct EnableGridGeometryCache { static constexpr bool value = true; }; // We use the same grid as in the stationary one-phase model, a structured 2D grid: template struct Grid { using type = Dune::YaspGrid<2>; }; // The problem class that specifies initial and boundary conditions: template struct Problem { using type = TracerTestProblem; }; // We define the spatial parameters for our tracer simulation: template struct SpatialParams { private: using GridGeometry = GetPropType; using Scalar = GetPropType; public: using type = TracerTestSpatialParams; }; // One can choose between a formulation in terms of mass or mole fractions. // Here, we are using mass fractions. template struct UseMoles { static constexpr bool value = false; }; // We use solution-independent molecular diffusion coefficients. Per default, solution-dependent // diffusion coefficients are assumed during the computation of the jacobian matrix entries. Specifying // solution-independent diffusion coefficients can speed up computations: template struct SolutionDependentMolecularDiffusion { static constexpr bool value = false; }; // We set the above created tracer fluid system: template struct FluidSystem { using type = TracerFluidSystem; }; // We leave the namespace Properties and Dumux. } // end namespace Properties } // end namespace Dumux #endif
 ... ... @@ -23,26 +23,30 @@ // ## The file spatialparams_1p.hh // // // In this file, we generate a random permeability field in the constructor of the OnePTestSpatialParams class. // For this, we use the random number generation facilities provided by the C++ standard library. // This file contains the __spatial parameters class__ which defines the // distributions for the porous medium parameters permeability and porosity // over the computational grid // // In this example, we use a randomly generated and element-wise distributed // permeability field. For this, we use the random number generation facilitie // provided by the C++ standard library. #include // We use the properties for porous medium flow models, declared in the file properties.hh. #include // We include the spatial parameters class for single-phase models discretized by finite volume schemes. // The spatial parameters defined for this example will inherit from those. // We include the spatial parameters class for single-phase models discretized // by finite volume schemes, from which the spatial parameters defined for this // example will inherit. #include namespace Dumux { // In the OnePTestSpatialParams class, we define all functions needed to describe the porous medium, e.g. porosity and permeability for the 1p_problem. // In the OnePTestSpatialParams` class, we define all functions needed to describe // the porous medium, e.g. porosity and permeability, for the 1p_problem. template class OnePTestSpatialParams : public FVSpatialParamsOneP> { // We declare aliases for types that we are going to need in this class. // The following convenience aliases will be used throughout this class: using GridView = typename GridGeometry::GridView; using FVElementGeometry = typename GridGeometry::LocalView; using SubControlVolume = typename FVElementGeometry::SubControlVolume; ... ... @@ -58,15 +62,17 @@ public: