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
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
mesh.set_region(VRG, CVIDs)
mim.im_nodes(CVIDs)
Thank you.
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.
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
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.
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.