# vthb file structure

**URL:** https://discourse.paraview.org/t/vthb-file-structure/7224
**Category:** ParaView Support
**Tags:** vtk
**Created:** [May 13, 2021, 3:33pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224 "2021-05-13T15:33:55Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![henry2004y](https://discourse.paraview.org/user_avatar/discourse.paraview.org/henry2004y/32/2296_2.png) [@henry2004y](https://discourse.paraview.org/u/henry2004y)
#### Post date: [May 13, 2021, 3:33pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/1 "2021-05-13T15:33:55Z")

</div>

Hi,

I am learning about the structure of the VTK AMR file with suffix .vthb. As I now understand it, the top level meta data with \*.vthb contains the base grid information, and the refined AMR boxes on each subsequent level:

```auto
<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_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_1.vti"/>
      <DataSet index="1" amr_box="6 9 4 9 0 -1" file="test_2.vti"/>
    </Block>
  </vtkOverlappingAMR>
</VTKFile>

```

Then each child file with \*.vti is just regular image files on a structured grid.

However, I am not sure is this is efficient in handling many small image files. For example, if the refined cells are distributed in an irregular shape (e.g. figure 9 in [visualization-analysis-of-amr-datasets](https://blog.kitware.com/visualization-analysis-of-amr-datasets/)), theoretically there will be a lot of small file pieces. I am wondering if anyone has any experience in handling this kind of AMR dataset, and to what extent can it work properly?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 14, 2021, 8:26am UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/2 "2021-05-14T08:26:04Z")

</div>

With overlapping AMR, the number of images files can easilly be kept small. You can basically have one image by level of rafinement. Just blank the voxel that you consider not defined in a level of rafinement.

---

<div class="post-metadata">

### Author: ![henry2004y](https://discourse.paraview.org/user_avatar/discourse.paraview.org/henry2004y/32/2296_2.png) [@henry2004y](https://discourse.paraview.org/u/henry2004y)
#### Post date: [May 14, 2021, 9:02am UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/3 "2021-05-14T09:02:21Z")

</div>

Here is an example level 0 image file:

```auto
<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="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>

```

Do you mean that we can take advantage of this `vtkGhostType` UInt8 array to specify whether or not a cell has been refined? For this image file to be valid, I still need to provide some data to these cells even if they are refined right, as been shown here by the `Gaussian-Pulse` Float64 array?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 14, 2021, 9:07am UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/4 "2021-05-14T09:07:46Z")

</div>

> [@henry2004y](#):
>
> array to specify whether or not a cell has been refined?

Yes, non refined cell should still be present in the refined layer but set as blank.

> I still need to provide some data to these cells even if they are refined right, as been shown here by the `Gaussian-Pulse` Float64 array?

Absolutely.

This is the tradeoff of overlapping vs non-overlapping AMR.

---

<div class="post-metadata">

### Author: ![henry2004y](https://discourse.paraview.org/user_avatar/discourse.paraview.org/henry2004y/32/2296_2.png) [@henry2004y](https://discourse.paraview.org/u/henry2004y)
#### Post date: [May 14, 2021, 10:57am UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/5 "2021-05-14T10:57:54Z")

</div>

Btw, do we have a non-overlapping AMR class?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 14, 2021, 12:21pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/6 "2021-05-14T12:21:19Z")

</div>

of course. A vthb can contains a overlapping or non-overlapping amr. I can provide example dataset if needed.

---

<div class="post-metadata">

### Author: ![henry2004y](https://discourse.paraview.org/user_avatar/discourse.paraview.org/henry2004y/32/2296_2.png) [@henry2004y](https://discourse.paraview.org/u/henry2004y)
#### Post date: [May 15, 2021, 6:09pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/7 "2021-05-15T18:09:20Z")

</div>

I am having some issues blanking cells on the finest AMR level. I tried to follow your suggestion by creating one image file per level, using `vtkGhostType` described in [ghost-and-blanking-visibility-changes](https://blog.kitware.com/ghost-and-blanking-visibility-changes/) and defined in [vtkDataSetAttributes](https://vtk.org/doc/nightly/html/vtkDataSetAttributes_8h_source.html) to blank the cells. Each image file covers the same simulation domain, but with different resolutions. However, somehow ParaView couldn’t recognize that certain cells on the finest refinement level do not exist, and the `vtkGhostType` values shown in the Information panel did not match the values in the image file.

Here are the sample files I am talking about.  
[my2d.vthb](https://discourse.paraview.org/uploads/short-url/2pa6M3E2W0PgV1wMtPD5laE9xvS.vthb) (443 Bytes)  
[test\_0.vti](https://discourse.paraview.org/uploads/short-url/bFn0dte5v6NSQpDAanD7b4UQMQw.vti) (1.2 KB) [test\_1.vti](https://discourse.paraview.org/uploads/short-url/mPWWoSbIFC7ki3uPrw89EZdAwRD.vti) (3.2 KB)

Where am I doing wrong? How should I use `vtkGhostType` properly?

In the VTK repository, I found this [AMR visibility test for XYZ](https://github.com/Kitware/VTK/blob/6a9c565da01bcd6295d0bcbb66c0a9d0d2eaa69e/Filters/AMR/Testing/Cxx/TestAMRBlanking.cxx#L133), but it is not clear to me how the visibility is handled.

1. It seems like visibility is set by the `BlankCells` method in [vtkParallelAMRUtilities.cxx](https://github.com/Kitware/VTK/blob/6a9c565da01bcd6295d0bcbb66c0a9d0d2eaa69e/Filters/AMR/vtkParallelAMRUtilities.cxx#L126). But somehow I couldn’t find where the internal function [Search · BlankGridsAtLevel (github.com)](https://github.com/Kitware/VTK/search?q=BlankGridsAtLevel) in the loop over AMR level is defined.
2. In the XYZ test setup

```auto
      // Root block
      origin[0] = origin[1] = origin[2] = 0.0;
      spacing[0] = spacing[1] = spacing[2] = 1.0;
      ndims[0] = ndims[1] = ndims[2] = 4;
      gridPtr = GetGrid(origin, spacing, ndims);
      box = vtkAMRBox(origin, ndims, spacing, amrDataSet->GetOrigin(), description);
      amrDataSet->SetSpacing(0, spacing);
      amrDataSet->SetAMRBox(0, 0, box);
      amrDataSet->SetDataSet(0, 0, gridPtr);
      gridPtr->Delete();

      // Refined patch that covers entire root domain
      origin[0] = origin[1] = origin[2] = 0.0;
      spacing[0] = spacing[1] = spacing[2] = 0.5;
      ndims[0] = ndims[1] = ndims[2] = 6;
      gridPtr = GetGrid(origin, spacing, ndims);
      box = vtkAMRBox(origin, ndims, spacing, amrDataSet->GetOrigin(), description);
      amrDataSet->SetSpacing(1, spacing);
      amrDataSet->SetAMRBox(1, 0, box);
      amrDataSet->SetDataSet(1, 0, gridPtr);
      gridPtr->Delete();

```

Why does the refined patch covers the entire root domain given `ndims` on the level 6 and `spacing` 0.5, while in the root level `ndims` is 4 and `spacing` is 1.0?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 17, 2021, 8:10am UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/8 "2021-05-17T08:10:17Z")

</div>

I’d suggest using a nightly version of ParaView first, I’ve made some fixes recently.

---

<div class="post-metadata">

### Author: ![henry2004y](https://discourse.paraview.org/user_avatar/discourse.paraview.org/henry2004y/32/2296_2.png) [@henry2004y](https://discourse.paraview.org/u/henry2004y)
#### Post date: [May 17, 2021, 8:17am UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/9 "2021-05-17T08:17:15Z")

</div>

The version I was using is ParaView v5.9.0.

Now I am testing on the nightly build of ParaView v5.9.1. Indeed I can see the changes reading the same file I posted:

- On the coarse level, those cells with `vtkGhostType==0` are not displayed anymore (which is actually a bit of strange since this is supposed to be `vtkOverlappingAMR`)
- On the fine level, I still cannot visualize the coarse cells that are denoted with `vtkGhostType!=0` correctly. I tried UInt8 values 8, 16, and 32.

How should I proceed @mwestphal ?

I find this [description of AMR dataset](https://docs.paraview.org/en/latest/UsersGuide/understandingData.html#amr-dataset) in the documentation. It would be great to have some more sample data that we can play with.

---

<div class="post-metadata">

### Author: ![Nic](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/45deac/32.png) [@Nic](https://discourse.paraview.org/u/Nic)
#### Post date: [September 21, 2021, 12:49pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/10 "2021-09-21T12:49:01Z")

</div>

My apologies for bumping this thread, would it be possible to get an example dataset for non-overlapping amr?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [September 21, 2021, 1:34pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/11 "2021-09-21T13:34:38Z")

</div>

[spcth.0](https://discourse.paraview.org/uploads/short-url/nDUxqt3rH7AIZevfiaQEiBTlxiK.0) (2.1 MB)

---

<div class="post-metadata">

### Author: ![Nic](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/45deac/32.png) [@Nic](https://discourse.paraview.org/u/Nic)
#### Post date: [September 21, 2021, 1:36pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/12 "2021-09-21T13:36:39Z")

</div>

Thank you very much. Is that similar to a vtkNonOverlappingAMR xml file?  
(Edit: if that’s a thing)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [September 21, 2021, 1:39pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/13 "2021-09-21T13:39:39Z")

</div>

Here is the .vthb version (XML VTK File format)

[vthb.zip](https://discourse.paraview.org/uploads/short-url/ko7shn4pYp0tz6Rb7JR0HTFSAWL.zip) (56.3 KB)

---

<div class="post-metadata">

### Author: ![Nic](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/45deac/32.png) [@Nic](https://discourse.paraview.org/u/Nic)
#### Post date: [September 21, 2021, 1:40pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/14 "2021-09-21T13:40:28Z")

</div>

That is extremely useful, thank you!

---

<div class="post-metadata">

### Author: ![nikic](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/94ad74/32.png) [@nikic](https://discourse.paraview.org/u/nikic)
#### Post date: [September 21, 2021, 2:39pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/15 "2021-09-21T14:39:17Z")

</div>

Hi @mwestphal - thank you for sharing the .vthb set of data

I’m finding I can only visualize the block level=“0” set of vtis, is there an obvious/known explanation for this?

(I’ve tried replacing other levels with a level 0 tag, in which case only the last block of level 0 is shown. Happy to explain further if necessary.)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [September 21, 2021, 2:44pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/16 "2021-09-21T14:44:42Z")

</div>

Set the default number of levels to 5 ?

---

<div class="post-metadata">

### Author: ![nikic](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/94ad74/32.png) [@nikic](https://discourse.paraview.org/u/nikic)
#### Post date: [September 21, 2021, 2:46pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/17 "2021-09-21T14:46:08Z")

</div>

ah yes that did the trick, thanks!

---

<div class="post-metadata">

### Author: ![Nic](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/n/45deac/32.png) [@Nic](https://discourse.paraview.org/u/Nic)
#### Post date: [September 21, 2021, 3:50pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/18 "2021-09-21T15:50:53Z")

</div>

Last one, is NonOverlappingAMR compatible with Volume Rendering?  
Your first example (spcth.0) and the next one seem to fail (PV 5.9.1) with:

> ERROR: In C:\glr\builds\paraview\paraview-ci\build\superbuild\paraview\src\VTK\Common\ExecutionModel\vtkCompositeDataPipeline.cxx, line 154  
> vtkPVDataRepresentationPipeline (0000021E16F58090): Can not execute simple algorithm without output ports

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [September 21, 2021, 3:55pm UTC](https://discourse.paraview.org/t/vthb-file-structure/7224/19 "2021-09-21T15:55:37Z")

</div>

Not yet.
