Para-view(or Visit)による非構造格子の可視化のためのXDMFファイル(.xmf)の作成

任意の非構造格子の可視化ファイルを下記に示す。
[visit-users] using hdf5 files with visit (XDMF help)
ここで提供されているサンプルのうち一つに変数を付け加えただけである。

可視化に最低限必要な情報は節点数、要素数、節点座標、各要素が持つ節点の番号のみであり、vtkやplyファイルと同様である。
ただ、可視化できるデータの量は格段に増えている。一度のファイルでほぼ無制限に節点や要素が持つ変数を設置できる。これは普通のvtkファイルだとできなかった(はず)。
変数もスカラー、ベクトルはおろか、テンソルにも対応している。恐ろしい子である。



下記はvtkなどの可視化フォーマットに慣れている人ならばすぐに理解できると思われる。
そうでなくても、xml形式で各変数の意味を説明しているので、下記をひな型に自分の用途に合わせて編集するのは簡単だろう。
Dimensionを定義しているため、数値の改行は本来必要ない。

<?xml version="1.0" ?>
<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []>

<Xdmf>
    <Domain>
        <Grid Name="Mixed">
            <Topology Type="Mixed" NumberOfElements="3" >
                <DataItem Format="XML" DataType="Int" Dimensions="19">
		6   0 1 2 6
		5   3 4 5 6
                9   7 8 9 10 11 12 13 14
                </DataItem>
            </Topology>
            <Geometry Type="XYZ">
                <DataItem Format="XML" Dimensions="15 3">
                0.0    0.0    0.0
                1.0    0.0    0.0
                1.0    1.0    0.0
                0.0    0.0    2.0
                1.0    0.0    2.0
                1.0    1.0    2.0
                0.0    1.0    2.0
                0.0    0.0    3.0
                1.0    0.0    3.0
                1.0    1.0    3.0
                0.0    1.0    3.0
                0.0    0.0    4.0
                1.0    0.0    4.0
                1.0    1.0    4.0
                0.0    1.0    4.0
                </DataItem>
            </Geometry>
            <Attribute Name="NodeScalar" Center="Node">
                <DataItem Format="XML" Dimensions="15">
		 100 200 300 400 500
		 600 600 700 800 900
	     1000 1100 1200 1300 1400
                </DataItem>
	</Attribute>
        <Attribute Name="CellScalar" Center="Cell">
            <DataItem Format="XML" Dimensions="3">
	    	1 2 3 
            </DataItem>
        </Attribute>
        <Attribute Name="NodeVector" AttributeType="Vector" Center="Node">
            <DataItem Format="XML" Dimensions="15 3">
	    	1.0 0.0 0.0 
	    	2.0 0.0 0.0  
	    	3.0 0.0 0.0 
	    	4.0 0.0 0.0
	    	5.0 0.0 0.0
	    	6.0 0.0 0.0
	    	6.0 0.0 0.0
	        7.0 0.0 0.0 
	    	8.0 0.0 0.0
	    	9.0 0.0 0.0
	    	10.0 0.0 0.0
	        11.0 0.0 0.0
	    	12.0 0.0 0.0
	    	13.0 0.0 0.0
	    	14.0 0.0 0.0
            </DataItem>
	</Attribute>
        <Attribute Name="CellVector" AttributeType="Vector" Center="Cell">
            <DataItem Format="XML" Dimensions="3 3">
	    	1 0 0
	    	2 0 0
	    	3 0 0
            </DataItem>
        </Attribute>
        <Attribute Name="NodeTensor" AttributeType="Tensor" Center="Node">
            <DataItem Format="XML" Dimensions="15 9">
	    	1.0 2.0 3.0 1.0 2.0 3.0 1.0 2.0 3.0
	    	2.0 1.0 3.0 1.0 3.0 2.0 1.0 3.0 2.0
	    	3.0 4.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0
	    	4.0 0.0 0.0 4.0 5.0 4.0 4.0 5.0 4.0
	    	5.0 0.0 0.0 1.0 2.0 3.0 1.0 2.0 3.0
	    	6.0 0.0 0.0 1.0 3.0 2.0 1.0 3.0 2.0
	    	6.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
	        7.0 0.0 0.0 4.0 5.0 4.0 4.0 5.0 4.0
	    	8.0 0.0 0.0 1.0 2.0 3.0 1.0 2.0 3.0
	    	9.0 0.0 0.0 1.0 3.0 2.0 1.0 3.0 2.0
	    	1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
	        1.0 0.0 0.0 4.0 5.0 4.0 4.0 5.0 4.0
	    	1.0 0.0 0.0 1.0 2.0 3.0 1.0 2.0 3.0
	    	1.0 0.0 0.0 1.0 3.0 2.0 1.0 3.0 2.0
	    	1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
            </DataItem>      
	</Attribute>
        <Attribute Name="CellTensor" AttributeType="Tensor" Center="Cell">
            <DataItem Format="XML" Dimensions="3 9">
	    	1 0 0 1.0 2.0 3.0 1.0 2.0 3.0
	    	2 0 0 1.0 3.0 2.0 1.0 3.0 2.0
	    	3 0 0 0.0 0.0 0.0 0.0 0.0 0.0
            </DataItem>
       </Attribute>
        <Attribute Name="NodeSymTensor" AttributeType="Tensor6" Center="Node">
            <DataItem Format="XML" Dimensions="15 9">
	    	1.0 2.0 3.0 1.0 2.0 3.0
	    	2.0 1.0 3.0 1.0 3.0 2.0
	    	3.0 4.0 1.0 0.0 0.0 0.0
	    	4.0 0.0 0.0 4.0 5.0 4.0
	    	5.0 0.0 0.0 1.0 2.0 3.0
	    	6.0 0.0 0.0 1.0 3.0 2.0
	    	6.0 0.0 0.0 0.0 0.0 0.0
	        7.0 0.0 0.0 4.0 5.0 4.0
	    	8.0 0.0 0.0 1.0 2.0 3.0
	    	9.0 0.0 0.0 1.0 3.0 2.0
	    	1.0 0.0 0.0 0.0 0.0 0.0
	        1.0 0.0 0.0 4.0 5.0 4.0
	    	1.0 0.0 0.0 1.0 2.0 3.0
	    	1.0 0.0 0.0 1.0 3.0 2.0
	    	1.0 0.0 0.0 0.0 0.0 0.0
            </DataItem>      
	</Attribute>
        <Attribute Name="CellSymTensor" AttributeType="Tensor6" Center="Cell">
            <DataItem Format="XML" Dimensions="3 9">
	    	1 0 0 1.0 2.0 3.0
	    	2 0 0 1.0 3.0 2.0
	    	3 0 0 0.0 0.0 0.0
            </DataItem>
       </Attribute>
        </Grid>
    </Domain>
</Xdmf>

上のxmlを可視化したものが以下。二階のテンソルを入力しているので、次元が9つある。

f:id:bigvalley:20151101175758p:plain

要素の定義として、要素の種類を番号で設定する必要がある(6:四面体,5:四角形,9:六面体)が、下記の公式サイトにはその資料が見つからなかった。
XdmfWeb

調べたところ、XDMFをさらに拡張したフォーマットを提供しているグループが説明書きを書いてくれていた。
Separated Variables Representation Visualisation | Reduced Order Modeling


上記サイトで提供しているpdfファイルに細かく書いてある。

なお、データ数が増加する場合はxml形式に変数をべた書きするのではなく、
hdf5ファイルなどの外部ファイルにバイナリ形式でまとめたほうが、データの扱いとしてスマートだし可視化速度も速いと思う。

上記は簡単な例だけども、xmlの書き方次第でマルチドメインにも簡単に対応できる。