# Unstructured grid with different type of elements (triangle and lines)

**URL:** https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918
**Category:** ParaView Support
**Created:** [September 2, 2021, 10:32am UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918 "2021-09-02T10:32:55Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![Sagues](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@Sagues](https://discourse.paraview.org/u/Sagues)
#### Post date: [September 2, 2021, 10:32am UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/1 "2021-09-02T10:32:55Z")

</div>

I have a unstructured grid with different type of elements (triangles and lines), how can show only triangles or lines.

---

<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: [September 2, 2021, 10:49am UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/2 "2021-09-02T10:49:48Z")

</div>

- Open your dataset in a spreadsheet view
- Show cell data
- Sort by cell type
- Select all cells of a specific cell types
- Extract Selection
- Apply

---

<div class="post-metadata">

### Author: ![Sagues](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@Sagues](https://discourse.paraview.org/u/Sagues)
#### Post date: [September 2, 2021, 11:00am UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/3 "2021-09-02T11:00:20Z")

</div>

I need to write meshes (grids) with several type of cells in vtk format.  
How can I create a group for each type of cells and then show or not each group of cells.  
Multiblock, Multipeace, etc?

Thank you

---

<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: [September 2, 2021, 11:01am UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/4 "2021-09-02T11:01:14Z")

</div>

See my post above, then use GroupDataSet on the results

---

<div class="post-metadata">

### Author: ![Sagues](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@Sagues](https://discourse.paraview.org/u/Sagues)
#### Post date: [September 2, 2021, 11:07am UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/5 "2021-09-02T11:07:00Z")

</div>

Maybe I could use UnstructuredGridGeometryFilter for each type of cells

What do you think?

Thank you

---

<div class="post-metadata">

### Author: ![Sagues](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@Sagues](https://discourse.paraview.org/u/Sagues)
#### Post date: [September 2, 2021, 2:37pm UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/6 "2021-09-02T14:37:03Z")

</div>

I did this as you said:

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

However it does not solve my problem. I need to export my meshes to a vtk file. I have a mesh for each material or type of element. If I export all meshes in a model to a single unstructured mesh I loose the meshes for each element type or material.

For example:

I have a ship that has all theses meshes:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/b/b0a61b0f04a8b58b4598b68061f337198398b5a6.png)  
I need to create a vtk file with a unstructured grid but I can separate all these groups.

---

<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: [September 2, 2021, 2:47pm UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/7 "2021-09-02T14:47:26Z")

</div>

- Add ExtractSelection
- Apply
- File → SaveData

---

<div class="post-metadata">

### Author: ![Sagues](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@Sagues](https://discourse.paraview.org/u/Sagues)
#### Post date: [September 2, 2021, 2:54pm UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/8 "2021-09-02T14:54:14Z")

</div>

But I need to program a c++ library to do this automatically and add this option in a c++ program.  
I write vtk file with the unstructured grid but I do not know what can I do to create groups in vtk file.

---

<div class="post-metadata">

### Author: ![Sagues](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@Sagues](https://discourse.paraview.org/u/Sagues)
#### Post date: [September 2, 2021, 2:59pm UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/9 "2021-09-02T14:59:38Z")

</div>

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

Probably, if I write vtk files with materials (see the image above) I could achieve what I want.

---

<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: [September 2, 2021, 3:01pm UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/10 "2021-09-02T15:01:09Z")

</div>

> I need to program a c++ library to do this automatically and add this option in a c++ program.

Are you looking to use ParaView or VTK here ?

---

<div class="post-metadata">

### Author: ![Sagues](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@Sagues](https://discourse.paraview.org/u/Sagues)
#### Post date: [September 2, 2021, 3:04pm UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/11 "2021-09-02T15:04:22Z")

</div>

I would like to program a library with vtk to create files to be read in paraview.

---

<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: [September 2, 2021, 3:11pm UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/12 "2021-09-02T15:11:47Z")

</div>

Then this is a VTK question. See here for examples:  
[https://kitware.github.io/vtk-examples/site/](https://kitware.github.io/vtk-examples/site/)

and here for questions:  
[https://discourse.vtk.org/](https://discourse.vtk.org/)

---

<div class="post-metadata">

### Author: ![Sagues](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@Sagues](https://discourse.paraview.org/u/Sagues)
#### Post date: [September 2, 2021, 3:16pm UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/13 "2021-09-02T15:16:50Z")

</div>

Thank you very much

---

<div class="post-metadata">

### Author: ![Sagues](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@Sagues](https://discourse.paraview.org/u/Sagues)
#### Post date: [September 3, 2021, 10:02am UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/14 "2021-09-03T10:02:37Z")

</div>

Hi,

I have a model with three materials:  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/2/2a02eeb77b7ffa8f2a7a585c58cb722c09c45d92.png)

![image](https://discourse.paraview.org/uploads/default/original/2X/0/03f392bdd6100f02edb7e315ab8d8ad6d50a7872.png)

Is it possible to set properties to these materials, for example the name, in Paraview?

---

<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: [September 3, 2021, 10:11am UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/15 "2021-09-03T10:11:25Z")

</div>

A string woudl be only with a ProgrammableFilter.

Anything that can be computed can be set using a Calculator or a PythonCalculator.

---

<div class="post-metadata">

### Author: ![Sagues](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@Sagues](https://discourse.paraview.org/u/Sagues)
#### Post date: [September 3, 2021, 3:08pm UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/16 "2021-09-03T15:08:50Z")

</div>

Is it possible to deform a geometry using a vectorial results like displacement?

---

<div class="post-metadata">

### Author: ![wascott](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8e8cbc/32.png) [@wascott](https://discourse.paraview.org/u/wascott)
#### Post date: [September 3, 2021, 6:48pm UTC](https://discourse.paraview.org/t/unstructured-grid-with-different-type-of-elements-triangle-and-lines/7918/17 "2021-09-03T18:48:43Z")

</div>

Try using the Warp by Vector filter.
