# (CGNS) Is it possible to load a mesh with Cell-Centered solution and display the values in boundary patches?

**URL:** https://discourse.paraview.org/t/cgns-is-it-possible-to-load-a-mesh-with-cell-centered-solution-and-display-the-values-in-boundary-patches/12185
**Category:** ParaView Support
**Created:** [May 30, 2023, 10:33am UTC](https://discourse.paraview.org/t/cgns-is-it-possible-to-load-a-mesh-with-cell-centered-solution-and-display-the-values-in-boundary-patches/12185 "2023-05-30T10:33:28Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![SadBoySquad](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sadboysquad/32/11775_2.png) [@SadBoySquad](https://discourse.paraview.org/u/SadBoySquad)
#### Post date: [May 30, 2023, 10:33am UTC](https://discourse.paraview.org/t/cgns-is-it-possible-to-load-a-mesh-with-cell-centered-solution-and-display-the-values-in-boundary-patches/12185/1 "2023-05-30T10:33:28Z")

</div>

Greetings to all people here!

Some time ago I created a thread here, asking for help in properly displaying boundary patches from a CGNS file in ParaView.

The aforementioned thread is this one:

> [@(CGNS) Is it possible to load boundary patches from a CGNS file?](https://discourse.paraview.org/t/cgns-is-it-possible-to-load-boundary-patches-from-a-cgns-file/8119/1):
>
> Greetings to all people of this forum! For the past few days I have been searching for a way to display flow properties on boundary patches defined in the CGNS file, unfortunately to no avail. I found a relevant thread, but has zero responses: I also found a plugin that was written for older ParaView versions (it lists 4.3.1 on Git log), but does not work for current versions (I am on 5.9). I think the plugin loads correctly, since I am able to have the new “Load Boundary Elements (Unstruc…

My new question is kind of a follow-up to that thread, but since that thread provided a complete solution I figured I’d leave it as is and create a new thread for my new question.

# What I want to do

I want to, if possible, display variables on boundary patches in a CGNS file that contains a **CellCenter** solution.

# What is the current situation

Per the replies on the previous thread, displaying variables in boundary patches requires a **Vertex** based solution in the CGNS file.  
When I posted the previous thread I was working on a node-based solver and thus I was able to turn patches on and off and view the solution accordingly.

However, I now also have to work on a cell-based solver.  
ParaView is, of course, able to pickup the boundary patches (via the _FamilySpecified_ route discussed in the previous thread), however it cannot display the solution on boundary patches.  
This is completely expected, since the values on boundary faces cannot be directly derived from the _CellCenter_ solution in volume elements.

# What I’ve tried thus far

Since there is no official _CGNS for ParaView_ documentation, I tried to find a way to make this work.

## Using _Cell Data to Point Data_ in ParaView → Does not work

At first, I figured that if I convert the Cell solution to a Point solution I would be able to visualize variables in boundary patches.  
Unfortunately, this does not work. If you use the filter to convert the solution from Cells to Points, it only converts the solution in the Volume Mesh, not on boundary patches.

As far as I can tell, ParaView loads the volume and boundary meshes as separate entities.  
One can verify this by examining the total number of Cells and Nodes before and after the _Load Patches_ option.  
If _Load Patches_ is turned on, the total number of nodes is multiplied by the number of patches.  
This implies that ParaView takes all nodes and stores them independently for each boundary patch.  
Thus, if you convert Cell Data To Point Data, it only affects the volume mesh.  
Boundary patch meshes are not affected.

## Resampling from volume mesh to the boundary meshes → Does not work

I also gave this hacky way a try, of course it doesn’t work.  
For a given mesh, the boundary is not surrounded by any cell (since it is in the boundary).  
Thus the resampling does not return anything.

## Using the official CGNS _ParentData_ array for boundary elements → Does not work

CGNS provides the option to store parent elements for boundary patches.  
For each boundary element (face), the neighbor volume cell elements are given, in addition to the corresponding number of cell-face that the boundary face matches to.

Unfortunately, ParaView still does not seem to pickup the solution.  
The corresponding functionality is probably not implemented in the CGNS reader.

## Converting the CellCenter solution to a Vertex solution using CGNStools → Works, but is kinda slow

By using the _convert\_location_ utility provided by the CGNS library, one can convert a CellCenter solution to a Vertex solution. ParaView then can display variables on patches accordingly.

This option works but the _convert\_location_ utility is kinda slow, converting the solution on large datasets takes a lot of time. However, it only needs to be done once for each solution file.

# What other options are there, if any?

Is there anything else I can try?  
Fortunately, the _convert\_solution_ utility can kinda do the trick.  
However, perhaps there’s a way to do this more _elegantly_.  
Converting the solution can take a couple of hours for large datasets.

---

<div class="post-metadata">

### Author: ![SadBoySquad](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sadboysquad/32/11775_2.png) [@SadBoySquad](https://discourse.paraview.org/u/SadBoySquad)
#### Post date: [May 30, 2023, 10:34am UTC](https://discourse.paraview.org/t/cgns-is-it-possible-to-load-a-mesh-with-cell-centered-solution-and-display-the-values-in-boundary-patches/12185/2 "2023-05-30T10:34:28Z")

</div>

@MicK7 Tagging you here since you wrote the CGNS reader and you helped me out in the previous thread!

---

<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 30, 2023, 12:15pm UTC](https://discourse.paraview.org/t/cgns-is-it-possible-to-load-a-mesh-with-cell-centered-solution-and-display-the-values-in-boundary-patches/12185/3 "2023-05-30T12:15:26Z")

</div>

Hi @SadBoySquad

Please share your data

Best,

---

<div class="post-metadata">

### Author: ![Tiffany\_Chhim](https://discourse.paraview.org/user_avatar/discourse.paraview.org/tiffany_chhim/32/10690_2.png) [@Tiffany\_Chhim](https://discourse.paraview.org/u/Tiffany_Chhim)
#### Post date: [May 30, 2023, 12:22pm UTC](https://discourse.paraview.org/t/cgns-is-it-possible-to-load-a-mesh-with-cell-centered-solution-and-display-the-values-in-boundary-patches/12185/4 "2023-05-30T12:22:02Z")

</div>

Hello @SadBoySquad,

I’m not sure if this could suit your needs, but here is a small example file that is used for testing.  
This file uses **BCNeumann** boundary conditions with values on the faces ( **GridLocation** is **FaceCenter** ).

[VTK\_BCNeumannUnstructuredQuads.cgns](https://discourse.paraview.org/uploads/short-url/wY2AoEIro15njg9IVe2GSBmm3zi.cgns) (29.1 KB)

**BCDirichlet** and **BCNeumann** support has been added recently so you might need to use a nightly version of ParaView or a recent build if you are building the application yourself.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/f/fff1a97a3686446d9b66df9dc64e1eb87e234afe.png)

---

<div class="post-metadata">

### Author: ![SadBoySquad](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sadboysquad/32/11775_2.png) [@SadBoySquad](https://discourse.paraview.org/u/SadBoySquad)
#### Post date: [May 30, 2023, 1:45pm UTC](https://discourse.paraview.org/t/cgns-is-it-possible-to-load-a-mesh-with-cell-centered-solution-and-display-the-values-in-boundary-patches/12185/5 "2023-05-30T13:45:20Z")

</div>

@mwestphal

Here is a sample file:

> **[SC10\_steady\_modified.cgns](https://www.dropbox.com/s/9hhrmu0a4zrvgnd/SC10_steady_modified.cgns?dl=0)**
>
> Shared with Dropbox

It is the SC10\_steady.cgns file downloaded from the CGNS examples (the 4th file in the “Unstructured Grid Examples” in the lower half of the page).  
The link for the sample is the following:  
[https://cgns.github.io/CGNSFiles.html](https://cgns.github.io/CGNSFiles.html)

I only modified the initial sample file to have “Family Specified” boundary conditions.

As expected, the solution cannot be displayed on Boundary Patches (and why would it, ParaView cannot know how to match the boundary patches to the CellCenter solution).

---

<div class="post-metadata">

### Author: ![SadBoySquad](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sadboysquad/32/11775_2.png) [@SadBoySquad](https://discourse.paraview.org/u/SadBoySquad)
#### Post date: [May 30, 2023, 1:59pm UTC](https://discourse.paraview.org/t/cgns-is-it-possible-to-load-a-mesh-with-cell-centered-solution-and-display-the-values-in-boundary-patches/12185/6 "2023-05-30T13:59:23Z")

</div>

I think the format you propose has a different objective than what I want to achieve.

The format with _NeumannData_ and _DirichletData_ aims at giving the user information on applying boundary conditions.  
For example, it can give the Dirichlet value for Temperature in a boundary that has fixed Temperature throughout the simulation.  
Or it can give a scalar derivative via a the Neumann specification.

However, what I want to display is the _Solution_ on the boundary.  
For a Cell-Based solver, this would essentially be the value of the corresponding internal Cell that the boundary Face belongs to.  
For a Vertex-Based solver the implementations can vary, however the most common option is to not assign dirichlet values to boundary nodes themselves but instead use flux schemes to upwind boundary values from ghost nodes towards boundary nodes.  
Therefore, boundary values change with the solution.

---

<div class="post-metadata">

### Author: ![Tiffany\_Chhim](https://discourse.paraview.org/user_avatar/discourse.paraview.org/tiffany_chhim/32/10690_2.png) [@Tiffany\_Chhim](https://discourse.paraview.org/u/Tiffany_Chhim)
#### Post date: [May 30, 2023, 2:23pm UTC](https://discourse.paraview.org/t/cgns-is-it-possible-to-load-a-mesh-with-cell-centered-solution-and-display-the-values-in-boundary-patches/12185/7 "2023-05-30T14:23:44Z")

</div>

Oh thanks for the explanation, I see what you mean now 🙂

As you said, in ParaView, the boundary patches are separate from the volume cells and are not aware of each other.

I suggest the following solution:

1. Use “ **Extract Block** ” on the CGNS output to extract the volume mesh (“ **Internal** ” block)
2. Use “ **Extract Block** ” on the CGNS output to extract the boundary patches (“ **Patches** ” block(s))
3. Use “ **Resample with Dataset** ” with the output of step 1 as “Source Data Arrays” and the output of step 2 as “Destination Mesh” when prompted

 ![image](https://discourse.paraview.org/uploads/default/original/2X/3/3534fd8a9faed9f814e53292d4cc92c92c398104.png)

---

<div class="post-metadata">

### Author: ![SadBoySquad](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sadboysquad/32/11775_2.png) [@SadBoySquad](https://discourse.paraview.org/u/SadBoySquad)
#### Post date: [May 30, 2023, 2:42pm UTC](https://discourse.paraview.org/t/cgns-is-it-possible-to-load-a-mesh-with-cell-centered-solution-and-display-the-values-in-boundary-patches/12185/8 "2023-05-30T14:42:09Z")

</div>

Your solution works and, since ParaView can be launched in parallel mode, is probably much more efficient than using the serial _convert\_location_ utility from CGNStools.

Unless there is a way that is able to directly display CellCenter values from a _Solution_ node on boundary patches, I think this would be a good workaround.

Thank you! 🙂

p.s. #1  
For better surface visualization, I think that converting from Cell Data to Point data before extracting blocks provides a smoother contour of variables.

p.s. #2  
The solution you provided is very straightforward and simple, however I never though to extract both the internal mesh and the patches and then use _Resample with Dataset_.  
As per my initial post, I tried extracting a patch and Resampling from the initial file to the extracted patch, but I got nothing.  
Why does one need to extract both the Internal Mesh and the Patches in order to Resample correctly?

---

<div class="post-metadata">

### Author: ![Tiffany\_Chhim](https://discourse.paraview.org/user_avatar/discourse.paraview.org/tiffany_chhim/32/10690_2.png) [@Tiffany\_Chhim](https://discourse.paraview.org/u/Tiffany_Chhim)
#### Post date: [May 30, 2023, 3:02pm UTC](https://discourse.paraview.org/t/cgns-is-it-possible-to-load-a-mesh-with-cell-centered-solution-and-display-the-values-in-boundary-patches/12185/9 "2023-05-30T15:02:13Z")

</div>

You’re welcome! 🙂

Digging a little into the code, it seems that this is caused by the fact that the arrays are partial here, because they are not defined on the boundary patches.  
A piece of the documentation for `vtkCompositeDataProbeFilter` says:

> When dealing with composite datasets, partial arrays are common i.e.  
> data-arrays that are not available in all of the blocks. By default, this  
> filter only passes those point and cell data-arrays that are available in all  
> the blocks i.e. partial arrays are removed.

So using the output of the CGNS reader directly won’t resample the partial arrays.

---

<div class="post-metadata">

### Author: ![SadBoySquad](https://discourse.paraview.org/user_avatar/discourse.paraview.org/sadboysquad/32/11775_2.png) [@SadBoySquad](https://discourse.paraview.org/u/SadBoySquad)
#### Post date: [June 1, 2023, 7:05pm UTC](https://discourse.paraview.org/t/cgns-is-it-possible-to-load-a-mesh-with-cell-centered-solution-and-display-the-values-in-boundary-patches/12185/10 "2023-06-01T19:05:18Z")

</div>

Hey Mathieu, did you manage to check the file I provided?  
Is there another way to do this, or do I have to adopt the “Interpolation” route?

---

<div class="post-metadata">

### Author: ![MicK7](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mick7/32/1374_2.png) [@MicK7](https://discourse.paraview.org/u/MicK7)
#### Post date: [August 6, 2023, 2:44pm UTC](https://discourse.paraview.org/t/cgns-is-it-possible-to-load-a-mesh-with-cell-centered-solution-and-display-the-values-in-boundary-patches/12185/11 "2023-08-06T14:44:48Z")

</div>

You are not completely right `NeumannData` and `DirichletData` can be use to provide field for the solver at boundary conditions. But since they accept multiple containers, the solver can also provide face center or vertex solution in a BCDataSet CGNS node that paraview will be able to load.  
BCDataSet are just container for the BC data.
