GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/examples/1ptracer/properties_tracer.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 3 8 37.5%
Functions: 1 4 25.0%
Branches: 2 10 20.0%

Line Branch Exec Source
1 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 //
4 // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7
8 #ifndef DUMUX_TRACER_TEST_PROPERTIES_HH
9 #define DUMUX_TRACER_TEST_PROPERTIES_HH
10
11 // ## Compile-time settings (`properties_tracer.hh`)
12 //
13 // This file defines the type tag used for the tracer transport simulation, for
14 // which we then specialize `properties` to the needs of the desired setup.
15 //
16 // [[content]]
17 //
18 // ### Includes
19 // [[details]] includes
20 // As for the single-phase problem, atype tag is defined also for this simulation.
21 // Here, we inherit all properties of the `Tracer` type tag, a convenience type tag
22 // that specializes most of the required properties for tracer transport flow simulations in DuMu<sup>x</sup>.
23 #include <dumux/porousmediumflow/tracer/model.hh>
24
25 // We use YaspGrid, an implementation of the dune grid interface for structured grids.
26 #include <dune/grid/yaspgrid.hh>
27 // We want to discretize the equations with the cell centered finite volume scheme using
28 // two-point-flux approximation.
29 #include <dumux/discretization/cctpfa.hh>
30 // This includes the base class for fluid systems. We will define a custom fluid
31 // system that inherits from that class.
32 #include <dumux/material/fluidsystems/base.hh>
33
34 // We include the problem and spatial parameter headers used for this simulation.
35 #include "problem_tracer.hh"
36 #include "spatialparams_tracer.hh"
37 // [[/details]]
38 //
39 // ### Definition of a custom fluid system
40 //
41 // In the following, we define a new tracer fluid system that contains a single component
42 // with a molar mass of 0.3 kg/mol. This fluid system derives from the base class for
43 // fluid systems `FluidSystems::Base`.
44 // [[codeblock]]
45 namespace Dumux {
46
47 // In the following, we create a new tracer fluid system and derive from the base fluid system.
48 template<class TypeTag>
49 class TracerFluidSystem : public FluidSystems::Base<GetPropType<TypeTag, Properties::Scalar>,
50 TracerFluidSystem<TypeTag>>
51 {
52 // Some convenience aliases to be used inside this class.
53 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
54 using Problem = GetPropType<TypeTag, Properties::Problem>;
55 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
56 using Element = typename GridView::template Codim<0>::Entity;
57 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
58 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
59
60 public:
61 // We specify that the fluid system only contains tracer components,
62 static constexpr bool isTracerFluidSystem()
63 { return true; }
64
65 // We define the number of components of this fluid system (one single tracer component)
66 static constexpr int numComponents = 1;
67
68 // This interface is designed to define the names of the components of the fluid system.
69 // Here, we only have a single component, so `compIdx` should always be 0.
70 // The component name is used for the vtk output.
71 2 static std::string componentName(int compIdx = 0)
72
2/6
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 { return "tracer_" + std::to_string(compIdx); }
73
74 // We set the phase name for the phase index (`phaseIdx`) for velocity vtk output:
75 // Here, we only have a single phase, so `phaseIdx` should always be zero.
76 static std::string phaseName(int phaseIdx = 0)
77
0/4
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22 { return "Groundwater"; }
78
79 // We set the molar mass of the tracer component with index `compIdx` (should again always be zero here).
80 static Scalar molarMass(unsigned int compIdx = 0)
81 { return 0.300; }
82
83 // We set the value for the binary diffusion coefficient. This
84 // might depend on spatial parameters like pressure / temperature.
85 // But, in this case we neglect diffusion and return 0.0.
86 static Scalar binaryDiffusionCoefficient(unsigned int compIdx,
87 const Problem& problem,
88 const Element& element,
89 const SubControlVolume& scv)
90 { return 0.0; }
91 };
92 // [[/codeblock]]
93 //
94 // ### Type tag definition
95 //
96 // We define a type tag for our simulation with the name `TracerTest` and inherit
97 // the properties specialized for the type tags `Tracer` and `CCTpfaModel`.
98 // This way, most of the properties required for tracer transport simulations using
99 // the cell centered finite volume scheme with two-point-flux approximation are
100 // conveniently specialized for our new type tag.
101 // However, some properties depend on user choices and no meaningful default value
102 // can be set. Those properties will be addressed later in this file.
103 // [[codeblock]]
104 namespace Properties {
105
106 // declaration of the `TracerTest` type tag for the tracer transport problem
107 namespace TTag {
108 struct TracerTest { using InheritsFrom = std::tuple<Tracer, CCTpfaModel>; };
109 }
110 // [[/codeblock]]
111 //
112 // ### Property specializations
113 //
114 // In the following piece of code, mandatory properties for which no meaningful
115 // default can be set, are specialized for our type tag `TracerTest`.
116 // [[codeblock]]
117 // We use the same grid type as in the stationary one-phase model, a structured 2D grid.
118 template<class TypeTag>
119 struct Grid<TypeTag, TTag::TracerTest> { using type = Dune::YaspGrid<2>; };
120
121 // This sets our problem class (see problem_tracer.hh) that specifies initial and boundary conditions.
122 template<class TypeTag>
123 struct Problem<TypeTag, TTag::TracerTest> { using type = TracerTestProblem<TypeTag>; };
124
125 // This defines the spatial parameters class (spatialparams_tracer.hh) for our tracer simulation.
126 template<class TypeTag>
127 struct SpatialParams<TypeTag, TTag::TracerTest>
128 {
129 private:
130 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
131 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
132 public:
133 using type = TracerTestSpatialParams<GridGeometry, Scalar>;
134 };
135
136 // We set the tracer fluid system that we have defined above.
137 template<class TypeTag>
138 struct FluidSystem<TypeTag, TTag::TracerTest> { using type = TracerFluidSystem<TypeTag>; };
139 // [[/codeblock]]
140 //
141 // The above are all mandatory properties, however, we also specialize the `UseMoles`
142 // property, which can be used to switch between mole or mass balances to be solved
143 // in compositional models. It defaults to `true`, and thus, to a molar formulation,
144 // and we set it to `false` here to specify that we want to solve the mass balance
145 // equation for the tracer component.
146 template<class TypeTag>
147 struct UseMoles<TypeTag, TTag::TracerTest> { static constexpr bool value = false; };
148
149 // Moreover, we specialize several properties related to efficiency optimizations
150 // [[details]] caching properties
151 // [[codeblock]]
152 // In Dumux, one has the option to activate/deactivate the grid-wide caching of geometries
153 // and variables. If active, the CPU time can be significantly reduced as less dynamic
154 // memory allocation procedures are necessary. Per default, grid-wide caching is disabled
155 // to ensure minimal memory requirements, however, in this example we want to active all
156 // available caches, which significanlty increases the memory demand but makes the simulation faster
157 template<class TypeTag>
158 struct EnableGridVolumeVariablesCache<TypeTag, TTag::TracerTest> { static constexpr bool value = true; };
159 template<class TypeTag>
160 struct EnableGridFluxVariablesCache<TypeTag, TTag::TracerTest> { static constexpr bool value = true; };
161 template<class TypeTag>
162 struct EnableGridGeometryCache<TypeTag, TTag::TracerTest> { static constexpr bool value = true; };
163
164 // We use solution-independent molecular diffusion coefficients. Per default, solution-dependent
165 // diffusion coefficients are assumed during the computation of the jacobian matrix entries. Specifying
166 // solution-independent diffusion coefficients can speed up computations significantly.
167 template<class TypeTag>
168 struct SolutionDependentMolecularDiffusion<TypeTag, TTag::TracerTest>
169 { static constexpr bool value = false; };
170
171 } // end namespace Properties
172 } // end namespace Dumux
173 // [[/codeblock]]
174 // [[/details]]
175 // [[/content]]
176 #endif
177