73 std::pair<std::string, PropertyVectorBase*>
const& property_pair,
74 unsigned int const n_files,
unsigned int const chunk_size_bytes)
78 std::size_t num_of_tuples = 0;
79 void const* data_ptr = 0;
84 auto f = [&data_type, &num_of_tuples, &data_ptr,
85 &property_pair](
auto basic_type) ->
bool
87 auto const property_base = property_pair.second;
88 auto const typed_property =
91 if (typed_property ==
nullptr)
97 data_ptr = typed_property->data();
99 if constexpr (std::is_same_v<double,
decltype(basic_type)>)
104 static_assert((std::numeric_limits<double>::digits == 53),
105 "Double has 52 bits fractional part");
108 else if constexpr (std::is_same_v<float,
decltype(basic_type)>)
113 static_assert((std::numeric_limits<float>::digits == 24),
114 "Float has 23 bits fractional part");
117 else if constexpr (std::is_same_v<int,
decltype(basic_type)>)
119 static_assert((std::numeric_limits<int>::digits == 31),
120 "Signed int has 32-1 bits");
138 else if constexpr (std::is_same_v<
unsigned int,
decltype(basic_type)>)
140 static_assert((std::numeric_limits<unsigned int>::digits == 32),
141 "Unsigned int has 32 bits");
144 else if constexpr (std::is_same_v<std::size_t,
decltype(basic_type)>)
146 static_assert((std::numeric_limits<std::size_t>::digits == 64),
147 "size_t has 64 bits");
150 else if constexpr (std::is_same_v<char,
decltype(basic_type)>)
154 else if constexpr (std::is_same_v<
unsigned char,
decltype(basic_type)>)
156 static_assert((std::numeric_limits<unsigned char>::digits == 8),
157 "Unsigned char has 8 bits");
167 f(
double{}) || f(
float{}) || f(
int{}) || f(
long{}) || f(
unsigned{}) ||
168 f(
long{}) || f(
static_cast<unsigned long>(0)) || f(std::size_t{}) ||
169 f(
char{}) || f(
static_cast<unsigned char>(0));
176 auto const& property_base = property_pair.second;
177 auto const& global_components =
178 property_base->getNumberOfGlobalComponents();
183 assert(global_components >= 0);
184 auto const ui_global_components =
185 static_cast<unsigned int>(global_components);
188 property_base->getMeshItemType();
190 std::string
const& name = property_base->getPropertyName();
192 HdfData hdf = {data_ptr, num_of_tuples, ui_global_components, name,
193 data_type, n_files, chunk_size_bytes};
195 XdmfData xdmf = {num_of_tuples, ui_global_components, data_type,
196 name, mesh_item_type, 0,
199 return XdmfHdfData{std::move(hdf), std::move(xdmf)};
204 unsigned int const chunk_size_bytes)
210 std::vector<XdmfHdfData> attributes;
211 for (
auto const& [name, property_base] : properties)
218 if (!property_base->is_for_output)
225 std::pair(std::string(name), property_base), n_files,
229 attributes.push_back(attribute.value());
233 WARN(
"Could not create attribute meta of {:s}.", name);
241 std::vector<MeshLib::Node*>
const& nodes = mesh.
getNodes();
243 int const point_size = 3;
244 std::vector<double> values;
245 values.reserve(nodes.size() * point_size);
246 for (
auto const& n : nodes)
248 const double* x = n->data();
249 values.insert(values.cend(), x, x + point_size);
256 unsigned int const n_files,
257 unsigned int const chunk_size_bytes)
259 std::string
const name =
"geometry";
260 std::vector<MeshLib::Node*>
const& nodes = mesh.
getNodes();
262 int const point_size = 3;
263 auto const& partition_dim = nodes.size();
274 name, std::nullopt, 2,
277 return XdmfHdfData{std::move(hdf), std::move(xdmf)};
281 std::size_t
const offset)
283 std::vector<MeshLib::Element*>
const& elements = mesh.
getElements();
284 std::vector<int> values;
285 values.reserve(elements.size());
287 for (
auto const& cell : elements)
289 auto const ogs_cell_type = cell->getCellType();
291 values.push_back(xdmf_cell_id);
298 for (std::size_t i = 0; i < cell->getNumberOfNodes(); ++i)
301 values.push_back(node->
getID() + offset);
308 unsigned int const n_files,
309 unsigned int const chunk_size_bytes)
311 std::string
const name =
"topology";
314 n_files, chunk_size_bytes};
319 return XdmfHdfData{std::move(hdf), std::move(xdmf)};
Definition of the Element class.
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition of mesh-related Enumerations.
Enum for all propertyVector data types.
Definition of the Mesh class.
Definition of the Node class.
std::size_t getID() const
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Properties & getProperties()
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
std::size_t getNumberOfTuples() const
constexpr auto to_underlying(E e) noexcept
Converts an enumeration to its underlying type.
const std::string OGS_VERSION
std::vector< int > 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...
constexpr auto cellTypeOGS2XDMF(MeshLib::CellType const &cell_type)
std::optional< XdmfHdfData > transformAttribute(std::pair< std::string, PropertyVectorBase * > const &property_pair, unsigned int const n_files, unsigned int const chunk_size_bytes)
std::vector< double > transformToXDMFGeometry(MeshLib::Mesh const &mesh)
Copies all node points into a new vector. Contiguous data used for writing. Conform with XDMF standar...
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.
static constexpr auto elemOGSTypeToXDMFType()
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< int > const &values, unsigned int const n_files, unsigned int const chunk_size_bytes)
Create meta data for topology used for HDF5 and XDMF.
constexpr auto elem_type_ogs2xdmf
CellType
Types of mesh elements supported by OpenGeoSys.
Dispatches functions specific to execution platform (w/o MPI)
unsigned int number_of_nodes