问题描述
我的数据集是一个N x N矩阵,它表示一个标量字段。
通过定义我自己的标量字段类来完成矩阵表示。这样,我可以避免使用双指针,并且可以将数据写入连续的内存块中。因此,FIELD(i,j)
转换为FIELD[i + N*j]
。
现在,我编写了以下代码,将一些数据写入HDF5(矩阵为2)。
#include "H5Cpp.h"
#include "Mesh2D.h"
using namespace H5;
int main()
{
int Nx = 10;
int Ny = 10;
Mesh2D HFIELD{Nx,Ny,0};
HFIELD.meshfill(2);
HFIELD.print();
//Create HDF5 file//
const H5std_string FILE_NAME("EXAMPLE_DSET.h5");
H5File file(FILE_NAME,H5F_ACC_TRUNC);
//Create the data space for the data set//
hsize_t dims[2];
const int RANK = 2;
dims[0] = Nx;
dims[1] = Ny;
DataSpace dataspace(RANK,dims);
//Create the dataset//
const H5std_string DATASET_NAME("dset");
DataSet dataset = file.createDataSet(DATASET_NAME,PredType::NATIVE_DOUBLE,dataspace);
//Write the data to the dataset using default memory space,file space and transfer properties//
dataset.write(HFIELD,PredType::NATIVE_DOUBLE);
return 0;
}
但是,出现以下错误:
error: no matching function for call to ‘H5::DataSet::write(Mesh2D&,const H5::PredType&)’
34 | dataset.write(HFIELD,PredType::NATIVE_DOUBLE);
我该如何克服这个问题?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)