# Do AMR writers create a file for each AMRBox/block?

**URL:** https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788
**Category:** ParaView Support
**Created:** [October 25, 2018, 1:34am UTC](https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788 "2018-10-25T01:34:05Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Aandreyev](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@Aandreyev](https://discourse.paraview.org/u/Aandreyev)
#### Post date: [October 25, 2018, 1:34am UTC](https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788/1 "2018-10-25T01:34:05Z")

</div>

Hello all,

I am trying to make our AMR code write out a data format that paraview understands natively without having to convert to an unstructured grid. The AMR code does have the 2:1 refinement restriction usual to AMR and it seems like vtkXMLPHierarchicalBoxDataWriter is the only option. However after playing around with it (and the overlapping AMR analog) it seems that this writer ends up writing and xml file for each amrbox. Given that I can have up to 300,000 of them, writing a file for each one does not seem feasible. Is there something I am missing/not understanding in the process, or will I just need to write my own reader?

Thank you all in advance,  
Andrey

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.paraview.org/user_avatar/discourse.paraview.org/banesullivan/32/11714_2.png) [@banesullivan](https://discourse.paraview.org/u/banesullivan)
#### Post date: [October 26, 2018, 5:22am UTC](https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788/2 "2018-10-26T05:22:00Z")

</div>

> [@Aandreyev](#):
>
> or will I just need to write my own reader?

I am unfamiliar with the AMR datasets/file types but if you decide to create your own reader, it isn’t all that difficult using ParaView 5.6’s new [Python Algorithm plugin capability](https://gitlab.kitware.com/paraview/paraview/blob/master/Examples/Plugins/PythonAlgorithm/PythonAlgorithmExamples.py).

Check out [this post](https://discourse.paraview.org/t/how-to-get-block-indexes-in-python/797/2) and [this snippet](https://github.com/OpenGeoVis/PVGeo/blob/master/snippets/PV_Composite_Writer.py) from [**PVGeo**](http://pvgeo.org) for details on making your own file writers!

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [October 26, 2018, 1:35pm UTC](https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788/3 "2018-10-26T13:35:07Z")

</div>

I indeed wouldn’t recommend `vtkXMLPHierarchicalBoxDataWriter` for large data at scale – at least the way it is currently. ParaView can read in BoxLib (and soon AMReX), Flash AMR files as well. Maybe that’d be better approach.

---

<div class="post-metadata">

### Author: ![Aandreyev](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@Aandreyev](https://discourse.paraview.org/u/Aandreyev)
#### Post date: [October 26, 2018, 2:24pm UTC](https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788/4 "2018-10-26T14:24:25Z")

</div>

Thank you for the response. Do you by any chance have an example Flash AMR file that I can use as a reference? I may still go to the personal reader route, but it would be nice to have two options.

---

<div class="post-metadata">

### Author: ![Aandreyev](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@Aandreyev](https://discourse.paraview.org/u/Aandreyev)
#### Post date: [October 26, 2018, 6:31pm UTC](https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788/5 "2018-10-26T18:31:45Z")

</div>

Thank you Bane,

If I can create a reader in python that would be great. And I looked over the example and it looks fairly straight forward, but one question…

—Once I write the reader, what are the steps to actually plug it into Paraview so I can open a file and read it using that reader?

Thank you in advance

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.paraview.org/user_avatar/discourse.paraview.org/banesullivan/32/11714_2.png) [@banesullivan](https://discourse.paraview.org/u/banesullivan)
#### Post date: [October 26, 2018, 7:42pm UTC](https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788/6 "2018-10-26T19:42:04Z")

</div>

If you follow the example in that snippet, then simply load the `.py` file as a plugin to **ParaView 5.6** (won’t work on older versions) through the plugin manager.

Tools -\> Plugin Manager -\> Load New…

Also, to be clear, are you making a reader or a writer? That snippet explains the writers. Readers are a bit more straightforward but I could provide another example from [**PVGeo**](http://pvgeo.org) if needed

---

<div class="post-metadata">

### Author: ![Aandreyev](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@Aandreyev](https://discourse.paraview.org/u/Aandreyev)
#### Post date: [October 26, 2018, 7:52pm UTC](https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788/7 "2018-10-26T19:52:46Z")

</div>

I’m only writing a reader for now. And that is easy! Thank you!

---

<div class="post-metadata">

### Author: ![Aandreyev](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@Aandreyev](https://discourse.paraview.org/u/Aandreyev)
#### Post date: [October 26, 2018, 8:21pm UTC](https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788/8 "2018-10-26T20:21:49Z")

</div>

Actually one more question now that I think about it. And thank you for all the help, btw. If I need this reader to work with client/server, is there another step that I need?

Thank you!

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.paraview.org/user_avatar/discourse.paraview.org/banesullivan/32/11714_2.png) [@banesullivan](https://discourse.paraview.org/u/banesullivan)
#### Post date: [October 26, 2018, 9:19pm UTC](https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788/9 "2018-10-26T21:19:04Z")

</div>

I’m not too sure… I think @utkarsh.ayachit would be the expert on that

---

<div class="post-metadata">

### Author: ![Aandreyev](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@Aandreyev](https://discourse.paraview.org/u/Aandreyev)
#### Post date: [November 20, 2018, 11:07pm UTC](https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788/10 "2018-11-20T23:07:12Z")

</div>

Hi @banesullivan, I think I’m close to getting a basic version going, but whenever I load it into paraview, I get an error message that reads like this: “is either not designed to run on windows or it contains an error”. However I have basic script that seems to work outside of paraview. I believe that I have followed the steps minus all the time stamp issue since I’m not worried about that at the moment.

The test case is very simple, it’s just a dummy AMR file that I’m trying to make paraview see. Do you see anything glaringly wrong about the approach (attached) since you’re very knowledgeable on the topic?

We’ve done something similar with some XDMF modifications, but since the error gives no hint as to what the problem is, this is hard to debug.

Thank you in advance.

[corvidAMRReader\_r1.py](https://discourse.paraview.org/uploads/default/original/1X/7b0873875429da6b8a1f9baeb89c3d30abd977f1.py) (5.5 KB)  
[vamr\_reader\_test.py](https://discourse.paraview.org/uploads/default/original/1X/9e1cf651ab330ba218373ea1ffb8182e0c628246.py) (526 Bytes)

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.paraview.org/user_avatar/discourse.paraview.org/banesullivan/32/11714_2.png) [@banesullivan](https://discourse.paraview.org/u/banesullivan)
#### Post date: [November 22, 2018, 4:51am UTC](https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788/11 "2018-11-22T04:51:44Z")

</div>

Double check that `h5py` is available in your Python environment. Unfortunately, simple import errors/typos can cause the message your seeing.

I’ve never been able to get the `h5py` package to work in ParaView…  
I usually try to use lighter weight alternatives for handling h5 files, but if you build ParaView yourself you can get `h5py` in there… @Daan_van_Vugt has experience with this I think?

Otherwise it looks good to me (though I am working remotely via an iPad and can’t give it a try for a few days)

---

<div class="post-metadata">

### Author: ![Aandreyev](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@Aandreyev](https://discourse.paraview.org/u/Aandreyev)
#### Post date: [November 26, 2018, 4:59pm UTC](https://discourse.paraview.org/t/do-amr-writers-create-a-file-for-each-amrbox-block/788/12 "2018-11-26T16:59:33Z")

</div>

Thanks Bane! Yeah it seems that pvpython does not have h5py in it, so the solution seems to be install paraview with the system python. @utkarsh.ayachit, is there any thing on the horizon to have h5py included in pvpython?

Thank you for all your help guys!
