# Paraview to visualize a field like in the tutorial

**URL:** <https://fenicsproject.discourse.group/t/paraview-to-visualize-a-field-like-in-the-tutorial/4846>\
**Category:** I/O\
**Created:** [January 6, 2021, 2:09pm UTC](https://fenicsproject.discourse.group/t/paraview-to-visualize-a-field-like-in-the-tutorial/4846 "2021-01-06T14:09:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![raboynics](https://avatars.discourse-cdn.com/v4/letter/r/4bbf92/32.png) [@raboynics](https://fenicsproject.discourse.group/u/raboynics)\
**Post date:** [January 6, 2021, 2:09pm UTC](https://fenicsproject.discourse.group/t/paraview-to-visualize-a-field-like-in-the-tutorial/4846/1 "2021-01-06T14:09:48Z")

</div>

I realize it’s a question related to Paraview more than FEniCS, but I am trying to reproduce the views of magnetostatics.py from the FEniCS tutorial. I am talking about the figure 15 and figure 16 of [https://fenicsproject.org/pub/tutorial/html/.\_ftut1015.html](https://fenicsproject.org/pub/tutorial/html/._ftut1015.html).  
When I plot the vector potential using Paraview, by default it is a flat 2D surface that looks like it could become the picture of the FEniCS tutorial if I managed to make it three dimensional, but I haven’t found out how to achieve this. Any idea?

And regarding the magnetic field itself (figure 16), Paraview shows, by default, a single color (and no indication of any value). Examining the field.vtu file with a text editor seems to indicate non zero values, so Paraview should in principle be able to show some patterns instead of a flat color. I am not sure how to reproduce figure 16 at all. Any pointer?

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [January 6, 2021, 2:26pm UTC](https://fenicsproject.discourse.group/t/paraview-to-visualize-a-field-like-in-the-tutorial/4846/2 "2021-01-06T14:26:18Z")

</div>

Use the `Warp by Scalar` Filter. (I’ve recently updated this demo to be used with dolfin-X, and I’ve mentioned this feature specifically at the end of [https://jorgensd.github.io/dolfinx-tutorial/chapter3/em.html](https://jorgensd.github.io/dolfinx-tutorial/chapter3/em.html)).

In general, in paraview you have an option to chose the variable you would like to visualize.  
 ![button](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/d/dba9354f3f3eabd779ab1e54e2c0950c6facd714.png)  
Below it says `vtkBlockColors`, and can be changed to the field of interest.

---

<div class="post-metadata">

**Author:** ![raboynics](https://avatars.discourse-cdn.com/v4/letter/r/4bbf92/32.png) [@raboynics](https://fenicsproject.discourse.group/u/raboynics)\
**Post date:** [January 6, 2021, 3:08pm UTC](https://fenicsproject.discourse.group/t/paraview-to-visualize-a-field-like-in-the-tutorial/4846/3 "2021-01-06T15:08:17Z")

</div>

First of all, thanks a lot for the very quick response. I was not aware of the documentation for dolfinx, I will try to switch to it.

Thanks to your guidance I was able to reproduce the vector potential in Paraview. I also had to increase the “scale factor” in Paraview for the 3D view to appear.

However I am still unable to visualize the magnetic field.  
Now, when selecting the field, all I get is the following (low resolution? So strange…) picture.

 ![2021-01-06-160549_1920x1080_scrot](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/5/598ac82ae7f573e692d9c9a1667b3f81b2c1d699.png)  
It looks very different than figure 16 of the tutorial.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [January 6, 2021, 3:11pm UTC](https://fenicsproject.discourse.group/t/paraview-to-visualize-a-field-like-in-the-tutorial/4846/4 "2021-01-06T15:11:20Z")

</div>

The magnetic field is a vector field, and can be visualized either by using the `Glyph`s filter (with corresponding scaling), or the `Stream Tracer` to create a plot similar to the one in figure 16.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [January 6, 2021, 3:28pm UTC](https://fenicsproject.discourse.group/t/paraview-to-visualize-a-field-like-in-the-tutorial/4846/5 "2021-01-06T15:28:35Z")

</div>

> [@raboynics](#):
>
> First of all, thanks a lot for the very quick response. I was not aware of the documentation for dolfinx, I will try to switch to it.

I would hold off switching for a little while, we are making quite a few interface changes atm, to make it easier for end-users. However, feel free to leave feedback on the tutorial, using the issue tracker on the top of the page/

---

<div class="post-metadata">

**Author:** ![raboynics](https://avatars.discourse-cdn.com/v4/letter/r/4bbf92/32.png) [@raboynics](https://fenicsproject.discourse.group/u/raboynics)\
**Post date:** [January 6, 2021, 3:36pm UTC](https://fenicsproject.discourse.group/t/paraview-to-visualize-a-field-like-in-the-tutorial/4846/6 "2021-01-06T15:36:27Z")

</div>

Alright. On the top of my head, right now, I would say a documentation (I guess it already exists?) about how to import mesh files that are generated for example with gmsh, as I believe the support for mshr is dropped now and the only way to deal with a mesh is with an external generation.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [January 6, 2021, 4:57pm UTC](https://fenicsproject.discourse.group/t/paraview-to-visualize-a-field-like-in-the-tutorial/4846/7 "2021-01-06T16:57:03Z")

</div>

I have a two tutorials on my personal web page:

> **[Tutorials](https://jsdokken.com/tutorials.html)**
>
> Personal web page

And there are several examples (the EM example and deflection of a membrane) that used the Gmsh Python interface to create meshes in the dolfin-x tutorial.
