GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/examples/1ptracer/problem_1p.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 10 12 83.3%
Functions: 1 2 50.0%
Branches: 69 94 73.4%

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_ONEP_TEST_PROBLEM_HH
9 #define DUMUX_ONEP_TEST_PROBLEM_HH
10
11 // ## Initial and boundary conditions (`problem_1p.hh`)
12 //
13 // This file contains the __problem class__ which defines the initial and boundary
14 // conditions for the single-phase flow simulation.
15 //
16 // [[content]]
17 //
18 // ### Include files
19 //
20 // Include the `PorousMediumFlowProblem` class, the base
21 // class from which we will derive.
22 #include <dumux/porousmediumflow/problem.hh>
23 // Include the `BoundaryTypes` class which specifies the boundary types set in this problem.
24 #include <dumux/common/boundarytypes.hh>
25
26 // ### The problem class
27 // We enter the problem class where all necessary boundary conditions and initial conditions are set for our simulation.
28 // As we are solving a problem related to flow in porous media, we inherit from the base class `PorousMediumFlowProblem`.
29 // [[codeblock]]
30 namespace Dumux {
31
32 template<class TypeTag>
33 1 class OnePTestProblem : public PorousMediumFlowProblem<TypeTag>
34 {
35 // A few convenience aliases used throughout this class.
36 using ParentType = PorousMediumFlowProblem<TypeTag>;
37 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
38 using Element = typename GridView::template Codim<0>::Entity;
39 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
40
41 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
42 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
43 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
44 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
45 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
46 using BoundaryTypes = Dumux::BoundaryTypes<PrimaryVariables::size()>;
47
48 static constexpr int dimWorld = GridView::dimensionworld;
49
50 public:
51 // This is the constructor of our problem class:
52 1 OnePTestProblem(std::shared_ptr<const GridGeometry> gridGeometry)
53
5/14
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
3 : ParentType(gridGeometry) {}
54 // [[/codeblock]]
55
56 // #### Boundary conditions
57 // With the following function we define the __type of boundary conditions__ depending on the location.
58 // Two types of boundary conditions can be specified: Dirichlet or Neumann boundary conditions. On
59 // Dirichlet boundaries, the values of the primary variables need to be fixed. On a Neumann boundaries,
60 // values for derivatives need to be fixed. Mixed boundary conditions (different types for different
61 // equations on the same boundary) are not accepted for cell-centered finite volume schemes.
62 // [[codeblock]]
63 BoundaryTypes boundaryTypesAtPos(const GlobalPosition& globalPos) const
64 {
65 // we define a small epsilon value
66 1400 Scalar eps = 1.0e-6;
67
68 // Initially, set Neumann boundary conditions for all equations
69
8/10
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 600 times.
✓ Branch 5 taken 200 times.
✓ Branch 6 taken 150 times.
✓ Branch 7 taken 50 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1400 BoundaryTypes values;
70 1400 values.setAllNeumann();
71
72 // On the top and bottom, use Dirichlet boundary conditions to prescribe pressures later.
73
24/30
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 150 times.
✓ Branch 5 taken 50 times.
✓ Branch 6 taken 150 times.
✓ Branch 7 taken 50 times.
✓ Branch 8 taken 150 times.
✓ Branch 9 taken 50 times.
✓ Branch 10 taken 150 times.
✓ Branch 11 taken 50 times.
✓ Branch 12 taken 600 times.
✓ Branch 13 taken 200 times.
✓ Branch 14 taken 600 times.
✓ Branch 15 taken 200 times.
✓ Branch 16 taken 600 times.
✓ Branch 17 taken 200 times.
✓ Branch 18 taken 150 times.
✓ Branch 19 taken 50 times.
✓ Branch 20 taken 150 times.
✓ Branch 21 taken 50 times.
✓ Branch 22 taken 150 times.
✓ Branch 23 taken 50 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
4200 const auto yMax = this->gridGeometry().bBoxMax()[dimWorld-1];
74
32/40
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 50 times.
✓ Branch 6 taken 100 times.
✓ Branch 7 taken 50 times.
✓ Branch 8 taken 150 times.
✓ Branch 9 taken 50 times.
✓ Branch 10 taken 150 times.
✓ Branch 11 taken 50 times.
✓ Branch 12 taken 100 times.
✓ Branch 13 taken 50 times.
✓ Branch 14 taken 100 times.
✓ Branch 15 taken 50 times.
✓ Branch 16 taken 600 times.
✓ Branch 17 taken 200 times.
✓ Branch 18 taken 600 times.
✓ Branch 19 taken 200 times.
✓ Branch 20 taken 400 times.
✓ Branch 21 taken 200 times.
✓ Branch 22 taken 400 times.
✓ Branch 23 taken 200 times.
✓ Branch 24 taken 150 times.
✓ Branch 25 taken 50 times.
✓ Branch 26 taken 150 times.
✓ Branch 27 taken 50 times.
✓ Branch 28 taken 100 times.
✓ Branch 29 taken 50 times.
✓ Branch 30 taken 100 times.
✓ Branch 31 taken 50 times.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
2800 if (globalPos[dimWorld-1] < eps || globalPos[dimWorld-1] > yMax - eps)
75 values.setAllDirichlet();
76
77 return values;
78 }
79 // [[/codeblock]]
80
81 // The following function specifies the __values on Dirichlet boundaries__.
82 // We need to define values for the primary variable (pressure), for which we
83 // set a pressure of 1.1 bar and 1 bar at the bottom and top boundaries, respectively.
84 // [[codeblock]]
85 PrimaryVariables dirichletAtPos(const GlobalPosition& globalPos) const
86 {
87 // instantiate a primary variables object
88 400 PrimaryVariables values;
89
90 // and assign a pressure value in [Pa] such that at the bottom boundary
91 // a pressure of 1.1 bar is set, and on the top boundary a pressure of 1 bar.
92 800 values[0] = 1.0e5*(1.1 - globalPos[dimWorld-1]*0.1);
93 return values;
94 }
95 // [[/codeblock]]
96
97 }; // end class definition of OnePTestProblem
98 } // end namespace Dumux
99 // [[/codeblock]]
100 // [[/content]]
101 #endif
102