GCC Code Coverage Report


Directory: gridformat/
File: gridformat/vtk/pvti_reader.hpp
Date: 2024-11-20 14:41:59
Exec Total Coverage
Lines: 27 28 96.4%
Functions: 6 6 100.0%
Branches: 20 38 52.6%

Line Branch Exec Source
1 // SPDX-FileCopyrightText: 2022-2023 Dennis Gläser <dennis.glaeser@iws.uni-stuttgart.de>
2 // SPDX-License-Identifier: MIT
3 /*!
4 * \file
5 * \ingroup VTK
6 * \copydoc GridFormat::PVTIReader
7 */
8 #ifndef GRIDFORMAT_VTK_PVTI_READER_HPP_
9 #define GRIDFORMAT_VTK_PVTI_READER_HPP_
10
11 #include <gridformat/vtk/vti_reader.hpp>
12 #include <gridformat/vtk/pxml_reader.hpp>
13
14 namespace GridFormat {
15
16 /*!
17 * \ingroup VTK
18 * \brief Reader for .pvtp file format
19 * \copydetails VTK::PXMLStructuredGridReader
20 */
21 class PVTIReader : public VTK::PXMLStructuredGridReader<VTIReader> {
22 using ParentType = VTK::PXMLStructuredGridReader<VTIReader>;
23
24 public:
25 1 PVTIReader()
26
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 : ParentType("PImageData")
27 1 {}
28
29 48 explicit PVTIReader(const NullCommunicator&)
30
2/4
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
96 : ParentType("PImageData")
31 48 {}
32
33 template<Concepts::Communicator C>
34 132 explicit PVTIReader(const C& comm)
35
2/4
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 132 times.
✗ Branch 6 not taken.
264 : ParentType("PImageData", comm)
36 132 {}
37
38 private:
39 2 std::string _name() const override {
40
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
4 return "PVTIReader";
41 }
42
43 9 std::vector<double> _ordinates(unsigned int direction) const override {
44
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
9 if (this->_num_process_pieces() == 0)
45 return {};
46
2/2
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 3 times.
9 if (this->_num_process_pieces() == 1)
47
1/2
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
6 return this->_readers().front().ordinates(direction);
48
49
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 const auto extents = this->_specs().extents;
50
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 const auto extent_begin = this->_specs().extents[2*direction];
51
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 const auto origin = this->origin();
52
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 const auto spacing = this->spacing();
53 3 const std::size_t num_ordinates(extents[2*direction + 1] - extent_begin + 1);
54
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 std::vector<double> result(num_ordinates);
55
1/2
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
6 std::ranges::copy(
56
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 std::views::iota(std::size_t{0}, num_ordinates) | std::views::transform([&] (const std::size_t i) {
57 16 return origin[direction] + (extent_begin + i)*spacing[direction];
58
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 }),
59 result.begin()
60 );
61 3 return result;
62 3 }
63 };
64
65 } // namespace GridFormat
66
67 #endif // GRIDFORMAT_VTK_PVTI_READER_HPP_
68