Commit a6ea9aee authored by Dennis Gläser's avatar Dennis Gläser
Browse files

introduce model traits and property

This commit introduce a model traits class that encapsulates a few properties,
such as NumEq, NumComponents as well as the specifications on active processes
(EnableAdvection ... ). The respective property tags become obsolete and can be
deleted.
parent 672c5f3b
......@@ -58,7 +58,7 @@ class BoxLocalAssemblerBase : public FVLocalAssemblerBase<TypeTag, Assembler, Im
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
enum { numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq() };
public:
......@@ -223,7 +223,7 @@ class BoxLocalAssembler<TypeTag, Assembler, DiffMethod::numeric, /*implicit=*/tr
using LocalResidual = typename GET_PROP_TYPE(TypeTag, LocalResidual);
using ElementResidualVector = typename LocalResidual::ElementResidualVector;
enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
enum { numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq() };
enum { dim = GET_PROP_TYPE(TypeTag, GridView)::dimension };
static constexpr bool enableGridFluxVarsCache = GET_PROP_VALUE(TypeTag, EnableGridFluxVariablesCache);
......@@ -342,7 +342,7 @@ class BoxLocalAssembler<TypeTag, Assembler, DiffMethod::numeric, /*implicit=*/fa
using LocalResidual = typename GET_PROP_TYPE(TypeTag, LocalResidual);
using ElementResidualVector = typename LocalResidual::ElementResidualVector;
enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
enum { numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq() };
enum { dim = GET_PROP_TYPE(TypeTag, GridView)::dimension };
public:
......
......@@ -140,7 +140,7 @@ class CCLocalAssembler<TypeTag, Assembler, DiffMethod::numeric, /*implicit=*/tru
using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables);
using JacobianMatrix = typename GET_PROP_TYPE(TypeTag, JacobianMatrix);
enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
enum { numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq() };
enum { dim = GET_PROP_TYPE(TypeTag, GridView)::dimension };
using FluxStencil = Dumux::FluxStencil<FVElementGeometry>;
......@@ -316,7 +316,7 @@ class CCLocalAssembler<TypeTag, Assembler, DiffMethod::numeric, /*implicit=*/fal
using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables);
using JacobianMatrix = typename GET_PROP_TYPE(TypeTag, JacobianMatrix);
enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
enum { numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq() };
public:
using ParentType::ParentType;
......
......@@ -88,7 +88,7 @@ class StaggeredLocalAssembler<TypeTag,
using FaceSolutionVector = typename GET_PROP_TYPE(TypeTag, FaceSolutionVector);
using FaceSolution = typename GET_PROP_TYPE(TypeTag, StaggeredFaceSolution);
enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
enum { numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq() };
using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables);
......
......@@ -47,6 +47,7 @@ NEW_PROP_TAG(Indices); //!< Enumerations for the numeric model
NEW_PROP_TAG(PrimaryVariables); //!< A vector of primary variables
NEW_PROP_TAG(NumEqVector); //!< A vector of size number equations that can be used for Neumann fluxes, sources, residuals, ...
NEW_PROP_TAG(GridView); //!< The type of the grid view according to the grid type
NEW_PROP_TAG(ModelTraits); //!< Traits class encapsulating model specifications
NEW_PROP_TAG(Problem); //!< Property to specify the type of a problem which has to be solved
NEW_PROP_TAG(PointSource); //!< Property defining the type of point source used
NEW_PROP_TAG(PointSourceHelper); //!< Property defining the class that computes which sub control volume point sources belong to
......@@ -131,7 +132,7 @@ NEW_PROP_TAG(UseKelvinEquation); //!< If we use Kelvin equatio
////////////////////////////////////////////////////////////////////////////////
// Properties used by models involving mineralization:
////////////////////////////////////////////////////////////////////////////////
NEW_PROP_TAG(NumSPhases);
NEW_PROP_TAG(NonMineralizationModelTraits);
NEW_PROP_TAG(NonMineralizationVtkOutputFields);
NEW_PROP_TAG(NonMineralizationVolumeVariables);
......@@ -143,6 +144,7 @@ NEW_PROP_TAG(IsothermalVolumeVariables);
NEW_PROP_TAG(IsothermalLocalResidual);
NEW_PROP_TAG(IsothermalIndices);
NEW_PROP_TAG(IsothermalNumEq);
NEW_PROP_TAG(IsothermalModelTraits);
// specify if we evaluate the permeability in the volume (for discontinuous fields)
// or at the scvf center for analytical permeability fields (e.g. convergence studies)
......@@ -195,7 +197,7 @@ NEW_PROP_TAG(PressureFormulation); //! the formulation of the pressure e.g most
/////////////////////////////////////////////////////////////
// Properties used by the nonequilibrium model
/////////////////////////////////////////////////////////////
NEW_PROP_TAG(EquilibriumModelTraits);
NEW_PROP_TAG(EquilibriumLocalResidual);
NEW_PROP_TAG(EquilibriumIndices);
NEW_PROP_TAG(EquilibriumVtkOutputFields);
......
......@@ -43,7 +43,7 @@ NEW_TYPE_TAG(ModelProperties);
SET_TYPE_PROP(ModelProperties, Scalar, double);
//! Set the default vector with size number of equations to a field vector
SET_TYPE_PROP(ModelProperties, NumEqVector, Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), GET_PROP_VALUE(TypeTag, NumEq)>);
SET_TYPE_PROP(ModelProperties, NumEqVector, Dune::FieldVector<typename GET_PROP_TYPE(TypeTag, Scalar), GET_PROP_TYPE(TypeTag, ModelTraits)::numEq()>);
//! Set the default primary variable vector to a vector of size of number of equations
SET_TYPE_PROP(ModelProperties, PrimaryVariables, typename GET_PROP_TYPE(TypeTag, NumEqVector));
......
......@@ -62,8 +62,8 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::box>
enum { dimWorld = GridView::dimensionworld} ;
enum
{
numPhases = GET_PROP_VALUE(TypeTag, NumPhases),
numComponents = GET_PROP_VALUE(TypeTag,NumComponents)
numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(),
numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents()
};
using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
......
......@@ -60,7 +60,7 @@ class FouriersLawImplementation<TypeTag, DiscretizationMethod::box>
enum { dim = GridView::dimension} ;
enum { dimWorld = GridView::dimensionworld} ;
enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases)} ;
enum { numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases()} ;
using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
......
......@@ -63,7 +63,7 @@ class FouriersLawNonEquilibriumImplementation<TypeTag, DiscretizationMethod::box
enum { dim = GridView::dimension} ;
enum { dimWorld = GridView::dimensionworld} ;
enum { numPhases = GET_PROP_VALUE(TypeTag, NumPhases)} ;
enum { numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases()} ;
enum { numEnergyEqFluid = GET_PROP_VALUE(TypeTag, NumEnergyEqFluid) };
enum {sPhaseIdx = FluidSystem::sPhaseIdx};
......
......@@ -64,8 +64,8 @@ class MaxwellStefansLawImplementation<TypeTag, DiscretizationMethod::box >
enum { dimWorld = GridView::dimensionworld} ;
enum
{
numPhases = GET_PROP_VALUE(TypeTag, NumPhases),
numComponents = GET_PROP_VALUE(TypeTag,NumComponents)
numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(),
numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents()
};
using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
......
......@@ -91,7 +91,7 @@ class DarcysLawImplementation<TypeTag, DiscretizationMethod::ccmpfa>
{
static constexpr int dim = GridView::dimension;
static constexpr int dimWorld = GridView::dimensionworld;
static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases);
static constexpr int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases();
using DualGridNodalIndexSet = typename GET_PROP_TYPE(TypeTag, DualGridNodalIndexSet);
using Stencil = typename DualGridNodalIndexSet::NodalGridStencilType;
......
......@@ -114,6 +114,7 @@ private:
template<class TypeTag>
class CCMpfaElementFluxVariablesCache<TypeTag, false>
{
using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits);
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using GridIndexType = typename GridView::IndexSet::IndexType;
using Element = typename GridView::template Codim<0>::Entity;
......@@ -133,12 +134,12 @@ class CCMpfaElementFluxVariablesCache<TypeTag, false>
//! physics traits class to define the data handles
struct PhysicsTraits
{
static constexpr bool enableAdvection = GET_PROP_VALUE(TypeTag, EnableAdvection);
static constexpr bool enableMolecularDiffusion = GET_PROP_VALUE(TypeTag, EnableMolecularDiffusion);
static constexpr bool enableHeatConduction = GET_PROP_VALUE(TypeTag, EnableEnergyBalance);
static constexpr bool enableAdvection = ModelTraits::enableAdvection();
static constexpr bool enableMolecularDiffusion = ModelTraits::enableMolecularDiffusion();
static constexpr bool enableHeatConduction = ModelTraits::enableEnergyBalance();
static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases);
static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents);
static constexpr int numPhases = ModelTraits::numPhases();
static constexpr int numComponents = ModelTraits::numComponents();
};
public:
......
......@@ -55,7 +55,7 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::ccmpfa>
using FluxVariablesCache = typename GET_PROP_TYPE(TypeTag, FluxVariablesCache);
using BalanceEqOpts = typename GET_PROP_TYPE(TypeTag, BalanceEqOpts);
static constexpr int numComponents = GET_PROP_VALUE(TypeTag,NumComponents);
static constexpr int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents();
using ComponentFluxVector = Dune::FieldVector<Scalar, numComponents>;
//! Class that fills the cache corresponding to mpfa Fick's Law
......@@ -111,7 +111,7 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::ccmpfa>
static constexpr int dim = GridView::dimension;
static constexpr int dimWorld = GridView::dimensionworld;
static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases);
static constexpr int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases();
public:
// export filler type
......
......@@ -42,6 +42,7 @@ namespace Dumux
template<class TypeTag>
class CCMpfaFluxVariablesCacheFiller
{
using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits);
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using Element = typename GridView::template Codim<0>::Entity;
......@@ -64,9 +65,9 @@ class CCMpfaFluxVariablesCacheFiller
static constexpr int dim = GridView::dimension;
static constexpr int dimWorld = GridView::dimensionworld;
static constexpr bool doAdvection = GET_PROP_VALUE(TypeTag, EnableAdvection);
static constexpr bool doDiffusion = GET_PROP_VALUE(TypeTag, EnableMolecularDiffusion);
static constexpr bool doHeatConduction = GET_PROP_VALUE(TypeTag, EnableEnergyBalance);
static constexpr bool doAdvection = ModelTraits::enableAdvection();
static constexpr bool doDiffusion = ModelTraits::enableMolecularDiffusion();
static constexpr bool doHeatConduction = ModelTraits::enableEnergyBalance();
static constexpr bool soldependentAdvection = GET_PROP_VALUE(TypeTag, SolutionDependentAdvection);
static constexpr bool soldependentDiffusion = GET_PROP_VALUE(TypeTag, SolutionDependentMolecularDiffusion);
......@@ -310,8 +311,8 @@ private:
using DiffusionType = typename GET_PROP_TYPE(TypeTag, MolecularDiffusionType);
using DiffusionFiller = typename DiffusionType::Cache::Filler;
static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases);
static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents);
static constexpr int numPhases = ModelTraits::numPhases();
static constexpr int numComponents = ModelTraits::numComponents();
for (unsigned int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
{
......@@ -497,7 +498,7 @@ private:
}
// assemble pressure vectors
for (unsigned int pIdx = 0; pIdx < GET_PROP_VALUE(TypeTag, NumPhases); ++pIdx)
for (unsigned int pIdx = 0; pIdx < ModelTraits::numPhases(); ++pIdx)
{
const auto& evv = &elemVolVars();
auto getPressure = [&evv, pIdx] (auto volVarIdx) { return (evv->operator[](volVarIdx)).pressure(pIdx); };
......
......@@ -49,6 +49,7 @@ class CCMpfaGridFluxVariablesCache;
template<class TypeTag>
class CCMpfaGridFluxVariablesCache<TypeTag, true>
{
using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits);
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using Element = typename GridView::template Codim<0>::Entity;
......@@ -71,12 +72,12 @@ class CCMpfaGridFluxVariablesCache<TypeTag, true>
//! physics traits class to define the data handles
struct PhysicsTraits
{
static constexpr bool enableAdvection = GET_PROP_VALUE(TypeTag, EnableAdvection);
static constexpr bool enableMolecularDiffusion = GET_PROP_VALUE(TypeTag, EnableMolecularDiffusion);
static constexpr bool enableHeatConduction = GET_PROP_VALUE(TypeTag, EnableEnergyBalance);
static constexpr bool enableAdvection = ModelTraits::enableAdvection();
static constexpr bool enableMolecularDiffusion = ModelTraits::enableMolecularDiffusion();
static constexpr bool enableHeatConduction = ModelTraits::enableEnergyBalance();
static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases);
static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents);
static constexpr int numPhases = ModelTraits::numPhases();
static constexpr int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents();
};
public:
......
......@@ -62,8 +62,8 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::cctpfa>
static const int dim = GridView::dimension;
static const int dimWorld = GridView::dimensionworld;
static const int numPhases = GET_PROP_VALUE(TypeTag, NumPhases);
static const int numComponents = GET_PROP_VALUE(TypeTag,NumComponents);
static const int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases();
static const int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents();
using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
......
......@@ -37,6 +37,7 @@ namespace Dumux
template<class TypeTag>
class CCTpfaFluxVariablesCacheFiller
{
using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits);
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::LocalView;
......@@ -47,9 +48,9 @@ class CCTpfaFluxVariablesCacheFiller
using Element = typename GridView::template Codim<0>::Entity;
static constexpr bool doAdvection = GET_PROP_VALUE(TypeTag, EnableAdvection);
static constexpr bool doDiffusion = GET_PROP_VALUE(TypeTag, EnableMolecularDiffusion);
static constexpr bool doHeatConduction = GET_PROP_VALUE(TypeTag, EnableEnergyBalance);
static constexpr bool doAdvection = ModelTraits::enableAdvection();
static constexpr bool doDiffusion = ModelTraits::enableMolecularDiffusion();
static constexpr bool doHeatConduction = ModelTraits::enableEnergyBalance();
static constexpr bool soldependentAdvection = GET_PROP_VALUE(TypeTag, SolutionDependentAdvection);
static constexpr bool soldependentDiffusion = GET_PROP_VALUE(TypeTag, SolutionDependentMolecularDiffusion);
......@@ -145,8 +146,8 @@ private:
using DiffusionFiller = typename DiffusionType::Cache::Filler;
using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases);
static constexpr int numComponents = GET_PROP_VALUE(TypeTag, NumComponents);
static constexpr int numPhases = ModelTraits::numPhases();
static constexpr int numComponents = ModelTraits::numComponents();
// forward to the filler of the diffusive quantities
for (unsigned int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
......
......@@ -63,8 +63,8 @@ class MaxwellStefansLawImplementation<TypeTag, DiscretizationMethod::cctpfa >
static const int dim = GridView::dimension;
static const int dimWorld = GridView::dimensionworld;
static const int numPhases = GET_PROP_VALUE(TypeTag, NumPhases);
static const int numComponents = GET_PROP_VALUE(TypeTag,NumComponents);
static const int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases();
static const int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents();
using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
......
......@@ -61,7 +61,7 @@ SET_BOOL_PROP(FiniteVolumeModel, EnableGridVolumeVariablesCache, false);
SET_BOOL_PROP(FiniteVolumeModel, EnableGridFluxVariablesCache, false);
//! Boundary types at a single degree of freedom
SET_TYPE_PROP(FiniteVolumeModel, BoundaryTypes, BoundaryTypes<GET_PROP_VALUE(TypeTag, NumEq)>);
SET_TYPE_PROP(FiniteVolumeModel, BoundaryTypes, BoundaryTypes<GET_PROP_TYPE(TypeTag, ModelTraits)::numEq()>);
// TODO: bundle SolutionVector, JacobianMatrix
// in LinearAlgebra traits
......@@ -74,7 +74,7 @@ SET_PROP(FiniteVolumeModel, JacobianMatrix)
{
private:
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
enum { numEq = GET_PROP_TYPE(TypeTag, ModelTraits)::numEq() };
using MatrixBlock = typename Dune::FieldMatrix<Scalar, numEq, numEq>;
public:
using type = typename Dune::BCRSMatrix<MatrixBlock>;
......
......@@ -86,6 +86,20 @@ SET_TYPE_PROP(StaggeredModel, ElementFluxVariablesCache, StaggeredElementFluxVar
//! Set the face solution type
SET_TYPE_PROP(StaggeredModel, StaggeredFaceSolution, StaggeredFaceSolution<TypeTag>);
//! Dummy model traits struct until the model traits
//! are actually implemented for models using staggered grid
SET_PROP(StaggeredModel, ModelTraits)
{
private:
struct DummyTraits
{
static constexpr int numEq() { return GET_PROP_VALUE(TypeTag, NumEq); }
static constexpr int numPhases() { return GET_PROP_VALUE(TypeTag, NumPhases); }
};
public:
using type = DummyTraits;
};
//! Set the grid variables (volume, flux and face variables)
SET_PROP(StaggeredModel, GridVariables)
{
......
......@@ -234,7 +234,7 @@ class VtkOutputModule
using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
static constexpr int numPhases = GET_PROP_VALUE(TypeTag, NumPhases);
static constexpr int numPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases();
static constexpr bool isBox = GET_PROP_TYPE(TypeTag, FVGridGeometry)::discMethod == DiscretizationMethod::box;
static constexpr int dofCodim = isBox ? dim : 0;
......
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