87 std::pair<std::string, PropertyVectorBase*>
const& property_pair,
88 unsigned int const n_files,
unsigned int const chunk_size_bytes)
92 std::size_t num_of_tuples = 0;
93 void const* data_ptr = 0;
98 auto f = [&data_type, &num_of_tuples, &data_ptr,
99 &property_pair](
auto basic_type) ->
bool
101 auto const property_base = property_pair.second;
102 auto const typed_property =
105 if (typed_property ==
nullptr)
111 data_ptr = typed_property->data();
113 if constexpr (std::is_same_v<double,
decltype(basic_type)>)
118 static_assert((std::numeric_limits<double>::digits == 53),
119 "Double has 52 bits fractional part");
122 else if constexpr (std::is_same_v<float,
decltype(basic_type)>)
127 static_assert((std::numeric_limits<float>::digits == 24),
128 "Float has 23 bits fractional part");
131 else if constexpr (std::is_same_v<int32_t,
decltype(basic_type)>)
135 else if constexpr (std::is_same_v<uint32_t,
decltype(basic_type)>)
139 else if constexpr (std::is_same_v<int64_t,
decltype(basic_type)>)
143 else if constexpr (std::is_same_v<uint64_t,
decltype(basic_type)>)
147 else if constexpr (std::is_same_v<int8_t,
decltype(basic_type)>)
151 else if constexpr (std::is_same_v<uint8_t,
decltype(basic_type)>)
155 else if constexpr (std::is_same_v<char,
decltype(basic_type)>)
159 else if constexpr (std::is_same_v<
unsigned char,
decltype(basic_type)>)
161 static_assert((std::numeric_limits<unsigned char>::digits == 8),
162 "Unsigned char has 8 bits");
165 else if constexpr (std::is_same_v<
unsigned long,
decltype(basic_type)>)
167 if (
sizeof(
unsigned long) == 8 &&
168 std::numeric_limits<unsigned long>::digits == 64)
172 else if (
sizeof(
unsigned long) == 4 &&
173 std::numeric_limits<unsigned long>::digits == 32)
182 else if constexpr (std::is_same_v<std::size_t,
decltype(basic_type)>)
184 if (
sizeof(std::size_t) == 8 &&
185 std::numeric_limits<std::size_t>::digits == 64)
189 else if (
sizeof(std::size_t) == 4 &&
190 std::numeric_limits<std::size_t>::digits == 32)
206 f(
double{}) || f(
float{}) || f(
int{}) || f(
long{}) || f(
unsigned{}) ||
207 f(
long{}) || f(
static_cast<unsigned long>(0)) || f(std::size_t{}) ||
208 f(
char{}) || f(
static_cast<unsigned char>(0));
215 auto const& property_base = property_pair.second;
216 auto const& global_components =
217 property_base->getNumberOfGlobalComponents();
222 assert(global_components >= 0);
223 auto const ui_global_components =
224 static_cast<unsigned int>(global_components);
227 property_base->getMeshItemType();
229 std::string
const& name = property_base->getPropertyName();
231 HdfData hdf = {data_ptr, num_of_tuples, ui_global_components, name,
232 data_type, n_files, chunk_size_bytes};
234 XdmfData xdmf{num_of_tuples, ui_global_components, data_type,
235 name, mesh_item_type, n_files,
238 return XdmfHdfData{std::move(hdf), std::move(xdmf)};
243 unsigned int const chunk_size_bytes)
249 std::vector<XdmfHdfData> attributes;
250 for (
auto const& [name, property_base] : properties)
257 if (!property_base->is_for_output)
264 std::pair(std::string(name), property_base), n_files,
268 attributes.push_back(attribute.value());
272 WARN(
"Could not create attribute meta of {:s}.", name);
295 unsigned int const n_files,
296 unsigned int const chunk_size_bytes)
298 std::string
const name =
"geometry";
299 std::vector<MeshLib::Node*>
const& nodes = mesh.
getNodes();
301 int const point_size = 3;
302 auto const& partition_dim = nodes.size();
313 name, std::nullopt, n_files,
316 return XdmfHdfData{std::move(hdf), std::move(xdmf)};
367 std::vector<MeshLib::Element*>
const& elements = mesh.
getElements();
368 std::vector<std::size_t> values;
370 auto const push_cellnode_ids_to_vector =
371 [&values, &offset](
auto const& cell)
373 values |= ranges::actions::push_back(
375 ranges::views::transform([&offset](
auto const node_id)
376 { return node_id + offset; }));
382 values.reserve(elements.size() * 2);
384 for (
auto const& cell : elements)
386 auto const ogs_cell_type = cell->getCellType();
393 push_cellnode_ids_to_vector(cell);
398 values.reserve(elements.size() * elements[0]->getNumberOfNodes());
399 for (
auto const& cell : elements)
401 push_cellnode_ids_to_vector(cell);
405 return {values, topology_type};
std::pair< std::vector< std::size_t >, ParentDataType > transformToXDMFTopology(MeshLib::Mesh const &mesh, std::size_t const offset)
Copies all cells into a new vector. Contiguous data used for writing. The topology is specific to xdm...
XdmfHdfData transformGeometry(MeshLib::Mesh const &mesh, double const *data_ptr, unsigned int const n_files, unsigned int const chunk_size_bytes)
Create meta data for geometry used for hdf5 and xdmf.
std::vector< XdmfHdfData > transformAttributes(MeshLib::Mesh const &mesh, unsigned int const n_files, unsigned int const chunk_size_bytes)
Create meta data for attributes used for hdf5 and xdmf.
XdmfHdfData transformTopology(std::vector< std::size_t > const &values, ParentDataType const parent_data_type, unsigned int const n_files, unsigned int const chunk_size_bytes)
Create meta data for topology used for HDF5 and XDMF.