GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/examples/1ptracer/spatialparams_tracer.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 4 13 30.8%
Functions: 1 6 16.7%
Branches: 9 20 45.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_SPATIAL_PARAMS_HH
9 #define DUMUX_TRACER_TEST_SPATIAL_PARAMS_HH
10
11 // ## Parameter distributions (`spatialparams_tracer.hh`)
12 //
13 //
14 // In this file, we define spatial properties of the porous medium such as permeability
15 // and porosity in various functions for the tracer problem. Furthermore, spatially-dependent
16 // properties of the tracer fluid system are defined as well as functions related to setting
17 // and retrieving the volume fluxes calculated from the solution of the 1p problem.
18 //
19 // [[content]]
20 //
21 // ### Include files
22 // We include the spatial parameters class for single-phase models discretized by
23 // finite volume schemes, from which the spatial parameters defined for this example will inherit.
24 #include <dumux/porousmediumflow/fvspatialparams1p.hh>
25
26 // ### The spatial parameters class
27 //
28 // In the OnePTestSpatialParams class, we define all functions needed to define
29 // the spatially-dependent parameters for the tracer problem.
30 // We inherit from the FVPorousMediumFlowSpatialParamsOneP class here, which is the base class for
31 // spatial parameters in the context of single-phase porous medium flow applications
32 // using finite volume discretization schemes.
33 // [[codeblock]]
34 namespace Dumux {
35
36 template<class GridGeometry, class Scalar>
37 class TracerTestSpatialParams
38 : public FVPorousMediumFlowSpatialParamsOneP<GridGeometry, Scalar,
39 TracerTestSpatialParams<GridGeometry, Scalar>>
40 {
41 using GridView = typename GridGeometry::GridView;
42 using FVElementGeometry = typename GridGeometry::LocalView;
43 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
44 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
45 using Element = typename GridView::template Codim<0>::Entity;
46 using ParentType = FVPorousMediumFlowSpatialParamsOneP<GridGeometry, Scalar,
47 TracerTestSpatialParams<GridGeometry, Scalar>>;
48
49 static const int dimWorld = GridView::dimensionworld;
50 using GlobalPosition = typename Dune::FieldVector<Scalar, dimWorld>;
51
52 public:
53
54 1 TracerTestSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
55
2/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3 : ParentType(gridGeometry) {}
56 // [[/codeblock]]
57 //
58 // #### Properties of the porous matrix
59 // We define the same porosity for the whole domain as in the 1p spatialparams.
60 Scalar porosityAtPos(const GlobalPosition& globalPos) const
61 { return 0.2; }
62
63 // #### Properties of the fluid phase
64 // In the following, we define fluid phase properties that are spatial parameters
65 // in the tracer model.
66 // They can possible vary in space but are usually constants.
67 // We define the fluid density to a constant value of 1000 $`\frac{kg}{m^3}`$ (liquid water).
68 Scalar fluidDensity(const Element &element,
69 const SubControlVolume& scv) const
70 { return 1000; }
71
72 // The following functions define the molar mass of the fluid phase as function of the
73 // elements of the computational grid and the position in the domain.
74 // [[codeblock]]
75 // This interface defines the fluid phase's molar mass within the sub-control volume `scv`
76 // inside an `element` of the computational grid.
77 Scalar fluidMolarMass(const Element& element,
78 const SubControlVolume& scv) const
79 { return fluidMolarMassAtPos(scv.dofPosition()); }
80
81 // This interface defines the fluid phase's molar mass depending on the position in the domain.
82 Scalar fluidMolarMassAtPos(const GlobalPosition& globalPos) const
83 { return 18.0; }
84 // [[/codeblock]]
85 //
86 // #### The volume fluxes
87 // The following function returns the volume flux across the given sub-control volume face `scvf`.
88 // This flux is obtained from the vector `volumeFlux_` that contains the fluxes across al sub-control
89 // volume faces of the discretization. This vector can be set using the `setVolumeFlux` function.
90 template<class ElementVolumeVariables>
91 Scalar volumeFlux(const Element &element,
92 const FVElementGeometry& fvGeometry,
93 const ElementVolumeVariables& elemVolVars,
94 const SubControlVolumeFace& scvf) const
95 {
96
6/12
✗ Branch 0 not taken.
✓ Branch 1 taken 107800 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107800 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4900000 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 4900000 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 25000 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 25000 times.
10070000 return volumeFlux_[scvf.index()];
97 }
98
99 // This function allows setting the volume fluxes for all sub-control volume faces of the discretization.
100 // This is used in the main function after these fluxes have been based on the pressure solution obtained
101 // with the single-phase model.
102 void setVolumeFlux(const std::vector<Scalar>& f)
103
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 { volumeFlux_ = f; }
104
105 // The remainder of the class contains the private data members, which in this case
106 // are only the volume fluxes across the sub-control volume faces of the discretization.
107 // [[codeblock]]
108 private:
109 std::vector<Scalar> volumeFlux_;
110 }; // end class definition TracerTestSpatialParams
111 } // end namespace Dumux
112 // [[/codeblock]]
113 // [[/content]]
114 #endif
115