# Convexes in mesh.set\_regions() and mim.id\_nodes()

**URL:** <https://getfem.discourse.group/t/convexes-in-mesh-set-regions-and-mim-id-nodes/99>\
**Category:** Questions and issues\
**Created:** [August 16, 2025, 11:02am UTC](https://getfem.discourse.group/t/convexes-in-mesh-set-regions-and-mim-id-nodes/99 "2025-08-16T11:02:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lorenzo.iron](https://avatars.discourse-cdn.com/v4/letter/l/b5ac83/32.png) [@lorenzo.iron](https://getfem.discourse.group/u/lorenzo.iron)\
**Post date:** [August 16, 2025, 11:02am UTC](https://getfem.discourse.group/t/convexes-in-mesh-set-regions-and-mim-id-nodes/99/1 "2025-08-16T11:02:46Z")

</div>

Hello,

in the user-guide of mesh.set\_regions() it is written “If a vector is provided (or a one row matrix) the region will represent the corresponding set of convex.” but it seems not accepted. For example if I provide the CVIDs resulting from

`CVIDs=`mesh.convexes\_in\_box([x1,y1],[x2,y2])

id doesn’t work. The only way to have it work is providing an additional row to the matrix full of “-1” like the following

`mesh.set_region(region_name, [CVIDs, [-1 for i in CVIDs]])`

Is the indication in the User-Guide to be removed?

Same for mim.im\_nodes(). the guide stated that a list of covexes can be provided but it only works passing also an additional vector of “-1” or “65535” for each convex.

Working example

```auto
import getfem as gf
mesh=gf.Mesh('cartesian', [0,1,2,3], [0,1,2,3])
CVIDs=mesh.convexes_in_box([0,0],[3,1])
VRG=1
mesh.set_region(VRG, [CVIDs, [-1 for i in CVIDs]])
print('VRG\n', mesh.region(VRG))
mim=gf.MeshIm(mesh,3)
mim.im_nodes(mesh.region(VRG))

```

Not working commands

```auto
mesh.set_region(VRG, CVIDs)
mim.im_nodes(CVIDs)

```

Thank you.

---

<div class="post-metadata">

**Author:** ![Konstantinos.Poulios](https://avatars.discourse-cdn.com/v4/letter/k/ac91a4/32.png) [@Konstantinos.Poulios](https://getfem.discourse.group/u/Konstantinos.Poulios)\
**Post date:** [August 19, 2025, 10:15am UTC](https://getfem.discourse.group/t/convexes-in-mesh-set-regions-and-mim-id-nodes/99/2 "2025-08-19T10:15:20Z")

</div>

interesting, I didn’t know this, I was always filling the extra row with -1, but the documentation is actually correct. It is just not clear what is meant with 1-row matrix.

For example  
`mesh.set_region(99,[[0,1,2,3]])`  
will work, the same also about `mim.im_nodes()`.

It is logical to expect that it should also work with  
`mesh.set_region(99,[0,1,2,3])`  
but currently this is not supported. I will try to remember to add this convenience feature for the next release.

---

<div class="post-metadata">

**Author:** ![lorenzo.iron](https://avatars.discourse-cdn.com/v4/letter/l/b5ac83/32.png) [@lorenzo.iron](https://getfem.discourse.group/u/lorenzo.iron)\
**Post date:** [August 20, 2025, 2:12pm UTC](https://getfem.discourse.group/t/convexes-in-mesh-set-regions-and-mim-id-nodes/99/3 "2025-08-20T14:12:52Z")

</div>

Hello Kostas,

thank you for your commitment.

I’d like to point out another aspect related another command `CVIDs=mesh.convexes_in_box([0,0],[0.3,0.1])`

whose Guide reads

```auto
Signature: mesh.convexes_in_box(pmin, pmax)
Docstring:
Return the set of convexes lying entirely within the box defined by the corner points `pmin` and `pmax`.

The output `CVIDs` is a two-rows matrix, the first row lists convex
#ids, and the second one lists face numbers (local number in the
convex). If `CVIDs` is given, it returns portion of the boundary of
the convex set defined by the #ids listed in `CVIDs`.
File: /opt/venv/lib/python3.10/site-packages/getfem/getfem.py
Type: method

```

but the output is in reality a list and not a CVIDs two-rows matrix as stated. Maybe this command should be modified to return actually a two rows matrix embedding the -1s and compatible with `mesh.set_region()` and `mim.im_nodes()`, or optionally a clean 1-row matrix as you discovered, or otherwise changing the description of the Guide to “list” or “vector“ in case the modification of the current output of this commands would involve troubles elsewhere inside the library.

Also the command mesh.cvid() and the command mesh.cvid\_from\_pid() return a list but in this case the context is clear from the Guide and there no mention to CVIDs (that now I interpret as a matrix).

Thank you.

---

<div class="post-metadata">

**Author:** ![lorenzo.iron](https://avatars.discourse-cdn.com/v4/letter/l/b5ac83/32.png) [@lorenzo.iron](https://getfem.discourse.group/u/lorenzo.iron)\
**Post date:** [August 28, 2025, 2:42pm UTC](https://getfem.discourse.group/t/convexes-in-mesh-set-regions-and-mim-id-nodes/99/4 "2025-08-28T14:42:34Z")

</div>

Hello Kostas,

It turns out that in Python the method mesh.outer\_faces\_with\_direction() doesn’t accept the output of mesh.region() as input CVIDs.

`import getfem as gf`  
`mesh=gf.Mesh(‘cartesian’, [0,1,2,3], [0,1,2,3])`  
`mesh.set_region(99, [mesh.convexes_in_box([0,0],[3,1])])`  
`mesh.outer_faces_with_direction([0, 1], 0.1, [mesh.region(99)[0]]) # working`  
`#mesh.outer_faces_with_direction([0, 1], 0.1, mesh.region(99)) # NOT working`

Of course we can handle a little bit the matrix as I did in the “# working” row but I believe that it should also natively work like in the “# NOT working“ row.

What you think about this?

Thank you.

---

<div class="post-metadata">

**Author:** ![Konstantinos.Poulios](https://avatars.discourse-cdn.com/v4/letter/k/ac91a4/32.png) [@Konstantinos.Poulios](https://getfem.discourse.group/u/Konstantinos.Poulios)\
**Post date:** [April 22, 2026, 1:05pm UTC](https://getfem.discourse.group/t/convexes-in-mesh-set-regions-and-mim-id-nodes/99/5 "2026-04-22T13:05:24Z")

</div>

> [@Konstantinos.Poulios](#):
>
> It is logical to expect that it should also work with  
> `mesh.set_region(99,[0,1,2,3])`  
> but currently this is not supported. I will try to remember to add this convenience feature for the next release.

Finally I have fixed this with this commit:

> **[Let set\_region() method of Mesh accept a flat array of convexes - getfem.git -](https://cgit.git.savannah.nongnu.org/cgit/getfem.git/commit/?id=e1551052f333d3dfb9f4c525f3c46658f11d9608)**

The other issues I still have to look at.
