Commit eb0a62dc authored by fabianw's avatar fabianw

Merge branch 'renamedSlices'

parents ad2e5ac9 2afe02bf
......@@ -133,6 +133,12 @@ public:
delete it->second;
}
ArgumentParser(const ArgumentParser& c) = delete;
ArgumentParser(ArgumentParser&& c) = default;
ArgumentParser &operator=(const ArgumentParser &c) = delete;
ArgumentParser &operator=(ArgumentParser &&c) = default;
void readFile(const std::string &filepath);
Value& operator()(std::string key);
......
......@@ -89,7 +89,7 @@ public:
virtual bool is_yperiodic() { return true; }
virtual bool is_zperiodic() { return true; }
~BlockLab()
virtual ~BlockLab()
{
_release(m_cacheBlock);
}
......
......@@ -59,6 +59,7 @@ public:
struct Object
{
virtual Region getRegion(const int _n[3]) { return Region(); }
virtual ~Object() {}
};
struct Face : Object
......
......@@ -218,7 +218,7 @@ public:
}
~GridMPI()
~GridMPI() override
{
for (auto it = SynchronizerMPIs.begin(); it != SynchronizerMPIs.end(); ++it)
delete it->second;
......
......@@ -44,21 +44,17 @@ inline void _warn_no_hdf5(void) {
// TStreamer::getAttributeName : Attribute name of the date ("Scalar", "Vector", "Tensor")
template<typename TStreamer, typename hdf5Real, typename TGrid>
void DumpHDF5(const TGrid &grid,
const int iCounter,
const typename TGrid::Real absTime,
const std::string &fname,
const std::string &dpath = ".",
const std::string &fileroot, // Filename without folder or extension.
const std::string &dirname = ".",
const bool bXMF = true)
{
#ifdef CUBISM_USE_HDF
typedef typename TGrid::BlockType B;
// fname is the base filepath tail without file type extension and
// additional identifiers
std::ostringstream filename;
std::ostringstream fullpath;
filename << fname;
fullpath << dpath << "/" << filename.str();
std::string filename_h5 = fileroot + ".h5";
std::string fullpath_h5 = dirname + "/" + filename_h5;
std::string fullpath_xmf = dirname + "/" + fileroot + ".xmf";
std::vector<BlockInfo> vInfo_local = grid.getBlocksInfo();
......@@ -69,7 +65,7 @@ void DumpHDF5(const TGrid &grid,
// startup file
H5open();
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
file_id = H5Fcreate((fullpath.str()+".h5").c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
file_id = H5Fcreate(fullpath_h5.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
status = H5Pclose(fapl_id); if(status<0) H5Eprint1(stdout);
///////////////////////////////////////////////////////////////////////////
......@@ -172,7 +168,7 @@ void DumpHDF5(const TGrid &grid,
if (bXMF)
{
FILE *xmf = 0;
xmf = fopen((fullpath.str()+".xmf").c_str(), "w");
xmf = fopen(fullpath_xmf.c_str(), "w");
fprintf(xmf, "<?xml version=\"1.0\" ?>\n");
fprintf(xmf, "<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n");
fprintf(xmf, "<Xdmf Version=\"2.0\">\n");
......@@ -182,18 +178,18 @@ void DumpHDF5(const TGrid &grid,
fprintf(xmf, " <Topology TopologyType=\"3DRectMesh\" Dimensions=\"%d %d %d\"/>\n\n", mesh_dims[2], mesh_dims[1], mesh_dims[0]);
fprintf(xmf, " <Geometry GeometryType=\"VxVyVz\">\n");
fprintf(xmf, " <DataItem Name=\"mesh_vx\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[0]);
fprintf(xmf, " %s:/vx\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vx\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " <DataItem Name=\"mesh_vy\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[1]);
fprintf(xmf, " %s:/vy\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vy\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " <DataItem Name=\"mesh_vz\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[2]);
fprintf(xmf, " %s:/vz\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vz\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " </Geometry>\n\n");
fprintf(xmf, " <Attribute Name=\"data\" AttributeType=\"%s\" Center=\"Cell\">\n", TStreamer::getAttributeName());
fprintf(xmf, " <DataItem Dimensions=\"%d %d %d %d\" NumberType=\"Float\" Precision=\"%d\" Format=\"HDF\">\n", (int)dims[0], (int)dims[1], (int)dims[2], (int)dims[3], (int)sizeof(hdf5Real));
fprintf(xmf, " %s:/data\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/data\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " </Attribute>\n");
fprintf(xmf, " </Grid>\n");
......
......@@ -28,24 +28,19 @@ CUBISM_NAMESPACE_BEGIN
// TStreamer::getAttributeName : Attribute name of the date ("Scalar", "Vector", "Tensor")
template<typename TStreamer, typename hdf5Real, typename TGrid>
void DumpHDF5_MPI(const TGrid &grid,
const int iCounter,
const typename TGrid::Real absTime,
const std::string &fname,
const std::string &dpath = ".",
const std::string &fileroot, // Filename without folder or extension.
const std::string &dirname = ".",
const bool bXMF = true)
{
#ifdef CUBISM_USE_HDF
typedef typename TGrid::BlockType B;
int rank;
// fname is the base filepath tail without file type extension and
// additional identifiers
std::ostringstream filename;
std::ostringstream fullpath;
filename << fname;
fullpath << dpath << "/" << filename.str();
std::string filename_h5 = fileroot + ".h5";
std::string fullpath_h5 = dirname + "/" + filename_h5;
std::string fullpath_xmf = dirname + "/" + fileroot + ".xmf";
int rank;
MPI_Comm comm = grid.getCartComm();
MPI_Comm_rank(comm, &rank);
......@@ -67,7 +62,7 @@ void DumpHDF5_MPI(const TGrid &grid,
{
H5open();
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
file_id = H5Fcreate((fullpath.str()+".h5").c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
file_id = H5Fcreate(fullpath_h5.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
status = H5Pclose(fapl_id);
for (size_t i = 0; i < 3; ++i)
......@@ -102,7 +97,7 @@ void DumpHDF5_MPI(const TGrid &grid,
H5open();
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
status = H5Pset_fapl_mpio(fapl_id, comm, MPI_INFO_NULL); if(status<0) H5Eprint1(stdout);
file_id = H5Fopen((fullpath.str()+".h5").c_str(), H5F_ACC_RDWR, fapl_id);
file_id = H5Fopen(fullpath_h5.c_str(), H5F_ACC_RDWR, fapl_id);
status = H5Pclose(fapl_id); if(status<0) H5Eprint1(stdout);
///////////////////////////////////////////////////////////////////////////
......@@ -203,7 +198,7 @@ void DumpHDF5_MPI(const TGrid &grid,
if (bXMF && rank==0)
{
FILE *xmf = 0;
xmf = fopen((fullpath.str()+".xmf").c_str(), "w");
xmf = fopen(fullpath_xmf.c_str(), "w");
fprintf(xmf, "<?xml version=\"1.0\" ?>\n");
fprintf(xmf, "<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n");
fprintf(xmf, "<Xdmf Version=\"2.0\">\n");
......@@ -213,18 +208,18 @@ void DumpHDF5_MPI(const TGrid &grid,
fprintf(xmf, " <Topology TopologyType=\"3DRectMesh\" Dimensions=\"%d %d %d\"/>\n\n", mesh_dims[2], mesh_dims[1], mesh_dims[0]);
fprintf(xmf, " <Geometry GeometryType=\"VxVyVz\">\n");
fprintf(xmf, " <DataItem Name=\"mesh_vx\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[0]);
fprintf(xmf, " %s:/vx\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vx\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " <DataItem Name=\"mesh_vy\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[1]);
fprintf(xmf, " %s:/vy\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vy\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " <DataItem Name=\"mesh_vz\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[2]);
fprintf(xmf, " %s:/vz\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vz\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " </Geometry>\n\n");
fprintf(xmf, " <Attribute Name=\"data\" AttributeType=\"%s\" Center=\"Cell\">\n", TStreamer::getAttributeName());
fprintf(xmf, " <DataItem Dimensions=\"%d %d %d %d\" NumberType=\"Float\" Precision=\"%d\" Format=\"HDF\">\n",(int)dims[0], (int)dims[1], (int)dims[2], (int)dims[3], (int)sizeof(hdf5Real));
fprintf(xmf, " %s:/data\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/data\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " </Attribute>\n");
fprintf(xmf, " </Grid>\n");
......
......@@ -306,10 +306,9 @@ namespace SliceTypes
// TStreamer::getAttributeName : Attribute name of the date ("Scalar", "Vector", "Tensor")
template<typename TStreamer, typename hdf5Real, typename TSlice>
void DumpSliceHDF5(const TSlice& slice,
const int stepID,
const typename TSlice::GridType::Real t,
const std::string &fname,
const std::string &dpath = ".",
const std::string &fileroot, // Filename without folder or extension.
const std::string &dirname = ".",
const bool bXMF = true)
{
#ifdef CUBISM_USE_HDF
......@@ -326,16 +325,13 @@ void DumpSliceHDF5(const TSlice& slice,
///////////////////////////////////////////////////////////////////////////
// startup file
// fname is the base filepath tail without file type extension and
// additional identifiers
std::ostringstream filename;
std::ostringstream fullpath;
filename << fname << "_slice" << slice.id();
fullpath << dpath << "/" << filename.str();
std::string filename_h5 = fileroot + ".h5";
std::string fullpath_h5 = dirname + "/" + filename_h5;
std::string fullpath_xmf = dirname + "/" + fileroot + ".xmf";
H5open();
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
file_id = H5Fcreate((fullpath.str()+".h5").c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
file_id = H5Fcreate(fullpath_h5.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
status = H5Pclose(fapl_id); if(status<0) H5Eprint1(stdout);
///////////////////////////////////////////////////////////////////////////
......@@ -419,7 +415,7 @@ void DumpSliceHDF5(const TSlice& slice,
if (bXMF)
{
FILE *xmf = 0;
xmf = fopen((fullpath.str()+".xmf").c_str(), "w");
xmf = fopen(fullpath_xmf.c_str(), "w");
fprintf(xmf, "<?xml version=\"1.0\" ?>\n");
fprintf(xmf, "<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n");
fprintf(xmf, "<Xdmf Version=\"2.0\">\n");
......@@ -432,15 +428,15 @@ void DumpSliceHDF5(const TSlice& slice,
fprintf(xmf, " %e\n", 0.0);
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " <DataItem Name=\"mesh_vy\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[0]);
fprintf(xmf, " %s:/vwidth\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vwidth\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " <DataItem Name=\"mesh_vz\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[1]);
fprintf(xmf, " %s:/vheight\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vheight\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " </Geometry>\n\n");
fprintf(xmf, " <Attribute Name=\"data\" AttributeType=\"%s\" Center=\"Cell\">\n", TStreamer::getAttributeName());
fprintf(xmf, " <DataItem Dimensions=\"%d %d %d\" NumberType=\"Float\" Precision=\"%d\" Format=\"HDF\">\n", (int)height, (int)width, (int)NCHANNELS, (int)sizeof(hdf5Real));
fprintf(xmf, " %s:/data\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/data\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " </Attribute>\n");
fprintf(xmf, " </Grid>\n");
......
......@@ -106,22 +106,19 @@ namespace SliceTypesMPI
// TStreamer::operate : Data access methods for read and write
// TStreamer::getAttributeName : Attribute name of the date ("Scalar", "Vector", "Tensor")
template<typename TStreamer, typename hdf5Real, typename TSlice>
void DumpSliceHDF5MPI(const TSlice& slice,
const int stepID,
const typename TSlice::GridType::Real t,
const std::string &fname,
const std::string &dpath = ".",
const bool bXMF = true)
void DumpSliceHDF5MPI(
const TSlice& slice,
const typename TSlice::GridType::Real t,
const std::string &fileroot, // Filename without folder or extension.
const std::string &dirname = ".",
const bool bXMF = true)
{
#ifdef CUBISM_USE_HDF
typedef typename TSlice::GridType::BlockType B;
// fname is the base filepath tail without file type extension and
// additional identifiers
std::ostringstream filename;
std::ostringstream fullpath;
filename << fname << "_slice" << slice.id();
fullpath << dpath << "/" << filename.str();
std::string filename_h5 = fileroot + ".h5";
std::string fullpath_h5 = dirname + "/" + filename_h5;
std::string fullpath_xmf = dirname + "/" + fileroot + ".xmf";
static const unsigned int NCHANNELS = TStreamer::NCHANNELS;
const unsigned int width = slice.localWidth();
......@@ -144,7 +141,7 @@ void DumpSliceHDF5MPI(const TSlice& slice,
{
H5open();
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
file_id = H5Fcreate((fullpath.str()+".h5").c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
file_id = H5Fcreate(fullpath_h5.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
status = H5Pclose(fapl_id);
for (size_t i = 0; i < 2; ++i)
......@@ -179,7 +176,7 @@ void DumpSliceHDF5MPI(const TSlice& slice,
H5open();
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
status = H5Pset_fapl_mpio(fapl_id, comm, MPI_INFO_NULL); if(status<0) H5Eprint1(stdout);
file_id = H5Fopen((fullpath.str()+".h5").c_str(), H5F_ACC_RDWR, fapl_id);
file_id = H5Fopen(fullpath_h5.c_str(), H5F_ACC_RDWR, fapl_id);
status = H5Pclose(fapl_id); if(status<0) H5Eprint1(stdout);
///////////////////////////////////////////////////////////////////////////
......@@ -250,7 +247,7 @@ void DumpSliceHDF5MPI(const TSlice& slice,
if (bXMF && 0 == myRank)
{
FILE *xmf = 0;
xmf = fopen((fullpath.str()+".xmf").c_str(), "w");
xmf = fopen(fullpath_xmf.c_str(), "w");
fprintf(xmf, "<?xml version=\"1.0\" ?>\n");
fprintf(xmf, "<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n");
fprintf(xmf, "<Xdmf Version=\"2.0\">\n");
......@@ -263,15 +260,15 @@ void DumpSliceHDF5MPI(const TSlice& slice,
fprintf(xmf, " %e\n", 0.0);
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " <DataItem Name=\"mesh_vy\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[0]);
fprintf(xmf, " %s:/vwidth\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vwidth\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " <DataItem Name=\"mesh_vz\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[1]);
fprintf(xmf, " %s:/vheight\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vheight\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " </Geometry>\n\n");
fprintf(xmf, " <Attribute Name=\"data\" AttributeType=\"%s\" Center=\"Cell\">\n", TStreamer::getAttributeName());
fprintf(xmf, " <DataItem Dimensions=\"%d %d %d\" NumberType=\"Float\" Precision=\"%d\" Format=\"HDF\">\n", (int)dims[0], (int)dims[1], (int)dims[2], (int)sizeof(hdf5Real));
fprintf(xmf, " %s:/data\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/data\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " </Attribute>\n");
fprintf(xmf, " </Grid>\n");
......
......@@ -298,21 +298,17 @@ namespace SubdomainTypes
// TStreamer::getAttributeName : Attribute name of the date ("Scalar", "Vector", "Tensor")
template<typename TStreamer, typename hdf5Real, typename TSubdomain>
void DumpSubdomainHDF5(const TSubdomain& subdomain,
const int stepID,
const typename TSubdomain::GridType::Real t,
const std::string &fname,
const std::string &dpath = ".",
const std::string &fileroot, // Filename w/o folder or extension.
const std::string &dirname = ".",
const bool bXMF = true)
{
#ifdef CUBISM_USE_HDF
typedef typename TSubdomain::GridType::BlockType B;
// fname is the base filepath tail without file type extension and
// additional identifiers
std::ostringstream filename;
std::ostringstream fullpath;
filename << fname << "_subdomain" << subdomain.id();
fullpath << dpath << "/" << filename.str();
std::string filename_h5 = fileroot + ".h5";
std::string fullpath_h5 = dirname + "/" + filename_h5;
std::string fullpath_xmf = dirname + "/" + fileroot + ".xmf";
herr_t status;
hid_t file_id, dataset_id, fspace_id, fapl_id, mspace_id;
......@@ -321,7 +317,7 @@ void DumpSubdomainHDF5(const TSubdomain& subdomain,
// startup file
H5open();
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
file_id = H5Fcreate((fullpath.str()+".h5").c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
file_id = H5Fcreate(fullpath_h5.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
status = H5Pclose(fapl_id); if(status<0) H5Eprint1(stdout);
///////////////////////////////////////////////////////////////////////////
......@@ -460,7 +456,7 @@ void DumpSubdomainHDF5(const TSubdomain& subdomain,
if (bXMF)
{
FILE *xmf = 0;
xmf = fopen((fullpath.str()+".xmf").c_str(), "w");
xmf = fopen(fullpath_xmf.c_str(), "w");
fprintf(xmf, "<?xml version=\"1.0\" ?>\n");
fprintf(xmf, "<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n");
fprintf(xmf, "<Xdmf Version=\"2.0\">\n");
......@@ -470,18 +466,18 @@ void DumpSubdomainHDF5(const TSubdomain& subdomain,
fprintf(xmf, " <Topology TopologyType=\"3DRectMesh\" Dimensions=\"%d %d %d\"/>\n\n", mesh_dims[2], mesh_dims[1], mesh_dims[0]);
fprintf(xmf, " <Geometry GeometryType=\"VxVyVz\">\n");
fprintf(xmf, " <DataItem Name=\"mesh_vx\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[0]);
fprintf(xmf, " %s:/vx\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vx\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " <DataItem Name=\"mesh_vy\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[1]);
fprintf(xmf, " %s:/vy\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vy\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " <DataItem Name=\"mesh_vz\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[2]);
fprintf(xmf, " %s:/vz\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vz\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " </Geometry>\n\n");
fprintf(xmf, " <Attribute Name=\"data\" AttributeType=\"%s\" Center=\"Cell\">\n", TStreamer::getAttributeName());
fprintf(xmf, " <DataItem Dimensions=\"%d %d %d %d\" NumberType=\"Float\" Precision=\"%d\" Format=\"HDF\">\n", (int)dims[0], (int)dims[1], (int)dims[2], (int)dims[3], (int)sizeof(hdf5Real));
fprintf(xmf, " %s:/data\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/data\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " </Attribute>\n");
fprintf(xmf, " </Grid>\n");
......
......@@ -141,24 +141,19 @@ namespace SubdomainTypesMPI
// TStreamer::getAttributeName : Attribute name of the date ("Scalar", "Vector", "Tensor")
template<typename TStreamer, typename hdf5Real, typename TSubdomain>
void DumpSubdomainHDF5MPI(const TSubdomain& subdomain,
const int stepID,
const typename TSubdomain::GridType::Real t,
const std::string &fname,
const std::string &dpath = ".",
const std::string &fileroot,
const std::string &dirname = ".",
const bool bXMF = true)
{
#ifdef CUBISM_USE_HDF
typedef typename TSubdomain::GridType::BlockType B;
int rank;
// fname is the base filepath tail without file type extension and
// additional identifiers
std::ostringstream filename;
std::ostringstream fullpath;
filename << fname << "_subdomain" << subdomain.id();
fullpath << dpath << "/" << filename.str();
std::string filename_h5 = fileroot + ".h5";
std::string fullpath_h5 = dirname + "/" + filename_h5;
std::string fullpath_xmf = dirname + "/" + fileroot + ".xmf";
int rank;
MPI_Comm comm = subdomain.getGrid()->getCartComm();
MPI_Comm_rank(comm, &rank);
......@@ -176,7 +171,7 @@ void DumpSubdomainHDF5MPI(const TSubdomain& subdomain,
{
H5open();
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
file_id = H5Fcreate((fullpath.str()+".h5").c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
file_id = H5Fcreate(fullpath_h5.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
status = H5Pclose(fapl_id);
for (size_t i = 0; i < 3; ++i)
......@@ -212,7 +207,7 @@ void DumpSubdomainHDF5MPI(const TSubdomain& subdomain,
H5open();
fapl_id = H5Pcreate(H5P_FILE_ACCESS);
status = H5Pset_fapl_mpio(fapl_id, comm, MPI_INFO_NULL); if(status<0) H5Eprint1(stdout);
file_id = H5Fopen((fullpath.str()+".h5").c_str(), H5F_ACC_RDWR, fapl_id);
file_id = H5Fopen(fullpath_h5.c_str(), H5F_ACC_RDWR, fapl_id);
status = H5Pclose(fapl_id); if(status<0) H5Eprint1(stdout);
///////////////////////////////////////////////////////////////////////////
......@@ -335,7 +330,7 @@ void DumpSubdomainHDF5MPI(const TSubdomain& subdomain,
if (bXMF && rank==0)
{
FILE *xmf = 0;
xmf = fopen((fullpath.str()+".xmf").c_str(), "w");
xmf = fopen(fullpath_xmf.c_str(), "w");
fprintf(xmf, "<?xml version=\"1.0\" ?>\n");
fprintf(xmf, "<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n");
fprintf(xmf, "<Xdmf Version=\"2.0\">\n");
......@@ -345,18 +340,18 @@ void DumpSubdomainHDF5MPI(const TSubdomain& subdomain,
fprintf(xmf, " <Topology TopologyType=\"3DRectMesh\" Dimensions=\"%d %d %d\"/>\n\n", mesh_dims[2], mesh_dims[1], mesh_dims[0]);
fprintf(xmf, " <Geometry GeometryType=\"VxVyVz\">\n");
fprintf(xmf, " <DataItem Name=\"mesh_vx\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[0]);
fprintf(xmf, " %s:/vx\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vx\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " <DataItem Name=\"mesh_vy\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[1]);
fprintf(xmf, " %s:/vy\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vy\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " <DataItem Name=\"mesh_vz\" Dimensions=\"%d\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n", mesh_dims[2]);
fprintf(xmf, " %s:/vz\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/vz\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " </Geometry>\n\n");
fprintf(xmf, " <Attribute Name=\"data\" AttributeType=\"%s\" Center=\"Cell\">\n", TStreamer::getAttributeName());
fprintf(xmf, " <DataItem Dimensions=\"%d %d %d %d\" NumberType=\"Float\" Precision=\"%d\" Format=\"HDF\">\n",(int)dims[0], (int)dims[1], (int)dims[2], (int)dims[3], (int)sizeof(hdf5Real));
fprintf(xmf, " %s:/data\n",(filename.str()+".h5").c_str());
fprintf(xmf, " %s:/data\n", filename_h5.c_str());
fprintf(xmf, " </DataItem>\n");
fprintf(xmf, " </Attribute>\n");
fprintf(xmf, " </Grid>\n");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment