# multimaterial data, NaNs and Catalyst V2

**URL:** https://discourse.paraview.org/t/multimaterial-data-nans-and-catalyst-v2/13115
**Category:** ParaView Support
**Tags:** catalyst
**Created:** [October 26, 2023, 3:29pm UTC](https://discourse.paraview.org/t/multimaterial-data-nans-and-catalyst-v2/13115 "2023-10-26T15:29:45Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![zetwal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/zetwal/32/8506_2.png) [@zetwal](https://discourse.paraview.org/u/zetwal)
#### Post date: [October 26, 2023, 3:29pm UTC](https://discourse.paraview.org/t/multimaterial-data-nans-and-catalyst-v2/13115/1 "2023-10-26T15:29:45Z")

</div>

Hello

I have a simulation that has multiple materials. So, I’m thinking that the easiest way to handle this is to put NANs in the cells for which there is no data for that material. That seems to work, and the NAN cells are being displayed as yellow. Is there a way to threshold out the NAN cells and not show them at all in ParaView?

What is the recommended way to handle multi material in Catalyst 2?

Pascal

---

<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: [October 26, 2023, 3:31pm UTC](https://discourse.paraview.org/t/multimaterial-data-nans-and-catalyst-v2/13115/2 "2023-10-26T15:31:45Z")

</div>

> [@zetwal](#):
>
> Is there a way to threshold out the NAN cells and not show them at all in ParaView?

Threshold should remove them but you can also make them transparent using NaN opacity.

> What is the recommended way to handle multi material in Catalyst 2?

@nicolas.vuaille @Lucas_Givord @Francois_Mazen

---

<div class="post-metadata">

### Author: ![zetwal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/zetwal/32/8506_2.png) [@zetwal](https://discourse.paraview.org/u/zetwal)
#### Post date: [October 26, 2023, 3:35pm UTC](https://discourse.paraview.org/t/multimaterial-data-nans-and-catalyst-v2/13115/3 "2023-10-26T15:35:08Z")

</div>

> [@zetwal](#):
>
> not show them at all in ParaView?

I just saw the NaN opacity which I am now setting to transparent. That seems to be doing it for me.

---

<div class="post-metadata">

### Author: ![zetwal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/zetwal/32/8506_2.png) [@zetwal](https://discourse.paraview.org/u/zetwal)
#### Post date: [October 26, 2023, 7:09pm UTC](https://discourse.paraview.org/t/multimaterial-data-nans-and-catalyst-v2/13115/4 "2023-10-26T19:09:04Z")

</div>

So, the NaN opacity actually does not work correctly. There are values that are not NaN that get hidden thus producing the wrong results. I found that out by looking at the spreadsheet; there are values that not NaNs in the csv view but are not visible in the rendered view.

What actually seems to work is to use the threshold filter and set the values of min and max to the minimum allowed and maximum allowed threshold values respectively.

So, is there a bug in the NaN opacity filter?

---

<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: [October 27, 2023, 7:33am UTC](https://discourse.paraview.org/t/multimaterial-data-nans-and-catalyst-v2/13115/5 "2023-10-27T07:33:15Z")

</div>

> [@zetwal](#):
>
> there a bug in the NaN opacity filter?

Please share a screenshot of the issue.

---

<div class="post-metadata">

### Author: ![zetwal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/zetwal/32/8506_2.png) [@zetwal](https://discourse.paraview.org/u/zetwal)
#### Post date: [November 6, 2023, 6:13pm UTC](https://discourse.paraview.org/t/multimaterial-data-nans-and-catalyst-v2/13115/6 "2023-11-06T18:13:11Z")

</div>

Below is an example that I made. The correct one is the thresholded one.

Original:

 ![one](https://discourse.paraview.org/uploads/default/original/2X/1/12615204c45197df47a2a7fe416acf10c6690d92.png)

Setting opacity to 0 for nan; a face is missing:

 ![opacity](https://discourse.paraview.org/uploads/default/original/2X/a/a1a37867cf08e939c96a5d6b11ad38e0a52f5051.png)

Thresholding:

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

The thresholded version is correct.

Sample code:

```auto
// Vertices: 0 1 2 3 4 5 
    std::vector<float> _coordsX = { 0, 0, 1, 1, 0.5, 0.5};
    std::vector<float> _coordsY = { 0, 0, 0, 0, 1, -1};
    std::vector<float> _coordsZ = { 0, 1, 0, 1, 0.5, 0.5};

    // 0 1 2 3 4 5 6 7 8 9 10 11 12
    // Faces A B C D E F G H I J K L M
    std::vector<int> _faceConnectivity = {0,1,2, 0,1,4, 1,2,4, 0,2,4, 1,3,4, 3,2,4, 2,1,4, 3,2,1, 0,1,5, 1,5,2, 0,5,2, 1,5,3, 3,5,2};    
    std::vector<int> _faceSize = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3};
    std::vector<int> _faceOffset = {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36};

    std::vector<int> _tetConnectivity = {0,1,2,3, 4,5,6,7, 0,8,9,10, 7,11,12,9}; 
    std::vector<int> _tetSize = {4, 4, 4, 4};
    std::vector<int> _tetOffset = {0, 4, 8, 12};

    float nan = std::nanf("1");
    std::vector<float> _valuesFaces = {10, 20, nan, 40};
    std::vector<float> _valuesVertex = {5, 10, 15, 20, 25,30};

    // create an explicit coordinate set
    mesh["coordsets/coords/type"].set("explicit");

    mesh["coordsets/coords/values/x"].set_external(&_coordsX[0], _coordsX.size());
    mesh["coordsets/coords/values/y"].set_external(&_coordsY[0], _coordsY.size());
    mesh["coordsets/coords/values/z"].set_external(&_coordsZ[0], _coordsZ.size());

    // add an unstructured topology
    mesh["topologies/mesh/type"].set("unstructured");
    mesh["topologies/mesh/coordset"].set("coords");

    mesh["topologies/mesh/elements/shape"].set("polyhedral");
    mesh["topologies/mesh/elements/connectivity"].set_external(&_tetConnectivity[0], _tetConnectivity.size());
    mesh["topologies/mesh/elements/sizes"].set_external(&_tetSize[0], _tetSize.size());
    mesh["topologies/mesh/elements/offsets"].set_external(&_tetOffset[0], _tetOffset.size());

    mesh["topologies/mesh/subelements/shape"].set("polygonal");
    mesh["topologies/mesh/subelements/connectivity"].set_external(&_faceConnectivity[0], _faceConnectivity.size());
    mesh["topologies/mesh/subelements/sizes"].set_external(&_faceSize[0], _faceSize.size());
    mesh["topologies/mesh/subelements/offsets"].set_external(&_faceOffset[0], _faceOffset.size());

    // add the data
    auto fields = mesh["fields"];

    fields["sim_valv/association"].set("vertex");
    fields["sim_valv/topology"].set("mesh");
    fields["sim_valv/volume_dependent"].set("false");
    fields["sim_valv/values"].set_external(&_valuesVertex[0], _valuesVertex.size());

    fields["sim_valf/association"].set("element");
    fields["sim_valf/topology"].set("mesh");
    fields["sim_valf/volume_dependent"].set("false");
    fields["sim_valf/values"].set_external(&_valuesFaces[0], _valuesFaces.size());

```

---

<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: [November 7, 2023, 9:23am UTC](https://discourse.paraview.org/t/multimaterial-data-nans-and-catalyst-v2/13115/7 "2023-11-07T09:23:31Z")

</div>

Could you share the data ?

---

<div class="post-metadata">

### Author: ![zetwal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/zetwal/32/8506_2.png) [@zetwal](https://discourse.paraview.org/u/zetwal)
#### Post date: [November 7, 2023, 12:57pm UTC](https://discourse.paraview.org/t/multimaterial-data-nans-and-catalyst-v2/13115/8 "2023-11-07T12:57:13Z")

</div>

Here you go:  
[sample\_data.tar.gz](https://discourse.paraview.org/uploads/short-url/bScfvejd6UeJmy05wDiE7Ou34kA.gz) (39.3 KB)

The data was generated by the code above as a test. In the dataset, each of the 4 ranks are outputting exactly the same data but in the simulation, each would output a section. You can see the issue from loading the vtpd file or just one vtu file.

---

<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: [November 7, 2023, 2:09pm UTC](https://discourse.paraview.org/t/multimaterial-data-nans-and-catalyst-v2/13115/9 "2023-11-07T14:09:25Z")

</div>

This is expected because the internal faces are hidden, even when there is opacity. You can use Shrink with a factor of 1 to separate each cell.

---

<div class="post-metadata">

### Author: ![zetwal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/zetwal/32/8506_2.png) [@zetwal](https://discourse.paraview.org/u/zetwal)
#### Post date: [November 7, 2023, 2:31pm UTC](https://discourse.paraview.org/t/multimaterial-data-nans-and-catalyst-v2/13115/10 "2023-11-07T14:31:34Z")

</div>

> [@mwestphal](#):
>
> because the internal faces are hidden, even when there is opacity. You can use Shrink with a factor of 1 to separate each cell.

I did not know about this. Thanks!
