From a9e80dc4366d2435979ebf5c6c32afd2d713a157 Mon Sep 17 00:00:00 2001 From: Mathis Kelm <mathis.kelm@iws.uni-stuttgart.de> Date: Sat, 27 Feb 2021 00:30:17 +0100 Subject: [PATCH] [test][tracer] Separate properties into their own header --- test/porousmediumflow/tracer/2ptracer/main.cc | 4 +- .../tracer/2ptracer/problem_tracer.hh | 89 ----------- .../tracer/2ptracer/properties_tracer.hh | 112 +++++++++++++ .../tracer/2ptracer/spatialparams_tracer.hh | 2 +- test/porousmediumflow/tracer/constvel/main.cc | 2 +- .../tracer/constvel/problem.hh | 126 +-------------- .../tracer/constvel/properties.hh | 147 ++++++++++++++++++ .../tracer/multiphase/problem.hh | 3 + 8 files changed, 268 insertions(+), 217 deletions(-) create mode 100644 test/porousmediumflow/tracer/2ptracer/properties_tracer.hh create mode 100644 test/porousmediumflow/tracer/constvel/properties.hh diff --git a/test/porousmediumflow/tracer/2ptracer/main.cc b/test/porousmediumflow/tracer/2ptracer/main.cc index fdc17277fc..66625cb9ae 100644 --- a/test/porousmediumflow/tracer/2ptracer/main.cc +++ b/test/porousmediumflow/tracer/2ptracer/main.cc @@ -5,7 +5,7 @@ * * * 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 * + * 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, * @@ -31,7 +31,7 @@ #include <dune/grid/io/file/vtk.hh> #include <test/porousmediumflow/2p/incompressible/problem.hh> -#include "problem_tracer.hh" +#include "properties_tracer.hh" #include <dumux/common/properties.hh> #include <dumux/common/parameters.hh> diff --git a/test/porousmediumflow/tracer/2ptracer/problem_tracer.hh b/test/porousmediumflow/tracer/2ptracer/problem_tracer.hh index 75d5e9215c..4d059a4828 100644 --- a/test/porousmediumflow/tracer/2ptracer/problem_tracer.hh +++ b/test/porousmediumflow/tracer/2ptracer/problem_tracer.hh @@ -24,100 +24,11 @@ #ifndef DUMUX_TWOP_TRACER_TEST_PROBLEM_HH #define DUMUX_TWOP_TRACER_TEST_PROBLEM_HH -#include <dune/grid/yaspgrid.hh> - #include <dumux/common/boundarytypes.hh> -#include <dumux/discretization/cctpfa.hh> -#include <dumux/porousmediumflow/tracer/model.hh> #include <dumux/porousmediumflow/problem.hh> -#include <dumux/material/fluidsystems/base.hh> - -#include "spatialparams_tracer.hh" namespace Dumux { -/*! - * \ingroup TracerTests - * \brief A 2p problem with multiple tracer bands in a porous groundwater reservoir with a lens - */ -template <class TypeTag> -class TwoPTracerTestProblem; - -namespace Properties { -//Create new type tags -namespace TTag { -struct TwoPTracerTest { using InheritsFrom = std::tuple<Tracer>; }; -struct TwoPTracerTestTpfa { using InheritsFrom = std::tuple<TwoPTracerTest, CCTpfaModel>; }; -} // end namespace TTag - -// Set the grid type -template<class TypeTag> -struct Grid<TypeTag, TTag::TwoPTracerTest> { using type = Dune::YaspGrid<2>; }; - -// Set the problem property -template<class TypeTag> -struct Problem<TypeTag, TTag::TwoPTracerTest> { using type = TwoPTracerTestProblem<TypeTag>; }; - -// Set the spatial parameters -template<class TypeTag> -struct SpatialParams<TypeTag, TTag::TwoPTracerTest> -{ - using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; - using Scalar = GetPropType<TypeTag, Properties::Scalar>; - using type = TwoPTracerTestSpatialParams<GridGeometry, Scalar>; -}; - -// Define whether mole(true) or mass (false) fractions are used -template<class TypeTag> -struct UseMoles<TypeTag, TTag::TwoPTracerTest> { static constexpr bool value = false; }; -template<class TypeTag> -struct SolutionDependentMolecularDiffusion<TypeTag, TTag::TwoPTracerTestTpfa> { static constexpr bool value = false; }; - -//! A simple fluid system with one tracer component -template<class TypeTag> -class TracerFluidSystem : public FluidSystems::Base<GetPropType<TypeTag, Properties::Scalar>, - TracerFluidSystem<TypeTag>> -{ - using Scalar = GetPropType<TypeTag, Properties::Scalar>; - using Problem = GetPropType<TypeTag, Properties::Problem>; - using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; - using Element = typename GridView::template Codim<0>::Entity; - using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; - using SubControlVolume = typename FVElementGeometry::SubControlVolume; - -public: - //! If the fluid system only contains tracer components - static constexpr bool isTracerFluidSystem() - { return true; } - - //! The number of components - static constexpr int numComponents = 1; - - //! Human readable component name (index compIdx) (for vtk output) - static std::string componentName(int compIdx) - { return "tracer_" + std::to_string(compIdx); } - - //! Molar mass in kg/mol of the component with index compIdx - static Scalar molarMass(unsigned int compIdx) - { return 0.300; } - - //! Binary diffusion coefficient - //! (might depend on spatial parameters like pressure / temperature) - static Scalar binaryDiffusionCoefficient(unsigned int compIdx, - const Problem& problem, - const Element& element, - const SubControlVolume& scv) - { - static const Scalar D = getParam<Scalar>("Problem.BinaryDiffusionCoefficient"); - return D; - } -}; - -template<class TypeTag> -struct FluidSystem<TypeTag, TTag::TwoPTracerTest> { using type = TracerFluidSystem<TypeTag>; }; - -} // end namespace Properties - /*! * \ingroup TracerTests * diff --git a/test/porousmediumflow/tracer/2ptracer/properties_tracer.hh b/test/porousmediumflow/tracer/2ptracer/properties_tracer.hh new file mode 100644 index 0000000000..f248cd3db7 --- /dev/null +++ b/test/porousmediumflow/tracer/2ptracer/properties_tracer.hh @@ -0,0 +1,112 @@ +// -*- 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 <http://www.gnu.org/licenses/>. * + *****************************************************************************/ +/*! + * \file + * \ingroup TracerTests + * \brief The properties of the 2p problem with multiple tracer bands in a porous groundwater reservoir with a lens + */ +#ifndef DUMUX_2P_TRACER_TEST_PROPERTIES_HH +#define DUMUX_2P_TRACER_TEST_PROPERTIES_HH + +#include <dune/grid/yaspgrid.hh> + +#include <dumux/discretization/cctpfa.hh> +#include <dumux/porousmediumflow/tracer/model.hh> +#include <dumux/material/fluidsystems/base.hh> + +#include "spatialparams_tracer.hh" + +#include "problem_tracer.hh" + +namespace Dumux::Properties { +//Create new type tags +namespace TTag { +struct TwoPTracerTest { using InheritsFrom = std::tuple<Tracer>; }; +struct TwoPTracerTestTpfa { using InheritsFrom = std::tuple<TwoPTracerTest, CCTpfaModel>; }; +} // end namespace TTag + +// Set the grid type +template<class TypeTag> +struct Grid<TypeTag, TTag::TwoPTracerTest> { using type = Dune::YaspGrid<2>; }; + +// Set the problem property +template<class TypeTag> +struct Problem<TypeTag, TTag::TwoPTracerTest> { using type = TwoPTracerTestProblem<TypeTag>; }; + +// Set the spatial parameters +template<class TypeTag> +struct SpatialParams<TypeTag, TTag::TwoPTracerTest> +{ + using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; + using Scalar = GetPropType<TypeTag, Properties::Scalar>; + using type = TwoPTracerTestSpatialParams<GridGeometry, Scalar>; +}; + +// Define whether mole(true) or mass (false) fractions are used +template<class TypeTag> +struct UseMoles<TypeTag, TTag::TwoPTracerTest> { static constexpr bool value = false; }; +template<class TypeTag> +struct SolutionDependentMolecularDiffusion<TypeTag, TTag::TwoPTracerTestTpfa> { static constexpr bool value = false; }; + +//! A simple fluid system with one tracer component +template<class TypeTag> +class TracerFluidSystem : public FluidSystems::Base<GetPropType<TypeTag, Properties::Scalar>, + TracerFluidSystem<TypeTag>> +{ + using Scalar = GetPropType<TypeTag, Properties::Scalar>; + using Problem = GetPropType<TypeTag, Properties::Problem>; + using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; + using Element = typename GridView::template Codim<0>::Entity; + using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; + using SubControlVolume = typename FVElementGeometry::SubControlVolume; + +public: + //! If the fluid system only contains tracer components + static constexpr bool isTracerFluidSystem() + { return true; } + + //! The number of components + static constexpr int numComponents = 1; + + //! Human readable component name (index compIdx) (for vtk output) + static std::string componentName(int compIdx) + { return "tracer_" + std::to_string(compIdx); } + + //! Molar mass in kg/mol of the component with index compIdx + static Scalar molarMass(unsigned int compIdx) + { return 0.300; } + + //! Binary diffusion coefficient + //! (might depend on spatial parameters like pressure / temperature) + static Scalar binaryDiffusionCoefficient(unsigned int compIdx, + const Problem& problem, + const Element& element, + const SubControlVolume& scv) + { + static const Scalar D = getParam<Scalar>("Problem.BinaryDiffusionCoefficient"); + return D; + } +}; + +template<class TypeTag> +struct FluidSystem<TypeTag, TTag::TwoPTracerTest> { using type = TracerFluidSystem<TypeTag>; }; + +} // end namespace Dumux::Properties + +#endif diff --git a/test/porousmediumflow/tracer/2ptracer/spatialparams_tracer.hh b/test/porousmediumflow/tracer/2ptracer/spatialparams_tracer.hh index c4a8695833..356d7b577f 100644 --- a/test/porousmediumflow/tracer/2ptracer/spatialparams_tracer.hh +++ b/test/porousmediumflow/tracer/2ptracer/spatialparams_tracer.hh @@ -5,7 +5,7 @@ * * * 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 * + * 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, * diff --git a/test/porousmediumflow/tracer/constvel/main.cc b/test/porousmediumflow/tracer/constvel/main.cc index ce969bab15..39f605be34 100644 --- a/test/porousmediumflow/tracer/constvel/main.cc +++ b/test/porousmediumflow/tracer/constvel/main.cc @@ -41,7 +41,7 @@ #include <dumux/io/vtkoutputmodule.hh> #include <dumux/io/grid/gridmanager.hh> -#include "problem.hh" +#include "properties.hh" int main(int argc, char** argv) { diff --git a/test/porousmediumflow/tracer/constvel/problem.hh b/test/porousmediumflow/tracer/constvel/problem.hh index 3e52531d85..33a0b42e69 100644 --- a/test/porousmediumflow/tracer/constvel/problem.hh +++ b/test/porousmediumflow/tracer/constvel/problem.hh @@ -26,135 +26,13 @@ #ifndef DUMUX_TRACER_TEST_PROBLEM_HH #define DUMUX_TRACER_TEST_PROBLEM_HH -#include <dune/grid/yaspgrid.hh> - +#include <dumux/common/properties.hh> +#include <dumux/common/parameters.hh> #include <dumux/common/boundarytypes.hh> -#include <dumux/discretization/box.hh> -#include <dumux/discretization/cctpfa.hh> -#include <dumux/discretization/ccmpfa.hh> -#include <dumux/porousmediumflow/tracer/model.hh> #include <dumux/porousmediumflow/problem.hh> -#include <dumux/material/fluidsystems/base.hh> - -#include "spatialparams.hh" - -#ifndef USEMOLES // default to true if not set through CMake -#define USEMOLES true -#endif namespace Dumux { -/** - * \ingroup TracerTests - * \brief Definition of a problem for the tracer problem: - * A rotating velocity field mixes a tracer band in a porous groundwater reservoir. - */ -template <class TypeTag> -class TracerTest; - -namespace Properties { -// Create new type tags -namespace TTag { -struct TracerTest { using InheritsFrom = std::tuple<Tracer>; }; -struct TracerTestTpfa { using InheritsFrom = std::tuple<TracerTest, CCTpfaModel>; }; -struct TracerTestMpfa { using InheritsFrom = std::tuple<TracerTest, CCMpfaModel>; }; -struct TracerTestBox { using InheritsFrom = std::tuple<TracerTest, BoxModel>; }; -} // end namespace TTag - -// enable caching -template<class TypeTag> -struct EnableGridVolumeVariablesCache<TypeTag, TTag::TracerTest> { static constexpr bool value = true; }; -template<class TypeTag> -struct EnableGridFluxVariablesCache<TypeTag, TTag::TracerTest> { static constexpr bool value = true; }; -template<class TypeTag> -struct EnableGridGeometryCache<TypeTag, TTag::TracerTest> { static constexpr bool value = true; }; - -// Set the grid type -template<class TypeTag> -struct Grid<TypeTag, TTag::TracerTest> { using type = Dune::YaspGrid<2>; }; - -// Set the problem property -template<class TypeTag> -struct Problem<TypeTag, TTag::TracerTest> { using type = TracerTest<TypeTag>; }; - -// Set the spatial parameters -template<class TypeTag> -struct SpatialParams<TypeTag, TTag::TracerTest> -{ - using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; - using Scalar = GetPropType<TypeTag, Properties::Scalar>; - using type = TracerTestSpatialParams<GridGeometry, Scalar>; -}; - -// Define whether mole(true) or mass (false) fractions are used -template<class TypeTag> -struct UseMoles<TypeTag, TTag::TracerTest> { static constexpr bool value = USEMOLES; }; - -//! A simple fluid system with one tracer component -template<class TypeTag> -class TracerFluidSystem : public FluidSystems::Base<GetPropType<TypeTag, Properties::Scalar>, - TracerFluidSystem<TypeTag>> -{ - using Scalar = GetPropType<TypeTag, Properties::Scalar>; - using Problem = GetPropType<TypeTag, Properties::Problem>; - using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; - using Element = typename GridView::template Codim<0>::Entity; - using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; - using SubControlVolume = typename FVElementGeometry::SubControlVolume; - -public: - static constexpr bool isTracerFluidSystem() - { return true; } - - //! The number of components - static constexpr int numComponents = 2; - static constexpr int numPhases = 1; - - //! Human readable component name (index compIdx) (for vtk output) - static std::string componentName(int compIdx) - { return "tracer_" + std::to_string(compIdx); } - - //! Human readable phase name (index phaseIdx) (for velocity vtk output) - static std::string phaseName(int phaseIdx = 0) - { return "Groundwater"; } - - //! Molar mass in kg/mol of the component with index compIdx - static Scalar molarMass(unsigned int compIdx) - { return 0.300; } - - //! Binary diffusion coefficient - //! (might depend on spatial parameters like pressure / temperature) - static Scalar binaryDiffusionCoefficient(unsigned int compIdx, - const Problem& problem, - const Element& element, - const SubControlVolume& scv) - { - static const Scalar D = getParam<Scalar>("Problem.D"); - static const Scalar D2 = getParam<Scalar>("Problem.D2"); - if (compIdx == 0) - return D; - else - return D2; - } - - /*! - * \copydoc Dumux::FluidSystems::Base::isCompressible - */ - static constexpr bool isCompressible(int phaseIdx) - { return false; } - - /*! - * \copydoc Dumux::FluidSystems::Base::viscosityIsConstant - */ - static constexpr bool viscosityIsConstant(int phaseIdx) - { return true; } -}; - -template<class TypeTag> -struct FluidSystem<TypeTag, TTag::TracerTest> { using type = TracerFluidSystem<TypeTag>; }; - -} // end namespace Properties - /*! * \ingroup TracerTests diff --git a/test/porousmediumflow/tracer/constvel/properties.hh b/test/porousmediumflow/tracer/constvel/properties.hh new file mode 100644 index 0000000000..c8b600e423 --- /dev/null +++ b/test/porousmediumflow/tracer/constvel/properties.hh @@ -0,0 +1,147 @@ +// -*- 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 <http://www.gnu.org/licenses/>. * + *****************************************************************************/ +/*! + * \file + * \ingroup TracerTests + * \brief The properties for the tracer problem: + * A rotating velocity field mixes a tracer band in a porous groundwater reservoir. + */ +#ifndef DUMUX_TRACER_TEST_PROPERTIES_HH +#define DUMUX_TRACER_TEST_PROPERTIES_HH + +#include <dune/grid/yaspgrid.hh> + +#include <dumux/discretization/box.hh> +#include <dumux/discretization/cctpfa.hh> +#include <dumux/discretization/ccmpfa.hh> +#include <dumux/porousmediumflow/tracer/model.hh> +#include <dumux/material/fluidsystems/base.hh> + +#include "spatialparams.hh" + +#ifndef USEMOLES // default to true if not set through CMake +#define USEMOLES true +#endif + +#include "problem.hh" + +namespace Dumux::Properties { +// Create new type tags +namespace TTag { +struct TracerTest { using InheritsFrom = std::tuple<Tracer>; }; +struct TracerTestTpfa { using InheritsFrom = std::tuple<TracerTest, CCTpfaModel>; }; +struct TracerTestMpfa { using InheritsFrom = std::tuple<TracerTest, CCMpfaModel>; }; +struct TracerTestBox { using InheritsFrom = std::tuple<TracerTest, BoxModel>; }; +} // end namespace TTag + +// enable caching +template<class TypeTag> +struct EnableGridVolumeVariablesCache<TypeTag, TTag::TracerTest> { static constexpr bool value = true; }; +template<class TypeTag> +struct EnableGridFluxVariablesCache<TypeTag, TTag::TracerTest> { static constexpr bool value = true; }; +template<class TypeTag> +struct EnableGridGeometryCache<TypeTag, TTag::TracerTest> { static constexpr bool value = true; }; + +// Set the grid type +template<class TypeTag> +struct Grid<TypeTag, TTag::TracerTest> { using type = Dune::YaspGrid<2>; }; + +// Set the problem property +template<class TypeTag> +struct Problem<TypeTag, TTag::TracerTest> { using type = TracerTest<TypeTag>; }; + +// Set the spatial parameters +template<class TypeTag> +struct SpatialParams<TypeTag, TTag::TracerTest> +{ + using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; + using Scalar = GetPropType<TypeTag, Properties::Scalar>; + using type = TracerTestSpatialParams<GridGeometry, Scalar>; +}; + +// Define whether mole(true) or mass (false) fractions are used +template<class TypeTag> +struct UseMoles<TypeTag, TTag::TracerTest> { static constexpr bool value = USEMOLES; }; + +//! A simple fluid system with one tracer component +template<class TypeTag> +class TracerFluidSystem : public FluidSystems::Base<GetPropType<TypeTag, Properties::Scalar>, + TracerFluidSystem<TypeTag>> +{ + using Scalar = GetPropType<TypeTag, Properties::Scalar>; + using Problem = GetPropType<TypeTag, Properties::Problem>; + using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; + using Element = typename GridView::template Codim<0>::Entity; + using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; + using SubControlVolume = typename FVElementGeometry::SubControlVolume; + +public: + static constexpr bool isTracerFluidSystem() + { return true; } + + //! The number of components + static constexpr int numComponents = 2; + static constexpr int numPhases = 1; + + //! Human readable component name (index compIdx) (for vtk output) + static std::string componentName(int compIdx) + { return "tracer_" + std::to_string(compIdx); } + + //! Human readable phase name (index phaseIdx) (for velocity vtk output) + static std::string phaseName(int phaseIdx = 0) + { return "Groundwater"; } + + //! Molar mass in kg/mol of the component with index compIdx + static Scalar molarMass(unsigned int compIdx) + { return 0.300; } + + //! Binary diffusion coefficient + //! (might depend on spatial parameters like pressure / temperature) + static Scalar binaryDiffusionCoefficient(unsigned int compIdx, + const Problem& problem, + const Element& element, + const SubControlVolume& scv) + { + static const Scalar D = getParam<Scalar>("Problem.D"); + static const Scalar D2 = getParam<Scalar>("Problem.D2"); + if (compIdx == 0) + return D; + else + return D2; + } + + /*! + * \copydoc Dumux::FluidSystems::Base::isCompressible + */ + static constexpr bool isCompressible(int phaseIdx) + { return false; } + + /*! + * \copydoc Dumux::FluidSystems::Base::viscosityIsConstant + */ + static constexpr bool viscosityIsConstant(int phaseIdx) + { return true; } +}; + +template<class TypeTag> +struct FluidSystem<TypeTag, TTag::TracerTest> { using type = TracerFluidSystem<TypeTag>; }; + +} // end namespace Dumux::Properties + +#endif diff --git a/test/porousmediumflow/tracer/multiphase/problem.hh b/test/porousmediumflow/tracer/multiphase/problem.hh index 530a345702..3bcd57a40f 100644 --- a/test/porousmediumflow/tracer/multiphase/problem.hh +++ b/test/porousmediumflow/tracer/multiphase/problem.hh @@ -26,6 +26,9 @@ #ifndef DUMUX_TRACER_MULTIPHASE_TEST_PROBLEM_HH #define DUMUX_TRACER_MULTIPHASE_TEST_PROBLEM_HH +#include <dumux/common/properties.hh> +#include <dumux/common/parameters.hh> + #include <dumux/common/boundarytypes.hh> #include <dumux/porousmediumflow/problem.hh> -- GitLab