How to read vertex boundary indicators from MSH format

139 views
Skip to first unread message

Jan Stebel

unread,
Aug 24, 2015, 5:21:28 AM8/24/15
to deal.II User Group
Hi all,

I want to read a GMSH mesh consisting of line elements where the vertex at each end has set a physical number (i.e. boundary indicator in deal.II terminology). After reading the mesh file using GridIn::read_msh(), the physical numbers of vertices are lost and the vertices have boundary indicators either 0 or 1. Is there a simple way how to read the original id's?

Thanks,
Jan

Wolfgang Bangerth

unread,
Aug 24, 2015, 5:45:17 PM8/24/15
to dea...@googlegroups.com
The GridIn functions don't pass on information about individual vertices
at the moment. Can you produce a simple enough example input file that
demonstrates what you want to happen, but where this doesn't happen?
Anything that we can make into a regular testcase would be useful.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@math.tamu.edu
www: http://www.math.tamu.edu/~bangerth/

Jan Stebel

unread,
Aug 25, 2015, 3:13:32 AM8/25/15
to deal.II User Group
On 08/24/2015 04:21 AM, Jan Stebel wrote:
>
> I want to read a GMSH mesh consisting of line elements where the vertex
> at each end has set a physical number (i.e. boundary indicator in
> deal.II terminology). After reading the mesh file using
> GridIn::read_msh(), the physical numbers of vertices are lost and the
> vertices have boundary indicators either 0 or 1. Is there a simple way
> how to read the original id's?

The GridIn functions don't pass on information about individual vertices
at the moment. Can you produce a simple enough example input file that
demonstrates what you want to happen, but where this doesn't happen?
Anything that we can make into a regular testcase would be useful.
 
A simple mesh file with line elements and two endpoints marked by physical numbers 10 (left) and 20 (right):

$MeshFormat
2.2 0 8
$EndMeshFormat
$Nodes
11
1 0 0 0
2 1 0 0
3 0.1 0 0
4 0.2 0 0
5 0.3 0 0
6 0.4 0 0
7 0.5 0 0
8 0.6 0 0
9 0.7 0 0
10 0.8 0 0
11 0.9 0 0
$EndNodes
$Elements
12
1 15 2 10 1 1
2 15 2 20 2 2
3 1 2 100 1 1 3
4 1 2 100 1 3 4
5 1 2 100 1 4 5
6 1 2 100 1 5 6
7 1 2 100 1 6 7
8 1 2 100 1 7 8
9 1 2 100 1 8 9
10 1 2 100 1 9 10
11 1 2 100 1 10 11
12 1 2 100 1 11 2
$EndElements

When processing by a code like:

  Triangulation<1,3> tri;
  GridIn<1,3> grid_in;
  grid_in.attach_triangulation(tri);
  std::ifstream input_file("l.msh");
  grid_in.read_msh(input_file);

  for (auto cell = tri.begin_active(); cell != tri.end(); ++cell)
  {
    for (unsigned int face = 0; face < 2; ++face)
    {
      if (cell->at_boundary(face))
        printf("vertex %d has boundary indicator %d\n", cell->face_index(face), cell->face(face)->boundary_indicator());
    }
  }

The result is:

vertex 0 has boundary indicator 0
vertex 1 has boundary indicator 1

I would like to have seen boundary indicators 10 and 20.

Thanks,
Jan

Wolfgang Bangerth

unread,
Aug 25, 2015, 12:05:07 PM8/25/15
to dea...@googlegroups.com

> The GridIn functions don't pass on information about individual vertices
> at the moment. Can you produce a simple enough example input file that
> demonstrates what you want to happen, but where this doesn't happen?
> Anything that we can make into a regular testcase would be useful.
>
>
> A simple mesh file with line elements and two endpoints marked by physical
> numbers 10 (left) and 20 (right): [...]

Great little testcase, thanks!

I've opened a bug report at
https://github.com/dealii/dealii/issues/1430
I hope to get to it sometime in the reasonably near future. Feel free to
subscribe to the report so that you get notified of any progress.

Wolfgang Bangerth

unread,
Aug 25, 2015, 5:34:11 PM8/25/15
to dea...@googlegroups.com
Fixed now -- thanks for the report!

Jan Stebel

unread,
Aug 26, 2015, 4:54:48 AM8/26/15
to deal.II User Group
Works! Thanks for quick fix.
Jan
Reply all
Reply to author
Forward
0 new messages