How to create mesh for a plate with a hole in Gmsh
Problem statement:
A rectangular section of size 2 X 1, with a hole at center (1, 0.5) of diameter 0.5.
Steps:
- Create points as per your geometry. For this go to Modules β Geometry β Elementary entities β Add β Point. You will see a dialogue box opened, just enter the coordinates of each point and click on add.
- After creating all point next step is to join all those point using line to form a complete geometry. For this Go to Modules β Geometry β Elementary entities β Add β Line. Follow the instructions shown on the screen, i.e you have to select the start and end point of the line.
- Create the hole using the circle option. For this Go to Modules β Geometry β Elementary entities β Add β Circle. Just enter the coordinates of center point and radius of circle.
- Next step is to create a Plane surface. For this Go to Modules β Geometry β Elementary entities β Add β Plane Surface. Then select the surface boundary of the rectangle and then select the circle boundary and then press βeβ to end selection.
- For 2D geometries it is very important to define Physical group for the created surface. For this Go to Modules β Geometry β Physical groups β Add β Surface β Give a proper name tag β select the surface and press βeβ to add.
- Next step is for meshing. You can simply go to Modules β Mesh β 1D β 2D.
- Last and final step is to save the mesh.
The file generated here will be saved in .msh format, which you can further convert into xdmf with the help of βMeshioβ and you are good to import this mesh file in FEniCS.
Script :
Point(1) = {0, 0, 0, 1.0};
Point(2) = {2, 0, 0, 1.0};
Point(3) = {2, 1, 0, 1.0};
Point(4) = {0, 1, 0, 1.0};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Circle(5) = {1, 0.5, 0, 0.25, 0, 2*Pi};
Curve Loop(1) = {3, 4, 1, 2};
Curve Loop(2) = {5};
Plane Surface(1) = {1, 2};
Physical Surface("domain", 6) = {1};