GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/io/grid/porenetwork/dgfwriter.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 34 34 100.0%
Functions: 3 3 100.0%
Branches: 41 66 62.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-FileCopyrightText: 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 PoreNetworkModels
10 * \brief Write pore-network grids with attached data to dgf file
11 */
12 #ifndef DUMUX_PORE_NETWORK_DGF_WRITER_HH
13 #define DUMUX_PORE_NETWORK_DGF_WRITER_HH
14
15 #include <string>
16 #include <iostream>
17 #include <fstream>
18
19 namespace Dumux::PoreNetwork {
20
21 /*!
22 * \ingroup PoreNetworkModels
23 * \brief Write pore-network grids with attached data to dgf file
24 */
25 template<class GridView, class GridData>
26 12 void writeDgf(const std::string& fileName, const GridView& gridView, const GridData& gridData)
27 {
28 12 const auto someElement = *(elements(gridView).begin());
29 12 const auto someVertex = *(vertices(gridView).begin());
30 12 const auto numVertexParams = gridData.parameters(someVertex).size();
31 12 const auto numElementParams = gridData.parameters(someElement).size();
32
33 12 std::ofstream dgfFile(fileName);
34
2/4
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
12 dgfFile << "DGF\nVertex % Coordinates, volumes and boundary flags of the pore bodies\nparameters " << numVertexParams << "\n";
35
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
12 dgfFile << "% Vertex parameters: ";
36
3/4
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 6 times.
48 for (const auto& p : gridData.vertexParameterNames())
37
1/2
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
36 dgfFile << p << " ";
38
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
12 dgfFile << "\n% Element parameters: ";
39
3/4
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 6 times.
48 for (const auto& p : gridData.elementParameterNames())
40
1/2
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
36 dgfFile << p << " ";
41 12 dgfFile << std::endl;
42
43
3/4
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 226 times.
✓ Branch 4 taken 6 times.
464 for (const auto& vertex : vertices(gridView))
44 {
45
2/4
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 226 times.
✗ Branch 5 not taken.
452 dgfFile << vertex.geometry().center() << " ";
46
47
1/2
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
452 const auto& params = gridData.parameters(vertex);
48
2/2
✓ Branch 0 taken 678 times.
✓ Branch 1 taken 226 times.
1808 for (int i = 0; i < params.size(); ++i)
49 {
50
1/2
✓ Branch 1 taken 678 times.
✗ Branch 2 not taken.
1356 dgfFile << params[i];
51
52
2/2
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 226 times.
1356 if (i < params.size() - 1)
53
1/2
✓ Branch 1 taken 452 times.
✗ Branch 2 not taken.
904 dgfFile << " ";
54 }
55
56 452 dgfFile << std::endl;
57 }
58
59
2/4
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
12 dgfFile << "#\nSIMPLEX % Connections of the pore bodies (pore throats)\nparameters " << numElementParams << "\n";
60
61
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 246 times.
✓ Branch 3 taken 6 times.
504 for (const auto& element : elements(gridView))
62 {
63
2/4
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 246 times.
✗ Branch 6 not taken.
492 dgfFile << gridView.indexSet().subIndex(element, 0, 1) << " ";
64
2/4
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 246 times.
✗ Branch 6 not taken.
492 dgfFile << gridView.indexSet().subIndex(element, 1, 1) << " ";
65
66
1/2
✓ Branch 1 taken 246 times.
✗ Branch 2 not taken.
492 const auto& params = gridData.parameters(element);
67
2/2
✓ Branch 0 taken 738 times.
✓ Branch 1 taken 246 times.
1968 for (int i = 0; i < params.size(); ++i)
68 {
69
1/2
✓ Branch 1 taken 738 times.
✗ Branch 2 not taken.
1476 dgfFile << params[i];
70
71
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 246 times.
1476 if (i < params.size() - 1)
72
1/2
✓ Branch 1 taken 492 times.
✗ Branch 2 not taken.
984 dgfFile << " ";
73 }
74
75 492 dgfFile << std::endl;
76 }
77
78
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
12 dgfFile << "#";
79 12 }
80
81 } // end namespace Dumux::PoreNetwork
82
83 #endif
84