Commit 28b678e4 authored by Sina Ackermann's avatar Sina Ackermann Committed by Timo Koch
Browse files

[tracer] Adapt tracer model

* use getParam
* change structure
* move properties to model.hh and remove folder implicit
parent 57ee0633
add_subdirectory("implicit")
#install headers
install(FILES
indices.hh
model.hh
localresidual.hh
volumevariables.hh
vtkoutputfields.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/porousmediumflow/1p2c/implicit)
#install headers
install(FILES
indices.hh
model.hh
properties.hh
propertydefaults.hh
volumevariables.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/porousmediumflow/1p2c/implicit)
// -*- 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 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 <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \brief Base class for all models which use the fully implicit tracer model.
* Adaption of the fully implicit scheme to the tracer transport model.
*/
#ifndef DUMUX_TRACER_MODEL_HH
#define DUMUX_TRACER_MODEL_HH
#include "properties.hh"
namespace Dumux
{
/*!
* \ingroup TracerModel
* \brief Adaption of the fully implicit scheme to the tracer transport model.
*
* This model implements a transport of a tracer, where density and viscosity of the
* fluid phase in which the tracer gets transported are not affected by the tracer.
* The velocity field is a given spatial parameter.
* The model is mainly useful for fast computations on given or precomputed
* velocity fields and thus generally makes sense only in combination with an incompressible
* one-phase flow velocity field or analytically given / artificial fields. However, reactions
* between multiple tracer components can be implemented.
*
* The transport of the components \f$\kappa \in \{ a, b, c, ... \}\f$ is described by the following equation:
\f[
\phi \frac{ \partial \varrho X^\kappa}{\partial t}
- \text{div} \left\lbrace \varrho X^\kappa {\textbf v_f}
+ \varrho D^\kappa_\text{pm} \frac{M^\kappa}{M_\alpha} \textbf{grad} x^\kappa \right\rbrace = q.
\f]
*
* All equations are discretized using a vertex-centered finite volume (box)
* or cell-centered finite volume scheme (TPFA or MPFA) as spatial
* and the implicit Euler method as time discretization.
* The model is able to use either mole or mass fractions. The property useMoles can be set to either true or false in the
* problem file. Make sure that the according units are used in the problem setup. useMoles is set to true by default.
*
* The primary variables the mole or mass fraction of dissolved components \f$x\f$.
* Note that the tracer model is always considered non-isothermal.
* The velocity output is fully compatible with the tracer model if you want to write the velocity field to vtk.
*/
template<class TypeTag >
class TracerModel : public GET_PROP_TYPE(TypeTag, BaseModel)
{
using ParentType = typename GET_PROP_TYPE(TypeTag, BaseModel);
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables);
public:
/*!
* \brief Apply the initial conditions to the model.
*
* \param problem The object representing the problem which needs to
* be simulated.
*/
void init(Problem& problem)
{
ParentType::init(problem);
// register standardized vtk output fields
auto& vtkOutputModule = problem.vtkOutputModule();
vtkOutputModule.addSecondaryVariable("x_" + std::string(FluidSystem::componentName(0)),
[](const VolumeVariables& v){ return v.moleFraction(0, 0); });
vtkOutputModule.addSecondaryVariable("X_" + std::string(FluidSystem::componentName(0)),
[](const VolumeVariables& v){ return v.massFraction(0, 0); });
vtkOutputModule.addSecondaryVariable("rho", [](const VolumeVariables& v){ return v.density(); });
}
};
} // end namespace Dumux
#include "propertydefaults.hh"
#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 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 <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \ingroup Properties
* \ingroup ImplicitProperties
* \ingroup TracerModel
* \file
*
* \brief Defines the properties required for the fully implicit tracer model.
*/
#ifndef DUMUX_TRACER_PROPERTIES_HH
#define DUMUX_TRACER_PROPERTIES_HH
#include <dumux/porousmediumflow/nonisothermal/implicit/model.hh>
namespace Dumux
{
// \{
namespace Properties
{
//////////////////////////////////////////////////////////////////
// Type tags
//////////////////////////////////////////////////////////////////
//! The type tags for the fully implicit tracer model.
NEW_TYPE_TAG(Tracer);
NEW_TYPE_TAG(BoxTracer, INHERITS_FROM(BoxModel, Tracer));
NEW_TYPE_TAG(CCTracer, INHERITS_FROM(CCTpfaModel, Tracer));
//////////////////////////////////////////////////////////////////
// Property tags
//////////////////////////////////////////////////////////////////
NEW_PROP_TAG(NumPhases); //!< Number of fluid phases in the system
NEW_PROP_TAG(NumComponents); //!< Number of fluid components in the system
NEW_PROP_TAG(Indices); //!< Enumerations for the model
NEW_PROP_TAG(SpatialParams); //!< The type of the spatial parameters
NEW_PROP_TAG(EffectiveDiffusivityModel); //!< The employed model for the computation of the effective diffusivity
NEW_PROP_TAG(FluidSystem); //!< Type of the multi-component relations
NEW_PROP_TAG(UseMoles); //!< Defines whether mole (true) or mass (false) fractions are used
NEW_PROP_TAG(SpatialParamsForchCoeff); //!< Property for the forchheimer coefficient
NEW_PROP_TAG(TauTortuosity); //!< Tortuosity value (tau) used in macroscopic diffusion
NEW_PROP_TAG(ProblemEnableGravity); //!< gravity flag for compatibility
}
// \}
}
#endif
......@@ -24,8 +24,6 @@
#ifndef DUMUX_TRACER_INDICES_HH
#define DUMUX_TRACER_INDICES_HH
#include "properties.hh"
namespace Dumux
{
// \{
......
......@@ -25,6 +25,8 @@
#ifndef DUMUX_TRACER_LOCAL_RESIDUAL_HH
#define DUMUX_TRACER_LOCAL_RESIDUAL_HH
#include <dumux/common/properties.hh>
namespace Dumux
{
......@@ -186,7 +188,7 @@ public:
}
template<class PartialDerivativeMatrices, class T = TypeTag>
std::enable_if_t<!GET_PROP_VALUE(T, ImplicitIsBox), void>
std::enable_if_t<GET_PROP_VALUE(T, DiscretizationMethod) != DiscretizationMethods::Box, void>
addFluxDerivatives(PartialDerivativeMatrices& derivativeMatrices,
const Problem& problem,
const Element& element,
......@@ -203,7 +205,7 @@ public:
const auto volFlux = problem.spatialParams().volumeFlux(element, fvGeometry, curElemVolVars, scvf);
// the upwind weight
static const Scalar upwindWeight = GET_PARAM_FROM_GROUP(TypeTag, Scalar, Implicit, UpwindWeight);
static const Scalar upwindWeight = getParam<Scalar>("Implicit.UpwindWeight");
// get the inside and outside volvars
const auto& insideVolVars = curElemVolVars[scvf.insideScvIdx()];
......@@ -230,7 +232,7 @@ public:
}
template<class JacobianMatrix, class T = TypeTag>
std::enable_if_t<GET_PROP_VALUE(T, ImplicitIsBox), void>
std::enable_if_t<GET_PROP_VALUE(T, DiscretizationMethod) == DiscretizationMethods::Box, void>
addFluxDerivatives(JacobianMatrix& A,
const Problem& problem,
const Element& element,
......@@ -248,7 +250,7 @@ public:
const auto volFlux = problem.spatialParams().volumeFlux(element, fvGeometry, curElemVolVars, scvf);
// the upwind weight
static const Scalar upwindWeight = GET_PARAM_FROM_GROUP(TypeTag, Scalar, Implicit, UpwindWeight);
static const Scalar upwindWeight = getParam<Scalar>("Implicit.UpwindWeight");
// get the inside and outside volvars
const auto& insideVolVars = curElemVolVars[scvf.insideScvIdx()];
......
......@@ -16,43 +16,74 @@
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
#ifndef DUMUX_TRACER_MODEL_HH
#define DUMUX_TRACER_MODEL_HH
/*!
* \ingroup Properties
* \ingroup ImplicitProperties
* \ingroup TracerModel
* \file
* \ingroup TracerModel
* \brief Adaption of the fully implicit scheme to the tracer transport model.
*
* This model implements a transport of a tracer, where density and viscosity of the
* fluid phase in which the tracer gets transported are not affected by the tracer.
* The velocity field is a given spatial parameter.
* The model is mainly useful for fast computations on given or precomputed
* velocity fields and thus generally makes sense only in combination with an incompressible
* one-phase flow velocity field or analytically given / artificial fields. However, reactions
* between multiple tracer components can be implemented.
*
* \brief Defines some default values for the properties of the fully implicit tracer model.
*/
* The transport of the components \f$\kappa \in \{ a, b, c, ... \}\f$ is described by the following equation:
\f[
\phi \frac{ \partial \varrho X^\kappa}{\partial t}
- \text{div} \left\lbrace \varrho X^\kappa {\textbf v_f}
+ \varrho D^\kappa_\text{pm} \frac{M^\kappa}{M_\alpha} \textbf{grad} x^\kappa \right\rbrace = q.
\f]
*
* All equations are discretized using a vertex-centered finite volume (box)
* or cell-centered finite volume scheme (TPFA or MPFA) as spatial
* and the implicit Euler method as time discretization.
* The model is able to use either mole or mass fractions. The property useMoles can be set to either true or false in the
* problem file. Make sure that the according units are used in the problem setup. useMoles is set to true by default.
*
* The primary variables the mole or mass fraction of dissolved components \f$x\f$.
* Note that the tracer model is always considered non-isothermal.
* The velocity output is fully compatible with the tracer model if you want to write the velocity field to vtk.
*/
#ifndef DUMUX_TRACER_PROPERTY_DEFAULTS_HH
#define DUMUX_TRACER_PROPERTY_DEFAULTS_HH
#include <dumux/common/properties.hh>
#include <dumux/material/spatialparams/implicit1p.hh>
#include <dumux/discretization/stationaryvelocityfield.hh>
#include <dumux/material/fluidmatrixinteractions/diffusivityconstanttortuosity.hh>
#include <dumux/porousmediumflow/properties.hh>
#include "properties.hh"
#include "model.hh"
#include "volumevariables.hh"
#include "indices.hh"
#include "localresidual.hh"
#include "volumevariables.hh"
#include "vtkoutputfields.hh"
#include <dumux/material/spatialparams/implicit1p.hh>
#include <dumux/discretization/stationaryvelocityfield.hh>
#include <dumux/material/fluidmatrixinteractions/diffusivityconstant.hh>
#include "localresidual.hh"
namespace Dumux
{
// \{
namespace Properties
{
//////////////////////////////////////////////////////////////////
// Property values
// Type tags
//////////////////////////////////////////////////////////////////
//! The type tags for the fully implicit tracer model.
NEW_TYPE_TAG(Tracer, INHERITS_FROM(PorousMediumFlow));
///////////////////////////////////////////////////////////////////////////
// properties for the tracer model
///////////////////////////////////////////////////////////////////////////
SET_INT_PROP(Tracer, NumPhases, 1); //!< The number of phases
SET_PROP(Tracer, NumEq) //!< set the number of equations
{
using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
static const int value = FluidSystem::numComponents;
static_assert(GET_PROP_VALUE(TypeTag, NumComponents) == value, "Number of equation has to be equal to number of components.");
};
SET_PROP(Tracer, NumComponents) //!< set the number of components
......@@ -66,9 +97,6 @@ SET_BOOL_PROP(Tracer, UseMoles, true); //!< Define that mole fractions are used
//! Use the tracer local residual function for the tracer model
SET_TYPE_PROP(Tracer, LocalResidual, TracerLocalResidual<TypeTag>);
//! define the model
SET_TYPE_PROP(Tracer, Model, TracerModel<TypeTag>);
//! Set the default vtk output fields
SET_TYPE_PROP(Tracer, VtkOutputFields, TracerVtkOutputFields<TypeTag>);
......@@ -78,43 +106,19 @@ SET_TYPE_PROP(Tracer, VolumeVariables, TracerVolumeVariables<TypeTag>);
//! We use darcy's law as the default for the advective fluxes
SET_TYPE_PROP(Tracer, AdvectionType, StationaryVelocityField<TypeTag>);
//! set gravity flag for compatibility
SET_BOOL_PROP(Tracer, ProblemEnableGravity, false);
//! Set the indices used by the tracer model
SET_TYPE_PROP(Tracer, Indices, TracerIndices<TypeTag>);
//! The spatial parameters to be employed.
//! Use ImplicitSpatialParamsOneP by default.
SET_TYPE_PROP(Tracer, SpatialParams, ImplicitSpatialParamsOneP<TypeTag>);
//! Use simple model with constant tortuosity as pm diffusivity model
SET_PROP(Tracer, EffectiveDiffusivityModel)
{
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using type = DiffusivityConstant<TypeTag>;
};
SET_TYPE_PROP(Tracer, EffectiveDiffusivityModel, DiffusivityConstantTortuosity<typename GET_PROP_TYPE(TypeTag, Scalar)>);
// physical processes to be considered by the isothermal model
SET_BOOL_PROP(Tracer, EnableAdvection, true);
SET_BOOL_PROP(Tracer, EnableMolecularDiffusion, true);
SET_BOOL_PROP(Tracer, EnableEnergyBalance, false);
//! default value for the forchheimer coefficient
// Source: Ward, J.C. 1964 Turbulent flow in porous media. ASCE J. Hydraul. Div 90.
// Actually the Forchheimer coefficient is also a function of the dimensions of the
// porous medium. Taking it as a constant is only a first approximation
// (Nield, Bejan, Convection in porous media, 2006, p. 10)
SET_SCALAR_PROP(Tracer, SpatialParamsForchCoeff, 0.55);
/*!
* \brief default value for tortuosity value (tau) used in macroscopic diffusion
*
* Value is 0.5 according to Carman 1937: <i>Fluid flow through granular beds</i>
* \cite carman1937
*/
SET_SCALAR_PROP(Tracer, TauTortuosity, 0.5);
} // end namespace Properties
// \}
} // end namespace Dumux
......
......@@ -23,10 +23,9 @@
#ifndef DUMUX_TRACER_VOLUME_VARIABLES_HH
#define DUMUX_TRACER_VOLUME_VARIABLES_HH
#include <dumux/common/properties.hh>
#include <dumux/discretization/volumevariables.hh>
#include "properties.hh"
namespace Dumux
{
......
......@@ -23,7 +23,7 @@
#ifndef DUMUX_TRACER_VTK_OUTPUT_FIELDS_HH
#define DUMUX_TRACER_VTK_OUTPUT_FIELDS_HH
#include <dumux/implicit/properties.hh>
#include <dumux/common/properties.hh>
namespace Dumux
{
......@@ -44,12 +44,12 @@ public:
// register standardized vtk output fields
for (int compIdx = 0; compIdx < FluidSystem::numComponents; ++compIdx)
{
vtk.addSecondaryVariable("x_" + std::string(FluidSystem::componentName(compIdx)),
[compIdx](const VolumeVariables& v){ return v.moleFraction(0, compIdx); });
vtk.addSecondaryVariable("X_" + std::string(FluidSystem::componentName(compIdx)),
[compIdx](const VolumeVariables& v){ return v.massFraction(0, compIdx); });
vtk.addVolumeVariable( [compIdx](const VolumeVariables& v){ return v.moleFraction(0, compIdx); },
"x_" + std::string(FluidSystem::componentName(compIdx)));
vtk.addVolumeVariable( [compIdx](const VolumeVariables& v){ return v.massFraction(0, compIdx); },
"X_" + std::string(FluidSystem::componentName(compIdx)));
}
vtk.addSecondaryVariable("rho", [](const VolumeVariables& v){ return v.density(); });
vtk.addVolumeVariable( [](const VolumeVariables& v){ return v.density(); },"rho");
}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment