Read in tethex grid

81 views
Skip to first unread message

Felix

unread,
Oct 30, 2017, 7:32:46 AM10/30/17
to deal.II User Group
Hi everyone,

I have problems to read in a .msh grid.
I constructed an isosurface (spacedim =2, dim = 3) which consists of triangles (see iso0.png, iso1.png and iso2.png) and saved it as iso.msh. Now I used tethex to convert the triangles to quadrangles - result saved in iso_quad.msh and tried to read it in as Triangulation <2,3> .

Code (should be correct):

 Triangulation <2,3> iso_grid;
std::string iso = "iso.msh";                                               //  consist of triangles
std::string iso_quad = "iso_quad.msh";                               

 tethex::run(iso, iso_quad, 1);                                         // iso_quad consist of quadrangles

//Read in "iso_quad.msh" as Triangulation <2,3>   
 GridIn<2,3> grid_in;   
 grid_in.attach_triangulation(iso_grid);
 std::ifstream infile(iso_quad.c_str());
 grid_in.read_msh( infile);


This resulted in following error:

An error occurred in line <9273> of file <../source/grid/tria.cc> in function

    virtual void dealii::Triangulation<2, 3>::create_triangulation(const std::vector<Point<spacedim> > &, const std::vector<CellData<dim> > &, const dealii::SubCellData &) [dim = 2, spacedim = 3]

The violated condition was: 

    neighbor->direction_flag() == false

The name and call sequence of the exception was:

    ExcNonOrientableTriangulation()

Additional Information: 

(none)


Has anyone an idea how to fix this?

Best regards
Felix
iso0.png
iso1.png
iso2.png
iso_quad.msh
iso.msh

Bruno Turcksin

unread,
Oct 30, 2017, 8:44:02 AM10/30/17
to deal.II User Group
Felix,


On Monday, October 30, 2017 at 7:32:46 AM UTC-4, Felix wrote:

The name and call sequence of the exception was:

    ExcNonOrientableTriangulation()

Additional Information: 

(none)


Has anyone an idea how to fix this?
The problem is that there is one or more cells that is not oriented correctly. You need to find which one(s) and reorder them. You can try to slightly change the parameters used to create the mesh and hope that the cells that are wrongly ordered disappear. However, what I would try is to use gmsh to directly produce a mesh of quadrangles.

Best,

Bruno

Felix

unread,
Oct 31, 2017, 7:07:01 AM10/31/17
to deal.II User Group

However, what I would try is to use gmsh to directly produce a mesh of quadrangles.

Do you mean that I should avoid this "iso.msh" (consist of triangles) and directly construct the isosurface consisting of quadrangle and save it as .msh? 

Bruno Turcksin

unread,
Oct 31, 2017, 8:13:25 AM10/31/17
to dea...@googlegroups.com
Felix,

2017-10-31 7:07 GMT-04:00 Felix <fxxx....@gmail.com>:

However, what I would try is to use gmsh to directly produce a mesh of quadrangles.

Do you mean that I should avoid this "iso.msh" (consist of triangles) and directly construct the isosurface consisting of quadrangle and save it as .msh?
Yes, that's what I would do.

Best,

Bruno
Message has been deleted

Felix

unread,
Nov 3, 2017, 6:48:12 AM11/3/17
to deal.II User Group
Hi Bruno,

I avoid this iso.msh file but it still not work. Maybe I should mention the whole way how this isosurface is constructed.

1. Grid is constructed by dealii -> saved as grid.vtk

2. grid.vtk is read by vtkUnstructuredGridReader -> construct isosurface with the vtk class vtkContourGrid

(3. saved isosurface as iso.msh)

4. convert it by tethex and save it as "iso_quad.msh"

5. read it in dealii

For a refinement ref = 1 of the dealii grid (see 1.) it worked. But for ref > 1 the above mentioned error happens. I do not really understand how this not correctly oriented cells are created since I thought that tethex takes care of that. Do you have any further ideas?

Best regards
Felix

Bruno Turcksin

unread,
Nov 3, 2017, 8:35:16 AM11/3/17
to dea...@googlegroups.com
Felix,

2017-11-03 6:48 GMT-04:00 Felix <fxxx....@gmail.com>:
For a refinement ref = 1 of the dealii grid (see 1.) it worked. But for ref > 1 the above mentioned error happens. I do not really understand how this not correctly oriented cells are created since I thought that tethex takes care of that. Do you have any further ideas?
There is maybe a bug in tethex, I don't know. You either need to find the cell(s) which is wrong and fix it or find another way to build your mesh :(

Best,

Bruno

Felix

unread,
Nov 3, 2017, 9:30:46 AM11/3/17
to deal.II User Group
Ok thanks for your help. I will try to find a way and then post it here.

Best regards,
Felix

Felix

unread,
Nov 6, 2017, 6:20:29 AM11/6/17
to deal.II User Group
The above code is correct. Tethex works fine if the values in your "iso.msh" are of type double. My used data is of type <usigned char> and so I converted them in <double> using the following code:     

   double d = (double) data[pos];    //data[pos] is of type unsigned char&

This lead to the error-prone behavior. It works, after I changed this to 

   double d = static_cast <double> (data[position]);

Best regards,
Felix

Bruno Turcksin

unread,
Nov 6, 2017, 7:59:39 AM11/6/17
to dea...@googlegroups.com
Felix,

I am glad that you found the problem. It's good to know that Tethex works correctly if you use double. 

Best, 

Bruno 

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/y9f4bLEedmw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wolfgang Bangerth

unread,
Nov 6, 2017, 7:13:07 PM11/6/17
to dea...@googlegroups.com
Felix -- is this code in tethex, or somewhere else? I don't recall where
tethex is actually hosted, but if you suggest that the lines above are
useful, maybe they can be incorporated into tethex?

Best
W.

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

Felix

unread,
Nov 17, 2017, 9:29:20 AM11/17/17
to deal.II User Group
This code is somewhere else. There is already an exception in tethex when the data-size is not equal to sizeof(double). So I think it is ok. 

Best regards,
Felix
Reply all
Reply to author
Forward
0 new messages