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
9 #include <fmt/format.h>
10 #include <fmt/ranges.h>
15 #include <h5pp/h5pp.h>
22 std::string get_type()
28 std::string get_type<int64_t>()
34 std::string get_type<double>()
40 std::string get_type<short>()
46 std::string get_type<std::string>()
54 m_hdf5_file = std::make_shared<h5pp::File>(filename, h5pp::FileAccess::REPLACE);
58 const std::string& name,
61 const std::vector<int64_t>& val,
62 const int64_t default_val)
68 const std::string& name,
71 const std::vector<double>& val,
72 const double default_val)
78 const std::string& name,
81 const std::vector<char>& val,
82 const char default_val)
84 std::vector<short> tmp;
85 tmp.reserve(val.size());
86 for (
const auto& v : val) tmp.push_back(v);
93 const std::string& name,
96 const std::vector<Rational>& val,
99 std::vector<std::string> tmp;
100 tmp.reserve(val.size());
101 int64_t max_size = -1;
102 for (
const auto& v : val) {
103 tmp.emplace_back(v.serialize());
104 max_size = std::max(max_size, int64_t(tmp.back().size()));
107 Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> data(tmp.size(), max_size);
108 data.setConstant(
int(
' '));
109 for (int64_t i = 0; i < data.rows(); ++i) {
110 for (int64_t j = 0; j < tmp[i].size(); ++j) {
111 data(i, j) = int(tmp[i][j]);
123 template <
typename Data,
typename T>
125 const std::string& name,
127 const int64_t stride,
129 const T& default_val)
131 std::stringstream ss;
135 m_hdf5_file->writeAttribute(stride, ss.str(),
"stride");
136 m_hdf5_file->writeAttribute(default_val, ss.str(),
"default_value");
137 m_hdf5_file->writeAttribute(type, ss.str(),
"dimension");
138 m_hdf5_file->writeAttribute(get_type<T>(), ss.str(),
"type");
151 m_name = fmt::format(
"mesh_{}", fmt::join(
id,
""));
163 std::string res =
"WMTK";
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_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