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 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 | 24 | std::ofstream dgfFile(fileName); | |
34 |
2/4✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
|
24 | 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 |
4/4✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 6 times.
|
84 | for (const auto& p : gridData.vertexParameterNames()) |
37 |
2/4✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
|
36 | dgfFile << p << " "; |
38 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
12 | dgfFile << "\n% Element parameters: "; |
39 |
4/4✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 6 times.
|
84 | for (const auto& p : gridData.elementParameterNames()) |
40 |
2/4✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
|
36 | dgfFile << p << " "; |
41 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
12 | dgfFile << std::endl; |
42 | |||
43 |
5/6✓ Branch 1 taken 226 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 226 times.
✓ Branch 4 taken 6 times.
✓ Branch 6 taken 226 times.
✗ Branch 7 not taken.
|
916 | for (const auto& vertex : vertices(gridView)) |
44 | { | ||
45 |
4/8✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 226 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 226 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 226 times.
✗ Branch 11 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 |
4/4✓ Branch 0 taken 678 times.
✓ Branch 1 taken 226 times.
✓ Branch 2 taken 678 times.
✓ Branch 3 taken 226 times.
|
2260 | for (int i = 0; i < params.size(); ++i) |
49 | { | ||
50 |
2/4✓ Branch 1 taken 678 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 678 times.
✗ Branch 5 not taken.
|
2712 | dgfFile << params[i]; |
51 | |||
52 |
4/4✓ Branch 0 taken 452 times.
✓ Branch 1 taken 226 times.
✓ Branch 2 taken 452 times.
✓ Branch 3 taken 226 times.
|
2712 | if (i < params.size() - 1) |
53 |
1/2✓ Branch 1 taken 452 times.
✗ Branch 2 not taken.
|
904 | dgfFile << " "; |
54 | } | ||
55 | |||
56 |
1/2✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
|
452 | dgfFile << std::endl; |
57 | } | ||
58 | |||
59 |
2/4✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
|
24 | dgfFile << "#\nSIMPLEX % Connections of the pore bodies (pore throats)\nparameters " << numElementParams << "\n"; |
60 | |||
61 |
5/6✓ Branch 1 taken 246 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 246 times.
|
996 | for (const auto& element : elements(gridView)) |
62 | { | ||
63 |
4/8✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
✓ Branch 3 taken 246 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 246 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 246 times.
✗ Branch 10 not taken.
|
492 | dgfFile << gridView.indexSet().subIndex(element, 0, 1) << " "; |
64 |
4/8✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
✓ Branch 3 taken 246 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 246 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 246 times.
✗ Branch 10 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 |
4/4✓ Branch 0 taken 738 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 738 times.
✓ Branch 3 taken 246 times.
|
2460 | for (int i = 0; i < params.size(); ++i) |
68 | { | ||
69 |
2/4✓ Branch 1 taken 738 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 738 times.
✗ Branch 5 not taken.
|
2952 | dgfFile << params[i]; |
70 | |||
71 |
4/4✓ Branch 0 taken 492 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 246 times.
|
2952 | if (i < params.size() - 1) |
72 |
1/2✓ Branch 1 taken 492 times.
✗ Branch 2 not taken.
|
984 | dgfFile << " "; |
73 | } | ||
74 | |||
75 |
1/2✓ Branch 1 taken 246 times.
✗ Branch 2 not taken.
|
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 |