https://www.xdmf.org/api.php?action=feedcontributions&user=128.63.127.201&feedformat=atomXdmfWeb - User contributions [en]2024-03-28T21:20:52ZUser contributionsMediaWiki 1.39.3https://www.xdmf.org/index.php?title=Main_Page&diff=21Main Page2007-05-03T17:27:35Z<p>128.63.127.201: </p>
<hr />
<div><big>e'''X'''tensible '''D'''ata '''M'''odel and '''F'''ormat</big><br />
<br />
<br />
<br />
The need for a standardized method to exchange scientific data between High Performance Computing codes and tools lead to the development of the eXtensible Data Model and Format (XDMF) . Uses for XDMF range from a standard format used by HPC codes to take advantage of widely used visualization programs like ParaView, to a mechanism for performing coupled calculations using multiple, previously stand alone codes. <br />
<br />
Data format refers to the raw data to be manipulated. Information like number type ( float, integer, etc.), precision, location, rank, and dimensions completely describe the any dataset regardless of its size. The description of the data is also separate from the values themselves. We refer to the description of the data as '''Light''' data and the values themselves as '''Heavy''' data. Light data is small and can be passed between modules easily. Heavy data may be potentially enormous; movement needs to be kept to a minimum. Due to the different nature of heavy and light data, they are stored using separate mechanisms. Light data is stored using XML, Heavy data is typically stored using HDF5. While we could have chosen to store the light data using HDF5 attributes using XML does not require every tool to have access to the compiled HDF5 libraries in order to perform simple operations.<br />
<br />
Data model refers to the intended use of the data. For example, a three dimensional array of floating point vales may be the X,Y,Z geometry for a grid or calculated vector values. Without a data model, it is impossible to tell the difference. Since the data model only describes the data, it is purely light data and thus stored using XML. It is targeted at scientific simulation data concentrating on scalars, vectors, and tensors defined on some type of computational grid. Structured and Unstructured grids are described via their topology and geometry. Calculated, time varying data values are described as attributes of the grid. The actual values for the grid geometry, connectivity, and attribute values are contained in the data format. This separation of data format and model allows HPC codes to efficiently produce and store vales in a convenient manner without being encumbered by our data model which may be different from their internal arrangement.<br />
<br />
<br />
XDMF uses XML to store Light data and to describe the data Model. HDF5 is used to store Heavy data. The data Format is stored redundantly in both XML and HDF5. This allows tools to parse XML to determine the resources that will be required to access the Heavy data. <br />
<br />
The data model in XDMF stored in XML provides the knowledge of what is represented by the Heavy data. In this model, HPC data is viewed as a hierarchy of Domains. A Domain must contain at least one Grid. A Grid is the basic representation of both the geometric and computed/measured values. A Grid is considered to be a group of elements with Structured or Unstructured Topology and their associated values. In addition to the topology of the Grid, Geometry, specifying the X, Y, and Z positions of the Grid is required. Finally, a Grid may have one or more Attributes. Attributes are used to store any other value associated with the grid and may be referenced to the Grid or to individual cells that comprise the Grid. <br />
<br />
The concept of separating the light data from the heavy data is critical to the performance of this data model and format. HPC codes can read and write data in large, contiguous chunks that are natural to their internal data storage, to achieve optimal I/O performance. If codes were required to significantly re-arrange data prior to I/O operations, data locality, and thus performance, could be adversely affected, particularly on codes that attempt to make maximum use of memory cache. The complexity of the dataset is described in the light data portion, which is small and transportable. For example, the light data might specify a topology of one million hexaherda while the heavy data would contain the geometric XYZ values of the mesh and pressure values at the cell centers stored in large, contiguous arrays. This key feature will allow reusable tools to be built that do not put onerous requirements on HPC codes. Despite the complexity of the organization described in the XML below, the HPC code only needs to produce the three HDF5 datasets for geometry, connectivity, and pressure values.<br />
<br />
While not required, a C++ API is provided to read and write XDMF data. This API has also been wrapped so it is available from popular languages like Python, Tcl, and Java. The API is not necessary in order to produce or consume XDMF data. Currently several HPC codes that already produced HDF5 data, use native text output to produce the XML necessary for valid XDMF. <br />
<br />
<br />
*[[XDMF Model and Format]]<br />
<br />
*[[XDMF API]]<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list]<br />
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]<br />
* [http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]</div>128.63.127.201https://www.xdmf.org/index.php?title=Main_Page&diff=20Main Page2007-05-03T17:26:44Z<p>128.63.127.201: </p>
<hr />
<div><big>e'''X'''tensible '''D'''ata '''M'''odel and '''F'''ormat</big><br />
<br />
<br />
<br />
The need for a standardized method to exchange scientific data between High Performance Computing codes and tools lead to the development of the eXtensible Data Model and Format (XDMF) . Uses for XDMF range from a standard format used by HPC codes to take advantage of widely used visualization programs like ParaView, to a mechanism for performing coupled calculations using multiple, previously stand alone codes. <br />
<br />
Data format refers to the raw data to be manipulated. Information like number type ( float, integer, etc.), precision, location, rank, and dimensions completely describe the any dataset regardless of its size. The description of the data is also separate from the values themselves. We refer to the description of the data as '''Light''' data and the values themselves as '''Heavy''' data. Light data is small and can be passed between modules easily. Heavy data may be potentially enormous; movement needs to be kept to a minimum. Due to the different nature of heavy and light data, they are stored using separate mechanisms. Light data is stored using XML, Heavy data is typically stored using HDF5. While we could have chosen to store the light data using HDF5 �attributes�, using XML does not require every tool to have access to the compiled HDF5 libraries in order to perform simple operations.<br />
<br />
Data model refers to the intended use of the data. For example, a three dimensional array of floating point vales may be the X,Y,Z geometry for a grid or calculated vector values. Without a data model, it is impossible to tell the difference. Since the data model only describes the data, it is purely light data and thus stored using XML. It is targeted at scientific simulation data concentrating on scalars, vectors, and tensors defined on some type of computational grid. Structured and Unstructured grids are described via their topology and geometry. Calculated, time varying data values are described as �attributes� of the grid. The actual values for the grid geometry, connectivity, and attribute values are contained in the data format. This separation of data format and model allows HPC codes to efficiently produce and store vales in a convenient manner without being encumbered by our data model which may be different from their internal arrangement.<br />
<br />
<br />
XDMF uses XML to store Light data and to describe the data Model. HDF5 is used to store Heavy data. The data Format is stored redundantly in both XML and HDF5. This allows tools to parse XML to determine the resources that will be required to access the Heavy data. <br />
<br />
The data model in XDMF stored in XML provides the knowledge of what is represented by the Heavy data. In this model, HPC data is viewed as a hierarchy of Domains. A Domain must contain at least one Grid. A Grid is the basic representation of both the geometric and computed/measured values. A Grid is considered to be a group of elements with Structured or Unstructured Topology and their associated values. In addition to the topology of the Grid, Geometry, specifying the X, Y, and Z positions of the Grid is required. Finally, a Grid may have one or more Attributes. Attributes are used to store any other value associated with the grid and may be referenced to the Grid or to individual cells that comprise the Grid. <br />
<br />
The concept of separating the light data from the heavy data is critical to the performance of this data model and format. HPC codes can read and write data in large, contiguous chunks that are natural to their internal data storage, to achieve optimal I/O performance. If codes were required to significantly re-arrange data prior to I/O operations, data locality, and thus performance, could be adversely affected, particularly on codes that attempt to make maximum use of memory cache. The complexity of the dataset is described in the light data portion, which is small and transportable. For example, the light data might specify a topology of one million hexaherda while the heavy data would contain the geometric XYZ values of the mesh and pressure values at the cell centers stored in large, contiguous arrays. This key feature will allow reusable tools to be built that do not put onerous requirements on HPC codes. Despite the complexity of the organization described in the XML below, the HPC code only needs to produce the three HDF5 datasets for geometry, connectivity, and pressure values.<br />
<br />
While not required, a C++ API is provided to read and write XDMF data. This API has also been wrapped so it is available from popular languages like Python, Tcl, and Java. The API is not necessary in order to produce or consume XDMF data. Currently several HPC codes that already produced HDF5 data, use native text output to produce the XML necessary for valid XDMF. <br />
<br />
<br />
*[[XDMF Model and Format]]<br />
<br />
*[[XDMF API]]<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list]<br />
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]<br />
* [http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]</div>128.63.127.201https://www.xdmf.org/index.php?title=XDMF_API&diff=15XDMF API2007-05-03T16:31:41Z<p>128.63.127.201: </p>
<hr />
<div>'''XDMF API'''<br />
<br />
<br />
While use of the XDMF API is not necessary to produce or consume valid XDMF datasets, there are many convenience features that make it attractive. The XDMF library give access to a C++ class library that is also wrapped for access from scripting languages like Python.<br />
<br />
<br />
All XDMF Objects are derived from XdmfObject. Via this object, debug information can be turned on or off for each object or globally for all objects. The methods DebugOn/Off() and GlobalDebugOn/Off() perform the<br />
se functions respectively.<br />
<br />
Most examples here are written in Python for clarity.<br />
<br />
'''XdmfDOM'''<br />
<br />
To understand access to XDMF data, understanding of the XdmfDOM is critical. XDMF uses the libxml2 library to parse and generate XML documents. XdmfDOM is a slightly higher abstraction of the Document Object Mod<br />
el (DOM). The DOM is an in-memory tree structure that represents the XML file. Nodes of the tree are added, deleted, queried and serialized. The low level libxml2 nodes are typedefed as XdmfXmlNode. <br />
<br />
The XdmfDOM can parser strings or files :<br />
Status = XdmfDOM.Parse(MyXMLString)<br />
or<br />
Status = XdmfDOM.Parse(<nowiki></nowiki>MyXMLFile.xmf<nowiki></nowiki>)<br />
<br />
As with many XDMF objects, status is either XDMF_SUCCESS or XDMF_FAIL which is defined in XdmfObject.h.<br />
<br />
Once the XML has been parsed into the DOM, the tree can be navigated and modified. There are several useful query mechanisms in XdmfDOM. The first method finds the n<nowiki></nowiki>th instance of an element bel<br />
ow a parent node :<br />
<br />
XdmfXmlNode FindElement (XdmfConstString TagName, XdmfInt32 Index=0, XdmfXmlNode Node=NULL, XdmfInt32 IgnoreInfo=1)<br />
<br />
If Node==NULL the root node is assumed to be the desired parent node. IgnoreInfo allows for all "Information" elements to be ignored. For example, to find the 3^rd^ Grid element under the Domain element :<br />
<br />
DomainNode = XdmfDOM.FindElemet(<nowiki></nowiki>Domain<nowiki></nowiki>) <nowiki>#</nowiki> Take all defaults<br />
GridNode = XdmfDOM.FindElement(<nowiki></nowiki>Grid<nowiki></nowiki>, 2, DomainNode) <nowiki>#</nowiki> Index is zero based <br />
<br />
By utilizing the XPath functionality of libxml2, the same Grid element can be found by :<br />
GridNode = XdmfDOM.FindElementByPath(<nowiki></nowiki>/Xdmf/Domain/Grid<nowiki>[</nowiki>3<nowiki>]</nowiki><nowiki></nowiki>) <nowiki>#</nowiki> XPath is 1 based<br />
<br />
Once the desired node is found, it can be queried and modified :<br />
NumberOfChildElements = XdmfDOM.GetNumberOfChildren(GridNode)<br />
Name = XdmfDOM.GetAttribute(GridNode, <nowiki></nowiki>Name<nowiki></nowiki>)<br />
SubGrid = XdmfDOM.InsertNew(GridNode, <nowiki></nowiki>Grid<nowiki></nowiki>)<br />
Status = XdmfDOM.Set(SubGrid, <nowiki></nowiki>Name<nowiki></nowiki>, <nowiki></nowiki>My SubGrid<nowiki></nowiki>)<br />
<br />
And finally written back out :<br />
XmlString = XdmfDOM.Serialize(GridNode)<br />
or<br />
Status = XdmfDOM.Write(<nowiki></nowiki>MyFile.xmf<nowiki></nowiki>)<br />
<br />
'''XdmfElement'''<br />
<br />
Each element type in an XDMF XML file has a corresponding XDMF object implementation. All of these are children of XdmfElement. Each XdmfElement must be provided with an XdmfDOM with which to operate. On input, <br />
the UpdateInformation() method will initialize the basic structure of the element <br />
from the XML without reading any HeavyData. The Update() method will access the HeavyData. Each derived object from XdmfElement (XdmfGrid for example) will override these methods.<br />
<br />
GridNode = DOM.FindElementByPath(<nowiki></nowiki>/Xdmf/Domain/Grid<nowiki>[</nowiki>3<nowiki>]</nowiki><nowiki></nowiki>) <br />
Grid = XdmfGrid() <nowiki>#</nowiki> Create<br />
Grid.SetDOM(DOM)<br />
Grid.SetElement(GridNode)<br />
Grid.UpdateInformation() <nowiki>#</nowiki> Update Light Structure<br />
Grid.Update() <nowiki>#</nowiki> Read HeavyData<br />
<br />
Once the DOM has been set for an XdmfElement, there are convenience methods such as Set() and Get() which are equivalent to the XdmfDOM methods.<br />
GridName = Grid.Get(<nowiki></nowiki>Name<nowiki></nowiki>)<br />
Is the same as<br />
<br />
DOM = Grid.GetDOM()<br />
GridNode = Grid.GetElement()<br />
GridName = DOM.Get(GridNode, <nowiki></nowiki>Name<nowiki></nowiki>)<br />
<br />
For output, the XdmfElement methods Insert() and Build() are used. Each derived object in XDMF will assure that only the proper type of element is inserted. For example, it is illegal to insert a Domain element directly below a Grid element. <br />
<br />
Info = XdmfInformation() <nowiki>#</nowiki> Arbitrary Name=Value Facility<br />
Info.SetName("Time")<br />
Info.SetValue("0.0123")<br />
Grid = XdmfGrid()<br />
Grid.Set(<nowiki></nowiki>Name<nowiki></nowiki>, <nowiki></nowiki>My Grid<nowiki></nowiki>)<br />
Grid.Insert(Info)<br />
Grid.Build()<br />
<br />
Results in <br />
<br />
&lt;Grid Name="My Grid"&gt;<br />
&lt;Information Name="Time" Value="0.0123" /&gt;<br />
&lt;/Grid&gt;<br />
The Build() method is recursive so that Build() will automatically be called for all child elements.<br />
<br />
'''XdmfArray'''<br />
<br />
The XdmfArray class is a self describing data structure. It is derived from the XdmfDataDesc class that gives it number type, precision, and shape (rank and dimensions). Many XDMF classes require an XdmfArray as<br />
input to methods. The following C++ example demonstrates creating an interlaced XYZ array from three separate variables:<br />
float <nowiki>*</nowiki>x, <nowiki>*</nowiki>y, <nowiki>*</nowiki>z;<br />
XdmfInt64 total, dims<nowiki>[</nowiki>3<nowiki>]</nowiki>;<br />
XdmfArray <nowiki>*</nowiki>xyz = new XdmfArray;<br />
<br />
dims<nowiki>[</nowiki>0<nowiki>]</nowiki> = 10;<br />
dims<nowiki>[</nowiki>1<nowiki>]</nowiki> = 20;<br />
dims<nowiki>[</nowiki>2<nowiki>]</nowiki> = 30;<br />
total = 10 <nowiki>*</nowiki> 20 <nowiki>*</nowiki> 30;<br />
xyz-&gt;SetNumberType(XDMF_FLOAT64_TYPE)<br />
xyz-&gt;SetShape(3, dims); // KDim, JDim, IDim<br />
xyz-&gt;SetValues(0, x, total, 3, 1); // SetValues (XdmfInt64 Index, XdmfFloat64 <nowiki>*</nowiki>Values,<br />
// XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride=1, // XdmfInt64 ValuesStride=1)<br />
xyz-&gt;SetValues(1, y, total, 3, 1);<br />
xyz-&gt;SetValues(2, z, total, 3, 1);<br />
<br />
When an XdmfArray is created, it is given a unique tag name. Array operations can be performed on XdmfArray data by using this name in an XdmfExpr(). The following Python program gives some examples.<br />
from Xdmf import <nowiki>*</nowiki><br />
<br />
def Expression(<nowiki>*</nowiki>args) :<br />
e = <nowiki></nowiki><nowiki></nowiki><br />
for arg in args :<br />
if hasattr(arg, <nowiki></nowiki>GetTagName<nowiki></nowiki>) :<br />
e += arg.GetTagName() + <nowiki></nowiki> <nowiki></nowiki><br />
else :<br />
e += arg + <nowiki></nowiki> <nowiki></nowiki><br />
return XdmfExpr(e)<br />
<br />
<br />
if __name__ == <nowiki></nowiki>__main__<nowiki></nowiki> :<br />
a1 = XdmfArray()<br />
a1.SetNumberType(XDMF_FLOAT32_TYPE)<br />
a1.SetNumberOfElements(20)<br />
a1.Generate(1, 20)<br />
a2 = XdmfArray()<br />
a2.SetNumberType(XDMF_INT32_TYPE)<br />
a2.SetNumberOfElements(5)<br />
a2.Generate(2, 10)<br />
print <nowiki></nowiki>a1 Values = <nowiki></nowiki>, a1.GetValues()<br />
print <nowiki></nowiki>a1<nowiki>[</nowiki>2:10<nowiki>]</nowiki> = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki><nowiki>[</nowiki> 2:10 <nowiki>] </nowiki><nowiki></nowiki>).GetValues()<br />
print <nowiki></nowiki>a2 Values = <nowiki></nowiki>, a2.GetValues()<br />
print <nowiki></nowiki>a1<nowiki>[</nowiki>a2<nowiki>]</nowiki> = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki><nowiki>[</nowiki><nowiki></nowiki>, a2, <nowiki></nowiki><nowiki>]</nowiki><nowiki></no<br />
wiki>).GetValues()<br />
print <nowiki></nowiki>a1 + a2 = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki> + <nowiki></nowiki>, a2).GetValues()<br />
print <nowiki></nowiki>a1 <nowiki>*</nowiki> a2 = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki> <nowiki>*</nowiki> <nowiki></nowiki>, a2).GetValues()<br />
a2.SetNumberType(XDMF_FLOAT32_TYPE)<br />
a2.SetNumberOfElements(20)<br />
a2.Generate(21, 40)<br />
print <nowiki></nowiki>a2 Values = <nowiki></nowiki>, a2.GetValues()<br />
print <nowiki></nowiki>a1 , a2 (Interlace) = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki> , <nowiki></nowiki>, a2).GetValues()<br />
print <nowiki></nowiki>a1 , a2, a1 (Interlace) = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki> , <nowiki></nowiki>, a2, <nowiki></nowiki> , <nowiki></nowiki>, a1).GetValues()<br />
print <nowiki></nowiki>a1 ; a2 (Concat) = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki> ; <nowiki></nowiki>, a2).GetValues()<br />
print <nowiki></nowiki>where(a1 &gt; 10) = <nowiki></nowiki> + Expression(<nowiki></nowiki>Where( <nowiki></nowiki>, a1 , <nowiki></nowiki> &gt; 10)<nowiki></nowiki>).GetValues()<br />
print <nowiki></nowiki>a2<nowiki>[</nowiki>where(a1 &gt; 10)<nowiki>]</nowiki> = <nowiki></nowiki> + Expression(a2, <nowiki></nowiki><nowiki>[</nowiki>Where( <nowiki></nowiki>, a1 , <nowiki></nowiki> &gt; 10<br />
)<nowiki>]</nowiki><nowiki></nowiki>).GetValues()<br />
<br />
While most of the functions are self explanatory the WHERE function is not. WHERE will return the indexes of the XdmfArray where a certain condition is true. In this example WHERE returns the indexes of XdmfArra<br />
y a1 where a1 is greater than 10. Notice that the XdmfExpr() function makes it easy to extract part of an XdmfArray.<br />
<br />
'''XdmfHDF'''<br />
<br />
In XDMF Light data is stored in XML while the Heavy data is typically stored in an HDF5 file.<br />
The XdmfHDF class simplifies access to HDF5 data, it is also derived from XdmfDataDesc. The following Python code demonstrates its use :<br />
<br />
<br />
from Xdmf import <nowiki>*</nowiki><br />
<br />
Geometry = <nowiki></nowiki>-1.75 -1.25 0 -1.25 -1.25 0 -0.75 <br />
Connectivity = <nowiki></nowiki>3 2 5 1 .<br />
Values = <nowiki></nowiki>100 200 300 ..<br />
<br />
<nowiki>#</nowiki> Geometry<br />
GeometryArray = XdmfArray()<br />
GeometryArray.SetValues(0, Geometry)<br />
H5 = XdmfHDF()<br />
H5.CopyType(GeometryArray)<br />
H5.CopyShape(GeometryArray)<br />
<nowiki>#</nowiki> Open for Writing. This will truncate the file.<br />
H5.Open(<nowiki></nowiki>Example1.h5:/Geometry<nowiki></nowiki>, <nowiki></nowiki>w<nowiki></nowiki>)<br />
H5.Write(GeometryArray)<br />
H5.Close()<br />
<br />
<nowiki>#</nowiki> Connectivity<br />
ConnectivityArray = XdmfArray()<br />
ConnectivityArray.SetValues(0, Connectivity)<br />
H5 = XdmfHDF()<br />
H5.CopyType(ConnectivityArray)<br />
H5.CopyShape(ConnectivityArray)<br />
<nowiki>#</nowiki> Open for Reading and Writing. This will NOT truncate the file.<br />
H5.Open(<nowiki></nowiki>Example1.h5:/Connectivity<nowiki></nowiki>, <nowiki></nowiki>rw<nowiki></nowiki>)<br />
H5.Write(ConnectivityArray)<br />
H5.Close()<br />
<br />
<br />
<nowiki>#</nowiki> Values<br />
ValueArray = XdmfArray()<br />
ValueArray.SetValues(0, Values)<br />
H5 = XdmfHDF()<br />
H5.CopyType(ValueArray)<br />
H5.CopyShape(ValueArray)<br />
<nowiki>#</nowiki> Open for Reading and Writing. This will NOT truncate the file.<br />
H5.Open(<nowiki></nowiki>Example1.h5:/Values<nowiki></nowiki>, <nowiki></nowiki>rw<nowiki></nowiki>)<br />
H5.Write(ValueArray)<br />
H5.Close()<br />
<br />
For reading, XdmfHDF will allocate an array if none is specified :<br />
Status = H5.Open(<nowiki></nowiki>Example1.h5:/Values<nowiki></nowiki>, <nowiki></nowiki>rw<nowiki></nowiki>)<br />
ValueArray = H5.Read()<br />
<br />
'''Reading XDMF'''<br />
<br />
Putting all of this together, assume Points.xmf is a valid XDMF XML file with a single uniform Grid. Here is a Python example to read and print values.<br />
<br />
dom = XdmfDOM()<br />
dom.Parse(<nowiki></nowiki>Points.xmf<nowiki></nowiki>)<br />
<br />
ge = dom.FindElementByPath(<nowiki></nowiki>/Xdmf/Domain/Grid<nowiki></nowiki>)<br />
grid = XdmfGrid()<br />
grid.SetDOM(dom)<br />
grid.SetElement(ge)<br />
grid.UpdateInformation()<br />
grid.Update() <br />
<br />
top = grid.GetTopology()<br />
top.DebugOn()<br />
conn = top.GetConnectivity()<br />
print <nowiki></nowiki>Values = <nowiki></nowiki>, conn.GetValues()<br />
<br />
geo = grid.GetGeometry()<br />
points = geo.GetPoints()<br />
print <nowiki></nowiki>Geo Type = <nowiki></nowiki>, geo.GetGeometryTypeAsString(), <nowiki></nowiki> <nowiki>#</nowiki> Points = <nowiki></nowiki>, geo.GetNumberOfPoints()<br />
print <nowiki></nowiki>Points = <nowiki></nowiki>, points.GetValues(0, 6)<br />
<br />
'''Writing XDMF'''<br />
<br />
Using the Insert() and Build() methods, an XDMF dataset can be generated programmatically as well . Internally, as XDMF objects are inserted, the DOM is "decorated" with their pointers. In this manner, the api c<br />
an get a object from an node of the DOM if it has been created. For reading XDMF, this allows multiple references to the same DataItem not to result in additional IO. For writing, this allows Build() to work rec<br />
ursively.<br />
<br />
d = XdmfDOM()<br />
<br />
root = XdmfRoot()<br />
root.SetDOM(d)<br />
root.SetVersion(2.2) <nowiki>#</nowiki> Change the Version number because we can<br />
root.Build()<br />
<nowiki>#</nowiki> Information<br />
i = XdmfInformation() <nowiki>#</nowiki> Arbitrary Name=Value Facility<br />
i.SetName("Time")<br />
i.SetValue("0.0123")<br />
root.Insert(i) <nowiki>#</nowiki> XML DOM is used as the keeper of the structure<br />
<nowiki>#</nowiki> Insert() creates an XML node and inserts it under<br />
<nowiki>#</nowiki> the parent<br />
<nowiki>#</nowiki> Domain<br />
dm = XdmfDomain()<br />
root.Insert(dm)<br />
<nowiki>#</nowiki> Grid<br />
g = XdmfGrid()<br />
g.SetName("Structured Grid")<br />
<nowiki>#</nowiki> Topology<br />
t = g.GetTopology()<br />
t.SetTopologyType(XDMF_3DCORECTMESH)<br />
t.GetShapeDesc().SetShapeFromString(<nowiki></nowiki>10 20 30<nowiki></nowiki>)<br />
<nowiki>#</nowiki> Geometry<br />
geo = g.GetGeometry()<br />
geo.SetGeometryType(XDMF_GEOMETRY_ORIGIN_DXDYDZ)<br />
geo.SetOrigin(1, 2, 3)<br />
geo.SetDxDyDz(0.1, 0.2, 0.3)<br />
dm.Insert(g)<br />
<nowiki>#</nowiki> Attribute<br />
attr = XdmfAttribute()<br />
attr.SetName("Pressure")<br />
attr.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_CELL);<br />
attr.SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR);<br />
p = attr.GetValues()<br />
p.SetNumberOfElements(10 <nowiki>*</nowiki> 20 <nowiki>*</nowiki> 30)<br />
p.Generate(0.0, 1.0, 0, p.GetNumberOfElements() - 1)<br />
g.Insert(attr)<br />
# Update XML and Write Values to DataItems<br />
root.Build() <nowiki>#</nowiki> DataItems &gt; 100 values are heavy<br />
print d.Serialize() <nowiki>#</nowiki> prints to stdout <br />
<br />
d.Write(<nowiki></nowiki>MyMesh.xmf<nowiki></nowiki>) <nowiki>#</nowiki> write to file</div>128.63.127.201https://www.xdmf.org/index.php?title=XDMF_API&diff=14XDMF API2007-05-03T16:30:38Z<p>128.63.127.201: </p>
<hr />
<div>'''XDMF API'''<br />
<br />
<br />
While use of the XDMF API is not necessary to produce or consume valid XDMF datasets, there are many convenience features that make it attractive. The XDMF library give access to a C++ class library that is also wrapped for access from scripting languages like Python.<br />
<br />
<br />
All XDMF Objects are derived from XdmfObject. Via this object, debug information can be turned on or off for each object or globally for all objects. The methods DebugOn/Off() and GlobalDebugOn/Off() perform the<br />
se functions respectively.<br />
<br />
Most examples here are written in Python for clarity.<br />
<br />
'''XdmfDOM'''<br />
<br />
To understand access to XDMF data, understanding of the XdmfDOM is critical. XDMF uses the libxml2 library to parse and generate XML documents. XdmfDOM is a slightly higher abstraction of the Document Object Mod<br />
el (DOM). The DOM is an in-memory tree structure that represents the XML file. Nodes of the tree are added, deleted, queried and serialized. The low level libxml2 nodes are typedefed as XdmfXmlNode. <br />
<br />
The XdmfDOM can parser strings or files :<br />
Status = XdmfDOM.Parse(MyXMLString)<br />
or<br />
Status = XdmfDOM.Parse(<nowiki></nowiki>MyXMLFile.xmf<nowiki></nowiki>)<br />
<br />
As with many XDMF objects, status is either XDMF_SUCCESS or XDMF_FAIL which is defined in XdmfObject.h.<br />
<br />
Once the XML has been parsed into the DOM, the tree can be navigated and modified. There are several useful query mechanisms in XdmfDOM. The first method finds the n<nowiki></nowiki>th instance of an element bel<br />
ow a parent node :<br />
<br />
XdmfXmlNode FindElement (XdmfConstString TagName, XdmfInt32 Index=0, XdmfXmlNode Node=NULL, XdmfInt32 IgnoreInfo=1)<br />
<br />
If Node==NULL the root node is assumed to be the desired parent node. IgnoreInfo allows for all "Information" elements to be ignored. For example, to find the 3^rd^ Grid element under the Domain element :<br />
<br />
DomainNode = XdmfDOM.FindElemet(<nowiki></nowiki>Domain<nowiki></nowiki>) <nowiki>#</nowiki> Take all defaults<br />
GridNode = XdmfDOM.FindElement(<nowiki></nowiki>Grid<nowiki></nowiki>, 2, DomainNode) <nowiki>#</nowiki> Index is zero based <br />
<br />
By utilizing the XPath functionality of libxml2, the same Grid element can be found by :<br />
GridNode = XdmfDOM.FindElementByPath(<nowiki></nowiki>/Xdmf/Domain/Grid<nowiki>[</nowiki>3<nowiki>]</nowiki><nowiki></nowiki>) <nowiki>#</nowiki> XPath is 1 based<br />
<br />
Once the desired node is found, it can be queried and modified :<br />
NumberOfChildElements = XdmfDOM.GetNumberOfChildren(GridNode)<br />
Name = XdmfDOM.GetAttribute(GridNode, <nowiki></nowiki>Name<nowiki></nowiki>)<br />
SubGrid = XdmfDOM.InsertNew(GridNode, <nowiki></nowiki>Grid<nowiki></nowiki>)<br />
Status = XdmfDOM.Set(SubGrid, <nowiki></nowiki>Name<nowiki></nowiki>, <nowiki></nowiki>My SubGrid<nowiki></nowiki>)<br />
<br />
And finally written back out :<br />
XmlString = XdmfDOM.Serialize(GridNode)<br />
or<br />
Status = XdmfDOM.Write(<nowiki></nowiki>MyFile.xmf<nowiki></nowiki>)<br />
<br />
'''XdmfElement'''<br />
<br />
Each element type in an XDMF XML file has a corresponding XDMF object implementation. All of these are children of XdmfElement. Each XdmfElement must be provided with an XdmfDOM with which to operate. On input, <br />
the UpdateInformation() method will initialize the basic structure of the element <br />
from the XML without reading any HeavyData. The Update() method will access the HeavyData. Each derived object from XdmfElement (XdmfGrid for example) will override these methods.<br />
<br />
GridNode = DOM.FindElementByPath(<nowiki></nowiki>/Xdmf/Domain/Grid<nowiki>[</nowiki>3<nowiki>]</nowiki><nowiki></nowiki>) <br />
Grid = XdmfGrid() <nowiki>#</nowiki> Create<br />
Grid.SetDOM(DOM)<br />
Grid.SetElement(GridNode)<br />
Grid.UpdateInformation() <nowiki>#</nowiki> Update Light Structure<br />
Grid.Update() <nowiki>#</nowiki> Read HeavyData<br />
<br />
Once the DOM has been set for an XdmfElement, there are convenience methods such as Set() and Get() which are equivalent to the XdmfDOM methods.<br />
GridName = Grid.Get(<nowiki></nowiki>Name<nowiki></nowiki>)<br />
Is the same as<br />
<br />
DOM = Grid.GetDOM()<br />
GridNode = Grid.GetElement()<br />
GridName = DOM.Get(GridNode, <nowiki></nowiki>Name<nowiki></nowiki>)<br />
<br />
For output, the XdmfElement methods Insert() and Build() are used. Each derived object in XDMF will assure that only the proper type of element is inserted. For example, it is illegal to insert a Domain element directly below a Grid element. <br />
<br />
Info = XdmfInformation() <nowiki>#</nowiki> Arbitrary Name=Value Facility<br />
Info.SetName("Time")<br />
Info.SetValue("0.0123")<br />
Grid = XdmfGrid()<br />
Grid.Set(<nowiki></nowiki>Name<nowiki></nowiki>, <nowiki></nowiki>My Grid<nowiki></nowiki>)<br />
Grid.Insert(Info)<br />
Grid.Build()<br />
<br />
Results in <br />
<br />
&lt;Grid Name="My Grid"&gt;<br />
&lt;Information Name="Time" Value="0.0123" /&gt;<br />
&lt;/Grid&gt;<br />
The Build() method is recursive so that Build() will automatically be called for all child elements.<br />
<br />
'''XdmfArray'''<br />
<br />
The XdmfArray class is a self describing data structure. It is derived from the XdmfDataDesc class that gives it number type, precision, and shape (rank and dimensions). Many XDMF classes require an XdmfArray as<br />
input to methods. The following C++ example demonstrates creating an interlaced XYZ array from three separate variables:<br />
float <nowiki>*</nowiki>x, <nowiki>*</nowiki>y, <nowiki>*</nowiki>z;<br />
XdmfInt64 total, dims<nowiki>[</nowiki>3<nowiki>]</nowiki>;<br />
XdmfArray <nowiki>*</nowiki>xyz = new XdmfArray;<br />
<br />
dims<nowiki>[</nowiki>0<nowiki>]</nowiki> = 10;<br />
dims<nowiki>[</nowiki>1<nowiki>]</nowiki> = 20;<br />
dims<nowiki>[</nowiki>2<nowiki>]</nowiki> = 30;<br />
total = 10 <nowiki>*</nowiki> 20 <nowiki>*</nowiki> 30;<br />
xyz-&gt;SetNumberType(XDMF_FLOAT64_TYPE)<br />
xyz-&gt;SetShape(3, dims); // KDim, JDim, IDim<br />
xyz-&gt;SetValues(0, x, total, 3, 1); // SetValues (XdmfInt64 Index, XdmfFloat64 <nowiki>*</nowiki>Values,<br />
// XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride=1, // XdmfInt64 ValuesStride=1)<br />
xyz-&gt;SetValues(1, y, total, 3, 1);<br />
xyz-&gt;SetValues(2, z, total, 3, 1);<br />
<br />
When an XdmfArray is created, it is given a unique tag name. Array operations can be performed on XdmfArray data by using this name in an XdmfExpr(). The following Python program gives some examples.<br />
from Xdmf import <nowiki>*</nowiki><br />
<br />
def Expression(<nowiki>*</nowiki>args) :<br />
e = <nowiki></nowiki><nowiki></nowiki><br />
for arg in args :<br />
if hasattr(arg, <nowiki></nowiki>GetTagName<nowiki></nowiki>) :<br />
e += arg.GetTagName() + <nowiki></nowiki> <nowiki></nowiki><br />
else :<br />
e += arg + <nowiki></nowiki> <nowiki></nowiki><br />
return XdmfExpr(e)<br />
<br />
<br />
if __name__ == <nowiki></nowiki>__main__<nowiki></nowiki> :<br />
a1 = XdmfArray()<br />
a1.SetNumberType(XDMF_FLOAT32_TYPE)<br />
a1.SetNumberOfElements(20)<br />
a1.Generate(1, 20)<br />
a2 = XdmfArray()<br />
a2.SetNumberType(XDMF_INT32_TYPE)<br />
a2.SetNumberOfElements(5)<br />
a2.Generate(2, 10)<br />
print <nowiki></nowiki>a1 Values = <nowiki></nowiki>, a1.GetValues()<br />
print <nowiki></nowiki>a1<nowiki>[</nowiki>2:10<nowiki>]</nowiki> = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki><nowiki>[</nowiki> 2:10 <nowiki>] </nowiki><nowiki></nowiki>).GetValues()<br />
print <nowiki></nowiki>a2 Values = <nowiki></nowiki>, a2.GetValues()<br />
print <nowiki></nowiki>a1<nowiki>[</nowiki>a2<nowiki>]</nowiki> = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki><nowiki>[</nowiki><nowiki></nowiki>, a2, <nowiki></nowiki><nowiki>]</nowiki><nowiki></no<br />
wiki>).GetValues()<br />
print <nowiki></nowiki>a1 + a2 = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki> + <nowiki></nowiki>, a2).GetValues()<br />
print <nowiki></nowiki>a1 <nowiki>*</nowiki> a2 = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki> <nowiki>*</nowiki> <nowiki></nowiki>, a2).GetValues()<br />
a2.SetNumberType(XDMF_FLOAT32_TYPE)<br />
a2.SetNumberOfElements(20)<br />
a2.Generate(21, 40)<br />
print <nowiki></nowiki>a2 Values = <nowiki></nowiki>, a2.GetValues()<br />
print <nowiki></nowiki>a1 , a2 (Interlace) = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki> , <nowiki></nowiki>, a2).GetValues()<br />
print <nowiki></nowiki>a1 , a2, a1 (Interlace) = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki> , <nowiki></nowiki>, a2, <nowiki></nowiki> , <nowiki></nowiki>, a1).GetValues()<br />
print <nowiki></nowiki>a1 ; a2 (Concat) = <nowiki></nowiki> + Expression(a1 , <nowiki></nowiki> ; <nowiki></nowiki>, a2).GetValues()<br />
print <nowiki></nowiki>where(a1 &gt; 10) = <nowiki></nowiki> + Expression(<nowiki></nowiki>Where( <nowiki></nowiki>, a1 , <nowiki></nowiki> &gt; 10)<nowiki></nowiki>).GetValues()<br />
print <nowiki></nowiki>a2<nowiki>[</nowiki>where(a1 &gt; 10)<nowiki>]</nowiki> = <nowiki></nowiki> + Expression(a2, <nowiki></nowiki><nowiki>[</nowiki>Where( <nowiki></nowiki>, a1 , <nowiki></nowiki> &gt; 10<br />
)<nowiki>]</nowiki><nowiki></nowiki>).GetValues()<br />
<br />
While most of the functions are self explanatory the WHERE function is not. WHERE will return the indexes of the XdmfArray where a certain condition is true. In this example WHERE returns the indexes of XdmfArra<br />
y a1 where a1 is greater than 10. Notice that the XdmfExpr() function makes it easy to extract part of an XdmfArray.<br />
<br />
'''XdmfHDF'''<br />
<br />
In XDMF Light data is stored in XML while the Heavy data is typically stored in an HDF5 file.<br />
The XdmfHDF class simplifies access to HDF5 data, it is also derived from XdmfDataDesc. The following Python code demonstrates its use :<br />
<br />
<br />
from Xdmf import <nowiki>*</nowiki><br />
<br />
Geometry = <nowiki></nowiki>-1.75 -1.25 0 -1.25 -1.25 0 -0.75 <br />
Connectivity = <nowiki></nowiki>3 2 5 1 .<br />
Values = <nowiki></nowiki>100 200 300 ..<br />
<br />
<nowiki>#</nowiki> Geometry<br />
GeometryArray = XdmfArray()<br />
GeometryArray.SetValues(0, Geometry)<br />
H5 = XdmfHDF()<br />
H5.CopyType(GeometryArray)<br />
H5.CopyShape(GeometryArray)<br />
<nowiki>#</nowiki> Open for Writing. This will truncate the file.<br />
H5.Open(<nowiki></nowiki>Example1.h5:/Geometry<nowiki></nowiki>, <nowiki></nowiki>w<nowiki></nowiki>)<br />
H5.Write(GeometryArray)<br />
H5.Close()<br />
<br />
<nowiki>#</nowiki> Connectivity<br />
ConnectivityArray = XdmfArray()<br />
ConnectivityArray.SetValues(0, Connectivity)<br />
H5 = XdmfHDF()<br />
H5.CopyType(ConnectivityArray)<br />
H5.CopyShape(ConnectivityArray)<br />
<nowiki>#</nowiki> Open for Reading and Writing. This will NOT truncate the file.<br />
H5.Open(<nowiki></nowiki>Example1.h5:/Connectivity<nowiki></nowiki>, <nowiki></nowiki>rw<nowiki></nowiki>)<br />
H5.Write(ConnectivityArray)<br />
H5.Close()<br />
<br />
<br />
<nowiki>#</nowiki> Values<br />
ValueArray = XdmfArray()<br />
ValueArray.SetValues(0, Values)<br />
H5 = XdmfHDF()<br />
H5.CopyType(ValueArray)<br />
H5.CopyShape(ValueArray)<br />
<nowiki>#</nowiki> Open for Reading and Writing. This will NOT truncate the file.<br />
H5.Open(<nowiki></nowiki>Example1.h5:/Values<nowiki></nowiki>, <nowiki></nowiki>rw<nowiki></nowiki>)<br />
H5.Write(ValueArray)<br />
H5.Close()<br />
<br />
For reading, XdmfHDF will allocate an array if none is specified :<br />
Status = H5.Open(<nowiki></nowiki>Example1.h5:/Values<nowiki></nowiki>, <nowiki></nowiki>rw<nowiki></nowiki>)<br />
ValueArray = H5.Read()<br />
<br />
'''Reading XDMF'''<br />
<br />
Putting all of this together, assume Points.xmf is a valid XDMF XML file with a single uniform Grid. Here is a Python example to read and print values.<br />
<br />
dom = XdmfDOM()<br />
dom.Parse(<nowiki></nowiki>Points.xmf<nowiki></nowiki>)<br />
<br />
ge = dom.FindElementByPath(<nowiki></nowiki>/Xdmf/Domain/Grid<nowiki></nowiki>)<br />
grid = XdmfGrid()<br />
grid.SetDOM(dom)<br />
grid.SetElement(ge)<br />
grid.UpdateInformation()<br />
grid.Update() <br />
<br />
top = grid.GetTopology()<br />
top.DebugOn()<br />
conn = top.GetConnectivity()<br />
print <nowiki></nowiki>Values = <nowiki></nowiki>, conn.GetValues()<br />
<br />
geo = grid.GetGeometry()<br />
points = geo.GetPoints()<br />
print <nowiki></nowiki>Geo Type = <nowiki></nowiki>, geo.GetGeometryTypeAsString(), <nowiki></nowiki> <nowiki>#</nowiki> Points = <nowiki></nowiki>, geo.GetNumberOfPoints()<br />
print <nowiki></nowiki>Points = <nowiki></nowiki>, points.GetValues(0, 6)<br />
<br />
'''Writing XDMF'''<br />
<br />
Using the Insert() and Build() methods, an XDMF dataset can be generated programmatically as well . Internally, as XDMF objects are inserted, the DOM is "decorated" with their pointers. In this manner, the api c<br />
an get a object from an node of the DOM if it has been created. For reading XDMF, this allows multiple references to the same DataItem not to result in additional IO. For writing, this allows Build() to work rec<br />
ursively.<br />
<br />
d = XdmfDOM()<br />
<br />
root = XdmfRoot()<br />
root.SetDOM(d)<br />
root.SetVersion(2.2) <nowiki>#</nowiki> Change the Version number because we can<br />
root.Build()<br />
<nowiki>#</nowiki> Information<br />
i = XdmfInformation() <nowiki>#</nowiki> Arbitrary Name=Value Facility<br />
i.SetName("Time")<br />
i.SetValue("0.0123")<br />
root.Insert(i) <nowiki>#</nowiki> XML DOM is used as the keeper of the structure<br />
<nowiki>#</nowiki> Insert() creates an XML node and inserts it under<br />
<nowiki>#</nowiki> the parent<br />
<nowiki>#</nowiki> Domain<br />
dm = XdmfDomain()<br />
root.Insert(dm)<br />
<nowiki>#</nowiki> Grid<br />
g = XdmfGrid()<br />
g.SetName("Structured Grid")<br />
<nowiki>#</nowiki> Topology<br />
t = g.GetTopology()<br />
t.SetTopologyType(XDMF_3DCORECTMESH)<br />
t.GetShapeDesc().SetShapeFromString(<nowiki></nowiki>10 20 30<nowiki></nowiki>)<br />
<nowiki>#</nowiki> Geometry<br />
geo = g.GetGeometry()<br />
geo.SetGeometryType(XDMF_GEOMETRY_ORIGIN_DXDYDZ)<br />
geo.SetOrigin(1, 2, 3)<br />
geo.SetDxDyDz(0.1, 0.2, 0.3)<br />
dm.Insert(g)<br />
<nowiki>#</nowiki> Attribute<br />
attr = XdmfAttribute()<br />
attr.SetName("Pressure")<br />
attr.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_CELL);<br />
attr.SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR);<br />
p = attr.GetValues()<br />
p.SetNumberOfElements(10 <nowiki>*</nowiki> 20 <nowiki>*</nowiki> 30)<br />
p.Generate(0.0, 1.0, 0, p.GetNumberOfElements() - 1)<br />
g.Insert(attr)<br />
<nowiki>#</nowiki> Update XML and Write Values to DataItems<br />
root.Build() <nowiki>#</nowiki> DataItems &gt; 100 values are heavy<br />
print d.Serialize() <nowiki>#</nowiki> prints to stdout <br />
<br />
d.Write(<nowiki></nowiki>MyMesh.xmf<nowiki></nowiki>) <nowiki>#</nowiki> write to file</div>128.63.127.201https://www.xdmf.org/index.php?title=XDMF_API&diff=13XDMF API2007-05-03T16:11:57Z<p>128.63.127.201: New page: '''XDMF API''' While use of the XDMF API is not necessary to produce or consume valid XDMF datasets, there are many convenience features that make it attractive. The XDMF library give a...</p>
<hr />
<div><br />
'''XDMF API'''<br />
<br />
<br />
While use of the XDMF API is not necessary to produce or consume valid XDMF datasets, there are many convenience features that make it attractive. The XDMF library give access to a C++ class library that is also wrapped for access from scripting languages like Python.<br />
<br />
<br />
All XDMF Objects are derived from XdmfObject. Via this object, debug information can be turned on or off for each object or globally for all objects. The methods DebugOn/Off() and GlobalDebugOn/Off() perform these functions respectively.<br />
<br />
Most examples here are written in Python for clarity.<br />
<br />
'''XdmfDOM'''<br />
<br />
To understand access to XDMF data, understanding of the XdmfDOM is critical. XDMF uses the libxml2 library to parse and generate XML documents. XdmfDOM is a slightly higher abstraction of the Document Object Model (DOM). The DOM is an in-memory tree structure that represents the XML file. Nodes of the tree are added, deleted, queried and serialized. The low level libxml2 nodes are typedefed as XdmfXmlNode. <br />
<br />
The XdmfDOM can parser strings or files :<br />
Status = XdmfDOM.Parse(MyXMLString)<br />
or<br />
Status = XdmfDOM.Parse(<nowiki>�</nowiki>MyXMLFile.xmf<nowiki>�</nowiki>)<br />
<br />
As with many XDMF objects, status is either XDMF_SUCCESS or XDMF_FAIL which is defined in XdmfObject.h.<br />
<br />
Once the XML has been parsed into the DOM, the tree can be navigated and modified. There are several useful query mechanisms in XdmfDOM. The first method finds the n<nowiki>�</nowiki>th instance of an element below a parent node :<br />
<br />
XdmfXmlNode FindElement (XdmfConstString TagName, XdmfInt32 Index=0, XdmfXmlNode Node=NULL, XdmfInt32 IgnoreInfo=1)<br />
<br />
If Node==NULL the root node is assumed to be the desired parent node. IgnoreInfo allows for all "Information" elements to be ignored. For example, to find the 3^rd^ Grid element under the Domain element :<br />
<br />
DomainNode = XdmfDOM.FindElemet(<nowiki>�</nowiki>Domain<nowiki>�</nowiki>) <nowiki>#</nowiki> Take all defaults<br />
GridNode = XdmfDOM.FindElement(<nowiki>�</nowiki>Grid<nowiki>�</nowiki>, 2, DomainNode) <nowiki>#</nowiki> Index is zero based <br />
<br />
By utilizing the XPath functionality of libxml2, the same Grid element can be found by :<br />
GridNode = XdmfDOM.FindElementByPath(<nowiki>�</nowiki>/Xdmf/Domain/Grid<nowiki>[</nowiki>3<nowiki>]</nowiki><nowiki>�</nowiki>) <nowiki>#</nowiki> XPath is 1 based<br />
<br />
Once the desired node is found, it can be queried and modified :<br />
NumberOfChildElements = XdmfDOM.GetNumberOfChildren(GridNode)<br />
Name = XdmfDOM.GetAttribute(GridNode, <nowiki>�</nowiki>Name<nowiki>�</nowiki>)<br />
SubGrid = XdmfDOM.InsertNew(GridNode, <nowiki>�</nowiki>Grid<nowiki>�</nowiki>)<br />
Status = XdmfDOM.Set(SubGrid, <nowiki>�</nowiki>Name<nowiki>�</nowiki>, <nowiki>�</nowiki>My SubGrid<nowiki>�</nowiki>)<br />
<br />
And finally written back out :<br />
XmlString = XdmfDOM.Serialize(GridNode)<br />
or<br />
Status = XdmfDOM.Write(<nowiki>�</nowiki>MyFile.xmf<nowiki>�</nowiki>)<br />
<br />
'''XdmfElement'''<br />
<br />
Each element type in an XDMF XML file has a corresponding XDMF object implementation. All of these are children of XdmfElement. Each XdmfElement must be provided with an XdmfDOM with which to operate. On input, the UpdateInformation() method will initialize the basic structure of the element <br />
from the XML without reading any HeavyData. The Update() method will access the HeavyData. Each derived object from XdmfElement (XdmfGrid for example) will override these methods.<br />
<br />
GridNode = DOM.FindElementByPath(<nowiki>�</nowiki>/Xdmf/Domain/Grid<nowiki>[</nowiki>3<nowiki>]</nowiki><nowiki>�</nowiki>) <br />
Grid = XdmfGrid() <nowiki>#</nowiki> Create<br />
Grid.SetDOM(DOM) <br />
Grid.SetElement(GridNode)<br />
Grid.UpdateInformation() <nowiki>#</nowiki> Update Light Structure<br />
Grid.Update() <nowiki>#</nowiki> Read HeavyData<br />
<br />
Once the DOM has been set for an XdmfElement, there are convenience methods such as Set() and Get() which are equivalent to the XdmfDOM methods.<br />
GridName = Grid.Get(<nowiki>�</nowiki>Name<nowiki>�</nowiki>)<br />
Is the same as<br />
DOM = Grid.GetDOM()<br />
GridNode = Grid.GetElement()<br />
GridName = DOM.Get(GridNode, <nowiki>�</nowiki>Name<nowiki>�</nowiki>)<br />
<br />
For output, the XdmfElement methods Insert() and Build() are used. Each derived object in XDMF will assure that only the proper type of element is inserted. For example, it is illegal to insert a Domain element directly below a Grid element. <br />
Info = XdmfInformation() <nowiki>#</nowiki> Arbitrary Name=Value Facility<br />
Info.SetName("Time")<br />
Info.SetValue("0.0123")<br />
Grid = XdmfGrid()<br />
Grid.Set(<nowiki>�</nowiki>Name<nowiki>�</nowiki>, <nowiki>�</nowiki>My Grid<nowiki>�</nowiki>)<br />
Grid.Insert(Info)<br />
Grid.Build()<br />
<br />
Results in <br />
<br />
&lt;Grid Name="My Grid"&gt;<br />
&lt;Information Name="Time" Value="0.0123" /&gt;<br />
&lt;/Grid&gt;<br />
<br />
The Build() method is recursive so that Build() will automatically be called for all child elements.<br />
<br />
'''XdmfArray'''<br />
<br />
The XdmfArray class is a self describing data structure. It is derived from the XdmfDataDesc class that gives it number type, precision, and shape (rank and dimensions). Many XDMF classes require an XdmfArray as input to methods. The following C++ example demonstrates creating an interlaced XYZ array from three separate variables:<br />
float <nowiki>*</nowiki>x, <nowiki>*</nowiki>y, <nowiki>*</nowiki>z;<br />
XdmfInt64 total, dims<nowiki>[</nowiki>3<nowiki>]</nowiki>;<br />
XdmfArray <nowiki>*</nowiki>xyz = new XdmfArray;<br />
<br />
dims<nowiki>[</nowiki>0<nowiki>]</nowiki> = 10;<br />
dims<nowiki>[</nowiki>1<nowiki>]</nowiki> = 20;<br />
dims<nowiki>[</nowiki>2<nowiki>]</nowiki> = 30;<br />
total = 10 <nowiki>*</nowiki> 20 <nowiki>*</nowiki> 30;<br />
xyz-&gt;SetNumberType(XDMF_FLOAT64_TYPE)<br />
xyz-&gt;SetShape(3, dims); // KDim, JDim, IDim<br />
xyz-&gt;SetValues(0, x, total, 3, 1); // SetValues (XdmfInt64 Index, XdmfFloat64 <nowiki>*</nowiki>Values,<br />
// XdmfInt64 NumberOfValues, XdmfInt64 ArrayStride=1, // XdmfInt64 ValuesStride=1)<br />
xyz-&gt;SetValues(1, y, total, 3, 1);<br />
xyz-&gt;SetValues(2, z, total, 3, 1);<br />
<br />
When an XdmfArray is created, it is given a unique tag name. Array operations can be performed on XdmfArray data by using this name in an XdmfExpr(). The following Python program gives some examples.<br />
from Xdmf import <nowiki>*</nowiki><br />
<br />
def Expression(<nowiki>*</nowiki>args) :<br />
e = <nowiki>�</nowiki><nowiki>�</nowiki><br />
for arg in args :<br />
if hasattr(arg, <nowiki>�</nowiki>GetTagName<nowiki>�</nowiki>) :<br />
e += arg.GetTagName() + <nowiki>�</nowiki> <nowiki>�</nowiki><br />
else :<br />
e += arg + <nowiki>�</nowiki> <nowiki>�</nowiki><br />
return XdmfExpr(e)<br />
<br />
<br />
if __name__ == <nowiki>�</nowiki>__main__<nowiki>�</nowiki> :<br />
a1 = XdmfArray()<br />
a1.SetNumberType(XDMF_FLOAT32_TYPE)<br />
a1.SetNumberOfElements(20)<br />
a1.Generate(1, 20)<br />
a2 = XdmfArray()<br />
a2.SetNumberType(XDMF_INT32_TYPE)<br />
a2.SetNumberOfElements(5)<br />
a2.Generate(2, 10)<br />
print <nowiki>�</nowiki>a1 Values = <nowiki>�</nowiki>, a1.GetValues()<br />
print <nowiki>�</nowiki>a1<nowiki>[</nowiki>2:10<nowiki>]</nowiki> = <nowiki>�</nowiki> + Expression(a1 , <nowiki>�</nowiki><nowiki>[</nowiki> 2:10 <nowiki>]</nowiki><nowiki>�</nowiki>).GetValues()<br />
print <nowiki>�</nowiki>a2 Values = <nowiki>�</nowiki>, a2.GetValues()<br />
print <nowiki>�</nowiki>a1<nowiki>[</nowiki>a2<nowiki>]</nowiki> = <nowiki>�</nowiki> + Expression(a1 , <nowiki>�</nowiki><nowiki>[</nowiki><nowiki>�</nowiki>, a2, <nowiki>�</nowiki><nowiki>]</nowiki><nowiki>�</nowiki>).GetValues()<br />
print <nowiki>�</nowiki>a1 + a2 = <nowiki>�</nowiki> + Expression(a1 , <nowiki>�</nowiki> + <nowiki>�</nowiki>, a2).GetValues()<br />
print <nowiki>�</nowiki>a1 <nowiki>*</nowiki> a2 = <nowiki>�</nowiki> + Expression(a1 , <nowiki>�</nowiki> <nowiki>*</nowiki> <nowiki>�</nowiki>, a2).GetValues()<br />
a2.SetNumberType(XDMF_FLOAT32_TYPE)<br />
a2.SetNumberOfElements(20)<br />
a2.Generate(21, 40)<br />
print <nowiki>�</nowiki>a2 Values = <nowiki>�</nowiki>, a2.GetValues()<br />
print <nowiki>�</nowiki>a1 , a2 (Interlace) = <nowiki>�</nowiki> + Expression(a1 , <nowiki>�</nowiki> , <nowiki>�</nowiki>, a2).GetValues()<br />
print <nowiki>�</nowiki>a1 , a2, a1 (Interlace) = <nowiki>�</nowiki> + Expression(a1 , <nowiki>�</nowiki> , <nowiki>�</nowiki>, a2, <nowiki>�</nowiki> , <nowiki>�</nowiki>, a1).GetValues()<br />
print <nowiki>�</nowiki>a1 ; a2 (Concat) = <nowiki>�</nowiki> + Expression(a1 , <nowiki>�</nowiki> ; <nowiki>�</nowiki>, a2).GetValues()<br />
print <nowiki>�</nowiki>where(a1 &gt; 10) = <nowiki>�</nowiki> + Expression(<nowiki>�</nowiki>Where( <nowiki>�</nowiki>, a1 , <nowiki>�</nowiki> &gt; 10)<nowiki>�</nowiki>).GetValues()<br />
print <nowiki>�</nowiki>a2<nowiki>[</nowiki>where(a1 &gt; 10)<nowiki>]</nowiki> = <nowiki>�</nowiki> + Expression(a2, <nowiki>�</nowiki><nowiki>[</nowiki>Where( <nowiki>�</nowiki>, a1 , <nowiki>�</nowiki> &gt; 10)<nowiki>]</nowiki><nowiki>�</nowiki>).GetValues()<br />
<br />
While most of the functions are self explanatory the WHERE function is not. WHERE will return the indexes of the XdmfArray where a certain condition is true. In this example WHERE returns the indexes of XdmfArray a1 where a1 is greater than 10. Notice that the XdmfExpr() function makes it easy to extract part of an XdmfArray.<br />
<br />
'''XdmfHDF'''<br />
<br />
In XDMF Light data is stored in XML while the Heavy data is typically stored in an HDF5 file.<br />
The XdmfHDF class simplifies access to HDF5 data, it is also derived from XdmfDataDesc. The following Python code demonstrates its use :<br />
<br />
<br />
from Xdmf import <nowiki>*</nowiki><br />
<br />
Geometry = <nowiki>�</nowiki>-1.75 -1.25 0 -1.25 -1.25 0 -0.75 ��<br />
Connectivity = <nowiki>�</nowiki>3 2 5 1 �.<br />
Values = <nowiki>�</nowiki>100 200 300 �..<br />
<br />
<nowiki>#</nowiki> Geometry<br />
GeometryArray = XdmfArray()<br />
GeometryArray.SetValues(0, Geometry)<br />
H5 = XdmfHDF()<br />
H5.CopyType(GeometryArray)<br />
H5.CopyShape(GeometryArray)<br />
<nowiki>#</nowiki> Open for Writing. This will truncate the file.<br />
H5.Open(<nowiki>�</nowiki>Example1.h5:/Geometry<nowiki>�</nowiki>, <nowiki>�</nowiki>w<nowiki>�</nowiki>)<br />
H5.Write(GeometryArray)<br />
H5.Close()<br />
<br />
<nowiki>#</nowiki> Connectivity<br />
ConnectivityArray = XdmfArray()<br />
ConnectivityArray.SetValues(0, Connectivity)<br />
H5 = XdmfHDF()<br />
H5.CopyType(ConnectivityArray)<br />
H5.CopyShape(ConnectivityArray)<br />
<nowiki>#</nowiki> Open for Reading and Writing. This will NOT truncate the file.<br />
H5.Open(<nowiki>�</nowiki>Example1.h5:/Connectivity<nowiki>�</nowiki>, <nowiki>�</nowiki>rw<nowiki>�</nowiki>)<br />
H5.Write(ConnectivityArray)<br />
H5.Close()<br />
<br />
<br />
<nowiki>#</nowiki> Values<br />
ValueArray = XdmfArray()<br />
ValueArray.SetValues(0, Values)<br />
H5 = XdmfHDF()<br />
H5.CopyType(ValueArray)<br />
H5.CopyShape(ValueArray)<br />
<nowiki>#</nowiki> Open for Reading and Writing. This will NOT truncate the file.<br />
H5.Open(<nowiki>�</nowiki>Example1.h5:/Values<nowiki>�</nowiki>, <nowiki>�</nowiki>rw<nowiki>�</nowiki>)<br />
H5.Write(ValueArray)<br />
H5.Close()<br />
<br />
For reading, XdmfHDF will allocate an array if none is specified :<br />
Status = H5.Open(<nowiki>�</nowiki>Example1.h5:/Values<nowiki>�</nowiki>, <nowiki>�</nowiki>rw<nowiki>�</nowiki>)<br />
ValueArray = H5.Read()<br />
<br />
'''Reading XDMF'''<br />
<br />
Putting all of this together, assume Points.xmf is a valid XDMF XML file with a single uniform Grid. Here is a Python example to read and print values.<br />
<br />
dom = XdmfDOM()<br />
dom.Parse(<nowiki>�</nowiki>Points.xmf<nowiki>�</nowiki>)<br />
<br />
ge = dom.FindElementByPath(<nowiki>�</nowiki>/Xdmf/Domain/Grid<nowiki>�</nowiki>)<br />
grid = XdmfGrid()<br />
grid.SetDOM(dom)<br />
grid.SetElement(ge)<br />
grid.UpdateInformation()<br />
grid.Update()<br />
<br />
top = grid.GetTopology()<br />
top.DebugOn()<br />
conn = top.GetConnectivity()<br />
print <nowiki>�</nowiki>Values = <nowiki>�</nowiki>, conn.GetValues()<br />
<br />
geo = grid.GetGeometry()<br />
points = geo.GetPoints()<br />
print <nowiki>�</nowiki>Geo Type = <nowiki>�</nowiki>, geo.GetGeometryTypeAsString(), <nowiki>�</nowiki> <nowiki>#</nowiki> Points = <nowiki>�</nowiki>, geo.GetNumberOfPoints()<br />
print <nowiki>�</nowiki>Points = <nowiki>�</nowiki>, points.GetValues(0, 6)<br />
<br />
'''Writing XDMF'''<br />
<br />
Using the Insert() and Build() methods, an XDMF dataset can be generated programmatically as well . Internally, as XDMF objects are inserted, the DOM is "decorated" with their pointers. In this manner, the api can get a object from an node of the DOM if it has been created. For reading XDMF, this allows multiple references to the same DataItem not to result in additional IO. For writing, this allows Build() to work recursively.<br />
<br />
d = XdmfDOM()<br />
<br />
root = XdmfRoot()<br />
root.SetDOM(d)<br />
root.SetVersion(2.2) <nowiki>#</nowiki> Change the Version number because we can<br />
root.Build()<br />
<nowiki>#</nowiki> Information<br />
i = XdmfInformation() <nowiki>#</nowiki> Arbitrary Name=Value Facility<br />
i.SetName("Time")<br />
i.SetValue("0.0123")<br />
root.Insert(i) <nowiki>#</nowiki> XML DOM is used as the keeper of the structure<br />
<nowiki>#</nowiki> Insert() creates an XML node and inserts it under<br />
<nowiki>#</nowiki> the parent<br />
<nowiki>#</nowiki> Domain<br />
dm = XdmfDomain()<br />
root.Insert(dm)<br />
<nowiki>#</nowiki> Grid<br />
g = XdmfGrid()<br />
g.SetName("Structured Grid")<br />
<nowiki>#</nowiki> Topology<br />
t = g.GetTopology()<br />
t.SetTopologyType(XDMF_3DCORECTMESH)<br />
t.GetShapeDesc().SetShapeFromString(<nowiki>�</nowiki>10 20 30<nowiki>�</nowiki>)<br />
<nowiki>#</nowiki> Geometry<br />
geo = g.GetGeometry()<br />
geo.SetGeometryType(XDMF_GEOMETRY_ORIGIN_DXDYDZ)<br />
geo.SetOrigin(1, 2, 3)<br />
geo.SetDxDyDz(0.1, 0.2, 0.3)<br />
dm.Insert(g)<br />
<nowiki>#</nowiki> Attribute<br />
attr = XdmfAttribute()<br />
attr.SetName("Pressure")<br />
attr.SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_CELL);<br />
attr.SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR);<br />
p = attr.GetValues()<br />
p.SetNumberOfElements(10 <nowiki>*</nowiki> 20 <nowiki>*</nowiki> 30)<br />
p.Generate(0.0, 1.0, 0, p.GetNumberOfElements() - 1)<br />
g.Insert(attr)<br />
<nowiki>#</nowiki> Update XML and Write Values to DataItems<br />
root.Build() <nowiki>#</nowiki> DataItems &gt; 100 values are heavy<br />
print d.Serialize() <nowiki>#</nowiki> prints to stdout<br />
<br />
d.Write(<nowiki>�</nowiki>MyMesh.xmf<nowiki>�</nowiki>) <nowiki>#</nowiki> write to file</div>128.63.127.201https://www.xdmf.org/index.php?title=Main_Page&diff=12Main Page2007-05-03T16:11:38Z<p>128.63.127.201: </p>
<hr />
<div><big>e'''X'''tensible '''D'''ata '''M'''odel and '''F'''ormat</big><br />
<br />
<br />
<br />
The need for a standardized method to exchange scientific data between High Performance Computing codes and tools lead to the development of the eXtensible Data Model and Format (XDMF) . Uses for XDMF range from a standard format used by HPC codes to take advantage of widely used visualization programs like ParaView and EnSight, to a mechanism for performing coupled calculations using multiple, previously stand alone codes. <br />
<br />
XDMF categorizes data by two main attributes; size and function. Data can be Light (typically less than about a thousand values) of Heavy (megabytes, terabytes, etc.). In addition to raw values, data can refer to Format (rank and dimensions of an array) or Model (how that data is to be used. i.e. XYZ coordinates vs. Vector components).<br />
<br />
XDMF uses XML to store Light data and to describe the data Model. HDF5 is used to store Heavy data. The data Format is stored redundantly in both XML and HDF5. This allows tools to parse XML to determine the resources that will be required to access the Heavy data. <br />
<br />
While not required, a C++ API is provided to read and write XDMF data. This API has also been wrapped so it is available from popular languages like Python, Tcl, and Java. The API is not necessary in order to produce or consume XDMF data. Currently several HPC codes that already produced HDF5 data, use native text output to produce the XML necessary for valid XDMF. <br />
<br />
[[XDMF Model and Format]]<br />
<br />
[[XDMF API]]<br />
<br />
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list]<br />
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]<br />
* [http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]</div>128.63.127.201https://www.xdmf.org/index.php?title=Main_Page&diff=11Main Page2007-05-03T16:11:24Z<p>128.63.127.201: </p>
<hr />
<div><big>e'''X'''tensible '''D'''ata '''M'''odel and '''F'''ormat</big><br />
<br />
<br />
<br />
The need for a standardized method to exchange scientific data between High Performance Computing codes and tools lead to the development of the eXtensible Data Model and Format (XDMF) . Uses for XDMF range from a standard format used by HPC codes to take advantage of widely used visualization programs like ParaView and EnSight, to a mechanism for performing coupled calculations using multiple, previously stand alone codes. <br />
<br />
XDMF categorizes data by two main attributes; size and function. Data can be Light (typically less than about a thousand values) of Heavy (megabytes, terabytes, etc.). In addition to raw values, data can refer to Format (rank and dimensions of an array) or Model (how that data is to be used. i.e. XYZ coordinates vs. Vector components).<br />
<br />
XDMF uses XML to store Light data and to describe the data Model. HDF5 is used to store Heavy data. The data Format is stored redundantly in both XML and HDF5. This allows tools to parse XML to determine the resources that will be required to access the Heavy data. <br />
<br />
While not required, a C++ API is provided to read and write XDMF data. This API has also been wrapped so it is available from popular languages like Python, Tcl, and Java. The API is not necessary in order to produce or consume XDMF data. Currently several HPC codes that already produced HDF5 data, use native text output to produce the XML necessary for valid XDMF. <br />
<br />
[[XDMF Model and Format]]<br />
[[XDMF API]]<br />
<br />
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list]<br />
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]<br />
* [http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]</div>128.63.127.201https://www.xdmf.org/index.php?title=XDMF_Model_and_Format&diff=8XDMF Model and Format2007-05-03T15:09:26Z<p>128.63.127.201: </p>
<hr />
<div> <br />
<br />
The need for a standardized method to exchange scientific data between High Performance Computing codes and tools lead to the development of ''the eXtensible Data Model and Format'' (''XDMF'') . Uses for XDMF range from a standard format used by HPC codes to take advantage of widely used visualization programs like ParaView and EnSight, to a mechanism for performing coupled calculations using multiple, previously stand alone codes. <br />
<br />
XDMF categorizes data by two main attributes; size and function. Data can be ''Light'' (typically less than about a thousand values) of ''Heavy'' (megabytes, terabytes, etc.). In addition to raw values, data can refer to ''Format'' (rank and dimensions of an array) or ''Model'' (how that data is to be used. i.e. XYZ coordinates vs. Vector components).<br />
<br />
XDMF uses XML to store Light data and to describe the data Model. HDF5 is used to store Heavy data. The data Format is stored redundantly in both XML and HDF5. This allows tools to parse XML to determine the resources that will be required to access the Heavy data. <br />
<br />
While not required, a C++ API is provided to read and write '''XDMF''' data. This API has also been wrapped so it is available from popular languages like Python, Tcl, and Java. The API is not necessary in order to produce or consume XDMF data. Currently several HPC codes that already produced HDF5 data, use native text output to produce the XML necessary for valid XDMF. <br />
<br />
'''XML'''<br />
The eXtensible Markup Language (XML) format is widely used for many purposes and is well documented at many sites. There are numerous open source parsers available for XML. The XDMF API takes advantage of the libxml2 parser to provide the necessary functionality. Without going into too much detail, XDMF views XML as a "personalized HTML" with some special rules. It it case sensative and is made of three major components : elements, entities, and processing information. In XDMF we<nowiki>�</nowiki>re primarily concerned with the elements. These elements follow the basic form :<br />
&lt;ElementTag<br />
AttributeName="AttribteValue"<br />
AttributeName="AttributeValue"<br />
�.. &gt;<br />
''CData''<br />
&lt;/ElementTag&gt;<br />
Each element begins with an &lt;tag&gt; and ends with a &lt;/tag&gt;. Optionally there can be several "Name=Value" pairs which convey additional information. Between the &lt;tag&gt; and the &lt;/tag&gt; there can be other &lt;tag&gt;&lt;/tag&gt; pairs and/or character data (CData). CData is typically where the values are stored; like the actual text in an HTML document. The XML parser in the XDMF API parses the XML file and builds an tree structure in memory to describe its contents. This tree can be queried, modified, and then "serialized" back into XML.<br />
<br />
Comment in XML start with a "&lt;!--" and end with a "--&gt;". So &lt;!--This is a Comment --&gt;.<br />
<br />
XML is said to be "well formed" if it is syntactically correct. This is all of the quotes match, all elements have end elements, etc. XML is said to be "valid" if it conforms to the ''Schema'' or ''DTD'' defined at the head of the document. For example, the schema might specify that element type A can contain element B but not element C. Verifying that the provided XML is well formed and/or valid are functions typically performed by the XML parser. Additionally XDMF takes advantage of two major extensions to XML :<br />
<br />
'''XInclude'''<br />
As opposed to entity references in XML(which is a basic substitution mechanism), XInclude allows for the inclusion of files that are not well formed XML. This means that with XInclude the included file could be well formed XML or perhaps a flat text file of values. The syntax looks like this :<br />
<br />
'''&lt;Xdmf Version="2.0" xmlns:xi="[http://www.w3.org/2001/XInclude-http://www.w3.org/2001/XInclude]"&gt;'''<br />
'''&lt;xi:include href="Example3.xmf"/&gt;'''<br />
'''&lt;/Xdmf&gt;'''<br />
<br />
the xmlns:xi establishes a namespace xi. Then anywhere within the Xdmf element, xi:include will pull in the URL.<br />
<br />
'''XPath'''<br />
This allows for elements in the XML document and the API to reference specific elements in a document. For example :<br />
<br />
The first Grid in the first Domain<br />
'''/Xdmf/Domain/Grid'''<br />
The tenth Grid .... XPath is one based.<br />
'''/Xdmf/Domain/Grid<nowiki>[</nowiki>10<nowiki>]</nowiki>'''<br />
The first grid with an attribute ''Name'' which has a value of ''"Copper Plate"''<br />
'''/Xdmf/Domain/Grid<nowiki>[</nowiki>@Name="Copper Plate"<nowiki>]</nowiki>'''<br />
<br />
All valid XDMF must appear between the &lt;Xdmf&gt; and the &lt;/Xdmf&gt;. So a minimal (empty) XDMF XML file would be :<br />
<br />
'''&lt;?xml version="1.0" ?&gt;'''<br />
'''&lt;!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" <nowiki>[</nowiki><nowiki>]</nowiki>&gt;'''<br />
'''&lt;Xdmf Version="2.0"&gt;'''<br />
'''&lt;/Xdmf&gt;'''<br />
<br />
While there exists an Xdmf DTD and a Schema they are only necessary for validating parsers. For performance reasons, validation is typically disabled.<br />
<br />
'''XDMF Elements'''<br />
<br />
The organization of XDMF begins with the ''Xdmf'' element. So that parsers can distinguish from previous versions of XDMF, there exists a ''Version'' attribute (currently at 2.0). Any element in XDMF can have a ''Name'' attribute or have a ''Reference'' attribute. The Name attribute becomes important for grids while the Reference attribute is used to take advantage of the XPath facility (more detail on this later). Xdmf elements contain one or more ''Domain'' elements (computational domain). There is seldom motivation to have more than one Domain. <br />
<br />
A Domain can have one or more ''Grid'' elements. Each Grid contains a ''Topology'', ''Geometry'', and zero or more ''Attribute'' elements. Topology specifies the connectivity of the grid while Geometry specifies the location of the grid nodes. Attribute elements are used to specify values such as scalars and vectors that are located at the node, edge, face, cell center, or grid center. <br />
<br />
To specify actual values for connectivity, geometry, or attributes, XDMF defines a ''DataItem'' element. A DataItem can provide the actual values or provide the physical storage (which is typically an HDF5 file).<br />
<br />
'''XdmfItem'''<br />
<br />
There are six different types of DataItems :<br />
# '''Uniform''' � this is the default. A single array of values.<br />
# '''Collection''' � a one dimension array of DataItems<br />
# '''Tree''' � a hierarchical structure of DataItems<br />
# '''HyperSlab''' � contains two data items. The first selects the start, stride and count indexes of the second DataItem.<br />
# '''Coordinates''' � contains two DataItems. The first selects the parametric coordinates of the second DataItem.<br />
# '''Function''' � calculates an expression.<br />
<br />
'''Uniform '''<br />
The simplest type is Uniform that specifies a single array. As with all XDMF elements, there are reasonable defaults wherever possible. So the simplest DataItem would be :<br />
'''&lt;DataItem Dimensions="3"&gt;'''<br />
'''1.0 2.0 3.0'''<br />
'''&lt;/DataItem&gt;'''<br />
Since no ''ItemType'' has been specified, Uniform has been assumed. The default ''Format'' is XML and the default ''NumberType'' is a 32 bit floating point value. So the fully qualified DataItem for the same data would be :<br />
'''&lt;DataItem ItemType="Uniform"'''<br />
'''Format="XML"'''<br />
'''NumberType="Float" Precision="4"'''<br />
'''Rank="1" Dimensions="3"&gt;'''<br />
'''1.0 2.0 3.0'''<br />
'''&lt;/DataItem&gt;'''<br />
Since it is only practical to store a small amount of data values in the XML, production codes typically write their data to HDF5 and specify the location in XML. HDF5 is a hierarchical, self describing data format. So an application can open an HDF5 file without any prior knowledge of the data and determine the dimensions and number type of all the arrays stored in the file. XDMF requires that this information also be stored redundantly in the XML so that applications need not have access to the actual heavy data in order to determine storage requirements.<br />
<br />
For example, suppose an application stored a three dimensional array of pressure values at each iteration into an HDF5 file. The XML might be :<br />
'''&lt;DataItem ItemType="Uniform"'''<br />
'''Format="HDF"'''<br />
'''NumberType="Float" Precision="8"'''<br />
'''Dimensions="64 128 256"&gt;'''<br />
'''OutputData.h5:/Results/Iteration 100/Part 2/Pressure'''<br />
'''&lt;/DataItem&gt;'''<br />
Dimensions are specified with the slowest varying dimension first (i.e. KJI order). The HDF filename can be fully qualified, if it is not it is assumed to be located in the current directory or the same directory as the XML file. <br />
<br />
'''Collection and Tree'''<br />
Collections are Trees with only a single level. This is such a frequent occurrence that it was decided to make a Collection a separate type in case the application can optimize access. Collections and Trees have DataItem elements as children. The leaf nodes are Uniform DataItem elements :<br />
'''&lt;DataItem Name="Tree Example" ItemType="Tree"&gt;'''<br />
'''&lt;DataItem ItemType="Tree"&gt;'''<br />
'''&lt;DataItem Name="Collection 1" ItemType="Collection"&gt;'''<br />
'''&lt;DataItem Dimensions="3"&gt;'''<br />
'''1.0 2.0 3.0'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;DataItem Dimensions="4"&gt;'''<br />
'''4 5 6 7'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;DataItem Name="Collection 2" ItemType="Collection"&gt;'''<br />
'''&lt;DataItem Dimensions="3"&gt;'''<br />
'''7 8 9'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;DataItem Dimensions="4"&gt;'''<br />
'''10 11 12 13'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;DataItem ItemType="Uniform"'''<br />
'''Format="HDF"'''<br />
'''NumberType="Float" Precision="8"'''<br />
'''Dimensions="64 128 256"&gt;'''<br />
'''OutputData.h5:/Results/Iteration 100/Part 2/Pressure'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/DataItem&gt;'''<br />
This DataItem is a tree with three children. The first child is another tree that contains a collection of two uniform DataItem elements. The second child is a collection with two uniform DataItem elements. The third child is a uniform DataItem. <br />
<br />
'''HyperSlab and Coordinate'''<br />
<br />
A ''HyperSlab'' specifies a subset of some other DataItem. The slab is specified by giving the start, stide, and count of the vales in each of the target DataItem dimensions. For example, given a dataset MyData.h5:/XYZ that is 100x200x300x3, we could describe a region starting at <nowiki>[</nowiki>0,0,0,0<nowiki>]</nowiki>, ending at <nowiki>[</nowiki>50, 100, 150, 2<nowiki>]</nowiki> that includes every other plane of data with the HyperSlab DataItem <br />
'''&lt;DataItem ItemType="HyperSlab"'''<br />
'''Dimensions="25 50 75 3"'''<br />
'''Type="HyperSlab"&gt;'''<br />
'''&lt;DataItem'''<br />
'''Dimensions="3 4"'''<br />
'''Format="XML"&gt;'''<br />
'''0 0 0 0 '''<br />
'''2 2 2 1 '''<br />
'''25 50 75 3'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;DataItem'''<br />
'''Name="Points"'''<br />
'''Dimensions="100 200 300 3"'''<br />
'''Format="HDF"&gt;'''<br />
'''MyData.h5:/XYZ'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/DataItem&gt;'''<br />
Notice that the first DataItem specified Start, Stride and Count for each dimension of the second DataItem. Suppose, instead that we only wish to specify the first Y data value from the DataItem and the last X value. This can be accomplished by providing the parametric coordinated of the desired values and using the ''Coordinates'' ItemType.<br />
'''&lt;DataItem ItemType="HyperSlab"'''<br />
'''Dimensions="2"'''<br />
'''Type="HyperSlab"&gt;'''<br />
'''&lt;DataItem'''<br />
'''Dimensions="2 4"'''<br />
'''Format="XML"&gt;'''<br />
'''0 0 0 1'''<br />
'''99 199 299 0'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;DataItem'''<br />
'''Name="Points"'''<br />
'''Dimensions="100 200 300 3"'''<br />
'''Format="HDF"&gt;'''<br />
'''MyData.h5:/XYZ'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/DataItem&gt;'''<br />
<br />
The first Y value is index 1 of item 0,0,0 while the last X value is index 0 of item 99, 199, 299. The dimensionality of the specified coordinates must match that of the target DataItem. <br />
<br />
'''Function'''<br />
<br />
''Function'' ItemType specifies some operation on the children DataItem elements. The elements are referenced by $X where X is the zero based index of the child. For example, the following DataItem would add the two children DataItem elements together in a value by value operation resulting in the values 5.1, 7.2 and 9.3 :<br />
'''&lt;DataItem ItemType="Function" '''<br />
'''Function="$0 + $1"'''<br />
'''Dimensions="3"&gt;'''<br />
'''&lt;DataItem Dimensions="3"&gt;'''<br />
'''1.0 2.0 3.0'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;DataItem Dimensions="3"&gt;'''<br />
'''4.1 5.2 6.3'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/DataItem&gt;'''<br />
<br />
The function description can be arbitrarily complex and contain SIN, COS, TAN, ACOS, ASIN, ATAN, LOG, EXP, ABS, and SQRT. In addition, there are the JOIN() and WHERE() expressions. JOIN can concat or interlace arrays while WHERE() can extract values where some condition is true. In the following examples we take advantage of the XPath facility to reference DataItem elements that have been previously specified :<br />
<br />
Add the value 10 to every element<br />
'''&lt;DataItem Name="MyFunction" ItemType="Function"'''<br />
''' Function="10 + $0"&gt;'''<br />
''' &lt;DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>1<nowiki>]</nowiki>" /&gt;'''<br />
''' &lt;/DataItem&gt;'''<br />
<br />
Multiply two arrays (element by element) and take the absolute value<br />
''' &lt;DataItem ItemType="Function"'''<br />
''' Function="ABS($0 <nowiki>*</nowiki> $1)"&gt;'''<br />
''' &lt;DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>1<nowiki>]</nowiki>" /&gt;'''<br />
''' &lt;DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>2<nowiki>]</nowiki>" /&gt;'''<br />
''' &lt;/DataItem&gt;'''<br />
<br />
Select element 5 thru 15 from the first DataItem<br />
''' &lt;DataItem ItemType="Function"'''<br />
''' Function="$0<nowiki>[</nowiki>5:15<nowiki>]</nowiki>"&gt;'''<br />
''' &lt;DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>1<nowiki>]</nowiki>" /&gt;'''<br />
''' &lt;/DataItem&gt;'''<br />
<br />
Concat two arrays<br />
''' &lt;DataItem ItemType="Function"'''<br />
''' Function="JOIN($0 ; $1)"&gt;'''<br />
''' &lt;DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>1<nowiki>]</nowiki>" /&gt;'''<br />
''' &lt;DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>2<nowiki>]</nowiki>" /&gt;'''<br />
''' &lt;/DataItem&gt;'''<br />
<br />
Interlace 3 arrays (Useful for describing vectors from scalar data)<br />
''' &lt;DataItem ItemType="Function"'''<br />
''' Function="JOIN($0 , $1, $2)"&gt;'''<br />
''' &lt;DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>1<nowiki>]</nowiki>" /&gt;'''<br />
''' &lt;DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>2<nowiki>]</nowiki>" /&gt; '''<br />
''' &lt;DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>3<nowiki>]</nowiki>" /&gt;'''<br />
''' &lt;/DataItem&gt;'''<br />
<br />
'''Grid'''<br />
<br />
The DataItem element is used to define the data format portion of XDMF. It is sufficient to specify fairly complex data structures in a portable manner. The data model portion of XDMF begins with the ''Grid'' element. A Grid is a container for information related to 2D and 3D points, structured or unstructured connectivity, and assigned values.<br />
<br />
The Grid element now has a GridType attribute. Valid GridTypes are :<br />
# '''Uniform''' � a homogeneous single grid (i.e. a pile of triangles)<br />
# '''Collection''' � an array of Uniform grids<br />
# '''Tree''' � a hierarchical group<br />
# '''SubSet '''� a portion of another Grid<br />
<br />
Uniform Grid elements are the simplest type and must contain a ''Topology'' and ''Geometry'' element. Just like the DataItem element, Tree and Collection Grid elements contain other Grid elements as children :<br />
'''&lt;Grid Name="Car Wheel" GridType="Tree"&gt;'''<br />
'''&lt;Grid Name="Tire" GridType="Uniform"&gt;'''<br />
'''&lt;Topology �.'''<br />
'''&lt;Geometry �'''<br />
'''&lt;/Grid&gt;'''<br />
'''&lt;Grid Name="Lug Nuts" GridType="Collection"&gt;'''<br />
'''&lt;Grid Name="Lug Nut 0" GridType="Uniform"'''<br />
'''&lt;Topology �.'''<br />
'''&lt;Geometry �'''<br />
'''&lt;/Grid&gt;'''<br />
'''&lt;Grid Name="Lug Nut 1" GridType="Uniform"'''<br />
'''&lt;Topology �.'''<br />
'''&lt;Geometry �'''<br />
'''&lt;/Grid&gt;'''<br />
'''&lt;Grid Name="Lug Nut 2" GridType="Uniform"'''<br />
'''&lt;Topology �.'''<br />
'''&lt;Geometry �'''<br />
'''&lt;/Grid&gt;'''<br />
'''&lt;/Grid&gt;'''<br />
'''.'''<br />
'''.'''<br />
'''.'''<br />
<br />
A SubSet GridType is used to define a portion of another grid or define new attribute on grid. This only selects the geometry and topology of another grid, the attributes from the original grid are not assigned. The Section attribute of a SubSet can be ''DataItem'' or ''All'' :<br />
<br />
''' &lt;Grid Name="Portion" GridType="Subset" Section="DataItem"&gt;'''<br />
''&lt;!-- Select 2 cells from another grid. Which 2 are defined by the DataItem --&gt;Ther''<br />
''' &lt;DataItem'''<br />
''' DataType="Int"'''<br />
''' Dimensions="2"'''<br />
''' Format="XML"&gt;'''<br />
''' 0 2'''<br />
''' &lt;/DataItem&gt;'''<br />
''' &lt;Grid Name="Target" Reference="XML"&gt;'''<br />
''' /Xdmf/Domain/Grid<nowiki>[</nowiki>@Name="Main Grid"<nowiki>]</nowiki>'''<br />
''' &lt;/Grid&gt;'''<br />
''' &lt;Attribute Name="New Values" Center="Cell"&gt;'''<br />
''' &lt;DataItem Format="XML" Dimensions="2"&gt;'''<br />
''' 100 150'''<br />
''' &lt;/DataItem&gt;'''<br />
''' &lt;/Attribute&gt;'''<br />
''' &lt;/Grid&gt;'''<br />
'''Or '''<br />
''' &lt;Grid Name="Portion" GridType="Subset" Section="All"&gt;'''<br />
''&lt;!-- Select the entire grid and add an attribute --&gt;''<br />
''' &lt;Grid Name="Target" Reference="XML"&gt;'''<br />
''' /Xdmf/Domain/Grid<nowiki>[</nowiki>@Name="Main Grid"<nowiki>]</nowiki>'''<br />
''' &lt;/Grid&gt;'''<br />
''' &lt;Attribute Name="New Values" Center="Cell"&gt;'''<br />
''' &lt;DataItem Format="XML" Dimensions="3"&gt;'''<br />
''' 100 150 200'''<br />
''' &lt;/DataItem&gt;'''<br />
''' &lt;/Attribute&gt;'''<br />
''' &lt;/Grid&gt;'''<br />
<br />
'''Topology'''<br />
<br />
The Topology element describes the general organization of the data. This is the part of the computational grid that is invariant with rotation, translation, and scale. For structured grids, the connectivity is implicit. For unstructured grids, if the connectivity differs from the standard, an Order may be specified. Currently, the following Topology cell types are defined :<br />
'''Linear'''<br />
* Polyvertex � a group of unconnected points<br />
* Polyline � a group of line segments<br />
* Polygon<br />
* Triangle<br />
* Quadrilateral<br />
* Tetrahedron<br />
* Pyramid<br />
* Wedge<br />
* Hexahedron<br />
'''Quadratic'''<br />
* Edge_3 � Quadratic line with 3 nodes<br />
* Tri_6<br />
* Quad_8<br />
* Tet_10<br />
* Pyramid_13<br />
* Wedge_15<br />
* Hex_20<br />
'''Arbitrary'''<br />
* Mixed � a mixture of unstructured cells<br />
'''Structured'''<br />
* 2DSMesh - Curvilinear<br />
* 2DRectMesh � Axis are perpendicular<br />
* 2DCoRectMesh � Axis are perpendicular and spacing is constant<br />
* 3DSMesh<br />
* 3DRectMesh<br />
* 3DCoRectMesh<br />
<br />
There is a ''NodesPerElement'' attribute for the cell types where it is not implicit. For example, to define a group of Octagons, set Type="Polygon" and NodesPerElement="8". For structured grid topologies, the connectivity is implicit. For unstructured topologies the Topology element must contain a DataItem that defines the connectivity :<br />
'''&lt;Topology Type="Quadrilateral" NumberOfElements="2" &gt;'''<br />
'''&lt;DataItem Format="XML" DataType="Int" Dimensions="2 4"&gt;'''<br />
'''0 1 2 3'''<br />
'''1 6 7 2'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/Topology&gt;'''<br />
The connectivity defines the indexes into the XYZ geometry that define the cell. In this example, the two quads share an edge defined by the line from node 1 to node 2. A Topology element can define ''Dimensions'' or ''NumberOfElements''; this is just added for clarity.<br />
<br />
Mixed topologies must define the cell type of every element. If that cell type does have an implicit number of nodes, that must also be specified. In this example, we define a topology of three cells consisting of a Tet (cell type 6) a Polygon (cell type 3) and a Hex (cell type 9) :<br />
'''&lt;Topology Type="Mixed" NumberOfElements="3" &gt;'''<br />
'''&lt;DataItem Format="XML" DataType="Int" Dimensions="20"&gt;'''<br />
'''6 0 1 2 7'''<br />
'''3 4 4 5 6 7'''<br />
'''9 8 9 10 11 12 13 14 15'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/Topology&gt;'''<br />
Notice that the Polygon must define the number of nodes (4) before its connectivity. The cell type numbers are defined in the API documentation.<br />
<br />
'''Geometry'''<br />
<br />
The Geometry element describes the XYZ values of the mesh. The important attribute here is the organization of the points. The default is XYZ; an X,Y, and Z for each point starting at parametric index 0. Possible organizations are :<br />
* '''XYZ''' - Interlaced locations<br />
* '''XY''' - Z is set to 0.0<br />
* '''X_Y_Z''' - X,Y, and Z are separate arrays<br />
* '''VXVYVZ''' - Three arrays, one for each axis<br />
* '''ORIGIN_DXDYDZ''' - Six Values : Ox,Oy,Oz + Dx,Dy,Dz<br />
<br />
The following Geometry element defines 8 points :<br />
'''&lt;Geometry Type="XYZ"&gt;'''<br />
'''&lt;DataItem Format="XML" Dimensions="2 4 3"&gt;'''<br />
'''0.0 0.0 0.0'''<br />
'''1.0 0.0 0.0'''<br />
'''1.0 1.0 0.0'''<br />
'''0.0 1.0 0.0'''<br />
<br />
'''0.0 0.0 2.0'''<br />
'''1.0 0.0 2.0'''<br />
'''1.0 1.0 2.0'''<br />
'''0.0 1.0 2.0'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/Geometry&gt;'''<br />
Together with the Grid and Topology element we now have enough to a full XDMF XML file that defines two quadrilaterals that share an edge (notice not all points are used):<br />
'''&lt;?xml version="1.0" ?&gt;'''<br />
'''&lt;!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" <nowiki>[</nowiki><nowiki>]</nowiki>&gt;'''<br />
<br />
'''&lt;Xdmf Version="2.0" xmlns:xi="[http://www.w3.org/2001/XInclude-http://www.w3.org/2001/XInclude]"&gt;'''<br />
'''&lt;Domain&gt;'''<br />
'''&lt;Grid Name="Two Quads&gt;'''<br />
'''&lt;Topology Type="Quadrilateral" NumberOfElements="2" &gt;'''<br />
'''&lt;DataItem Format="XML" '''<br />
'''DataType="Int"'''<br />
'''Dimensions="2 4"&gt;'''<br />
'''0 1 2 3'''<br />
'''1 6 7 2'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/Topology&gt;'''<br />
'''&lt;Geometry Type="XYZ"&gt;'''<br />
'''&lt;DataItem Format="XML" Dimensions="2 4 3"&gt;'''<br />
'''0.0 0.0 0.0'''<br />
'''1.0 0.0 0.0'''<br />
'''1.0 1.0 0.0'''<br />
'''0.0 1.0 0.0'''<br />
<br />
'''0.0 0.0 2.0'''<br />
'''1.0 0.0 2.0'''<br />
'''1.0 1.0 2.0'''<br />
'''0.0 1.0 2.0'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/Geometry&gt;'''<br />
'''&lt;/Grid&gt;'''<br />
'''&lt;/Domain&gt;'''<br />
'''&lt;/Xdmf&gt;'''<br />
It is valid to have DataItem elements to be direct children of the Xdmf or Domain elements. This could be useful if several Grid share the same Geometry but have separate Topology :<br />
'''&lt;?xml version="1.0" ?&gt;'''<br />
'''&lt;!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" <nowiki>[</nowiki><nowiki>]</nowiki>&gt;'''<br />
<br />
'''&lt;Xdmf Version="2.0" xmlns:xi="[http://www.w3.org/2001/XInclude-http://www.w3.org/2001/XInclude]"&gt;'''<br />
'''&lt;Domain&gt;'''<br />
'''&lt;DataItem Name="Point Data" Format="XML" Dimensions="2 4 3"&gt;'''<br />
'''0.0 0.0 0.0'''<br />
'''1.0 0.0 0.0'''<br />
'''1.0 1.0 0.0'''<br />
'''0.0 1.0 0.0'''<br />
<br />
'''0.0 0.0 2.0'''<br />
'''1.0 0.0 2.0'''<br />
'''1.0 1.0 2.0'''<br />
'''0.0 1.0 2.0'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;Grid Name="Two Quads&gt;'''<br />
'''&lt;Topology Type="Quadrilateral" NumberOfElements="2" &gt;'''<br />
'''&lt;DataItem Format="XML" '''<br />
'''DataType="Int"'''<br />
'''Dimensions="2 4"&gt;'''<br />
'''0 1 2 3'''<br />
'''1 6 7 2'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/Topology&gt;'''<br />
'''&lt;Geometry Type="XYZ"&gt;'''<br />
'''&lt;DataItem Reference="XML"&gt;'''<br />
'''/Xdmf/Domain/DataItem<nowiki>[</nowiki>@Name="Point Data"<nowiki>]</nowiki>'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/Geometry&gt;'''<br />
'''&lt;/Grid&gt;'''<br />
'''&lt;/Domain&gt;'''<br />
'''&lt;/Xdmf&gt;'''<br />
<br />
'''Attribute'''<br />
<br />
The Attribute element defines values associated with the mesh. Currently the supported types of values are :<br />
* '''Scalar'''<br />
* '''Vector'''<br />
* '''Tensor''' � 9 values expected<br />
* '''Tensor6''' � a symmetrical tensor<br />
* '''Matrix ''' - an arbitrary NxM matrix<br />
These values can be centered on :<br />
* '''Node'''<br />
* '''Edge'''<br />
* '''Face'''<br />
* '''Cell'''<br />
* '''Grid'''<br />
A Grid centered Attribute might be something like "Material Type" where the value is constant everywhere in the grid. Edge and Face centered values are defined, but don<nowiki>�</nowiki>t map well to many visualization systems. Typically Attributes are assigned on the Node :<br />
'''&lt;Attribute Name="Node Values" Center="Node"&gt;'''<br />
'''&lt;DataItem Format="XML" Dimensions="6 4"&gt;'''<br />
'''100 200 300 400'''<br />
'''500 600 600 700'''<br />
'''800 900 1000 1100'''<br />
'''1200 1300 1400 1500'''<br />
'''1600 1700 1800 1900'''<br />
'''2000 2100 2200 2300'''<br />
'''&lt;/DataItem&gt;'''<br />
'''&lt;/Attribute&gt;'''<br />
Or assigned to the cell centers :<br />
'''&lt;Attribute Name="Cell Values" Center="Cell"&gt;'''<br />
'''&lt;DataItem Format="XML" Dimensions="3"&gt;'''<br />
''' 3000 2000 1000'''<br />
''' &lt;/DataItem&gt;'''<br />
'''&lt;/Attribute&gt;'''<br />
<br />
'''Information'''<br />
<br />
There is regularly code or system specific information that needs to be stored with the data that does not map to the current data model. There is an ''Information'' element. This is intended for application specific information that can be ignored. A good example might be the bounds of a grid for use in visualization. Information elements have a Name and Value attribute. If Value is nonexistent the value is in the CDATA of the element :<br />
'''&lt;Information Name="XBounds" Value="0.0 10.0"/&gt;'''<br />
'''&lt;Information Name="Bounds"&gt; 0.0 10.0 100.0 110.0 200.0 210.0 &lt;/Information&gt;'''<br />
Several items can be addressed using the ''Information'' element like time, units, descriptions, etc. without polluting the XDMF schema. If some of these get used extensively they may be promoted to XDMF elements in the future.</div>128.63.127.201https://www.xdmf.org/index.php?title=XDMF_Model_and_Format&diff=7XDMF Model and Format2007-05-03T14:33:58Z<p>128.63.127.201: </p>
<hr />
<div><br />
<br />
The need for a standardized method to exchange scientific data between High Performance Computing codes and tools lead to the development of ''the eXtensible Data Model and Format'' (''XDMF'') . Uses for XDMF range from a standard format used by HPC codes to take advantage of widely used visualization programs like ParaView and EnSight, to a mechanism for performing coupled calculations using multiple, previously stand alone codes. <br />
<br />
XDMF categorizes data by two main attributes; size and function. Data can be ''Light'' (typically less than about a thousand values) of ''Heavy'' (megabytes, terabytes, etc.). In addition to raw values, data can refer to ''Format'' (rank and dimensions of an array) or ''Model'' (how that data is to be used. i.e. XYZ coordinates vs. Vector components).<br />
<br />
XDMF uses XML to store Light data and to describe the data Model. HDF5 is used to store Heavy data. The data Format is stored redundantly in both XML and HDF5. This allows tools to parse XML to determine the resources that will be required to access the Heavy data. <br />
<br />
While not required, a C++ API is provided to read and write '''XDMF''' data. This API has also been wrapped so it is available from popular languages like Python, Tcl, and Java. The API is not necessary in order to produce or consume XDMF data. Currently several HPC codes that already produced HDF5 data, use native text output to produce the XML necessary for valid XDMF. <br />
<br />
'''XML'''<br />
The eXtensible Markup Language (XML) format is widely used for many purposes and is well documented at many sites. There are numerous open source parsers available for XML. The XDMF API takes advantage of the libxml2 parser to provide the necessary functionality. Without going into too much detail, XDMF views XML as a "personalized HTML" with some special rules. It it case sensative and is made of three major components : elements, entities, and processing information. In XDMF we<nowiki>�</nowiki>re primarily concerned with the elements. These elements follow the basic form :<br />
<ElementTag<br />
AttributeName="AttribteValue"<br />
AttributeName="AttributeValue"<br />
�.. ><br />
''CData''<br />
</ElementTag><br />
Each element begins with an <tag> and ends with a </tag>. Optionally there can be several "Name=Value" pairs which convey additional information. Between the <tag> and the </tag> there can be other <tag></tag> pairs and/or character data (CData). CData is typically where the values are stored; like the actual text in an HTML document. The XML parser in the XDMF API parses the XML file and builds an tree structure in memory to describe its contents. This tree can be queried, modified, and then "serialized" back into XML.<br />
<br />
Comment in XML start with a "<!--" and end with a "-->". So <!--This is a Comment -->.<br />
<br />
XML is said to be "well formed" if it is syntactically correct. This is all of the quotes match, all elements have end elements, etc. XML is said to be "valid" if it conforms to the ''Schema'' or ''DTD'' defined at the head of the document. For example, the schema might specify that element type A can contain element B but not element C. Verifying that the provided XML is well formed and/or valid are functions typically performed by the XML parser. Additionally XDMF takes advantage of two major extensions to XML :<br />
<br />
'''XInclude'''<br />
As opposed to entity references in XML(which is a basic substitution mechanism), XInclude allows for the inclusion of files that are not well formed XML. This means that with XInclude the included file could be well formed XML or perhaps a flat text file of values. The syntax looks like this :<br />
<br />
'''<Xdmf Version="2.0" xmlns:xi="[http://www.w3.org/2001/XInclude-http://www.w3.org/2001/XInclude]">'''<br />
'''<xi:include href="Example3.xmf"/>'''<br />
'''</Xdmf>'''<br />
<br />
the xmlns:xi establishes a namespace xi. Then anywhere within the Xdmf element, xi:include will pull in the URL.<br />
<br />
'''XPath'''<br />
This allows for elements in the XML document and the API to reference specific elements in a document. For example :<br />
<br />
The first Grid in the first Domain<br />
'''/Xdmf/Domain/Grid'''<br />
The tenth Grid .... XPath is one based.<br />
'''/Xdmf/Domain/Grid<nowiki>[</nowiki>10<nowiki>]</nowiki>'''<br />
The first grid with an attribute ''Name'' which has a value of ''"Copper Plate"''<br />
'''/Xdmf/Domain/Grid<nowiki>[</nowiki>@Name="Copper Plate"<nowiki>]</nowiki>'''<br />
<br />
All valid XDMF must appear between the <Xdmf> and the </Xdmf>. So a minimal (empty) XDMF XML file would be :<br />
<br />
'''<?xml version="1.0" ?>'''<br />
'''<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" <nowiki>[</nowiki><nowiki>]</nowiki>>'''<br />
'''<Xdmf Version="2.0">'''<br />
'''</Xdmf>'''<br />
<br />
While there exists an Xdmf DTD and a Schema they are only necessary for validating parsers. For performance reasons, validation is typically disabled.<br />
<br />
'''XDMF Elements'''<br />
<br />
The organization of XDMF begins with the ''Xdmf'' element. So that parsers can distinguish from previous versions of XDMF, there exists a ''Version'' attribute (currently at 2.0). Any element in XDMF can have a ''Name'' attribute or have a ''Reference'' attribute. The Name attribute becomes important for grids while the Reference attribute is used to take advantage of the XPath facility (more detail on this later). Xdmf elements contain one or more ''Domain'' elements (computational domain). There is seldom motivation to have more than one Domain. <br />
<br />
A Domain can have one or more ''Grid'' elements. Each Grid contains a ''Topology'', ''Geometry'', and zero or more ''Attribute'' elements. Topology specifies the connectivity of the grid while Geometry specifies the location of the grid nodes. Attribute elements are used to specify values such as scalars and vectors that are located at the node, edge, face, cell center, or grid center. <br />
<br />
To specify actual values for connectivity, geometry, or attributes, XDMF defines a ''DataItem'' element. A DataItem can provide the actual values or provide the physical storage (which is typically an HDF5 file).<br />
<br />
'''XdmfItem'''<br />
<br />
There are six different types of DataItems :<br />
# '''Uniform''' � this is the default. A single array of values.<br />
# '''Collection''' � a one dimension array of DataItems<br />
# '''Tree''' � a hierarchical structure of DataItems<br />
# '''HyperSlab''' � contains two data items. The first selects the start, stride and count indexes of the second DataItem.<br />
# '''Coordinates''' � contains two DataItems. The first selects the parametric coordinates of the second DataItem.<br />
# '''Function''' � calculates an expression.<br />
<br />
'''Uniform '''<br />
The simplest type is Uniform that specifies a single array. As with all XDMF elements, there are reasonable defaults wherever possible. So the simplest DataItem would be :<br />
'''<DataItem Dimensions="3">'''<br />
'''1.0 2.0 3.0'''<br />
'''</DataItem>'''<br />
Since no ''ItemType'' has been specified, Uniform has been assumed. The default ''Format'' is XML and the default ''NumberType'' is a 32 bit floating point value. So the fully qualified DataItem for the same data would be :<br />
'''<DataItem ItemType="Uniform"'''<br />
'''Format="XML"'''<br />
'''NumberType="Float" Precision="4"'''<br />
'''Rank="1" Dimensions="3">'''<br />
'''1.0 2.0 3.0'''<br />
'''</DataItem>'''<br />
Since it is only practical to store a small amount of data values in the XML, production codes typically write their data to HDF5 and specify the location in XML. HDF5 is a hierarchical, self describing data format. So an application can open an HDF5 file without any prior knowledge of the data and determine the dimensions and number type of all the arrays stored in the file. XDMF requires that this information also be stored redundantly in the XML so that applications need not have access to the actual heavy data in order to determine storage requirements.<br />
<br />
For example, suppose an application stored a three dimensional array of pressure values at each iteration into an HDF5 file. The XML might be :<br />
'''<DataItem ItemType="Uniform"'''<br />
'''Format="HDF"'''<br />
'''NumberType="Float" Precision="8"'''<br />
'''Dimensions="64 128 256">'''<br />
'''OutputData.h5:/Results/Iteration 100/Part 2/Pressure'''<br />
'''</DataItem>'''<br />
Dimensions are specified with the slowest varying dimension first (i.e. KJI order). The HDF filename can be fully qualified, if it is not it is assumed to be located in the current directory or the same directory as the XML file. <br />
<br />
'''Collection and Tree'''<br />
Collections are Trees with only a single level. This is such a frequent occurrence that it was decided to make a Collection a separate type in case the application can optimize access. Collections and Trees have DataItem elements as children. The leaf nodes are Uniform DataItem elements :<br />
'''<DataItem Name="Tree Example" ItemType="Tree">'''<br />
'''<DataItem ItemType="Tree">'''<br />
'''<DataItem Name="Collection 1" ItemType="Collection">'''<br />
'''<DataItem Dimensions="3">'''<br />
'''1.0 2.0 3.0'''<br />
'''</DataItem>'''<br />
'''<DataItem Dimensions="4">'''<br />
'''4 5 6 7'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
'''<DataItem Name="Collection 2" ItemType="Collection">'''<br />
'''<DataItem Dimensions="3">'''<br />
'''7 8 9'''<br />
'''</DataItem>'''<br />
'''<DataItem Dimensions="4">'''<br />
'''10 11 12 13'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
'''<DataItem ItemType="Uniform"'''<br />
'''Format="HDF"'''<br />
'''NumberType="Float" Precision="8"'''<br />
'''Dimensions="64 128 256">'''<br />
'''OutputData.h5:/Results/Iteration 100/Part 2/Pressure'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
This DataItem is a tree with three children. The first child is another tree that contains a collection of two uniform DataItem elements. The second child is a collection with two uniform DataItem elements. The third child is a uniform DataItem. <br />
<br />
'''HyperSlab and Coordinate'''<br />
<br />
A ''HyperSlab'' specifies a subset of some other DataItem. The slab is specified by giving the start, stide, and count of the vales in each of the target DataItem dimensions. For example, given a dataset MyData.h5:/XYZ that is 100x200x300x3, we could describe a region starting at <nowiki>[</nowiki>0,0,0,0<nowiki>]</nowiki>, ending at <nowiki>[</nowiki>50, 100, 150, 2<nowiki>]</nowiki> that includes every other plane of data with the HyperSlab DataItem <br />
'''<DataItem ItemType="HyperSlab"'''<br />
'''Dimensions="25 50 75 3"'''<br />
'''Type="HyperSlab">'''<br />
'''<DataItem'''<br />
'''Dimensions="3 4"'''<br />
'''Format="XML">'''<br />
'''0 0 0 0 '''<br />
'''2 2 2 1 '''<br />
'''25 50 75 3'''<br />
'''</DataItem>'''<br />
'''<DataItem'''<br />
'''Name="Points"'''<br />
'''Dimensions="100 200 300 3"'''<br />
'''Format="HDF">'''<br />
'''MyData.h5:/XYZ'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
Notice that the first DataItem specified Start, Stride and Count for each dimension of the second DataItem. Suppose, instead that we only wish to specify the first Y data value from the DataItem and the last X value. This can be accomplished by providing the parametric coordinated of the desired values and using the ''Coordinates'' ItemType.<br />
'''<DataItem ItemType="HyperSlab"'''<br />
'''Dimensions="2"'''<br />
'''Type="HyperSlab">'''<br />
'''<DataItem'''<br />
'''Dimensions="2 4"'''<br />
'''Format="XML">'''<br />
'''0 0 0 1'''<br />
'''99 199 299 0'''<br />
'''</DataItem>'''<br />
'''<DataItem'''<br />
'''Name="Points"'''<br />
'''Dimensions="100 200 300 3"'''<br />
'''Format="HDF">'''<br />
'''MyData.h5:/XYZ'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
<br />
The first Y value is index 1 of item 0,0,0 while the last X value is index 0 of item 99, 199, 299. The dimensionality of the specified coordinates must match that of the target DataItem. <br />
<br />
'''Function'''<br />
<br />
''Function'' ItemType specifies some operation on the children DataItem elements. The elements are referenced by $X where X is the zero based index of the child. For example, the following DataItem would add the two children DataItem elements together in a value by value operation resulting in the values 5.1, 7.2 and 9.3 :<br />
'''<DataItem ItemType="Function" '''<br />
'''Function="$0 + $1"'''<br />
'''Dimensions="3">'''<br />
'''<DataItem Dimensions="3">'''<br />
'''1.0 2.0 3.0'''<br />
'''</DataItem>'''<br />
'''<DataItem Dimensions="3">'''<br />
'''4.1 5.2 6.3'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
<br />
The function description can be arbitrarily complex and contain SIN, COS, TAN, ACOS, ASIN, ATAN, LOG, EXP, ABS, and SQRT. In addition, there are the JOIN() and WHERE() expressions. JOIN can concat or interlace arrays while WHERE() can extract values where some condition is true. In the following examples we take advantage of the XPath facility to reference DataItem elements that have been previously specified :<br />
<br />
Add the value 10 to every element<br />
'''<DataItem Name="MyFunction" ItemType="Function"'''<br />
''' Function="10 + $0">'''<br />
''' <DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>1<nowiki>]</nowiki>" />'''<br />
''' </DataItem>'''<br />
<br />
Multiply two arrays (element by element) and take the absolute value<br />
''' <DataItem ItemType="Function"'''<br />
''' Function="ABS($0 <nowiki>*</nowiki> $1)">'''<br />
''' <DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>1<nowiki>]</nowiki>" />'''<br />
''' <DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>2<nowiki>]</nowiki>" />'''<br />
''' </DataItem>'''<br />
<br />
Select element 5 thru 15 from the first DataItem<br />
''' <DataItem ItemType="Function"'''<br />
''' Function="$0<nowiki>[</nowiki>5:15<nowiki>]</nowiki>">'''<br />
''' <DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>1<nowiki>]</nowiki>" />'''<br />
''' </DataItem>'''<br />
<br />
Concat two arrays<br />
''' <DataItem ItemType="Function"'''<br />
''' Function="JOIN($0 ; $1)">'''<br />
''' <DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>1<nowiki>]</nowiki>" />'''<br />
''' <DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>2<nowiki>]</nowiki>" />'''<br />
''' </DataItem>'''<br />
<br />
Interlace 3 arrays (Useful for describing vectors from scalar data)<br />
''' <DataItem ItemType="Function"'''<br />
''' Function="JOIN($0 , $1, $2)">'''<br />
''' <DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>1<nowiki>]</nowiki>" />'''<br />
''' <DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>2<nowiki>]</nowiki>" /> '''<br />
''' <DataItem Reference="/Xdmf/DataItem<nowiki>[</nowiki>3<nowiki>]</nowiki>" />'''<br />
''' </DataItem>'''<br />
<br />
'''Grid'''<br />
<br />
The DataItem element is used to define the data format portion of XDMF. It is sufficient to specify fairly complex data structures in a portable manner. The data model portion of XDMF begins with the ''Grid'' element. A Grid is a container for information related to 2D and 3D points, structured or unstructured connectivity, and assigned values.<br />
<br />
The Grid element now has a GridType attribute. Valid GridTypes are :<br />
# '''Uniform''' � a homogeneous single grid (i.e. a pile of triangles)<br />
# '''Collection''' � an array of Uniform grids<br />
# '''Tree''' � a hierarchical group<br />
# '''SubSet '''� a portion of another Grid<br />
<br />
Uniform Grid elements are the simplest type and must contain a ''Topology'' and ''Geometry'' element. Just like the DataItem element, Tree and Collection Grid elements contain other Grid elements as children :<br />
'''<Grid Name="Car Wheel" GridType="Tree">'''<br />
'''<Grid Name="Tire" GridType="Uniform">'''<br />
'''<Topology �.'''<br />
'''<Geometry �'''<br />
'''</Grid>'''<br />
'''<Grid Name="Lug Nuts" GridType="Collection">'''<br />
'''<Grid Name="Lug Nut 0" GridType="Uniform"'''<br />
'''<Topology �.'''<br />
'''<Geometry �'''<br />
'''</Grid>'''<br />
'''<Grid Name="Lug Nut 1" GridType="Uniform"'''<br />
'''<Topology �.'''<br />
'''<Geometry �'''<br />
'''</Grid>'''<br />
'''<Grid Name="Lug Nut 2" GridType="Uniform"'''<br />
'''<Topology �.'''<br />
'''<Geometry �'''<br />
'''</Grid>'''<br />
'''</Grid>'''<br />
'''.'''<br />
'''.'''<br />
'''.'''<br />
<br />
A SubSet GridType is used to define a portion of another grid or define new attribute on grid. This only selects the geometry and topology of another grid, the attributes from the original grid are not assigned. The Section attribute of a SubSet can be ''DataItem'' or ''All'' :<br />
<br />
''' <Grid Name="Portion" GridType="Subset" Section="DataItem">'''<br />
''<!-- Select 2 cells from another grid. Which 2 are defined by the DataItem -->Ther''<br />
''' <DataItem'''<br />
''' DataType="Int"'''<br />
''' Dimensions="2"'''<br />
''' Format="XML">'''<br />
''' 0 2'''<br />
''' </DataItem>'''<br />
''' <Grid Name="Target" Reference="XML">'''<br />
''' /Xdmf/Domain/Grid<nowiki>[</nowiki>@Name="Main Grid"<nowiki>]</nowiki>'''<br />
''' </Grid>'''<br />
''' <Attribute Name="New Values" Center="Cell">'''<br />
''' <DataItem Format="XML" Dimensions="2">'''<br />
''' 100 150'''<br />
''' </DataItem>'''<br />
''' </Attribute>'''<br />
''' </Grid>'''<br />
'''Or '''<br />
''' <Grid Name="Portion" GridType="Subset" Section="All">'''<br />
''<!-- Select the entire grid and add an attribute -->''<br />
''' <Grid Name="Target" Reference="XML">'''<br />
''' /Xdmf/Domain/Grid<nowiki>[</nowiki>@Name="Main Grid"<nowiki>]</nowiki>'''<br />
''' </Grid>'''<br />
''' <Attribute Name="New Values" Center="Cell">'''<br />
''' <DataItem Format="XML" Dimensions="3">'''<br />
''' 100 150 200'''<br />
''' </DataItem>'''<br />
''' </Attribute>'''<br />
''' </Grid>'''<br />
<br />
'''Topology'''<br />
<br />
The Topology element describes the general organization of the data. This is the part of the computational grid that is invariant with rotation, translation, and scale. For structured grids, the connectivity is implicit. For unstructured grids, if the connectivity differs from the standard, an Order may be specified. Currently, the following Topology cell types are defined :<br />
'''Linear'''<br />
* Polyvertex � a group of unconnected points<br />
* Polyline � a group of line segments<br />
* Polygon<br />
* Triangle<br />
* Quadrilateral<br />
* Tetrahedron<br />
* Pyramid<br />
* Wedge<br />
* Hexahedron<br />
'''Quadratic'''<br />
* Edge_3 � Quadratic line with 3 nodes<br />
* Tri_6<br />
* Quad_8<br />
* Tet_10<br />
* Pyramid_13<br />
* Wedge_15<br />
* Hex_20<br />
'''Arbitrary'''<br />
* Mixed � a mixture of unstructured cells<br />
'''Structured'''<br />
* 2DSMesh - Curvilinear<br />
* 2DRectMesh � Axis are perpendicular<br />
* 2DCoRectMesh � Axis are perpendicular and spacing is constant<br />
* 3DSMesh<br />
* 3DRectMesh<br />
* 3DCoRectMesh<br />
<br />
There is a ''NodesPerElement'' attribute for the cell types where it is not implicit. For example, to define a group of Octagons, set Type="Polygon" and NodesPerElement="8". For structured grid topologies, the connectivity is implicit. For unstructured topologies the Topology element must contain a DataItem that defines the connectivity :<br />
'''<Topology Type="Quadrilateral" NumberOfElements="2" >'''<br />
'''<DataItem Format="XML" DataType="Int" Dimensions="2 4">'''<br />
'''0 1 2 3'''<br />
'''1 6 7 2'''<br />
'''</DataItem>'''<br />
'''</Topology>'''<br />
The connectivity defines the indexes into the XYZ geometry that define the cell. In this example, the two quads share an edge defined by the line from node 1 to node 2. A Topology element can define ''Dimensions'' or ''NumberOfElements''; this is just added for clarity.<br />
<br />
Mixed topologies must define the cell type of every element. If that cell type does have an implicit number of nodes, that must also be specified. In this example, we define a topology of three cells consisting of a Tet (cell type 6) a Polygon (cell type 3) and a Hex (cell type 9) :<br />
'''<Topology Type="Mixed" NumberOfElements="3" >'''<br />
'''<DataItem Format="XML" DataType="Int" Dimensions="20">'''<br />
'''6 0 1 2 7'''<br />
'''3 4 4 5 6 7'''<br />
'''9 8 9 10 11 12 13 14 15'''<br />
'''</DataItem>'''<br />
'''</Topology>'''<br />
Notice that the Polygon must define the number of nodes (4) before its connectivity. The cell type numbers are defined in the API documentation.<br />
<br />
'''Geometry'''<br />
<br />
The Geometry element describes the XYZ values of the mesh. The important attribute here is the organization of the points. The default is XYZ; an X,Y, and Z for each point starting at parametric index 0. Possible organizations are :<br />
* '''XYZ''' - Interlaced locations<br />
* '''XY''' - Z is set to 0.0<br />
* '''X_Y_Z''' - X,Y, and Z are separate arrays<br />
* '''VXVYVZ''' - Three arrays, one for each axis<br />
* '''ORIGIN_DXDYDZ''' - Six Values : Ox,Oy,Oz + Dx,Dy,Dz<br />
<br />
The following Geometry element defines 8 points :<br />
'''<Geometry Type="XYZ">'''<br />
'''<DataItem Format="XML" Dimensions="2 4 3">'''<br />
'''0.0 0.0 0.0'''<br />
'''1.0 0.0 0.0'''<br />
'''1.0 1.0 0.0'''<br />
'''0.0 1.0 0.0'''<br />
<br />
'''0.0 0.0 2.0'''<br />
'''1.0 0.0 2.0'''<br />
'''1.0 1.0 2.0'''<br />
'''0.0 1.0 2.0'''<br />
'''</DataItem>'''<br />
'''</Geometry>'''<br />
Together with the Grid and Topology element we now have enough to a full XDMF XML file that defines two quadrilaterals that share an edge (notice not all points are used):<br />
'''<?xml version="1.0" ?>'''<br />
'''<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" <nowiki>[</nowiki><nowiki>]</nowiki>>'''<br />
<br />
'''<Xdmf Version="2.0" xmlns:xi="[http://www.w3.org/2001/XInclude-http://www.w3.org/2001/XInclude]">'''<br />
'''<Domain>'''<br />
'''<Grid Name="Two Quads>'''<br />
'''<Topology Type="Quadrilateral" NumberOfElements="2" >'''<br />
'''<DataItem Format="XML" '''<br />
'''DataType="Int"'''<br />
'''Dimensions="2 4">'''<br />
'''0 1 2 3'''<br />
'''1 6 7 2'''<br />
'''</DataItem>'''<br />
'''</Topology>'''<br />
'''<Geometry Type="XYZ">'''<br />
'''<DataItem Format="XML" Dimensions="2 4 3">'''<br />
'''0.0 0.0 0.0'''<br />
'''1.0 0.0 0.0'''<br />
'''1.0 1.0 0.0'''<br />
'''0.0 1.0 0.0'''<br />
<br />
'''0.0 0.0 2.0'''<br />
'''1.0 0.0 2.0'''<br />
'''1.0 1.0 2.0'''<br />
'''0.0 1.0 2.0'''<br />
'''</DataItem>'''<br />
'''</Geometry>'''<br />
'''</Grid>'''<br />
'''</Domain>'''<br />
'''</Xdmf>'''<br />
It is valid to have DataItem elements to be direct children of the Xdmf or Domain elements. This could be useful if several Grid share the same Geometry but have separate Topology :<br />
'''<?xml version="1.0" ?>'''<br />
'''<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" <nowiki>[</nowiki><nowiki>]</nowiki>>'''<br />
<br />
'''<Xdmf Version="2.0" xmlns:xi="[http://www.w3.org/2001/XInclude-http://www.w3.org/2001/XInclude]">'''<br />
'''<Domain>'''<br />
'''<DataItem Name="Point Data" Format="XML" Dimensions="2 4 3">'''<br />
'''0.0 0.0 0.0'''<br />
'''1.0 0.0 0.0'''<br />
'''1.0 1.0 0.0'''<br />
'''0.0 1.0 0.0'''<br />
<br />
'''0.0 0.0 2.0'''<br />
'''1.0 0.0 2.0'''<br />
'''1.0 1.0 2.0'''<br />
'''0.0 1.0 2.0'''<br />
'''</DataItem>'''<br />
'''<Grid Name="Two Quads>'''<br />
'''<Topology Type="Quadrilateral" NumberOfElements="2" >'''<br />
'''<DataItem Format="XML" '''<br />
'''DataType="Int"'''<br />
'''Dimensions="2 4">'''<br />
'''0 1 2 3'''<br />
'''1 6 7 2'''<br />
'''</DataItem>'''<br />
'''</Topology>'''<br />
'''<Geometry Type="XYZ">'''<br />
'''<DataItem Reference="XML">'''<br />
'''/Xdmf/Domain/DataItem<nowiki>[</nowiki>@Name="Point Data"<nowiki>]</nowiki>'''<br />
'''</DataItem>'''<br />
'''</Geometry>'''<br />
'''</Grid>'''<br />
'''</Domain>'''<br />
'''</Xdmf>'''<br />
<br />
'''Attribute'''<br />
<br />
The Attribute element defines values associated with the mesh. Currently the supported types of values are :<br />
* '''Scalar'''<br />
* '''Vector'''<br />
* '''Tensor''' � 9 values expected<br />
* '''Tensor6''' � a symmetrical tensor<br />
* '''Matrix ''' - an arbitrary NxM matrix<br />
These values can be centered on :<br />
* '''Node'''<br />
* '''Edge'''<br />
* '''Face'''<br />
* '''Cell'''<br />
* '''Grid'''<br />
A Grid centered Attribute might be something like "Material Type" where the value is constant everywhere in the grid. Edge and Face centered values are defined, but don<nowiki>�</nowiki>t map well to many visualization systems. Typically Attributes are assigned on the Node :<br />
'''<Attribute Name="Node Values" Center="Node">'''<br />
'''<DataItem Format="XML" Dimensions="6 4">'''<br />
'''100 200 300 400'''<br />
'''500 600 600 700'''<br />
'''800 900 1000 1100'''<br />
'''1200 1300 1400 1500'''<br />
'''1600 1700 1800 1900'''<br />
'''2000 2100 2200 2300'''<br />
'''</DataItem>'''<br />
'''</Attribute>'''<br />
Or assigned to the cell centers :<br />
'''<Attribute Name="Cell Values" Center="Cell">'''<br />
'''<DataItem Format="XML" Dimensions="3">'''<br />
''' 3000 2000 1000'''<br />
''' </DataItem>'''<br />
'''</Attribute>'''<br />
<br />
'''Information'''<br />
<br />
There is regularly code or system specific information that needs to be stored with the data that does not map to the current data model. There is an ''Information'' element. This is intended for application specific information that can be ignored. A good example might be the bounds of a grid for use in visualization. Information elements have a Name and Value attribute. If Value is nonexistent the value is in the CDATA of the element :<br />
'''<Information Name="XBounds" Value="0.0 10.0"/>'''<br />
'''<Information Name="Bounds"> 0.0 10.0 100.0 110.0 200.0 210.0 </Information>'''<br />
Several items can be addressed using the ''Information'' element like time, units, descriptions, etc. without polluting the XDMF schema. If some of these get used extensively they may be promoted to XDMF elements in the future.</div>128.63.127.201https://www.xdmf.org/index.php?title=XDMF_Model_and_Format&diff=6XDMF Model and Format2007-05-03T14:29:07Z<p>128.63.127.201: </p>
<hr />
<div><br />
<br />
The need for a standardized method to exchange scientific data between High Performance Computing codes and tools lead to the development of ''the eXtensible Data Model and Format'' (''XDMF'') . Uses for XDMF range from a standard format used by HPC codes to take advantage of widely used visualization programs like ParaView and EnSight, to a mechanism for performing coupled calculations using multiple, previously stand alone codes. <br />
<br />
XDMF categorizes data by two main attributes; size and function. Data can be ''Light'' (typically less than about a thousand values) of ''Heavy'' (megabytes, terabytes, etc.). In addition to raw values, data can refer to ''Format'' (rank and dimensions of an array) or ''Model'' (how that data is to be used. i.e. XYZ coordinates vs. Vector components).<br />
<br />
XDMF uses XML to store Light data and to describe the data Model. HDF5 is used to store Heavy data. The data Format is stored redundantly in both XML and HDF5. This allows tools to parse XML to determine the resources that will be required to access the Heavy data. <br />
<br />
While not required, a C++ API is provided to read and write '''XDMF''' data. This API has also been wrapped so it is available from popular languages like Python, Tcl, and Java. The API is not necessary in order to produce or consume XDMF data. Currently several HPC codes that already produced HDF5 data, use native text output to produce the XML necessary for valid XDMF. <br />
<br />
'''XML'''<br />
The eXtensible Markup Language (XML) format is widely used for many purposes and is well documented at many sites. There are numerous open source parsers available for XML. The XDMF API takes advantage of the libxml2 parser to provide the necessary functionality. Without going into too much detail, XDMF views XML as a "personalized HTML" with some special rules. It it case sensative and is made of three major components : elements, entities, and processing information. In XDMF we\�re primarily concerned with the elements. These elements follow the basic form :<br />
<ElementTag<br />
AttributeName="AttribteValue"<br />
AttributeName="AttributeValue"<br />
�.. ><br />
''CData''<br />
</ElementTag><br />
Each element begins with an <tag> and ends with a </tag>. Optionally there can be several "Name=Value" pairs which convey additional information. Between the <tag> and the </tag> there can be other <tag></tag> pairs and/or character data (CData). CData is typically where the values are stored; like the actual text in an HTML document. The XML parser in the XDMF API parses the XML file and builds an tree structure in memory to describe its contents. This tree can be queried, modified, and then "serialized" back into XML.<br />
<br />
Comment in XML start with a "<!--" and end with a "-->". So <!--This is a Comment -->.<br />
<br />
XML is said to be "well formed" if it is syntactically correct. This is all of the quotes match, all elements have end elements, etc. XML is said to be "valid" if it conforms to the ''Schema'' or ''DTD'' defined at the head of the document. For example, the schema might specify that element type A can contain element B but not element C. Verifying that the provided XML is well formed and/or valid are functions typically performed by the XML parser. Additionally XDMF takes advantage of two major extensions to XML :<br />
<br />
'''XInclude'''<br />
As opposed to entity references in XML(which is a basic substitution mechanism), XInclude allows for the inclusion of files that are not well formed XML. This means that with XInclude the included file could be well formed XML or perhaps a flat text file of values. The syntax looks like this :<br />
<br />
'''<Xdmf Version="2.0" xmlns:xi="[http://www.w3.org/2001/XInclude-http://www.w3.org/2001/XInclude]">'''<br />
'''<xi:include href="Example3.xmf"/>'''<br />
'''</Xdmf>'''<br />
<br />
the xmlns:xi establishes a namespace xi. Then anywhere within the Xdmf element, xi:include will pull in the URL.<br />
<br />
'''XPath'''<br />
This allows for elements in the XML document and the API to reference specific elements in a document. For example :<br />
<br />
The first Grid in the first Domain<br />
'''/Xdmf/Domain/Grid'''<br />
The tenth Grid .... XPath is one based.<br />
'''/Xdmf/Domain/Grid\[10\]'''<br />
The first grid with an attribute ''Name'' which has a value of ''"Copper Plate"''<br />
'''/Xdmf/Domain/Grid\[@Name="Copper Plate"\]'''<br />
<br />
All valid XDMF must appear between the <Xdmf> and the </Xdmf>. So a minimal (empty) XDMF XML file would be :<br />
<br />
'''<?xml version="1.0" ?>'''<br />
'''<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" \[\]>'''<br />
'''<Xdmf Version="2.0">'''<br />
'''</Xdmf>'''<br />
<br />
While there exists an Xdmf DTD and a Schema they are only necessary for validating parsers. For performance reasons, validation is typically disabled.<br />
<br />
'''XDMF Elements'''<br />
<br />
The organization of XDMF begins with the ''Xdmf'' element. So that parsers can distinguish from previous versions of XDMF, there exists a ''Version'' attribute (currently at 2.0). Any element in XDMF can have a ''Name'' attribute or have a ''Reference'' attribute. The Name attribute becomes important for grids while the Reference attribute is used to take advantage of the XPath facility (more detail on this later). Xdmf elements contain one or more ''Domain'' elements (computational domain). There is seldom motivation to have more than one Domain. <br />
<br />
A Domain can have one or more ''Grid'' elements. Each Grid contains a ''Topology'', ''Geometry'', and zero or more ''Attribute'' elements. Topology specifies the connectivity of the grid while Geometry specifies the location of the grid nodes. Attribute elements are used to specify values such as scalars and vectors that are located at the node, edge, face, cell center, or grid center. <br />
<br />
To specify actual values for connectivity, geometry, or attributes, XDMF defines a ''DataItem'' element. A DataItem can provide the actual values or provide the physical storage (which is typically an HDF5 file).<br />
<br />
'''XdmfItem'''<br />
<br />
There are six different types of DataItems :<br />
# '''Uniform''' � this is the default. A single array of values.<br />
# '''Collection''' � a one dimension array of DataItems<br />
# '''Tree''' � a hierarchical structure of DataItems<br />
# '''HyperSlab''' � contains two data items. The first selects the start, stride and count indexes of the second DataItem.<br />
# '''Coordinates''' � contains two DataItems. The first selects the parametric coordinates of the second DataItem.<br />
# '''Function''' � calculates an expression.<br />
<br />
'''Uniform '''<br />
The simplest type is Uniform that specifies a single array. As with all XDMF elements, there are reasonable defaults wherever possible. So the simplest DataItem would be :<br />
'''<DataItem Dimensions="3">'''<br />
'''1.0 2.0 3.0'''<br />
'''</DataItem>'''<br />
Since no ''ItemType'' has been specified, Uniform has been assumed. The default ''Format'' is XML and the default ''NumberType'' is a 32 bit floating point value. So the fully qualified DataItem for the same data would be :<br />
'''<DataItem ItemType="Uniform"'''<br />
'''Format="XML"'''<br />
'''NumberType="Float" Precision="4"'''<br />
'''Rank="1" Dimensions="3">'''<br />
'''1.0 2.0 3.0'''<br />
'''</DataItem>'''<br />
Since it is only practical to store a small amount of data values in the XML, production codes typically write their data to HDF5 and specify the location in XML. HDF5 is a hierarchical, self describing data format. So an application can open an HDF5 file without any prior knowledge of the data and determine the dimensions and number type of all the arrays stored in the file. XDMF requires that this information also be stored redundantly in the XML so that applications need not have access to the actual heavy data in order to determine storage requirements.<br />
<br />
For example, suppose an application stored a three dimensional array of pressure values at each iteration into an HDF5 file. The XML might be :<br />
'''<DataItem ItemType="Uniform"'''<br />
'''Format="HDF"'''<br />
'''NumberType="Float" Precision="8"'''<br />
'''Dimensions="64 128 256">'''<br />
'''OutputData.h5:/Results/Iteration 100/Part 2/Pressure'''<br />
'''</DataItem>'''<br />
Dimensions are specified with the slowest varying dimension first (i.e. KJI order). The HDF filename can be fully qualified, if it is not it is assumed to be located in the current directory or the same directory as the XML file. <br />
<br />
'''Collection and Tree'''<br />
Collections are Trees with only a single level. This is such a frequent occurrence that it was decided to make a Collection a separate type in case the application can optimize access. Collections and Trees have DataItem elements as children. The leaf nodes are Uniform DataItem elements :<br />
'''<DataItem Name="Tree Example" ItemType="Tree">'''<br />
'''<DataItem ItemType="Tree">'''<br />
'''<DataItem Name="Collection 1" ItemType="Collection">'''<br />
'''<DataItem Dimensions="3">'''<br />
'''1.0 2.0 3.0'''<br />
'''</DataItem>'''<br />
'''<DataItem Dimensions="4">'''<br />
'''4 5 6 7'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
'''<DataItem Name="Collection 2" ItemType="Collection">'''<br />
'''<DataItem Dimensions="3">'''<br />
'''7 8 9'''<br />
'''</DataItem>'''<br />
'''<DataItem Dimensions="4">'''<br />
'''10 11 12 13'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
'''<DataItem ItemType="Uniform"'''<br />
'''Format="HDF"'''<br />
'''NumberType="Float" Precision="8"'''<br />
'''Dimensions="64 128 256">'''<br />
'''OutputData.h5:/Results/Iteration 100/Part 2/Pressure'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
This DataItem is a tree with three children. The first child is another tree that contains a collection of two uniform DataItem elements. The second child is a collection with two uniform DataItem elements. The third child is a uniform DataItem. <br />
<br />
'''HyperSlab and Coordinate'''<br />
<br />
A ''HyperSlab'' specifies a subset of some other DataItem. The slab is specified by giving the start, stide, and count of the vales in each of the target DataItem dimensions. For example, given a dataset MyData.h5:/XYZ that is 100x200x300x3, we could describe a region starting at \[0,0,0,0\], ending at \[50, 100, 150, 2\] that includes every other plane of data with the HyperSlab DataItem <br />
'''<DataItem ItemType="HyperSlab"'''<br />
'''Dimensions="25 50 75 3"'''<br />
'''Type="HyperSlab">'''<br />
'''<DataItem'''<br />
'''Dimensions="3 4"'''<br />
'''Format="XML">'''<br />
'''0 0 0 0 '''<br />
'''2 2 2 1 '''<br />
'''25 50 75 3'''<br />
'''</DataItem>'''<br />
'''<DataItem'''<br />
'''Name="Points"'''<br />
'''Dimensions="100 200 300 3"'''<br />
'''Format="HDF">'''<br />
'''MyData.h5:/XYZ'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
Notice that the first DataItem specified Start, Stride and Count for each dimension of the second DataItem. Suppose, instead that we only wish to specify the first Y data value from the DataItem and the last X value. This can be accomplished by providing the parametric coordinated of the desired values and using the ''Coordinates'' ItemType.<br />
'''<DataItem ItemType="HyperSlab"'''<br />
'''Dimensions="2"'''<br />
'''Type="HyperSlab">'''<br />
'''<DataItem'''<br />
'''Dimensions="2 4"'''<br />
'''Format="XML">'''<br />
'''0 0 0 1'''<br />
'''99 199 299 0'''<br />
'''</DataItem>'''<br />
'''<DataItem'''<br />
'''Name="Points"'''<br />
'''Dimensions="100 200 300 3"'''<br />
'''Format="HDF">'''<br />
'''MyData.h5:/XYZ'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
<br />
The first Y value is index 1 of item 0,0,0 while the last X value is index 0 of item 99, 199, 299. The dimensionality of the specified coordinates must match that of the target DataItem. <br />
<br />
'''Function'''<br />
<br />
''Function'' ItemType specifies some operation on the children DataItem elements. The elements are referenced by $X where X is the zero based index of the child. For example, the following DataItem would add the two children DataItem elements together in a value by value operation resulting in the values 5.1, 7.2 and 9.3 :<br />
'''<DataItem ItemType="Function" '''<br />
'''Function="$0 + $1"'''<br />
'''Dimensions="3">'''<br />
'''<DataItem Dimensions="3">'''<br />
'''1.0 2.0 3.0'''<br />
'''</DataItem>'''<br />
'''<DataItem Dimensions="3">'''<br />
'''4.1 5.2 6.3'''<br />
'''</DataItem>'''<br />
'''</DataItem>'''<br />
<br />
The function description can be arbitrarily complex and contain SIN, COS, TAN, ACOS, ASIN, ATAN, LOG, EXP, ABS, and SQRT. In addition, there are the JOIN() and WHERE() expressions. JOIN can concat or interlace arrays while WHERE() can extract values where some condition is true. In the following examples we take advantage of the XPath facility to reference DataItem elements that have been previously specified :<br />
<br />
Add the value 10 to every element<br />
'''<DataItem Name="MyFunction" ItemType="Function"'''<br />
''' Function="10 + $0">'''<br />
''' <DataItem Reference="/Xdmf/DataItem\[1\]" />'''<br />
''' </DataItem>'''<br />
<br />
Multiply two arrays (element by element) and take the absolute value<br />
''' <DataItem ItemType="Function"'''<br />
''' Function="ABS($0 \* $1)">'''<br />
''' <DataItem Reference="/Xdmf/DataItem\[1\]" />'''<br />
''' <DataItem Reference="/Xdmf/DataItem\[2\]" />'''<br />
''' </DataItem>'''<br />
<br />
Select element 5 thru 15 from the first DataItem<br />
''' <DataItem ItemType="Function"'''<br />
''' Function="$0\[5:15\]">'''<br />
''' <DataItem Reference="/Xdmf/DataItem\[1\]" />'''<br />
''' </DataItem>'''<br />
<br />
Concat two arrays<br />
''' <DataItem ItemType="Function"'''<br />
''' Function="JOIN($0 ; $1)">'''<br />
''' <DataItem Reference="/Xdmf/DataItem\[1\]" />'''<br />
''' <DataItem Reference="/Xdmf/DataItem\[2\]" />'''<br />
''' </DataItem>'''<br />
<br />
Interlace 3 arrays (Useful for describing vectors from scalar data)<br />
''' <DataItem ItemType="Function"'''<br />
''' Function="JOIN($0 , $1, $2)">'''<br />
''' <DataItem Reference="/Xdmf/DataItem\[1\]" />'''<br />
''' <DataItem Reference="/Xdmf/DataItem\[2\]" /> '''<br />
''' <DataItem Reference="/Xdmf/DataItem\[3\]" />'''<br />
''' </DataItem>'''<br />
<br />
'''Grid'''<br />
<br />
The DataItem element is used to define the data format portion of XDMF. It is sufficient to specify fairly complex data structures in a portable manner. The data model portion of XDMF begins with the ''Grid'' element. A Grid is a container for information related to 2D and 3D points, structured or unstructured connectivity, and assigned values.<br />
<br />
The Grid element now has a GridType attribute. Valid GridTypes are :<br />
# '''Uniform''' � a homogeneous single grid (i.e. a pile of triangles)<br />
# '''Collection''' � an array of Uniform grids<br />
# '''Tree''' � a hierarchical group<br />
# '''SubSet '''� a portion of another Grid<br />
<br />
Uniform Grid elements are the simplest type and must contain a ''Topology'' and ''Geometry'' element. Just like the DataItem element, Tree and Collection Grid elements contain other Grid elements as children :<br />
'''<Grid Name="Car Wheel" GridType="Tree">'''<br />
'''<Grid Name="Tire" GridType="Uniform">'''<br />
'''<Topology �.'''<br />
'''<Geometry �'''<br />
'''</Grid>'''<br />
'''<Grid Name="Lug Nuts" GridType="Collection">'''<br />
'''<Grid Name="Lug Nut 0" GridType="Uniform"'''<br />
'''<Topology �.'''<br />
'''<Geometry �'''<br />
'''</Grid>'''<br />
'''<Grid Name="Lug Nut 1" GridType="Uniform"'''<br />
'''<Topology �.'''<br />
'''<Geometry �'''<br />
'''</Grid>'''<br />
'''<Grid Name="Lug Nut 2" GridType="Uniform"'''<br />
'''<Topology �.'''<br />
'''<Geometry �'''<br />
'''</Grid>'''<br />
'''</Grid>'''<br />
'''.'''<br />
'''.'''<br />
'''.'''<br />
<br />
A SubSet GridType is used to define a portion of another grid or define new attribute on grid. This only selects the geometry and topology of another grid, the attributes from the original grid are not assigned. The Section attribute of a SubSet can be ''DataItem'' or ''All'' :<br />
<br />
''' <Grid Name="Portion" GridType="Subset" Section="DataItem">'''<br />
''<!-- Select 2 cells from another grid. Which 2 are defined by the DataItem -->Ther''<br />
''' <DataItem'''<br />
''' DataType="Int"'''<br />
''' Dimensions="2"'''<br />
''' Format="XML">'''<br />
''' 0 2'''<br />
''' </DataItem>'''<br />
''' <Grid Name="Target" Reference="XML">'''<br />
''' /Xdmf/Domain/Grid\[@Name="Main Grid"\]'''<br />
''' </Grid>'''<br />
''' <Attribute Name="New Values" Center="Cell">'''<br />
''' <DataItem Format="XML" Dimensions="2">'''<br />
''' 100 150'''<br />
''' </DataItem>'''<br />
''' </Attribute>'''<br />
''' </Grid>'''<br />
'''Or '''<br />
''' <Grid Name="Portion" GridType="Subset" Section="All">'''<br />
''<!-- Select the entire grid and add an attribute -->''<br />
''' <Grid Name="Target" Reference="XML">'''<br />
''' /Xdmf/Domain/Grid\[@Name="Main Grid"\]'''<br />
''' </Grid>'''<br />
''' <Attribute Name="New Values" Center="Cell">'''<br />
''' <DataItem Format="XML" Dimensions="3">'''<br />
''' 100 150 200'''<br />
''' </DataItem>'''<br />
''' </Attribute>'''<br />
''' </Grid>'''<br />
<br />
'''Topology'''<br />
<br />
The Topology element describes the general organization of the data. This is the part of the computational grid that is invariant with rotation, translation, and scale. For structured grids, the connectivity is implicit. For unstructured grids, if the connectivity differs from the standard, an Order may be specified. Currently, the following Topology cell types are defined :<br />
'''Linear'''<br />
* Polyvertex � a group of unconnected points<br />
* Polyline � a group of line segments<br />
* Polygon<br />
* Triangle<br />
* Quadrilateral<br />
* Tetrahedron<br />
* Pyramid<br />
* Wedge<br />
* Hexahedron<br />
'''Quadratic'''<br />
* Edge_3 � Quadratic line with 3 nodes<br />
* Tri_6<br />
* Quad_8<br />
* Tet_10<br />
* Pyramid_13<br />
* Wedge_15<br />
* Hex_20<br />
'''Arbitrary'''<br />
* Mixed � a mixture of unstructured cells<br />
'''Structured'''<br />
* 2DSMesh - Curvilinear<br />
* 2DRectMesh � Axis are perpendicular<br />
* 2DCoRectMesh � Axis are perpendicular and spacing is constant<br />
* 3DSMesh<br />
* 3DRectMesh<br />
* 3DCoRectMesh<br />
<br />
There is a ''NodesPerElement'' attribute for the cell types where it is not implicit. For example, to define a group of Octagons, set Type="Polygon" and NodesPerElement="8". For structured grid topologies, the connectivity is implicit. For unstructured topologies the Topology element must contain a DataItem that defines the connectivity :<br />
'''<Topology Type="Quadrilateral" NumberOfElements="2" >'''<br />
'''<DataItem Format="XML" DataType="Int" Dimensions="2 4">'''<br />
'''0 1 2 3'''<br />
'''1 6 7 2'''<br />
'''</DataItem>'''<br />
'''</Topology>'''<br />
The connectivity defines the indexes into the XYZ geometry that define the cell. In this example, the two quads share an edge defined by the line from node 1 to node 2. A Topology element can define ''Dimensions'' or ''NumberOfElements''; this is just added for clarity.<br />
<br />
Mixed topologies must define the cell type of every element. If that cell type does have an implicit number of nodes, that must also be specified. In this example, we define a topology of three cells consisting of a Tet (cell type 6) a Polygon (cell type 3) and a Hex (cell type 9) :<br />
'''<Topology Type="Mixed" NumberOfElements="3" >'''<br />
'''<DataItem Format="XML" DataType="Int" Dimensions="20">'''<br />
'''6 0 1 2 7'''<br />
'''3 4 4 5 6 7'''<br />
'''9 8 9 10 11 12 13 14 15'''<br />
'''</DataItem>'''<br />
'''</Topology>'''<br />
Notice that the Polygon must define the number of nodes (4) before its connectivity. The cell type numbers are defined in the API documentation.<br />
<br />
'''Geometry'''<br />
<br />
The Geometry element describes the XYZ values of the mesh. The important attribute here is the organization of the points. The default is XYZ; an X,Y, and Z for each point starting at parametric index 0. Possible organizations are :<br />
* '''XYZ''' - Interlaced locations<br />
* '''XY''' - Z is set to 0.0<br />
* '''X_Y_Z''' - X,Y, and Z are separate arrays<br />
* '''VXVYVZ''' - Three arrays, one for each axis<br />
* '''ORIGIN_DXDYDZ''' - Six Values : Ox,Oy,Oz + Dx,Dy,Dz<br />
<br />
The following Geometry element defines 8 points :<br />
'''<Geometry Type="XYZ">'''<br />
'''<DataItem Format="XML" Dimensions="2 4 3">'''<br />
'''0.0 0.0 0.0'''<br />
'''1.0 0.0 0.0'''<br />
'''1.0 1.0 0.0'''<br />
'''0.0 1.0 0.0'''<br />
<br />
'''0.0 0.0 2.0'''<br />
'''1.0 0.0 2.0'''<br />
'''1.0 1.0 2.0'''<br />
'''0.0 1.0 2.0'''<br />
'''</DataItem>'''<br />
'''</Geometry>'''<br />
Together with the Grid and Topology element we now have enough to a full XDMF XML file that defines two quadrilaterals that share an edge (notice not all points are used):<br />
'''<?xml version="1.0" ?>'''<br />
'''<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" \[\]>'''<br />
<br />
'''<Xdmf Version="2.0" xmlns:xi="[http://www.w3.org/2001/XInclude-http://www.w3.org/2001/XInclude]">'''<br />
'''<Domain>'''<br />
'''<Grid Name="Two Quads>'''<br />
'''<Topology Type="Quadrilateral" NumberOfElements="2" >'''<br />
'''<DataItem Format="XML" '''<br />
'''DataType="Int"'''<br />
'''Dimensions="2 4">'''<br />
'''0 1 2 3'''<br />
'''1 6 7 2'''<br />
'''</DataItem>'''<br />
'''</Topology>'''<br />
'''<Geometry Type="XYZ">'''<br />
'''<DataItem Format="XML" Dimensions="2 4 3">'''<br />
'''0.0 0.0 0.0'''<br />
'''1.0 0.0 0.0'''<br />
'''1.0 1.0 0.0'''<br />
'''0.0 1.0 0.0'''<br />
<br />
'''0.0 0.0 2.0'''<br />
'''1.0 0.0 2.0'''<br />
'''1.0 1.0 2.0'''<br />
'''0.0 1.0 2.0'''<br />
'''</DataItem>'''<br />
'''</Geometry>'''<br />
'''</Grid>'''<br />
'''</Domain>'''<br />
'''</Xdmf>'''<br />
It is valid to have DataItem elements to be direct children of the Xdmf or Domain elements. This could be useful if several Grid share the same Geometry but have separate Topology :<br />
'''<?xml version="1.0" ?>'''<br />
'''<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" \[\]>'''<br />
<br />
'''<Xdmf Version="2.0" xmlns:xi="[http://www.w3.org/2001/XInclude-http://www.w3.org/2001/XInclude]">'''<br />
'''<Domain>'''<br />
'''<DataItem Name="Point Data" Format="XML" Dimensions="2 4 3">'''<br />
'''0.0 0.0 0.0'''<br />
'''1.0 0.0 0.0'''<br />
'''1.0 1.0 0.0'''<br />
'''0.0 1.0 0.0'''<br />
<br />
'''0.0 0.0 2.0'''<br />
'''1.0 0.0 2.0'''<br />
'''1.0 1.0 2.0'''<br />
'''0.0 1.0 2.0'''<br />
'''</DataItem>'''<br />
'''<Grid Name="Two Quads>'''<br />
'''<Topology Type="Quadrilateral" NumberOfElements="2" >'''<br />
'''<DataItem Format="XML" '''<br />
'''DataType="Int"'''<br />
'''Dimensions="2 4">'''<br />
'''0 1 2 3'''<br />
'''1 6 7 2'''<br />
'''</DataItem>'''<br />
'''</Topology>'''<br />
'''<Geometry Type="XYZ">'''<br />
'''<DataItem Reference="XML">'''<br />
'''/Xdmf/Domain/DataItem\[@Name="Point Data"\]'''<br />
'''</DataItem>'''<br />
'''</Geometry>'''<br />
'''</Grid>'''<br />
'''</Domain>'''<br />
'''</Xdmf>'''<br />
<br />
'''Attribute'''<br />
<br />
The Attribute element defines values associated with the mesh. Currently the supported types of values are :<br />
* '''Scalar'''<br />
* '''Vector'''<br />
* '''Tensor''' � 9 values expected<br />
* '''Tensor6''' � a symmetrical tensor<br />
* '''Matrix ''' - an arbitrary NxM matrix<br />
These values can be centered on :<br />
* '''Node'''<br />
* '''Edge'''<br />
* '''Face'''<br />
* '''Cell'''<br />
* '''Grid'''<br />
A Grid centered Attribute might be something like "Material Type" where the value is constant everywhere in the grid. Edge and Face centered values are defined, but don\�t map well to many visualization systems. Typically Attributes are assigned on the Node :<br />
'''<Attribute Name="Node Values" Center="Node">'''<br />
'''<DataItem Format="XML" Dimensions="6 4">'''<br />
'''100 200 300 400'''<br />
'''500 600 600 700'''<br />
'''800 900 1000 1100'''<br />
'''1200 1300 1400 1500'''<br />
'''1600 1700 1800 1900'''<br />
'''2000 2100 2200 2300'''<br />
'''</DataItem>'''<br />
'''</Attribute>'''<br />
Or assigned to the cell centers :<br />
'''<Attribute Name="Cell Values" Center="Cell">'''<br />
'''<DataItem Format="XML" Dimensions="3">'''<br />
''' 3000 2000 1000'''<br />
''' </DataItem>'''<br />
'''</Attribute>'''<br />
<br />
'''Information'''<br />
<br />
There is regularly code or system specific information that needs to be stored with the data that does not map to the current data model. There is an ''Information'' element. This is intended for application specific information that can be ignored. A good example might be the bounds of a grid for use in visualization. Information elements have a Name and Value attribute. If Value is nonexistent the value is in the CDATA of the element :<br />
'''<Information Name="XBounds" Value="0.0 10.0"/>'''<br />
'''<Information Name="Bounds"> 0.0 10.0 100.0 110.0 200.0 210.0 </Information>'''<br />
Several items can be addressed using the ''Information'' element like time, units, descriptions, etc. without polluting the XDMF schema. If some of these get used extensively they may be promoted to XDMF elements in the future.</div>128.63.127.201https://www.xdmf.org/index.php?title=XDMF_Model_and_Format&diff=5XDMF Model and Format2007-05-03T14:11:51Z<p>128.63.127.201: New page: <p class=MsoNormal><b><span style='font-size:18.0pt;color:red'>XML</span></b></p> <p class=MsoNormal>The eXtensible Markup Language (XML) format is widely used for many purposes and is w...</p>
<hr />
<div><br />
<p class=MsoNormal><b><span style='font-size:18.0pt;color:red'>XML</span></b></p><br />
<br />
<p class=MsoNormal>The eXtensible Markup Language (XML) format is widely used<br />
for many purposes and is well documented at many sites. There are numerous open<br />
source parsers available for XML. The XDMF API takes advantage of the libxml2<br />
parser to provide the necessary functionality. Without going into too much<br />
detail, XDMF views XML as a &quot;personalized HTML&quot; with some special<br />
rules. It it case sensative and is made of three major components : elements,<br />
entities, and processing information. In XDMF were primarily concerned with<br />
the elements. These elements follow the basic form :</p><br />
<br />
<p class=MsoNormal style='margin-left:.5in'><span style='color:blue'>&lt;ElementTag</span></p><br />
<p class=MsoNormal style='margin-left:1.0in'><span style='color:blue'>AttributeName=&quot;AttribteValue&quot;</span></p><br />
<br />
<p class=MsoNormal style='margin-left:1.0in'><span style='color:blue'>AttributeName=&quot;AttributeValue&quot;</span></p><br />
<br />
<p class=MsoNormal style='margin-left:1.0in'><span style='color:blue'><br />
.. &gt;</span></p><br />
<br />
<p class=MsoNormal style='margin-left:1.5in'><b><i><span style='color:blue'>CData</span></i></b></p><br />
<br />
<p class=MsoNormal style='margin-left:.5in'><span style='color:blue'>&lt;/ElementTag&gt;</span></p><br />
<br />
<p class=MsoNormal>Each element begins with an &lt;tag&gt; and ends with a<br />
&lt;/tag&gt;. Optionally there can be several &quot;Name=Value&quot; pairs<br />
which convey additional information. Between the &lt;tag&gt; and the<br />
&lt;/tag&gt; there can be other &lt;tag&gt;&lt;/tag&gt; pairs and/or character<br />
data (CData). CData is typically where the values are stored; like the actual<br />
text in an HTML document. The XML parser in the XDMF API parses the XML file<br />
and builds an tree structure in memory to describe its contents. This tree can<br />
be queried, modified, and then &quot;serialized&quot; back into XML.</p><br />
<br />
<p class=MsoNormal>&nbsp;</p><br />
<br />
<p class=MsoNormal>Comment in XML start with a &lt;!-- and end with a<br />
--&gt;.� So &lt;!--This is a Comment --&gt;.</p><br />
<br />
<p class=MsoNormal>&nbsp;</p><br />
<br />
<p class=MsoNormal>XML is said to be well formed if it is syntactically<br />
correct. This is all of the quotes match, all elements have end elements, etc.<br />
XML is said to be valid if it conforms to the <i>Schema</i> or <i>DTD</i><br />
defined at the head of the document. For example, the schema might specify that<br />
element type A can contain element B but not element C. Verifying that the<br />
provided XML is well formed and/or valid are functions typically performed by<br />
the XML parser. Additionally XDMF takes advantage of two major extensions to<br />
XML :</p><br />
<br />
<p class=MsoNormal>&nbsp;</p><br />
<br />
<p class=MsoNormal><b>XInclude</b></p><br />
<br />
<p class=MsoNormal>As opposed to entity references in XML(which is a basic<br />
substitution mechanism), XInclude allows for the inclusion of files that are<br />
not well formed XML. This means that with XInclude the included file could be<br />
well formed XML or perhaps a flat text file of values. The syntax looks like<br />
this :</p><br />
<br />
<p class=MsoNormal>&nbsp;</p><br />
<br />
<p class=MsoNormal><b><span style='color:blue'>&lt;Xdmf Version=&quot;2.0&quot;<br />
xmlns:xi=&quot;</span></b><span style='color:blue'><a<br />
href="http://www.w3.org/2001/XInclude"><b><span style='color:blue'>http://www.w3.org/2001/XInclude</span></b></a><b>&quot;&gt;</b></span></p><br />
<br />
<p class=MsoNormal><b><span style='color:blue'>&lt;xi:include<br />
href=&quot;Example3.xmf&quot;/&gt;</span></b></p><br />
<br />
<p class=MsoNormal><b><span style='color:blue'>&lt;/Xdmf&gt;</span></b></p><br />
<br />
<p class=MsoNormal>&nbsp;</p><br />
<br />
<p class=MsoNormal>the xmlns:xi establishes a namespace xi. Then anywhere<br />
within the Xdmf element, xi:include will pull in the URL.</p><br />
<br />
<p class=MsoNormal>&nbsp;</p><br />
<br />
<p class=MsoNormal><b>XPath</b></p><br />
<br />
<p class=MsoNormal>This allows for elements in the XML document and the API to<br />
reference specific elements in a document. For example :</p><br />
<br />
<p class=MsoNormal>&nbsp;</p><br />
<br />
<p class=MsoNormal>The first Grid in the first Domain</p><br />
<br />
<p class=MsoNormal><b><span style='color:blue'>/Xdmf/Domain/Grid</span></b></p><br />
<br />
<p class=MsoNormal>The tenth Grid .... XPath is one based.</p><br />
<br />
<p class=MsoNormal><b><span style='color:blue'>/Xdmf/Domain/Grid[10]</span></b></p><br />
<br />
<p class=MsoNormal>The first grid with an attribute <i>Name</i> which has a<br />
value of <i>Copper Plate</i></p><br />
<br />
<p class=MsoNormal><b><span style='color:blue'>/Xdmf/Domain/Grid[@Name=Copper<br />
Plate]</span></b></p><br />
<br />
<p class=MsoNormal>&nbsp;</p><br />
<br />
<p class=MsoNormal>All valid XDMF must appear between the &lt;Xdmf&gt; and the<br />
&lt;/Xdmf&gt;. So a minimal (empty) XDMF XML file would be :</p><br />
<br />
<p class=MsoNormal>&nbsp;</p><br />
<br />
<p class=MsoNormal><b><span style='color:blue'>&lt;?xml version=&quot;1.0&quot;<br />
?&gt;</span></b></p><br />
<br />
<p class=MsoNormal><b><span style='color:blue'>&lt;!DOCTYPE Xdmf SYSTEM<br />
&quot;Xdmf.dtd&quot; []&gt;</span></b></p><br />
<br />
<p class=MsoNormal><b><span style='color:blue'>&lt;Xdmf Version=2.0&gt;</span></b></p><br />
<br />
<p class=MsoNormal><b><span style='color:blue'>&lt;/Xdmf&gt;</span></b></p><br />
<br />
<p class=MsoNormal><b><span style='color:blue'>&nbsp;</span></b></p><br />
<br />
<p class=MsoNormal>While there exists an Xdmf DTD and a Schema they are only<br />
necessary for validating parsers. For performance reasons, validation is<br />
typically disabled.</p><br />
<br />
<p class=MsoNormal>&nbsp;</p><br />
<br />
<p class=MsoNormal><b><span style='font-size:18.0pt;color:red'>XDMF Elements</span></b></p><br />
<br />
<p class=MsoNormal>&nbsp;</p></div>128.63.127.201https://www.xdmf.org/index.php?title=Main_Page&diff=4Main Page2007-05-03T12:50:09Z<p>128.63.127.201: </p>
<hr />
<div><big>e'''X'''tensible '''D'''ata '''M'''odel and '''F'''ormat</big><br />
<br />
<br />
<br />
The need for a standardized method to exchange scientific data between High Performance Computing codes and tools lead to the development of the eXtensible Data Model and Format (XDMF) . Uses for XDMF range from a standard format used by HPC codes to take advantage of widely used visualization programs like ParaView and EnSight, to a mechanism for performing coupled calculations using multiple, previously stand alone codes. <br />
<br />
XDMF categorizes data by two main attributes; size and function. Data can be Light (typically less than about a thousand values) of Heavy (megabytes, terabytes, etc.). In addition to raw values, data can refer to Format (rank and dimensions of an array) or Model (how that data is to be used. i.e. XYZ coordinates vs. Vector components).<br />
<br />
XDMF uses XML to store Light data and to describe the data Model. HDF5 is used to store Heavy data. The data Format is stored redundantly in both XML and HDF5. This allows tools to parse XML to determine the resources that will be required to access the Heavy data. <br />
<br />
While not required, a C++ API is provided to read and write XDMF data. This API has also been wrapped so it is available from popular languages like Python, Tcl, and Java. The API is not necessary in order to produce or consume XDMF data. Currently several HPC codes that already produced HDF5 data, use native text output to produce the XML necessary for valid XDMF. <br />
<br />
[[XDMF Model and Format]]<br />
<br />
<br />
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list]<br />
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]<br />
* [http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]</div>128.63.127.201https://www.xdmf.org/index.php?title=Main_Page&diff=3Main Page2007-05-03T12:49:51Z<p>128.63.127.201: </p>
<hr />
<div><big>e'''X'''tensible '''D'''ata '''M'''odel and '''F'''ormat</big><br />
<br />
Consult the [http://meta.wikimedia.org/wiki/Help:Contents User's Guide] for information on using the wiki software.<br />
<br />
The need for a standardized method to exchange scientific data between High Performance Computing codes and tools lead to the development of the eXtensible Data Model and Format (XDMF) . Uses for XDMF range from a standard format used by HPC codes to take advantage of widely used visualization programs like ParaView and EnSight, to a mechanism for performing coupled calculations using multiple, previously stand alone codes. <br />
<br />
XDMF categorizes data by two main attributes; size and function. Data can be Light (typically less than about a thousand values) of Heavy (megabytes, terabytes, etc.). In addition to raw values, data can refer to Format (rank and dimensions of an array) or Model (how that data is to be used. i.e. XYZ coordinates vs. Vector components).<br />
<br />
XDMF uses XML to store Light data and to describe the data Model. HDF5 is used to store Heavy data. The data Format is stored redundantly in both XML and HDF5. This allows tools to parse XML to determine the resources that will be required to access the Heavy data. <br />
<br />
While not required, a C++ API is provided to read and write XDMF data. This API has also been wrapped so it is available from popular languages like Python, Tcl, and Java. The API is not necessary in order to produce or consume XDMF data. Currently several HPC codes that already produced HDF5 data, use native text output to produce the XML necessary for valid XDMF. <br />
<br />
[[XDMF Model and Format]]<br />
<br />
<br />
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list]<br />
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]<br />
* [http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]</div>128.63.127.201https://www.xdmf.org/index.php?title=Main_Page&diff=2Main Page2007-05-03T12:44:36Z<p>128.63.127.201: /* Getting started */</p>
<hr />
<div><big>'''MediaWiki has been successfully installed.'''</big><br />
<br />
Consult the [http://meta.wikimedia.org/wiki/Help:Contents User's Guide] for information on using the wiki software.<br />
<br />
The need for a standardized method to exchange scientific data between High Performance Computing codes and tools lead to the development of the eXtensible Data Model and Format (XDMF) . Uses for XDMF range from a standard format used by HPC codes to take advantage of widely used visualization programs like ParaView and EnSight, to a mechanism for performing coupled calculations using multiple, previously stand alone codes. <br />
<br />
XDMF categorizes data by two main attributes; size and function. Data can be Light (typically less than about a thousand values) of Heavy (megabytes, terabytes, etc.). In addition to raw values, data can refer to Format (rank and dimensions of an array) or Model (how that data is to be used. i.e. XYZ coordinates vs. Vector components).<br />
<br />
XDMF uses XML to store Light data and to describe the data Model. HDF5 is used to store Heavy data. The data Format is stored redundantly in both XML and HDF5. This allows tools to parse XML to determine the resources that will be required to access the Heavy data. <br />
<br />
While not required, a C++ API is provided to read and write XDMF data. This API has also been wrapped so it is available from popular languages like Python, Tcl, and Java. The API is not necessary in order to produce or consume XDMF data. Currently several HPC codes that already produced HDF5 data, use native text output to produce the XML necessary for valid XDMF. <br />
<br />
[[XDMF Model and Format]]XdmfFormat.html<br />
<br />
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list]<br />
* [http://www.mediawiki.org/wiki/Help:FAQ MediaWiki FAQ]<br />
* [http://mail.wikimedia.org/mailman/listinfo/mediawiki-announce MediaWiki release mailing list]</div>128.63.127.201