JuliaVTK / WriteVTK.jl

Julia package for writing VTK XML files
Other
150 stars 32 forks source link

Formats for AMR dataset? #77

Open henry2004y opened 3 years ago

henry2004y commented 3 years ago

Hello,

Do you know if it is possible to generate any AMR-based VTK file formats? The data I have is organized in a block-based AMR format, but I have little knowledge of how VTK handles AMR datasets. It would be great if there exists a proper format already and I can convert to that.

henry2004y commented 3 years ago

As a reference, this is an example in C++ for writing a 2D AMR dataset.

I have found some interesting stuff. In ParaView 5.9, there is a AMR GaussianPulse Source which allows you to generate a sample AMR data. Here I create a 2D pulse. This can then be stored in this *.vthb file, which looks like

<VTKFile type="vtkOverlappingAMR" version="1.1" byte_order="LittleEndian" header_type="UInt64">
  <vtkOverlappingAMR origin="-2 -2 0" grid_description="XY">
    <Block level="0" spacing="0.5 0.5 0.5">
      <DataSet index="0" amr_box="0 4 0 4 0 -1" file="test/test_0.vti"/>
    </Block>
    <Block level="1" spacing="0.25 0.25 0.5">
      <DataSet index="0" amr_box="0 3 0 5 0 -1" file="test/test_1.vti"/>
      <DataSet index="1" amr_box="6 9 4 9 0 -1" file="test/test_2.vti"/>
    </Block>
  </vtkOverlappingAMR>
</VTKFile>

Each linked .vti file is just a standard image file like (test/test_0.vti)

<VTKFile type="ImageData" version="2.2" byte_order="LittleEndian" header_type="UInt64">
  <ImageData WholeExtent="0 5 0 5 0 0" Origin="-2 -2 0" Spacing="0.5 0.5 0.5" Direction="1 0 0 0 1 0 0 0 1">
  <Piece Extent="0 5 0 5 0 0">
    <PointData>
    </PointData>
    <CellData>
      <DataArray type="Float64" Name="Centroid" NumberOfComponents="3" format="ascii" RangeMin="0.3535533905932738" RangeMax="2.4748737341529163">
        -1.75 -1.75 0 -1.25 -1.75 0
        -0.75 -1.75 0 -0.25 -1.75 0
        0.25 -1.75 0 -1.75 -1.25 0
        -1.25 -1.25 0 -0.75 -1.25 0
        -0.25 -1.25 0 0.25 -1.25 0
        -1.75 -0.75 0 -1.25 -0.75 0
        -0.75 -0.75 0 -0.25 -0.75 0
        0.25 -0.75 0 -1.75 -0.25 0
        -1.25 -0.25 0 -0.75 -0.25 0
        -0.25 -0.25 0 0.25 -0.25 0
        -1.75 0.25 0 -1.25 0.25 0
        -0.75 0.25 0 -0.25 0.25 0
        0.25 0.25 0
        <InformationKey name="L2_NORM_FINITE_RANGE" location="vtkDataArray" length="2">
          <Value index="0">
            0.35355339059
          </Value>
          <Value index="1">
            2.4748737342
          </Value>
        </InformationKey>
        <InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
          <Value index="0">
            0.35355339059
          </Value>
          <Value index="1">
            2.4748737342
          </Value>
        </InformationKey>
      </DataArray>
      <DataArray type="Float64" Name="Gaussian-Pulse" format="ascii" RangeMin="1.1448674228227765e-11" RangeMax="0.3032653298563167">
        1.1448674228227765e-11 4.618724830985297e-9 2.52173831283944e-7 0.0000018633265860393355 0.0000018633265860393355 4.618724830985297e-9
        0.0000018633265860393355 0.00010173418450532208 0.0007517195964887862 0.0007517195964887862 2.52173831283944e-7 0.00010173418450532208
        0.005554498269121153 0.0410424993119494 0.0410424993119494 0.0000018633265860393355 0.0007517195964887862 0.0410424993119494
        0.3032653298563167 0.3032653298563167 0.0000018633265860393355 0.0007517195964887862 0.0410424993119494 0.3032653298563167
        0.3032653298563167
      </DataArray>
      <DataArray type="UInt8" Name="vtkGhostType" format="ascii" RangeMin="0" RangeMax="8">
        8 8 0 0 0 8
        8 0 0 0 8 8
        0 8 8 0 0 0
        8 8 0 0 0 8
        8
      </DataArray>
    </CellData>
  </Piece>
  </ImageData>
</VTKFile>

This indicates that in principle we can generate AMR dataset once we understand how those amr_box are organized.