36 #include "Hdf5ToXdmfConverter.hpp"
38 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
40 const std::string& rFileBaseName,
42 :
AbstractHdf5Converter<ELEMENT_DIM,SPACE_DIM>(rInputDirectory, rFileBaseName, pMesh,
"xdmf_output", 0u),
44 rFileBaseName, false )
47 std::vector<double> time_values = this->
mpReader->GetUnlimitedDimensionValues();
48 unsigned num_timesteps = time_values.size();
51 if (num_timesteps > 1)
53 this->
mTimeStep = time_values[1] - time_values[0];
61 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
63 XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* pDomDocument,
67 XERCES_CPP_NAMESPACE_USE
69 unsigned num_timesteps = this->mpReader->GetUnlimitedDimensionValues().size();
72 for (
unsigned var_index=0; var_index<this->mNumVariables; var_index++)
74 std::string variable_name = this->mpReader->GetVariableNames()[var_index];
79 DOMElement* p_attr_element = pDomDocument->createElement(X(
"Attribute"));
80 p_attr_element->setAttribute(X(
"Name"), X(variable_name));
81 p_attr_element->setAttribute(X(
"Center"), X(
"Node"));
82 pGridElement->appendChild(p_attr_element);
87 DOMElement* p_hype_element = pDomDocument->createElement(X(
"DataItem"));
88 p_hype_element->setAttribute(X(
"ItemType"), X(
"HyperSlab"));
89 std::stringstream dim_stream;
96 dim_stream <<
"1 " << num_nodes <<
" 1";
97 p_hype_element->setAttribute(X(
"Dimensions"), X(dim_stream.str()));
98 p_attr_element->appendChild(p_hype_element);
103 DOMElement* p_xml_element = pDomDocument->createElement(X(
"DataItem"));
104 p_xml_element->setAttribute(X(
"Format"), X(
"XML"));
105 p_xml_element->setAttribute(X(
"Dimensions"), X(
"3 3"));
106 p_hype_element->appendChild(p_xml_element);
111 std::stringstream XMLStream;
112 XMLStream << timeStep <<
" 0 " << var_index <<
" ";
113 XMLStream <<
"1 1 1 ";
115 XMLStream <<
"1 " << num_nodes <<
" 1";
116 DOMText* p_xml_text = pDomDocument->createTextNode(X(XMLStream.str()));
117 p_xml_element->appendChild(p_xml_text);
122 DOMElement* p_hdf_element = pDomDocument->createElement(X(
"DataItem"));
123 p_hdf_element->setAttribute(X(
"Format"), X(
"HDF"));
124 p_hdf_element->setAttribute(X(
"NumberType"), X(
"Float"));
125 p_hdf_element->setAttribute(X(
"Precision"), X(
"8"));
126 std::stringstream hdf_dims_stream;
128 hdf_dims_stream << num_timesteps <<
" " << num_nodes <<
" " << this->mNumVariables;
129 p_hdf_element->setAttribute(X(
"Dimensions"), X(hdf_dims_stream.str()));
130 p_hype_element->appendChild(p_hdf_element);
135 std::stringstream HDFStream;
137 DOMText* p_hdf_text = pDomDocument->createTextNode(X(HDFStream.str()));
138 p_hdf_element->appendChild(p_hdf_text);
boost::shared_ptr< Hdf5DataReader > mpReader
void WriteFilesUsingMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, bool keepOriginalElementIndexing=true)
unsigned mNumberOfTimePoints
Hdf5ToXdmfConverter(const FileFinder &rInputDirectory, const std::string &rFileBaseName, AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh)
void AddDataOnNodes(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *pGridElement, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *pDomDocument, unsigned timeStep)