How to read mesh for the geometry, which has two materials.

118 views
Skip to first unread message

Deepika Kushwah

unread,
Feb 6, 2023, 3:01:17 AM2/6/23
to dea...@googlegroups.com
Hello Everyone,

I am trying to read mesh using Gmsh for the geometry attached.
 I have already checked step 49, and in the same way, I want to read the mesh for my geometry. Still, in my case, I cannot specify the manifold id correctly, and without specifying anything about the material id and manifold id, I am getting the following error.  
I am also attaching the .geo and .msh files and the piece of code for reference. 
image.png
image.png

Please help me to rectify this error. 


Thanks & Regards, 
Deepika

**************************************************************************
This e-mail is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. If you are not the
intended recipient, please contact the sender by reply e-mail and destroy
all copies and the original message. Any unauthorized review, use,
disclosure, dissemination, forwarding, printing or copying of this email
is strictly prohibited and appropriate legal action will be taken.
************************************************************************************************
matrix_fiber.txt
feb.geo
feb.msh

Deepika Kushwah

unread,
Feb 6, 2023, 4:02:22 AM2/6/23
to dea...@googlegroups.com
After recombining the mesh for the same geometry I am getting a different error. What is the meaning of this error I am not understanding. 
Please advise.

image.png

Wolfgang Bangerth

unread,
Feb 7, 2023, 7:43:53 PM2/7/23
to dea...@googlegroups.com

Deepika:
when running with the current deal.II version, the error message I get
is this (which I think explains the issue):

--------------------------------------------------------
An error occurred in line <2643> of file
</home/fac/g/bangerth/p/deal.II/1/dealii/source/grid/grid_in.cc> in function
void dealii::GridIn<dim, spacedim>::read_msh(std::istream&) [with
int dim = 2; int spacedim = 2; std::istream = std::basic_istream<char>]
The violated condition was:
cells.size() > 0
Additional information:
While reading a gmsh file, the reader function did not find any cells.
This sometimes happens if the file only contains a surface mesh, but
not a volume mesh.

The reader function did find 456 lines and 0 facets (surface triangles
or quadrilaterals).


Best
W.


On 2/6/23 01:00, Deepika Kushwah wrote:
> *** Caution: EXTERNAL Sender ***
>
> Hello Everyone,
>
> I am trying to read mesh using Gmsh for the geometry attached.
>  I have already checked step 49, and in the same way, I want to read
> the mesh for my geometry. Still, in my case, I cannot specify the
> manifold id correctly, and without specifying anything about the
> material id and manifold id, I am getting the following error.
> I am also attaching the .geo and .msh files and the piece of code for
> reference.
> image.png
> image.png
>
> Please help me to rectify this error.
>
>
> Thanks & Regards,
> Deepika
>
> **************************************************************************
> This e-mail is for the sole use of the intended recipient(s) and may
> contain confidential and privileged information. If you are not the
> intended recipient, please contact the sender by reply e-mail and destroy
> all copies and the original message. Any unauthorized review, use,
> disclosure, dissemination, forwarding, printing or copying of this email
> is strictly prohibited and appropriate legal action will be taken.
> ************************************************************************************************
>
>
> --
> The deal.II project is located at http://www.dealii.org/
> <https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dealii.org%2F&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cd8eb82933c2249ed14c108db081853df%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638112674141435862%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=QppMSJl4SKchjhUkFjkPFUQkka26a6EieILU0pfhLKc%3D&reserved=0>
> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fforum%2Fdealii%3Fhl%3Den&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cd8eb82933c2249ed14c108db081853df%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638112674141435862%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=U0n39BwNXOEirj3yrmN1Iz4vJAskzLdm5Tbe8Q0osbs%3D&reserved=0>
> ---
> You received this message because you are subscribed to the Google
> Groups "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to dealii+un...@googlegroups.com
> <mailto:dealii+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/CAKTdrpqikDwVDQF--up_%2B9oe9vnY_2%2BqyZXGLuDBLHYGcmK3Ag%40mail.gmail.com
> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fdealii%2FCAKTdrpqikDwVDQF--up_%252B9oe9vnY_2%252BqyZXGLuDBLHYGcmK3Ag%2540mail.gmail.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cd8eb82933c2249ed14c108db081853df%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638112674141435862%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=CEY0zwDDdhP1wef9eNjZUB55X61EVHn8R9p9n4ZZT7A%3D&reserved=0>.


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

Wolfgang Bangerth

unread,
Feb 7, 2023, 7:44:56 PM2/7/23
to dea...@googlegroups.com
On 2/6/23 02:01, Deepika Kushwah wrote:
> **
>
> After recombining the mesh for the same geometry I am getting a
> different error. What is the meaning of this error I am not understanding.

If you can share the mesh, I can see what I find.
Best
W.

Deepika Kushwah

unread,
Feb 8, 2023, 12:12:37 AM2/8/23
to dea...@googlegroups.com
Thank you Prof. for your reply.

Sorry, but I am not understanding the volume mesh. Although I have again tried to read the same geometry with the "Tranfinite" option. 
Now I am getting the following error (With or without using transfinite option)

image.png
The geometry and msh files are attached here for the reference:
image.png


To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/98ad1d1e-5ae3-7bc4-16c0-35f3d3a01eeb%40colostate.edu.


--
Thanks and Regards

Deepika Kushwah
20263203 
PhD Scholar, School of Mechanical Science,
IIT Goa 
7dec.geo
7dec.msh

Wolfgang Bangerth

unread,
Feb 8, 2023, 12:09:26 PM2/8/23
to dea...@googlegroups.com
On 2/7/23 22:11, Deepika Kushwah wrote:
>
> Sorry, but I am not understanding the volume mesh. Although I have again
> tried to read the same geometry with the "Tranfinite" option.
> Now I am getting the following error (With or without using transfinite
> option)

Deepika:
I think the error message is actually quite detailed. My suspicion is
that gmsh created a mesh in which the inner and the outer cells are
created with opposite orientations. I don't know how to fix this -- that
would be a question for the gmsh forum.

The geometry for which you are creating a mesh is similar to ones that
you can find in the GridGenerator namespace. It may be possible to not
use gmsh altogether, but create a mesh for this geometry in deal.II.
This would likely also yield a better mesh: Many of the cells in your
picture are very elongated.

Best
W.

Deepika Kushwah

unread,
Feb 9, 2023, 12:02:18 AM2/9/23
to dea...@googlegroups.com
Thank you Prof. for your suggestions.

I have already tried the merge triangulation for my geometry (using step -65), but during the loading conditions the deformation of the cells is not proper and separation is occurring between them.
(The boundary conditions are applied here as the left edge is fixed and the right edge is subjected to the displacement of 1 unit). Please see the attachment.
As per my understanding, the inner cell is not connected correctly with the outer cell. 
My questions are:
1. How to make sure that both the triangulations are united after using the merge triangulation option?
2. Is there anything wrong with my boundary Ids, material id or manifold id assignment?
image.png
image.png

Triangulation<2> tria_outer;
  //const bool colorize = true;
   GridGenerator::hyper_cube_with_cylindrical_hole(tria_outer, .5,1,0 ,0);
   
 Triangulation<2> tria_inner;
  GridGenerator::hyper_ball(tria_inner, Point<2>(), 0.5);
 
GridGenerator::merge_triangulations(tria_inner, tria_outer, triangulation);
 triangulation.reset_all_manifolds();
 triangulation.set_all_manifold_ids(0);
 
  for (const auto &cell : triangulation.cell_iterators())
    {
      for (const auto &face : cell->face_iterators())
         {
            if (face->at_boundary())
                      {
                         if (face->center()[0] == -1)
                        {
                          face->set_boundary_id (1);
                        }
                         if (face->center()[1] == -1)
                        {
                          face->set_boundary_id (2);
                        }
                         if (face->center()[0] == 1)
                        {
                         face->set_boundary_id (3);
                        }
                         if (face->center()[1] == 1)
                        {
                         face->set_boundary_id (4);
                        }
                      }
        
          bool face_at_sphere_boundary = true;
          for (const auto v : face->vertex_indices())
            {
              if (std::abs(face->vertex(v).norm_square() - 0.25) > 1e-12)
                face_at_sphere_boundary = false;
            }
          if (face_at_sphere_boundary)
            face->set_all_manifold_ids(10);
        }
      if (cell->center().norm_square() < 0.25)
        cell->set_material_id(15);
      else
        cell->set_material_id(20);
    }
  triangulation.set_manifold(10, SphericalManifold<2>());
  TransfiniteInterpolationManifold<2> transfinite_manifold;
   transfinite_manifold.initialize(triangulation);
   triangulation.set_manifold(0, transfinite_manifold);
 
  triangulation.refine_global(4);
 

--
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 the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.


--
Thanks and Regards

Deepika Kushwah

Daniel Arndt

unread,
Feb 9, 2023, 9:49:29 AM2/9/23
to dea...@googlegroups.com
Deepika,

step-65 (https://www.dealii.org/current/doxygen/deal.II/step_65.html) creates the geometry you are interested in. In particular, it is using

Triangulation<dim> tria_inner;
Triangulation<dim> tria_outer;
tria_outer, Point<dim>(), 0.5, std::sqrt(dim), 2 * dim);
 
with appropriate manifolds. When merging triangulations, you have to make sure that the vertices on the surface coincide.

Best,
Daniel

Deepika Kushwah

unread,
Feb 9, 2023, 10:01:47 AM2/9/23
to dea...@googlegroups.com
Sir,

Thanks for your response.

As mentioned in my previous mail I have followed the same procedure as mentioned by you.
Here I have used "hyper_cube_with cylindrical hole" in place of "hyper_shell" (Code has been attached).
However, it is not clear how to  ensure that the vertices on the surface coincide. 
It would be helpful if you could explain a little more in detail. 


Thanks
Deepika


Wolfgang Bangerth

unread,
Feb 9, 2023, 11:32:14 AM2/9/23
to dea...@googlegroups.com
On 2/9/23 08:01, Deepika Kushwah wrote:
>
> As mentioned in my previous mail I have followed the same procedure as
> mentioned by you.
> Here I have used "hyper_cube_with cylindrical hole" in place of
> "hyper_shell" (Code has been attached).
> However, it is not clear how to  ensure that the vertices on the surface
> coincide.
> It would be helpful if you could explain a little more in detail.

When you call merge_triangulation(), can you set a tolerance larger than
the default of 1e-12? Does that lead to merged vertices?

https://dealii.org/developer/doxygen/deal.II/namespaceGridGenerator.html#ae6b11dc96dd9165e25495f74def3655d

Deepika Kushwah

unread,
Feb 9, 2023, 1:29:34 PM2/9/23
to dea...@googlegroups.com
I have changed the default tolerance as you suggested but the problem is still persisting.
In the coarse meshing, there are only 4 points connected between the two triangulations and after refinement there is still the same connection.
How can we increase the connecting points?
image.png

--
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 the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.

Wolfgang Bangerth

unread,
Feb 9, 2023, 3:07:39 PM2/9/23
to dea...@googlegroups.com
On 2/9/23 11:28, Deepika Kushwah wrote:
> **
>
> I have changed the default tolerance as you suggested but the problem is
> still persisting.
> In the coarse meshing, there are only 4 points connected between the two
> triangulations and after refinement there is still the same connection.
> How can we increase the connecting points?

I see the problem now. If you count how many points there are on the
circle from the inner mesh and the outer mesh, the number is different.
These meshes *can't* be merged as you want. Merging meshes can only work
if you have the same number of vertices coming together at the interface
where you want to merge the meshes.

Deepika Kushwah

unread,
Feb 9, 2023, 11:04:32 PM2/9/23
to dea...@googlegroups.com
Thank you for your explanation.

Is there any other way by which I can create the same geometry (Circular inclusion in the square) ?
My project is related to "Multiscale Modeling of Failure of Composite Materials" for that purpose I need to create a different RVE (Representative Volume Element) for the heterogeneous material. These RVE may include one or more circular fiber or inclusions.
How can I solve this problem with dealii?

Please see the attached example of RVE below, which I want to create in dealii.

image.png


Thanks and regards,
Deepika


--
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 the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.

Wolfgang Bangerth

unread,
Feb 10, 2023, 12:55:40 PM2/10/23
to dea...@googlegroups.com

Deepika,
GridGenerator has a number of functions that do similar things to what you
want to do, such as plate_with_a_hole(), channel_with_hole(), specifically
merging different triangulations for different parts of the domain. You will
want to study how they are implemented:
https://github.com/dealii/dealii/blob/master/source/grid/grid_generator.cc

In the end, it all comes down to constructing the different pieces of a mesh
separately but in a way so that the resulting vertices match, and then merging
them. Search for merge_triangulation() in the file linked to above and try to
understand the context in which it is used, say in the plate_with_a_hole()
function. If you understand what is done there, you will understand how you
can create the meshes you want to generate.

Best
W.


On 2/9/23 21:03, Deepika Kushwah wrote:
> *** Caution: EXTERNAL Sender ***
>
> Thank you for your explanation.
>
> Is there any other way by which I can create the same geometry (Circular
> inclusion in the square) ?
> My project is related to "Multiscale Modeling of Failure of Composite
> Materials" for that purpose I need to create a different RVE (Representative
> Volume Element) for the heterogeneous material. These RVE may include one or
> more circular fiber or inclusions.
> How can I solve this problem with dealii?
>
> Please see the attached example of RVE below, which I want to create in dealii.
>
> image.png
>
>
> Thanks and regards,
> Deepika
>
>
> On Fri, Feb 10, 2023 at 1:37 AM Wolfgang Bangerth <bang...@colostate.edu
> <mailto:bang...@colostate.edu>> wrote:
>
> On 2/9/23 11:28, Deepika Kushwah wrote:
> > **
> >
> > I have changed the default tolerance as you suggested but the problem is
> > still persisting.
> > In the coarse meshing, there are only 4 points connected between the two
> > triangulations and after refinement there is still the same connection.
> > How can we increase the connecting points?
>
> I see the problem now. If you count how many points there are on the
> circle from the inner mesh and the outer mesh, the number is different.
> These meshes *can't* be merged as you want. Merging meshes can only work
> if you have the same number of vertices coming together at the interface
> where you want to merge the meshes.
>
> Best
>   W.
>
> --
> ------------------------------------------------------------------------
> Wolfgang Bangerth          email: bang...@colostate.edu
> <mailto:bang...@colostate.edu>
>                             www: http://www.math.colostate.edu/~bangerth/
> <http://www.math.colostate.edu/~bangerth/>
>
> --
> The deal.II project is located at http://www.dealii.org/
> <https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dealii.org%2F&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cd8425706e19d46b2ec6608db0b1bea49%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638115987960963969%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=w%2BmF3IiNsGXfIpVjYe9TH3f7gQGYEF8vRFXKdSEpncE%3D&reserved=0>
> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fforum%2Fdealii%3Fhl%3Den&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cd8425706e19d46b2ec6608db0b1bea49%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638115987960963969%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=KN2j6WWNRR9kN23JLtaujzUuXgfRmC5ygMpO%2BMYbnPs%3D&reserved=0>
> ---
> You received this message because you are subscribed to the Google Groups
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to dealii+un...@googlegroups.com
> <mailto:dealii%2Bunsu...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/c50b5e9c-75e1-b4b8-3b82-73f8b58e6b15%40colostate.edu <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fdealii%2Fc50b5e9c-75e1-b4b8-3b82-73f8b58e6b15%2540colostate.edu&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cd8425706e19d46b2ec6608db0b1bea49%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638115987960963969%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=W2u8k86RtWkQIEeIjgGA2%2FZeAK91CgpM3P%2B7T2tMnfk%3D&reserved=0>.
>
>
> **************************************************************************
> This e-mail is for the sole use of the intended recipient(s) and may
> contain confidential and privileged information. If you are not the
> intended recipient, please contact the sender by reply e-mail and destroy
> all copies and the original message. Any unauthorized review, use,
> disclosure, dissemination, forwarding, printing or copying of this email
> is strictly prohibited and appropriate legal action will be taken.
> ************************************************************************************************
>
> --
> The deal.II project is located at http://www.dealii.org/
> <https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dealii.org%2F&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cd8425706e19d46b2ec6608db0b1bea49%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638115987960963969%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=w%2BmF3IiNsGXfIpVjYe9TH3f7gQGYEF8vRFXKdSEpncE%3D&reserved=0>
> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fforum%2Fdealii%3Fhl%3Den&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cd8425706e19d46b2ec6608db0b1bea49%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638115987960963969%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=KN2j6WWNRR9kN23JLtaujzUuXgfRmC5ygMpO%2BMYbnPs%3D&reserved=0>
> ---
> You received this message because you are subscribed to the Google Groups
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to dealii+un...@googlegroups.com
> <mailto:dealii+un...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/CAKTdrpqk3Kuo_VYnGxmwwcyaQLvX%2BLSS3rfi8dKq%2BojXOnY-iw%40mail.gmail.com <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fdealii%2FCAKTdrpqk3Kuo_VYnGxmwwcyaQLvX%252BLSS3rfi8dKq%252BojXOnY-iw%2540mail.gmail.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cd8425706e19d46b2ec6608db0b1bea49%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C638115987960963969%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=33l1HpuOEEYpiv33TPNEalyMAhWogLo5OqUDB%2BNxjEM%3D&reserved=0>.

Deepika Kushwah

unread,
Feb 13, 2023, 10:37:22 PM2/13/23
to dea...@googlegroups.com
Thank you Prof. for the information. I'll check it out.



To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/ce3994d0-6476-8f02-201a-2842441367b8%40colostate.edu.


--
Thanks and Regards

Deepika Kushwah

Reply all
Reply to author
Forward
0 new messages