73 std::pair<std::string, PropertyVectorBase*>
const& property_pair,
74 unsigned int const n_files)
78 std::size_t num_of_tuples = 0;
79 void const* data_ptr = 0;
84 auto f = [&data_type, &num_of_tuples, &data_ptr, &property_pair](
85 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)>)
152 static_assert((std::numeric_limits<char>::digits == 7),
153 "Signed char has 8-1 bits");
156 else if constexpr (std::is_same_v<
unsigned char, decltype(basic_type)>)
158 static_assert((std::numeric_limits<unsigned char>::digits == 8),
159 "Unsigned char has 8 bits");
169 f(
double{}) || f(
float{}) || f(
int{}) || f(
long{}) || f(
unsigned{}) ||
170 f(
long{}) || f(
static_cast<unsigned long>(0)) || f(std::size_t{}) ||
171 f(
char{}) || f(
static_cast<unsigned char>(0));
178 auto const& property_base = property_pair.second;
179 auto const& global_components =
180 property_base->getNumberOfGlobalComponents();
185 assert(global_components >= 0);
186 auto const ui_global_components =
187 static_cast<unsigned int>(global_components);
190 property_base->getMeshItemType();
192 std::string
const&
name = property_base->getPropertyName();
194 HdfData hdf = {data_ptr, num_of_tuples, ui_global_components,
195 name, data_type, n_files};
197 XdmfData xdmf = {num_of_tuples, ui_global_components, data_type,
198 name, mesh_item_type, 0,
201 return XdmfHdfData{std::move(hdf), std::move(xdmf)};
205 unsigned int const n_files)
211 std::vector<XdmfHdfData> attributes;
212 for (
auto const& [
name, property_base] : properties)
219 if (
auto const attribute =
222 attributes.push_back(attribute.value());
226 WARN(
"Could not create attribute meta of {:s}.",
name);
234 std::vector<MeshLib::Node*>
const& nodes = mesh.
getNodes();
236 int const point_size = 3;
237 std::vector<double> values;
238 values.reserve(nodes.size() * point_size);
239 for (
auto const& n : nodes)
241 const double* x = n->getCoords();
242 values.insert(values.cend(), x, x + point_size);
249 double const* data_ptr,
250 unsigned int const n_files)
252 std::string
const name =
"geometry";
253 std::vector<MeshLib::Node*>
const& nodes = mesh.
getNodes();
255 int const point_size = 3;
256 auto const& partition_dim = nodes.size();
266 name, std::nullopt, 2,
269 return XdmfHdfData{std::move(hdf), std::move(xdmf)};
273 std::size_t
const offset)
275 std::vector<MeshLib::Element*>
const& elements = mesh.
getElements();
276 std::vector<int> values;
277 values.reserve(elements.size());
279 for (
auto const& cell : elements)
281 auto const ogs_cell_type = cell->getCellType();
283 values.push_back(xdmf_cell_id);
290 for (std::size_t i = 0; i < cell->getNumberOfNodes(); ++i)
293 values.push_back(node->
getID() + offset);
300 unsigned int const n_files)
302 std::string
const name =
"topology";
310 return XdmfHdfData{std::move(hdf), std::move(xdmf)};
Definition of the Element class.
void WARN(char const *fmt, Args const &... 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< XdmfHdfData > transformAttributes(MeshLib::Mesh const &mesh, unsigned int const n_files)
Create meta data for attributes used for hdf5 and xdmf.
XdmfHdfData transformGeometry(MeshLib::Mesh const &mesh, double const *data_ptr, unsigned int const n_files)
Create meta data for geometry used for hdf5 and xdmf.
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::vector< double > transformToXDMFGeometry(MeshLib::Mesh const &mesh)
Copies all node points into a new vector. Contiguous data used for writing. Conform with XDMF standar...
std::optional< XdmfHdfData > transformAttribute(std::pair< std::string, PropertyVectorBase * > const &property_pair, unsigned int const n_files)
XdmfHdfData transformTopology(std::vector< int > const &values, unsigned int const n_files)
Create meta data for topology used for HDF5 and XDMF.
static constexpr auto elemOGSTypeToXDMFType()
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