OGS
XdmfData.cpp
Go to the documentation of this file.
1
10#include "XdmfData.h"
11
12#include <cassert>
13#include <map>
14
15#include "BaseLib/Error.h"
16#include "MeshLib/Location.h"
17#include "partition.h"
18
19namespace MeshLib::IO
20{
21XdmfData::XdmfData(std::size_t const size_partitioned_dim,
22 std::size_t const size_tuple,
23 MeshPropertyDataType const mesh_property_data_type,
24 std::string const& name,
25 std::optional<MeshLib::MeshItemType> const attribute_center,
26 unsigned int const index,
27 unsigned int const n_files,
28 std::optional<ParentDataType> const parent_data_type)
29 : starts(
30 [&size_tuple]()
31 {
32 if (size_tuple > 1)
33 {
34 return std::vector<XdmfDimType>{0, 0};
35 }
36 else
37 {
38 return std::vector<XdmfDimType>{0};
39 }
40 }()),
41 strides(
42 [&size_tuple]()
43 {
44 if (size_tuple > 1)
45 {
46 return std::vector<XdmfDimType>{1, 1};
47 }
48 else
49 {
50 return std::vector<XdmfDimType>{1};
51 }
52 }()),
53 data_type(mesh_property_data_type),
54 size_partitioned_dim(size_partitioned_dim),
55 name(name),
56 attribute_center(attribute_center),
57 index(index),
58 parent_data_type(parent_data_type)
59{
60 auto partition_info = getPartitionInfo(size_partitioned_dim, n_files);
61 assert(partition_info.local_length <
62 std::numeric_limits<unsigned int>::max());
63 auto const ui_global_components =
64 static_cast<unsigned int>(partition_info.global_length);
65 auto const ui_tuple_size = static_cast<unsigned int>(size_tuple);
66
67 if (ui_tuple_size == 1)
68 {
69 global_block_dims = {ui_global_components};
70 }
71 else
72 {
73 global_block_dims = {ui_global_components, ui_tuple_size};
74 }
75
76 DBUG(
77 "XDMF: dataset name: {:s}, offset: {:d} "
78 "global_blocks: {:d}, tuples: {:d}",
79 name, partition_info.local_offset, global_block_dims[0], ui_tuple_size);
80}
81} // namespace MeshLib::IO
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
MeshPropertyDataType
Collects and holds all metadata for writing XDMF file.
PartitionInfo getPartitionInfo(std::size_t const size, unsigned int const n_files)
Definition partition.cpp:35
Dispatches functions specific to execution platform (w/o MPI)
XdmfData(std::size_t size_partitioned_dim, std::size_t size_tuple, MeshPropertyDataType mesh_property_data_type, std::string const &name, std::optional< MeshLib::MeshItemType > attribute_center, unsigned int const index, unsigned int n_files, std::optional< ParentDataType > parent_data_type)
XdmfData contains meta data to be passed to the XdmfWriter - it does not contain the actual values!...
Definition XdmfData.cpp:21