Error in `extract_topology_markers`

Sorry if this is a known bug. I did look into the forum and the repository, but did not find anything.

With a Gmsh file (/tmp/t.geo):

SetFactory("OpenCASCADE");

Point(1) = {0, 0, 0, 1.0};
Point(2) = {3, 0, 0, 1.0};
Rotate {{0, 0, 1}, {0, 0, 0}, Pi/6} {
  Duplicata { Point{2}; }
}
Point(4) = {1, 0, 0, 1.0};
Rotate {{0, 0, 1}, {0, 0, 0}, Pi/6} {
  Duplicata { Point{4}; }
}

Line(1) = {1, 4};
Line(2) = {5, 1};
Circle(3) = {4, 1, 5};
Line(4) = {4, 2};
Circle(5) = {2, 1, 3};
Line(6) = {3, 5};

Transfinite Curve {4} = 5 Using Progression 1;
Transfinite Curve {6} = 5 Using Progression 1;
a = 1;
Transfinite Curve {1} = 3 Using Progression a;
Transfinite Curve {2} = 3 Using Progression 1/a;

Curve Loop(1) = {1, 3, 2};
Plane Surface(1) = {1};
Curve Loop(2) = {4, 5, 6, -3};
Plane Surface(2) = {2};
Transfinite Surface {2};

Transfinite Curve {3} = 3 Using Progression 1;
Transfinite Curve {5} = 3 Using Progression 1;

Recombine Surface {2};
Physical Surface("small", 7) = {1};
Physical Surface("big", 8) = {2};

When trying to load the mesh (/tmp/t.py):

from dolfinx.io import gmshio
from mpi4py import MPI
import gmsh


gmsh.initialize()
gmsh.model.add("Temp")
gmsh.merge("/tmp/t.geo")
gmsh.finalize()
gmsh_file_data = gmshio.read_from_msh("/tmp/t.geo", MPI.COMM_WORLD, gdim=2)

The error is:

Traceback (most recent call last):
  File "/usr/lib/python3.10/pdb.py", line 1726, in main
    pdb._runscript(mainpyfile)
  File "/usr/lib/python3.10/pdb.py", line 1586, in _runscript
    self.run(statement)
  File "/usr/lib/python3.10/bdb.py", line 597, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "/tmp/t.py", line 10, in <module>
    gmsh_file_data = gmshio.read_from_msh("/tmp/t.geo", MPI.COMM_WORLD, gdim=2)
  File "/usr/lib/python3.10/site-packages/dolfinx/io/gmshio.py", line 292, in read_from_msh
    output = model_to_mesh(gmsh.model, comm, rank, gdim=gdim)
  File "/usr/lib/python3.10/site-packages/dolfinx/io/gmshio.py", line 188, in model_to_mesh
    topologies = extract_topology_and_markers(model)
  File "/usr/lib/python3.10/site-packages/dolfinx/io/gmshio.py", line 99, in extract_topology_and_markers
    assert len(entity_types) == 1
AssertionError
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /usr/lib/python3.10/site-packages/dolfinx/io/gmshio.py(99)extract_topology_and_markers()
-> assert len(entity_types) == 1

Hopefully, this helps:

#+TITLE: Debugger info for *pdb t.py shell*

This is based on an org-mode buffer. Hit tab to expand/contract sections.

* General Information (realgud-cmdbuf-info)
  - Debugger name       ::	pdb
  - Command-line args   ::	["python","-m","pdb","/tmp/t.py"]
  - Starting directory  ::	nil
  - Current source-code path  ::	[[/usr/lib/python3.10/site-packages/dolfinx/io/gmshio.py]]
  - Selected window should contain source? :: nil
  - Last input end      ::	1410
  - Source should go into short-key mode? :: t
  - In debugger?        ::	t
  - Ignore file regexps ::	(<string>)
  - remapped file names ::	nil

** Remap table for debugger commands
  - backtrace	::	where
  - clear	::	clear %X:%l
  - delete	::	clear %p
  - eval	::	!%s
  - finish	::	return
  - frame	::	*not-implemented*
  - info-breakpoints	::	break
  - info-locals-names-list	::	print('\n'.join(locals().keys()))
  - info-type	::	type(%s)
  - info-value	::	pp %s
  - kill	::	quit
  - shell	::	*not-implemented*


* Source Buffers Seen (srcbuf-list)
  - gmshio.py
  - t.py

** Source Positions Stopped at (loc-hist)
  -  buffer size  :: 20
  -  position     :: 0
*** 0
  - filename      :: /tmp/t.py
  - line number   :: 1
  - source marker :: #<marker at 1 in t.py>
  - cmdbuf marker :: #<marker at 123 in *pdb t.py shell*>
*** 1
  - filename      :: /usr/lib/python3.10/site-packages/dolfinx/io/gmshio.py
  - line number   :: 99
  - source marker :: #<marker at 3576 in gmshio.py>
  - cmdbuf marker :: #<marker at 1410 in *pdb t.py shell*>

#+STARTUP: overview
#+STARTUP: content
#+STARTUP: showall
#+STARTUP: showeverything

(How does one upload files around here?).

Thanks!

[Edit]

import dolfinx
import gmsh
print(dolfinx.common.git_commit_hash)
print(gmsh.GMSH_API_VERSION)

22f61674e9f0412f5c4a887f1d49c2c4edbfad4a
4.10.4

and

python --version
uname -r | head -n 1

Python 3.10.5
5.18.14-arch1-1

If I

  1. load t.geo in Gmsh

  2. Mesh 1D and 2D

  3. Save the file as t.msh

  4. Run

    from dolfinx.io import gmshio
    from mpi4py import MPI
    import gmsh
    gmsh_file_data = gmshio.read_from_msh("/tmp/t.msh", MPI.COMM_WORLD, gdim=2)
    
  5. I get

    Python 3.10.5 (main, Jun  6 2022, 18:49:26) [GCC 12.1.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from dolfinx.io import gmshio
    from mpi4py import MPI
    import gmsh
    >>> >>> >>> gmsh_file_data = gmshio.read_from_msh("/tmp/t.msh", MPI.COMM_WORLD, gdim=2)
    Info    : Reading '/tmp/t.msh'...
    Info    : 13 entities
    Info    : 18 nodes
    Info    : 12 elements
    Info    : Done reading '/tmp/t.msh'
    /usr/include/c++/12.1.0/bits/stl_vector.h:1123: constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::vector<long int>; _Alloc = std::allocator<std::vector<long int> >; reference = std::vector<long int>&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
    [myhost:462784] *** Process received signal ***
    [myhost:462784] Signal: Aborted (6)
    [myhost:462784] Signal code:  (-6)
    [myhost:462784] [ 0] /usr/lib/libc.so.6(+0x3e8e0)[0x7fd0e423e8e0]
    [myhost:462784] [ 1] /usr/lib/libc.so.6(+0x8e36c)[0x7fd0e428e36c]
    [myhost:462784] [ 2] /usr/lib/libc.so.6(raise+0x18)[0x7fd0e423e838]
    [myhost:462784] [ 3] /usr/lib/libc.so.6(abort+0xcf)[0x7fd0e4228535]
    [myhost:462784] [ 4] /usr/lib/libstdc++.so.6(+0xd2002)[0x7fd0e02d2002]
    [myhost:462784] [ 5] /usr/lib/libdolfinx.so.0.5(_ZN7dolfinx2io10xdmf_utils22distribute_entity_dataERKNS_4mesh4MeshEiRKSt4spanIKlLm18446744073709551615EERKS6_IKiLm18446744073709551615EE+0xf31)[0x7fd0e356f871]
    [myhost:462784] [ 6] /usr/lib/python3.10/site-packages/dolfinx/cpp.cpython-310-x86_64-linux-gnu.so(+0x1f601c)[0x7fd0e39f601c]
    [myhost:462784] [ 7] /usr/lib/python3.10/site-packages/dolfinx/cpp.cpython-310-x86_64-linux-gnu.so(+0x79fa3)[0x7fd0e3879fa3]
    [myhost:462784] [ 8] /usr/lib/libpython3.10.so.1.0(+0x155511)[0x7fd0e4755511]
    [myhost:462784] [ 9] /usr/lib/libpython3.10.so.1.0(_PyObject_MakeTpCall+0x2ab)[0x7fd0e474edeb]
    [myhost:462784] [10] /usr/lib/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x575a)[0x7fd0e474a19a]
    [myhost:462784] [11] /usr/lib/libpython3.10.so.1.0(_PyFunction_Vectorcall+0x79)[0x7fd0e47559c9]
    [myhost:462784] [12] /usr/lib/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x149c)[0x7fd0e4745edc]
    [myhost:462784] [13] /usr/lib/libpython3.10.so.1.0(_PyFunction_Vectorcall+0x79)[0x7fd0e47559c9]
    [myhost:462784] [14] /usr/lib/libpython3.10.so.1.0(_PyEval_EvalFrameDefault+0x149c)[0x7fd0e4745edc]
    [myhost:462784] [15] /usr/lib/libpython3.10.so.1.0(+0x1439d0)[0x7fd0e47439d0]
    [myhost:462784] [16] /usr/lib/libpython3.10.so.1.0(PyEval_EvalCode+0x94)[0x7fd0e47f3ea4]
    [myhost:462784] [17] /usr/lib/libpython3.10.so.1.0(+0x203923)[0x7fd0e4803923]
    [myhost:462784] [18] /usr/lib/libpython3.10.so.1.0(+0x1ff2ba)[0x7fd0e47ff2ba]
    [myhost:462784] [19] /usr/lib/libpython3.10.so.1.0(+0x12144b)[0x7fd0e472144b]
    [myhost:462784] [20] /usr/lib/libpython3.10.so.1.0(_PyRun_InteractiveLoopObject+0xcf)[0x7fd0e47215e2]
    [myhost:462784] [21] /usr/lib/libpython3.10.so.1.0(_PyRun_AnyFileObject+0x66)[0x7fd0e46a1f07]
    [myhost:462784] [22] /usr/lib/libpython3.10.so.1.0(PyRun_AnyFileExFlags+0x59)[0x7fd0e4721778]
    [myhost:462784] [23] /usr/lib/libpython3.10.so.1.0(+0x9607d)[0x7fd0e469607d]
    [myhost:462784] [24] /usr/lib/libpython3.10.so.1.0(Py_BytesMain+0x3b)[0x7fd0e47e546b]
    [myhost:462784] [25] /usr/lib/libc.so.6(+0x29290)[0x7fd0e4229290]
    [myhost:462784] [26] /usr/lib/libc.so.6(__libc_start_main+0x8a)[0x7fd0e422934a]
    [myhost:462784] [27] /usr/bin/python3(_start+0x25)[0x558e6fa2b045]
    [myhost:462784] *** End of error message ***
    
    Process Python aborted (core dumped)
    

Your mesh is a mixture of triangular and quadrilateral elements. This is currently not supported, see: Supporting mixed cell type meshes · GitHub

1 Like

Oh, ok. Thanks! Any (pro) suggestions on how I can deal with those wedges? :S

Mesh your whole domain as triangles.

Thanks. I see that the task is not easy to handle (thanks for the transparency and letting me see the roadmap). All the best!

Hi, again. I removed the Recombine line, but it still gave me the same error (?)

I do not get any error messages with:

SetFactory("OpenCASCADE");

Point(1) = {0, 0, 0, 1.0};
Point(2) = {3, 0, 0, 1.0};
Rotate {{0, 0, 1}, {0, 0, 0}, Pi/6} {
  Duplicata { Point{2}; }
}
Point(4) = {1, 0, 0, 1.0};
Rotate {{0, 0, 1}, {0, 0, 0}, Pi/6} {
  Duplicata { Point{4}; }
}

Line(1) = {1, 4};
Line(2) = {5, 1};
Circle(3) = {4, 1, 5};
Line(4) = {4, 2};
Circle(5) = {2, 1, 3};
Line(6) = {3, 5};

Transfinite Curve {4} = 5 Using Progression 1;
Transfinite Curve {6} = 5 Using Progression 1;
a = 1;
Transfinite Curve {1} = 3 Using Progression a;
Transfinite Curve {2} = 3 Using Progression 1/a;

Curve Loop(1) = {1, 3, 2};
Plane Surface(1) = {1};
Curve Loop(2) = {4, 5, 6, -3};
Plane Surface(2) = {2};
Transfinite Surface {2};

Transfinite Curve {3} = 3 Using Progression 1;
Transfinite Curve {5} = 3 Using Progression 1;

Physical Surface("small", 7) = {1};
Physical Surface("big", 8) = {2};

resulting in

$MeshFormat
4.1 0 8
$EndMeshFormat
$PhysicalNames
2
2 7 "small"
2 8 "big"
$EndPhysicalNames
$Entities
5 6 2 0
1 0 0 0 0 
2 3 0 0 0 
3 2.598076211353316 1.5 0 0 
4 1 0 0 0 
5 0.8660254037844387 0.4999999999999999 0 0 
1 -9.999999994736442e-08 -1e-07 -1e-07 1.0000001 1e-07 1e-07 0 2 1 -4 
2 -1.000000000028756e-07 -9.999999997511999e-08 -1e-07 0.8660255037844387 0.5000000999999999 1e-07 0 2 5 -1 
3 0.8660253037844391 -1.000000001416534e-07 -1e-07 1.0000001 0.5000000999999994 1e-07 0 2 4 -5 
4 0.9999999000000002 -1e-07 -1e-07 3.0000001 1e-07 1e-07 0 2 4 -2 
5 2.598076111353317 -1.000000003914536e-07 -1e-07 3.0000001 1.500000099999998 1e-07 0 2 2 -3 
6 0.8660253037844389 0.4999999000000001 -1e-07 2.598076311353316 1.5000001 1e-07 0 2 3 -5 
1 -9.999999994736442e-08 -1.000000001416534e-07 -1e-07 1.0000001 0.5000000999999999 1e-07 1 7 3 1 3 2 
2 0.8660253037844388 -1.000000003914536e-07 -1e-07 3.0000001 1.5000001 1e-07 1 8 4 4 5 6 -3 
$EndEntities
$Nodes
13 18 1 18
0 1 0 1
1
0 0 0
0 2 0 1
2
3 0 0
0 3 0 1
3
2.598076211353316 1.5 0
0 4 0 1
4
1 0 0
0 5 0 1
5
0.8660254037844387 0.4999999999999999 0
1 1 0 1
6
0.5 0 0
1 2 0 1
7
0.4330127018922194 0.25 0
1 3 0 1
8
0.9659258262890685 0.2588190451025199 0
1 4 0 3
9
10
11
1.5 0 0
2 0 0
2.5 0 0
1 5 0 1
12
2.897777478867205 0.7764571353075598 0
1 6 0 3
13
14
15
2.165063509461097 1.25 0
1.732050807568877 0.9999999999999999 0
1.299038105676658 0.75 0
2 1 0 0
2 2 0 3
16
17
18
1.448888739433603 0.3882285676537803 0
1.931851652578137 0.5176380902050405 0
2.414814565722671 0.6470476127563005 0
$EndNodes
$Elements
2 20 1 20
2 1 2 4
1 7 6 8 
2 7 1 6 
3 6 4 8 
4 8 5 7 
2 2 2 16
5 4 9 8 
6 8 9 16 
7 8 16 5 
8 5 16 15 
9 9 10 16 
10 16 10 17 
11 16 17 15 
12 15 17 14 
13 10 11 17 
14 17 11 18 
15 17 18 14 
16 14 18 13 
17 11 2 18 
18 18 2 12 
19 18 12 13 
20 13 12 3 
$EndElements

and read in with

from mpi4py import MPI
import dolfinx.io.gmshio
mesh, cell_tags, facet_tags = dolfinx.io.gmshio.read_from_msh("mesh.msh", MPI.COMM_WORLD, 0, gdim=2)
print(mesh, cell_tags, facet_tags)
1 Like

Oh! I see. I was trying .geo and you have .msh. (I stilll get the error with the .geo, but I don’t care.) Thanks!

This does not generate a new msh file. You would need to use gmsh.write("/tmp/t.geo")

I am really appreciative of your time and answer, and don’t want to bother you any more with this. Reading a .msh is enough for me. Thanks!
[Edit]
(Those four lines were to show that I could read the file without gmshio)