# How to structure xdfm file to visualize arbitrary number of vector components in Paraview?

**URL:** https://discourse.paraview.org/t/how-to-structure-xdfm-file-to-visualize-arbitrary-number-of-vector-components-in-paraview/13288
**Category:** ParaView Support
**Created:** [November 20, 2023, 3:04pm UTC](https://discourse.paraview.org/t/how-to-structure-xdfm-file-to-visualize-arbitrary-number-of-vector-components-in-paraview/13288 "2023-11-20T15:04:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Krzysztof\_Stopka](https://discourse.paraview.org/user_avatar/discourse.paraview.org/krzysztof_stopka/32/7828_2.png) [@Krzysztof\_Stopka](https://discourse.paraview.org/u/Krzysztof_Stopka)
#### Post date: [November 20, 2023, 3:04pm UTC](https://discourse.paraview.org/t/how-to-structure-xdfm-file-to-visualize-arbitrary-number-of-vector-components-in-paraview/13288/1 "2023-11-20T15:04:40Z")

</div>

Hello,

I am using simulation code that writes local micromechanical response variables to an .h5 file that I then visualize in ParaView using an xdmf file. Some of the response variables have three components (in the X, Y, and Z directions, for example) and some are tensors (such as stress and strain, which contain either 6 or 9 components depending on how they are written to the .h5 file and whether they are symmetric). However, I have other state variables from the simulation that I would like to visualize, and these may have an arbitrary number of components. For example, in an FCC crystal structure, I would like to visualize the 12 components of resolved shear stress on the 12 unique slip systems at each point.

I see that the xdmf documentation has five options for the `AttributeType` which includes `Scalar, Vector, Tensor, Tensor6, and Matrix` [XDMF Attribute type options.](https://www.xdmf.org/index.php/Xdmf2_Model_and_Format_Archive) It is obvious which `AttributeType` I should use for the micromechanical variables with 3, 6, or 9 components (e.g., `Vector`, `Tensor6`, and `Tensor`, respectively. However, I am unsure how to format the .xdmf file to visualize a variable with 12 components.

An example of my `.xdmf` script is shown below for a model with 128 x 128 x 128 voxels. The variables `gamma_accum` and `tau_0` each have 12 components that I would like to visualize. Is there an easy way to visualize these? Do I perhaps need to specify `AttributeType` of `Matrix` and then add another line somewhere? Everything I have tried thus far produces incorrect results and it is evident that the script is unsure how to read in the data for ParaView.

Thank you in advance for your help. I also apologize if this question is beyond the scope of this help forum.

Best regards,  
Kris

Krzysztof Stopka

```auto
<?xml version="1.0"?>
<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd"[]>
<Xdmf xmlns:xi="http://www.w3.org/2003/XInclude" Version="2.2">
 <Domain>
 
  <Grid Name="Cell Data" GridType="Uniform">
    <Topology TopologyType="3DCoRectMesh" Dimensions="129 129 129"></Topology>
    <Geometry Type="ORIGIN_DXDYDZ">
      <!-- Origin -->
      <DataItem Format="XML" Dimensions="3">0 0 0</DataItem>
      <!-- DxDyDz (Spacing/Resolution)-->
      <DataItem Format="XML" Dimensions="3">1 1 1</DataItem>
    </Geometry>
 
      <Attribute Name="displ_grad" AttributeType="Tensor" Center="Cell">
      <DataItem Format="HDF" Dimensions="128 128 128 9" NumberType="H5T_FLOAT" Precision="4" >
       SEM_128_128_128_64_core_result_cycle_000014_240min_VTK.h5:/cycle_000014_240min/displ_grad
      </DataItem>
       </Attribute>
 
 
      <Attribute Name="gamma_accum" AttributeType="Vector" Center="Cell">
      <DataItem Format="HDF" Dimensions="128 128 128 12" NumberType="H5T_FLOAT" Precision="4" >
       SEM_128_128_128_64_core_result_cycle_000014_240min_VTK.h5:/cycle_000014_240min/gamma_accum
      </DataItem>
       </Attribute>
 
 
      <Attribute Name="phase" AttributeType="Scalar" Center="Cell">
      <DataItem Format="HDF" Dimensions="128 128 128 1" NumberType="H5T_INTEGER" Precision="1" >
       SEM_128_128_128_64_core_result_cycle_000014_240min_VTK.h5:/cycle_000014_240min/phase
      </DataItem>
       </Attribute>
 
 
      <Attribute Name="strain_el" AttributeType="Tensor6" Center="Cell">
      <DataItem Format="HDF" Dimensions="128 128 128 6" NumberType="H5T_FLOAT" Precision="4" >
       SEM_128_128_128_64_core_result_cycle_000014_240min_VTK.h5:/cycle_000014_240min/strain_el
      </DataItem>
       </Attribute>
 
 
      <Attribute Name="strain_pl" AttributeType="Tensor6" Center="Cell">
      <DataItem Format="HDF" Dimensions="128 128 128 6" NumberType="H5T_FLOAT" Precision="4" >
       SEM_128_128_128_64_core_result_cycle_000014_240min_VTK.h5:/cycle_000014_240min/strain_pl
      </DataItem>
       </Attribute>
 
 
      <Attribute Name="stress" AttributeType="Tensor6" Center="Cell">
      <DataItem Format="HDF" Dimensions="128 128 128 6" NumberType="H5T_FLOAT" Precision="4" >
       SEM_128_128_128_64_core_result_cycle_000014_240min_VTK.h5:/cycle_000014_240min/stress
      </DataItem>
       </Attribute>
 
 
      <Attribute Name="tau_0" AttributeType="Vector" Center="Cell">
      <DataItem Format="HDF" Dimensions="128 128 128 12" NumberType="H5T_FLOAT" Precision="4" >
       SEM_128_128_128_64_core_result_cycle_000014_240min_VTK.h5:/cycle_000014_240min/tau_0
      </DataItem>
       </Attribute>
 
  </Grid>
    <!-- ***************END OF Cell Data*************** -->
 
 </Domain>
</Xdmf>

```

---

<div class="post-metadata">

### Author: ![Krzysztof\_Stopka](https://discourse.paraview.org/user_avatar/discourse.paraview.org/krzysztof_stopka/32/7828_2.png) [@Krzysztof\_Stopka](https://discourse.paraview.org/u/Krzysztof_Stopka)
#### Post date: [March 20, 2024, 7:44pm UTC](https://discourse.paraview.org/t/how-to-structure-xdfm-file-to-visualize-arbitrary-number-of-vector-components-in-paraview/13288/2 "2024-03-20T19:44:06Z")

</div>

Hello all,

I just wanted to post an update that specifying `AttributeType` as `Matrix` will fix this issue, i.e., it will allow ParaView to read in the data and allow the user to view any of the 12 components (12 for my specific example).

Best regards,  
Krzysztof Stopka

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [March 20, 2024, 8:14pm UTC](https://discourse.paraview.org/t/how-to-structure-xdfm-file-to-visualize-arbitrary-number-of-vector-components-in-paraview/13288/3 "2024-03-20T20:14:07Z")

</div>

Thanks for reporting back on this, @Krzysztof_Stopka !
