GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/examples/1protationsymmetry/problem.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 19 23 82.6%
Functions: 2 4 50.0%
Branches: 15 34 44.1%

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_ROTATION_SYMMETRY_PROBLEM_HH
9 #define DUMUX_ONEP_ROTATION_SYMMETRY_PROBLEM_HH
10
11 // ## The problem class (`problem.hh`)
12 // This file contains the __problem class__ which defines the initial and boundary
13 // conditions for the single-phase flow simulation.
14 // [[content]]
15 // ### Includes
16 #include <cmath> // for `std::log`
17 #include <dumux/common/boundarytypes.hh> // for `BoundaryTypes`
18 #include <dumux/common/properties.hh> // for `GetPropType`
19 #include <dumux/common/parameters.hh> // for `getParam`
20 #include <dumux/porousmediumflow/problem.hh> // for `PorousMediumFlowProblem`
21
22 // ### The problem class
23 // We enter the problem class where all necessary boundary conditions and initial conditions are set for our simulation.
24 // As this is a porous medium flow problem, we inherit from the base class `PorousMediumFlowProblem`.
25 namespace Dumux {
26
27 template<class TypeTag>
28 1 class RotSymExampleProblem : public PorousMediumFlowProblem<TypeTag>
29 {
30 using ParentType = PorousMediumFlowProblem<TypeTag>;
31 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
32 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
33 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
34 using BoundaryTypes = Dumux::BoundaryTypes<PrimaryVariables::size()>;
35 using Element = typename GridGeometry::GridView::template Codim<0>::Entity;
36 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
37
38 public:
39 // In the constructor, we obtain a number of parameters, related to fluid
40 // properties and boundary conditions, from the input file.
41 // [[codeblock]]
42 1 RotSymExampleProblem(std::shared_ptr<const GridGeometry> gridGeometry)
43
6/16
✓ 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 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
3 : ParentType(gridGeometry)
44 {
45 // fluid properties
46
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 k_ = getParam<Scalar>("SpatialParams.Permeability");
47
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 nu_ = getParam<Scalar>("Component.LiquidKinematicViscosity");
48
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 rho_ = getParam<Scalar>("Component.LiquidDensity");
49
50 // The inner radius r1 can be determined from the grid
51
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 r1_ = gridGeometry->bBoxMin()[0];
52
53 // boundary conditions
54
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 q1_ = getParam<Scalar>("Problem.Q1"); // mass flux into the domain at r1 in kg/s/m
55
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 p1_ = getParam<Scalar>("Problem.P1"); // pressure at the inner boundary at r1
56 1 }
57 // [[/codeblock]]
58
59 // #### Specify the types of boundary conditions
60 // This function is used to define the type of boundary conditions used depending on the location.
61 // Two types of boundary conditions can be specified: Dirichlet or Neumann boundary condition.
62 // On a Dirichlet boundary, the values of the primary variables need to be fixed. On a Neumann
63 // boundary condition, values for derivatives need to be fixed. Here, we use Dirichlet boundary
64 // conditions on all boundaries.
65 BoundaryTypes boundaryTypesAtPos(const GlobalPosition& globalPos) const
66 {
67
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 BoundaryTypes values;
68
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 values.setAllDirichlet();
69 return values;
70 }
71
72 // #### Specify Dirichlet boundary condition values
73 // This function is used to specify the values of the primary variables at Dirichlet boundaries.
74 // Here, we evaluate the analytical solution (see below) to define the pressures at the boundaries.
75 PrimaryVariables dirichletAtPos(const GlobalPosition& globalPos) const
76 10 { return exactSolution(globalPos); }
77
78 // #### Analytical solution
79 // The analytical solution to the problem of this example reads:
80 //
81 // ```math
82 // p = p (r) = p_1 - \frac{q_1 \nu}{2 \pi k} \text{ln} (\frac{r}{r_1}),
83 // ```
84 //
85 // where $`q_1`$ is the mass flux into the domain at the inner radius $`r_1`$
86 // (in kg/s/m) and $`\nu = \mu/\varrho`$ is the kinematic viscosity.
87 // The following function evaluates this solution depending on the
88 // position in the domain. We use this function here both to specify Dirichlet
89 // boundaries and to evaluate the error of the numerical solutions obtained for
90 // different levels of grid refinement.
91 // [[codeblock]]
92 6210 PrimaryVariables exactSolution(const GlobalPosition& globalPos) const
93 {
94 6210 const auto r = globalPos[0];
95 6210 const auto p = p1_ - 1.0/(2*M_PI)*nu_/k_*q1_*std::log(r/r1_);
96 6210 return p;
97 }
98
99 const Scalar exactVelocity(const GlobalPosition& globalPos) const
100 {
101 3100 const auto r = globalPos[0];
102 3100 const auto v = q1_/(2*M_PI)/rho_/r;
103 return v;
104 }
105
106 private:
107 // private data members required for the analytical solution
108 Scalar q1_, k_, nu_, r1_, p1_, rho_;
109 };
110
111 } // end namespace Dumux
112 // [[/codeblock]]
113 // [[/content]]
114 #endif
115