GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/examples/1ptracer/problem_1p.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 12 12 100.0%
Functions: 1 1 100.0%
Branches: 44 48 91.7%

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-FileCopyrightText: 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 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
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 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 1400 BoundaryTypes boundaryTypesAtPos(const GlobalPosition& globalPos) const
64 {
65 // we define a small epsilon value
66
8/8
✓ 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.
1400 Scalar eps = 1.0e-6;
67
68 // Initially, set Neumann boundary conditions for all equations.
69
8/8
✓ 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.
1400 BoundaryTypes values;
70 1400 values.setAllNeumann();
71
72 // On the top and bottom, use Dirichlet boundary conditions to prescribe pressures later.
73
8/8
✓ 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.
1400 const auto yMax = this->gridGeometry().bBoxMax()[dimWorld-1];
74
16/16
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 100 times.
✓ Branch 4 taken 150 times.
✓ Branch 5 taken 50 times.
✓ Branch 6 taken 50 times.
✓ Branch 7 taken 100 times.
✓ Branch 8 taken 600 times.
✓ Branch 9 taken 200 times.
✓ Branch 10 taken 200 times.
✓ Branch 11 taken 400 times.
✓ Branch 12 taken 150 times.
✓ Branch 13 taken 50 times.
✓ Branch 14 taken 50 times.
✓ Branch 15 taken 100 times.
1400 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 400 PrimaryVariables dirichletAtPos(const GlobalPosition& globalPos) const
86 {
87 // Instantiate a primary variables object
88
1/2
✓ Branch 1 taken 400 times.
✗ Branch 2 not taken.
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
1/2
✓ Branch 1 taken 400 times.
✗ Branch 2 not taken.
400 values[0] = 1.0e5*(1.1 - globalPos[dimWorld-1]*0.1);
93 return values;
94 }
95
96 }; // end class definition of OnePTestProblem
97 } // end namespace Dumux
98 // [[/codeblock]]
99 // [[/content]]
100 #endif
101