# Using meshes with tallies

**URL:** <https://openmc.discourse.group/t/using-meshes-with-tallies/1585>\
**Category:** User Support\
**Created:** [December 6, 2021, 7:35pm UTC](https://openmc.discourse.group/t/using-meshes-with-tallies/1585 "2021-12-06T19:35:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rherner](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rherner](https://openmc.discourse.group/u/rherner)\
**Post date:** [December 6, 2021, 7:35pm UTC](https://openmc.discourse.group/t/using-meshes-with-tallies/1585/1 "2021-12-06T19:35:49Z")

</div>

Hello all,

What’s the process and syntax needed to make a tally work with a specific mesh? Like if I wanted to create a rectangular mesh and have a heating tally taken at each of the specific mesh points, who would that look in the input file?

I’ve been trying to define specific meshes to feed into tallies and vice versa but keep getting errors, I’d like to keep this as simple a mesh tally as possible, any feedback would be great.

Regards,

---

<div class="post-metadata">

**Author:** ![mkreher13](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/mkreher13/32/4093_2.png) [@mkreher13](https://openmc.discourse.group/u/mkreher13)\
**Post date:** [December 6, 2021, 8:21pm UTC](https://openmc.discourse.group/t/using-meshes-with-tallies/1585/2 "2021-12-06T20:21:22Z")

</div>

Hello! Once you create the mesh (`my_mesh`) and the tally (`my_tally`), you can create a mesh\_filter and add it to the tally like this:  
`mesh_filter = openmc.MeshFilter(my_mesh)`  
`my_tally.filters.append(mesh_filter)`

---

<div class="post-metadata">

**Author:** ![rherner](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rherner](https://openmc.discourse.group/u/rherner)\
**Post date:** [December 6, 2021, 10:38pm UTC](https://openmc.discourse.group/t/using-meshes-with-tallies/1585/3 "2021-12-06T22:38:11Z")

</div>

Thank you this is very helpful, it’s much easier in my troubleshooting when I can see a visual like this. When we input this new form in we’re going a series of 0 values for our heating tally, I still need to check some things but if our system is critical and a single heating tally gives a nonzero answer that shouldn’t be the case correct?

---

<div class="post-metadata">

**Author:** ![mkreher13](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/mkreher13/32/4093_2.png) [@mkreher13](https://openmc.discourse.group/u/mkreher13)\
**Post date:** [December 7, 2021, 12:05am UTC](https://openmc.discourse.group/t/using-meshes-with-tallies/1585/4 "2021-12-07T00:05:20Z")

</div>

If you are getting all zeros, you probably have a problem with the mesh. Make sure it covers the fuel region!

---

<div class="post-metadata">

**Author:** ![Shimwell](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/shimwell/32/3876_2.png) [@Shimwell](https://openmc.discourse.group/u/Shimwell)\
**Post date:** [December 8, 2021, 5:00pm UTC](https://openmc.discourse.group/t/using-meshes-with-tallies/1585/5 "2021-12-08T17:00:50Z")

</div>

Looks like you have everything needed, but just in case here is an example of a 2d mesh tally [here](https://github.com/fusion-energy/neutronics-workshop/blob/main/tasks/task_08_CSG_mesh_tally/1_example_2d_mesh_tallies.ipynb)  
and a 3d mesh tally [here](https://github.com/fusion-energy/neutronics-workshop/blob/main/tasks/task_08_CSG_mesh_tally/2_example_3d_mesh_tallies.ipynb)

Also if you are wanting to convert the regular mesh tally to a VTK file for visualization in software like Paraview or Visit then you might find this [minimal python package](https://github.com/fusion-energy/openmc_mesh_tally_to_vtk) handy
