# Multiple Scalars per Cell or Face

**URL:** https://discourse.vtk.org/t/multiple-scalars-per-cell-or-face/2493
**Category:** Support
**Created:** [January 25, 2020, 1:13am UTC](https://discourse.vtk.org/t/multiple-scalars-per-cell-or-face/2493 "2020-01-25T01:13:50Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![akaszynski](https://discourse.vtk.org/user_avatar/discourse.vtk.org/akaszynski/32/10751_2.png) [@akaszynski](https://discourse.vtk.org/u/akaszynski)
#### Post date: [January 25, 2020, 1:13am UTC](https://discourse.vtk.org/t/multiple-scalars-per-cell-or-face/2493/1 "2020-01-25T01:13:50Z")

</div>

Hello,

Aside from array scalars, VTK currently supports point or cell scalars, which means either the scalars array needs to match the number of points or cells. I’d like to plot scalars such that each point of each cell had an assigned scalar. This is possible when each cell contains isolated points, but if cells share common points, it is impossible to assign scalars to each point of each cell.

Other than duplicating points in order to truly isolate cells within VTK, is there any way to add scalars to each point of each cell?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 26, 2020, 11:18pm UTC](https://discourse.vtk.org/t/multiple-scalars-per-cell-or-face/2493/2 "2020-01-26T23:18:51Z")

</div>

Hello, Alex,

Hmmm… In Open Inventor we have nomething called indexed vertexes, that is: you can create two vertexes sharing the same XYZ, so you can assign different scalars without duplicating geometry. In VTK, I think your best shot is to create `vtkCell`s of type [`vtkVertex`](https://vtk.org/doc/nightly/html/classvtkVertex.html). A `vtkVertex` is a cell wich is a single point. Of course you can create as many `vtkVertex`es as you like sharing the same `vtkPoint`.

all the best,

Paulo

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [January 28, 2020, 7:48pm UTC](https://discourse.vtk.org/t/multiple-scalars-per-cell-or-face/2493/3 "2020-01-28T19:48:57Z")

</div>

I think @Paulo_Carvalho’s approach using the `vtkVertex` cell approach in a `vtkUnstructuredGrid` would be the best approach as far as data storage goes. However, if the mesh has any cells other than vertices (e.g. quads, triangles, tetrahedrals, etc.) then you’ll immediately run into problems with missing cell data (though I suppose you could just fill those cells with NaNs but that might turn into a whole lotta NaNs that have to be stored).

Also, I can’t really wrap my head around how you might display this kind of data… would you interpolate the values at the nodes for each 2/3D cell across the cell? Or how might you display two values at the same vertex without using some sort of geometric distortion?

---

<div class="post-metadata">

### Author: ![akaszynski](https://discourse.vtk.org/user_avatar/discourse.vtk.org/akaszynski/32/10751_2.png) [@akaszynski](https://discourse.vtk.org/u/akaszynski)
#### Post date: [January 28, 2020, 7:55pm UTC](https://discourse.vtk.org/t/multiple-scalars-per-cell-or-face/2493/4 "2020-01-28T19:55:17Z")

</div>

As I’m hoping to plot 3D cells, vertices won’t work in this case. As for an example of the results plot:  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/5/5b1c153a9a8f677fb2d07263572802c3db8acd9b.png)

These are finite element stresses, which are continuous within elements but discontinuous between elements, hence why they share the same points, but different scalar data per point. The best I can come up with is representing each cell with unique, though co-located points, that way you can assign each cell with unique scalars.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [January 29, 2020, 3:19am UTC](https://discourse.vtk.org/t/multiple-scalars-per-cell-or-face/2493/5 "2020-01-29T03:19:13Z")

</div>

Looks like a usecase for a vtkExplicitStructuredGrid

> **[Introducing Explicit Structured Grids in VTK and ParaView - Kitware Blog](https://blog.kitware.com/introducing-explicit-structured-grids-in-vtk-and-paraview/)**
>
> Data Structure An explicit structured grid is a new data structure in VTK sharing properties of both structured and unstructured grids. This new dataset is ... Read More

---

<div class="post-metadata">

### Author: ![andreasbuykx](https://discourse.vtk.org/user_avatar/discourse.vtk.org/andreasbuykx/32/8137_2.png) [@andreasbuykx](https://discourse.vtk.org/u/andreasbuykx)
#### Post date: [January 30, 2020, 1:08pm UTC](https://discourse.vtk.org/t/multiple-scalars-per-cell-or-face/2493/6 "2020-01-30T13:08:15Z")

</div>

That’s an interesting data structure. Does it also support higher order cells or only linear ones?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [January 31, 2020, 4:13am UTC](https://discourse.vtk.org/t/multiple-scalars-per-cell-or-face/2493/7 "2020-01-31T04:13:05Z")

</div>

I would say yes but I defer to @JPouderoux for a definitive answer.

---

<div class="post-metadata">

### Author: ![goflo](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/g/f04885/32.png) [@goflo](https://discourse.vtk.org/u/goflo)
#### Post date: [April 27, 2020, 8:42am UTC](https://discourse.vtk.org/t/multiple-scalars-per-cell-or-face/2493/8 "2020-04-27T08:42:15Z")

</div>

Hi @andreasbuykx

I have the same requirement. I want also to visualize scalars to each point of each cell.  
Have you find a satisfying and well working solution?

Thanks!  
Best Regards,  
Florian

---

<div class="post-metadata">

### Author: ![andreasbuykx](https://discourse.vtk.org/user_avatar/discourse.vtk.org/andreasbuykx/32/8137_2.png) [@andreasbuykx](https://discourse.vtk.org/u/andreasbuykx)
#### Post date: [April 28, 2020, 8:55am UTC](https://discourse.vtk.org/t/multiple-scalars-per-cell-or-face/2493/9 "2020-04-28T08:55:08Z")

</div>

@goflo My approach is the same as that of @akaszynski : split the points into multiple co-located points and contour every cell by itself.

---

<div class="post-metadata">

### Author: ![goflo](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/g/f04885/32.png) [@goflo](https://discourse.vtk.org/u/goflo)
#### Post date: [April 28, 2020, 1:24pm UTC](https://discourse.vtk.org/t/multiple-scalars-per-cell-or-face/2493/10 "2020-04-28T13:24:05Z")

</div>

Thank you for your reply!  
That should work but it’s of course an ugly solution…
