1#if defined(__GNUG__) && !defined(__clang__)
2#pragma GCC diagnostic push
3#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
6#if defined(__GNUG__) && !defined(__clang__)
7#pragma GCC diagnostic pop
10#include <fmt/ranges.h>
29std::string get_type<int64_t>()
35std::string get_type<double>()
41std::string get_type<char>()
46std::string get_type<short>()
52std::string get_type<wmtk::Rational>()
57std::string get_type<std::string>()
65 m_hdf5_file = std::make_shared<h5pp::File>(filename, h5pp::FileAccess::REPLACE);
69 const std::string& name,
72 const std::vector<int64_t>& val,
73 const int64_t default_val)
79 const std::string& name,
82 const std::vector<double>& val,
83 const double default_val)
89 const std::string& name,
92 const std::vector<char>& val,
93 const char default_val)
95 std::vector<short> tmp;
96 tmp.reserve(val.size());
97 for (
const auto& v : val) tmp.push_back(v);
104 const std::string& name,
106 const int64_t stride,
107 const std::vector<Rational>& val,
110 std::vector<std::string> tmp;
111 tmp.reserve(val.size());
112 int64_t max_size = -1;
113 for (
const auto& v : val) {
114 tmp.emplace_back(v.serialize());
115 max_size = std::max(max_size, int64_t(tmp.back().size()));
118 Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> data(tmp.size(), max_size);
119 data.setConstant(
int(
' '));
120 for (int64_t i = 0; i < data.rows(); ++i) {
121 for (int64_t j = 0; j < tmp[i].size(); ++j) {
122 data(i, j) = int(tmp[i][j]);
134template <
typename Data,
typename T>
136 const std::string& name,
138 const int64_t stride,
140 const T& default_val)
142 std::string path = fmt::format(
"{}/{}/{}",
dataset_path(), type, name);
145 m_hdf5_file->writeAttribute(stride, path,
"stride");
146 m_hdf5_file->writeAttribute(default_val, path,
"default_value");
147 m_hdf5_file->writeAttribute(type, path,
"dimension");
148 m_hdf5_file->writeAttribute(get_type<T>(), path,
"type");
161 m_name = fmt::format(
"mesh_{}", fmt::join(
id,
""));
173 std::string res =
"WMTK";
187 const static std::string& name = get_type<T>();
188 const std::string path =
189 fmt::format(
"{}/{}_{}/{}",
dataset_path(),
"ATTRIBUTE_LIST", name, dim);
194template void HDF5Writer::write_attribute_names<double>(
int dim,
const std::vector<std::string>&);
195template void HDF5Writer::write_attribute_names<int64_t>(
int dim,
const std::vector<std::string>&);
196template void HDF5Writer::write_attribute_names<char>(
int dim,
const std::vector<std::string>&);
197template void HDF5Writer::write_attribute_names<wmtk::Rational>(
199 const std::vector<std::string>&);
std::string dataset_path() const
HDF5Writer(const std::filesystem::path &filename)
std::shared_ptr< h5pp::File > m_hdf5_file
void write_internal(const std::string &name, const int64_t type, const int64_t stride, const Data &val, const T &default_val)
void write_capacities(const std::vector< int64_t > &capacities) override
void write_attribute_names(int dim, const std::vector< std::string > &names)
void write_absolute_id(const std::vector< int64_t > &id) override
void write_top_simplex_type(const PrimitiveType type) override
bool write(const int) override
std::string to_binary() const