GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/embedded/2d3d/1p_1p/problem_fracture.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 37 38 97.4%
Functions: 3 4 75.0%
Branches: 109 178 61.2%

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 * \file
9 * \ingroup EmbeddedTests
10 * \brief A fracture problem.
11 */
12
13 #ifndef DUMUX_FRACTURE_PROBLEM_HH
14 #define DUMUX_FRACTURE_PROBLEM_HH
15
16 #include <dumux/common/boundarytypes.hh>
17 #include <dumux/common/parameters.hh>
18 #include <dumux/common/properties.hh>
19 #include <dumux/common/numeqvector.hh>
20
21 #include <dumux/porousmediumflow/problem.hh>
22 #include <dumux/porousmediumflow/1p/incompressiblelocalresidual.hh>
23
24 namespace Dumux {
25
26 /*!
27 * \ingroup EmbeddedTests
28 * \brief Exact solution 1D-3D.
29 */
30 template <class TypeTag>
31 class FractureProblem : public PorousMediumFlowProblem<TypeTag>
32 {
33 using ParentType = PorousMediumFlowProblem<TypeTag>;
34 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
35 using PointSource = GetPropType<TypeTag, Properties::PointSource>;
36 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
37 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
38 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
39 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
40 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
41 using GridView = typename GridGeometry::GridView;
42 using FVElementGeometry = typename GridGeometry::LocalView;
43 using SubControlVolume = typename GridGeometry::SubControlVolume;
44 using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
45 using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
46 using Element = typename GridView::template Codim<0>::Entity;
47 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
48
49 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
50
51 public:
52 2 FractureProblem(std::shared_ptr<const GridGeometry> gridGeometry,
53 std::shared_ptr<typename ParentType::SpatialParams> spatialParams,
54 std::shared_ptr<CouplingManager> couplingManager,
55 const std::string& paramGroup = "Fracture")
56 : ParentType(gridGeometry, spatialParams, paramGroup)
57
3/12
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
8 , couplingManager_(couplingManager)
58 {
59 // read parameters from input file
60
9/26
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2 times.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 2 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.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
4 name_ = getParam<std::string>("Vtk.OutputName") + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
61 2 }
62
63 /*!
64 * \name Problem parameters
65 */
66 // \{
67
68 /*!
69 * \brief The problem name.
70 *
71 * This is used as a prefix for files generated by the simulation.
72 */
73 const std::string& name() const
74
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 { return name_; }
75
76 // \}
77 /*!
78 * \name Boundary conditions
79 */
80 // \{
81
82 /*!
83 * \brief Specifies which kind of boundary condition should be
84 * used for which equation on a given boundary segment.
85 *
86 * \param globalPos The global position
87 */
88 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
89 {
90
4/6
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 90 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1848 BoundaryTypes values;
91 1848 values.setAllNeumann();
92
20/30
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 900 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 900 times.
✓ Branch 5 taken 108 times.
✓ Branch 6 taken 900 times.
✓ Branch 7 taken 108 times.
✓ Branch 8 taken 900 times.
✓ Branch 9 taken 108 times.
✓ Branch 10 taken 750 times.
✓ Branch 11 taken 90 times.
✓ Branch 12 taken 750 times.
✓ Branch 13 taken 90 times.
✓ Branch 14 taken 750 times.
✓ Branch 15 taken 90 times.
✓ Branch 16 taken 750 times.
✓ Branch 17 taken 90 times.
✓ Branch 18 taken 750 times.
✓ Branch 19 taken 90 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
9240 if (globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_)
93 values.setAllDirichlet();
94
20/30
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 870 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 870 times.
✓ Branch 6 taken 30 times.
✓ Branch 7 taken 870 times.
✓ Branch 8 taken 30 times.
✓ Branch 9 taken 870 times.
✓ Branch 10 taken 25 times.
✓ Branch 11 taken 725 times.
✓ Branch 12 taken 25 times.
✓ Branch 13 taken 725 times.
✓ Branch 14 taken 25 times.
✓ Branch 15 taken 725 times.
✓ Branch 16 taken 25 times.
✓ Branch 17 taken 725 times.
✓ Branch 18 taken 25 times.
✓ Branch 19 taken 725 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
8250 else if (globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
95 values.setAllDirichlet();
96 return values;
97 }
98
99 /*!
100 * \brief Evaluates the boundary conditions for a Dirichlet control volume.
101 *
102 * \param globalPos The global position
103 *
104 * For this method, the \a values parameter stores primary variables.
105 */
106 PrimaryVariables dirichletAtPos(const GlobalPosition& globalPos) const
107 {
108
10/20
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 25 times.
✓ Branch 11 taken 90 times.
✓ Branch 12 taken 25 times.
✓ Branch 13 taken 90 times.
✓ Branch 14 taken 25 times.
✓ Branch 15 taken 90 times.
✓ Branch 16 taken 25 times.
✓ Branch 17 taken 90 times.
✓ Branch 18 taken 25 times.
✓ Branch 19 taken 90 times.
575 if (globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_)
109 return PrimaryVariables(2e5);
110 else // (globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
111 25 return PrimaryVariables(1e5);
112 }
113
114 // \}
115
116 /*!
117 * \name Volume terms
118 */
119 // \{
120
121 /*!
122 * \brief Applies a vector of point sources which are possibly solution dependent.
123 *
124 * \param pointSources A vector of PointSource s that contain
125 source values for all phases and space positions.
126 *
127 * For this method, the \a values method of the point source
128 * has to return the absolute mass rate in kg/s. Positive values mean
129 * that mass is created, negative ones mean that it vanishes.
130 */
131 void addPointSources(std::vector<PointSource>& pointSources) const
132
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 { pointSources = this->couplingManager().lowDimPointSources(); }
133
134 /*!
135 * \brief Evaluates the point sources (added by addPointSources)
136 * for all phases within a given sub-control volume.
137 *
138 * This is the method for the case where the point source is
139 * solution dependent and requires some quantities that
140 * are specific to the fully-implicit method.
141 *
142 * \param source A single point source
143 * \param element The finite element
144 * \param fvGeometry The finite-volume geometry
145 * \param elemVolVars All volume variables for the element
146 * \param scv The sub-control volume within the element
147 *
148 * For this method, the \a values() method of the point sources returns
149 * the absolute rate mass generated or annihilated in kg/s. Positive values mean
150 * that mass is created, negative ones mean that it vanishes.
151 */
152 template<class ElementVolumeVariables>
153 1012798 void pointSource(PointSource& source,
154 const Element &element,
155 const FVElementGeometry& fvGeometry,
156 const ElementVolumeVariables& elemVolVars,
157 const SubControlVolume &scv) const
158 {
159 // compute source at every integration point
160 3038394 const Scalar pressure3D = this->couplingManager().bulkPriVars(source.id())[Indices::pressureIdx];
161 3038394 const Scalar pressure1D = this->couplingManager().lowDimPriVars(source.id())[Indices::pressureIdx];
162
163 // calculate the source
164 3038394 const Scalar meanDistance = this->couplingManager().averageDistance(source.id());
165
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1012794 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
1012798 static const Scalar matrixPerm = getParamFromGroup<Scalar>("Matrix", "SpatialParams.Permeability");
166
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1012793 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
1012798 static const Scalar rho = getParam<Scalar>("Component.LiquidDensity");
167
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1012794 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
1012798 static const Scalar mu = getParam<Scalar>("Component.LiquidKinematicViscosity")*rho;
168 1012798 const Scalar sourceValue = rho*(pressure3D - pressure1D)/meanDistance*matrixPerm/mu;
169 1012798 source = sourceValue*source.quadratureWeight()*source.integrationElement();
170 1012798 }
171
172 /*!
173 * \brief Evaluates the initial value for a control volume.
174 *
175 * \param globalPos The position for which the initial condition should be evaluated
176 *
177 * For this method, the \a priVars parameter stores primary
178 * variables.
179 */
180 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
181 596 { return PrimaryVariables(1e5); }
182
183 // \}
184
185 //! Called after every time step
186 //! Output the total global exchange term
187 2 void computeSourceIntegral(const SolutionVector& sol, const GridVariables& gridVars)
188 {
189 2 NumEqVector source(0.0);
190 4 auto fvGeometry = localView(this->gridGeometry());
191 4 auto elemVolVars = localView(gridVars.curGridVolVars());
192
4/4
✓ Branch 3 taken 596 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 596 times.
✓ Branch 6 taken 2 times.
602 for (const auto& element : elements(this->gridGeometry().gridView()))
193 {
194 596 fvGeometry.bindElement(element);
195 596 elemVolVars.bindElement(element, fvGeometry, sol);
196
5/6
✓ Branch 2 taken 596 times.
✓ Branch 3 taken 596 times.
✓ Branch 4 taken 596 times.
✓ Branch 5 taken 596 times.
✓ Branch 7 taken 596 times.
✗ Branch 8 not taken.
2384 for (auto&& scv : scvs(fvGeometry))
197 {
198
1/2
✓ Branch 1 taken 596 times.
✗ Branch 2 not taken.
596 auto pointSources = this->scvPointSources(element, fvGeometry, elemVolVars, scv);
199 596 pointSources *= scv.volume()*elemVolVars[scv].extrusionFactor();
200 596 source += pointSources;
201 }
202 }
203
204
2/4
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
4 std::cout << "Global integrated source (1D): " << source << '\n';
205 2 }
206
207 //! Get the coupling manager
208 const CouplingManager& couplingManager() const
209
14/16
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1012794 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1012794 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1012794 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 1012794 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 1012794 times.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 1012794 times.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
6076792 { return *couplingManager_; }
210
211 private:
212
213 static constexpr Scalar eps_ = 1.5e-7;
214 std::string name_;
215
216 std::shared_ptr<CouplingManager> couplingManager_;
217 };
218
219 } // end namespace Dumux
220
221 #endif
222