Request for API advice getting an inconsistent output
Hi, I am currently attempting to build xdmf files containing a TET mesh using the xdmf API language. Unfortunately I am having issues with an inconstant output to the xdmf file. When I call the subroutine below from one part of the main program it produces the Xdmf file labelled Version A, below, when it is called from a second place in the program it produces Version B. This is causing me some difficulty as I really need all the xdmf files to be of the form in Version A. This occurs even when the inputs into the subroutine are identical, I have checked this very carefully. I guess that either I have missed an xdmf api varrible or set one up incorrectly causing this inconstancy in the output. I’d appreciate any advice that would help me resolve it. If it helps, I am using the master branch xdmf library from 2018–10-30.
The Subroutine
#include "XdmfDomain.hpp"
#include "XdmfSystemUtils.hpp"
#include "XdmfWriter.hpp"
#include "XdmfHDF5Writer.hpp"
#include "XdmfInformation.hpp"
#include "XdmfAttribute.hpp"
#include "XdmfUnstructuredGrid.hpp"
#include "XdmfCurvilinearGrid.hpp"
#include "XdmfRectilinearGrid.hpp"
#include "XdmfRegularGrid.hpp"
#include "XdmfMap.hpp"
#include "XdmfGridCollection.hpp"
#include "XdmfGridCollectionType.hpp"
#include "XdmfAttributeType.hpp"
#include "XdmfAttributeCenter.hpp"
#include "XdmfSet.hpp"
#include "XdmfArray.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfTopology.hpp"
#include <string>
c_xdmf_writer(const char * fileName, const int nNode, const int nTet, const int tetSize, const double * dNodeX, const double * dNodeY, const double * dNodeZ, const int * iTet)
boost::shared_ptr<const XdmfTopologyType> type_use = XdmfTopologyType::NoTopologyType();
shared_ptr<XdmfDomain> primaryDomain = XdmfDomain::New();
shared_ptr<XdmfInformation> domaininfo = XdmfInformation::New("Domain", "Domain");
shared_ptr<XdmfInformation> domaininfoinfo = XdmfInformation::New("Information", "Information");
shared_ptr<XdmfUnstructuredGrid> ungrid = XdmfUnstructuredGrid::New();
shared_ptr<XdmfHDF5Writer> heavyWriter = XdmfHDF5Writer::New(std::string(fileName) + ".h5");
shared_ptr<XdmfWriter> xmlWriter = XdmfWriter::New(fileName, heavyWriter);
shared_ptr<XdmfGeometry> ungeometry = XdmfGeometry::New();
shared_ptr<XdmfInformation> ungeometryinfo = XdmfInformation::New("Geometry", "Node Coordinates");
shared_ptr<XdmfTopology> untopology = XdmfTopology::New();
shared_ptr<XdmfInformation> untopologyinfo = XdmfInformation::New("Topology", "Element definitions");
const int * elements;
int nRecords[2];
std::string elem_name;
std::vector<unsigned int> nodeDims;
std::vector<unsigned int> elemDims;
std::vector<double> nodeCoord;
type_use = XdmfTopologyType::Tetrahedron();
elements = iTet;
nRecords[0] = nTet;
nRecords[1] = tetSize;
elem_name = "Tet";
domaininfo->insert(domaininfoinfo);
primaryDomain->insert(domaininfo);
ungrid->setName("Unstructured Mesh");
//insert node coordinates into the XDMF data item
ungeometry->setType(XdmfGeometryType::XYZ());
ungeometry->setName("Unstructured Geometry");
nodeDims.push_back(nNode);
nodeDims.push_back(3);
ungeometry->initialize(XdmfArrayType::Float64(), nodeDims);
ungeometry->insert(0, dNodeX, nNode, 3, 1);
ungeometry->insert(1, dNodeY, nNode, 3, 1);
ungeometry->insert(2, dNodeZ, nNode, 3, 1);
ungeometry->insert(ungeometryinfo);
//insert element definitions into the XDMF data item for each element type
untopology->setType(type_use);
untopology->setName(elem_name +" definitions");
elemDims.push_back(nRecords[0]);
elemDims.push_back(nRecords[1]);
untopology->initialize(XdmfArrayType::UInt32(), elemDims);
untopology->insert(0, elements, nRecords[0]*nRecords[1], 1, 1);
ungrid->setTopology(untopology);
ungrid->setGeometry(ungeometry);
primaryDomain->insert(ungrid);
heavyWriter->setFileSizeLimit(1);
primaryDomain->accept(heavyWriter);
heavyWriter->setMode(XdmfHeavyDataWriter::Overwrite);
primaryDomain->accept(xmlWriter);
end:
return result;
XDMF file Version A
<?xml version="1.0" encoding="utf-8"?>
<Xdmf xmlns:xi="http://www.w3.org/2001/XInclude" Version="3.0">
<Domain>
<Information Name="Domain" Value="Domain">
<Information Name="Information" Value="Information"/>
</Information>
<Grid Name="Unstructured Mesh">
<Geometry Origin="" GeometryType="XYZ">
<Information Name="Geometry" Type="Node Coordinates"/>
<DataItem DataType="Float" Dimensions="9 3" Format="HDF" Precision="8">cube3_cf.xdmf.h5:Data0</DataItem>
</Geometry>
<Topology NumberOfElements="12" TopologyType="Tetrahedron">
<DataItem DataType="UInt" Dimensions="12 4" Format="HDF" Precision="4">cube3_cf.xdmf.h5:Data1</DataItem>
</Topology>
</Grid>
</Domain>
</Xdmf>
XDMF file Version B
<?xml version="1.0" encoding="utf-8"?>
<Xdmf xmlns:xi="http://www.w3.org/2001/XInclude" Version="3.0">
<Domain>
<Information Name="Domain" Value="Domain">
<Information Name="Information" Value="Information"/>
</Information>
<Grid Name="Unstructured Mesh">
<Geometry Origin="" Type="XYZ">
<Information Name="Geometry" Value="Node Coordinates"/>
<DataItem DataType="Float" Dimensions="9 3" Format="HDF" Precision="8"> cube3_cf.h5:Data0</DataItem>
</Geometry>
<Topology Dimensions="12" Type="Tetrahedron">
<DataItem DataType="UInt" Dimensions="12 4" Format="HDF" Precision="4"> cube3_cf.h5:Data1</DataItem>
</Topology>
</Grid>
</Domain>
</Xdmf>