29#include <itertools/itertools.hpp>
36namespace triqs::mesh {
79 mesh_point_t(
long n,
long d, uint64_t mhash) : index_(n), data_index_(d), mesh_hash_(mhash) {}
82 [[nodiscard]]
long index()
const {
return index_; }
85 [[nodiscard]]
long data_index()
const {
return data_index_; }
88 [[nodiscard]] uint64_t
mesh_hash() const noexcept {
return mesh_hash_; }
93 uint64_t mesh_hash_ = 0;
100 discrete(
long N = 0) : N_(N), mesh_hash_(N) { EXPECTS(N >= 0); }
152 [[nodiscard]] uint64_t
mesh_hash()
const {
return mesh_hash_; }
155 [[nodiscard]]
long size()
const {
return N_; }
167 [[nodiscard]]
auto cend()
const {
return end(); }
176 friend std::ostream &
operator<<(std::ostream &sout,
discrete const &m) {
return sout <<
"Discrete mesh of size " << m.
size(); }
182 void serialize(
auto &ar)
const { ar & N_ & mesh_hash_; }
191 [[nodiscard]]
static std::string
hdf5_format() {
return "MeshIndex"; }
201 h5::group gr = g.create_group(name);
202 h5::write_hdf5_format(gr, m);
203 h5::write(gr,
"size", m.
size());
214 h5::group gr = g.open_group(name);
215 h5::assert_hdf5_format(gr, m,
true);
216 long L = h5::read<long>(gr,
"size");
222 uint64_t mesh_hash_ = 0;
iterator end()
Get an iterator past the last block.
iterator begin()
Get an iterator to the first block.
int size() const
Get the total number of blocks.
Mesh point of a triqs::mesh::discrete mesh.
mesh_point_t(long n, long d, uint64_t mhash)
Construct a mesh point with a given index , data index and hash value of the parent mesh.
long data_index() const
Get the data index of the mesh point.
long index() const
Get the index of the mesh point.
discrete mesh_t
Parent mesh type.
uint64_t mesh_hash() const noexcept
Get the hash value of the parent mesh.
mesh_point_t()=default
Default constructor leaves the mesh point uninitialized.
void deserialize(auto &ar)
Deserialize the mesh from a generic archive.
bool operator==(discrete const &) const =default
Equal-to comparison operator compares the size of the meshes.
static std::string hdf5_format()
Get the HDF5 format tag.
index_t to_index(long d) const noexcept
Map a data index to the corresponding index .
bool is_index_valid(index_t n) const noexcept
Check if an index is valid.
data_index_t to_data_index(index_t n) const noexcept
Map an index to its corresponding data index .
mesh_point_t operator[](long d) const
Subscript operator to access a mesh point by its data index .
friend void h5_write(h5::group g, std::string const &name, discrete const &m)
Write a triqs::mesh::discrete mesh to HDF5.
auto cend() const
Get a const iterator to the end of the mesh.
friend void h5_read(h5::group g, std::string const &name, discrete &m)
Read a triqs::mesh::discrete mesh from HDF5.
friend std::ostream & operator<<(std::ostream &sout, discrete const &m)
Write a triqs::mesh::discrete mesh to a std::ostream.
long size() const
Get the size of the mesh, i.e. the number of mesh points.
auto cbegin() const
Get a const iterator to the beginning of the mesh.
void serialize(auto &ar) const
Serialize the mesh to a generic archive.
mesh_point_t operator()(index_t n) const
Function call operator to access a mesh point by its index .
uint64_t mesh_hash() const
Get the hash value of the mesh.
long data_index_t
Data index type.
auto begin() const
Get an iterator to the beginning of the mesh.
discrete(long N=0)
Construct a discrete mesh of a given size .
auto end() const
Get an iterator to the end of the mesh.
Common macros used in TRIQS.
Provides a generic random access iterator for 1D meshes.
A generic random access iterator for 1D meshes.