admin管理员组文章数量:1289528
I have a problem with the code below, I want to generate the triangular mesh only in the rectangular area, inside the circle, I don't want any mesh. How can I do this?
//Flow with obstacle
Mesh.MshFileVersion = 2.2;
// Size of the mesh
lc = 0.25;
// Points
Point(1) = {0, 0, 0, lc};
Point(2) = {8, 0, 0, lc};
Point(3) = {8, 2, 0, lc};
Point(4) = {0, 2, 0, lc};
// Circle
xc = 4; // Coord x
yc = 1; // Coord y
r = 0.2; // radius of the circle
Point(5) = {xc, yc + r, 0, lc}; // Point top
Point(6) = {xc, yc, 0, lc}; // Point central
Point(7) = {xc, yc - r, 0, lc}; // Point bottom
// Lines of the rectangle
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
// Circle
Circle(5) = {7, 6, 5};
Circle(6) = {5, 6, 7};
// Surface of the rectangle
Curve Loop(1) = {1, 2, 3, 4};
Plane Surface(1) = {1};
// Surface of the circle
Curve Loop(2) = {5, 6, 7};
Plane Surface(2) = {2};
// Setting the mesh
Transfinite Surface {1};
// Subtract the circle from the rectangle
BooleanDifference{ Plane Surface{1}; Delete; }{ Plane Surface{2}};
The code was generated in the GMSH software.
I have a problem with the code below, I want to generate the triangular mesh only in the rectangular area, inside the circle, I don't want any mesh. How can I do this?
//Flow with obstacle
Mesh.MshFileVersion = 2.2;
// Size of the mesh
lc = 0.25;
// Points
Point(1) = {0, 0, 0, lc};
Point(2) = {8, 0, 0, lc};
Point(3) = {8, 2, 0, lc};
Point(4) = {0, 2, 0, lc};
// Circle
xc = 4; // Coord x
yc = 1; // Coord y
r = 0.2; // radius of the circle
Point(5) = {xc, yc + r, 0, lc}; // Point top
Point(6) = {xc, yc, 0, lc}; // Point central
Point(7) = {xc, yc - r, 0, lc}; // Point bottom
// Lines of the rectangle
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
// Circle
Circle(5) = {7, 6, 5};
Circle(6) = {5, 6, 7};
// Surface of the rectangle
Curve Loop(1) = {1, 2, 3, 4};
Plane Surface(1) = {1};
// Surface of the circle
Curve Loop(2) = {5, 6, 7};
Plane Surface(2) = {2};
// Setting the mesh
Transfinite Surface {1};
// Subtract the circle from the rectangle
BooleanDifference{ Plane Surface{1}; Delete; }{ Plane Surface{2}};
The code was generated in the GMSH software.
Share Improve this question asked Feb 20 at 13:57 Afrânio AugustoAfrânio Augusto 211 silver badge1 bronze badge1 Answer
Reset to default 0Correct code is as following:
Mesh.MshFileVersion = 2.2;
// Size of the mesh
lc = 0.25;
// Points
Point(1) = {0, 0, 0, lc};
Point(2) = {8, 0, 0, lc};
Point(3) = {8, 2, 0, lc};
Point(4) = {0, 2, 0, lc};
// Circle
xc = 4; // Coord x
yc = 1; // Coord y
r = 0.2; // radius of the circle
Point(5) = {xc, yc + r, 0, lc}; // Point top
Point(6) = {xc, yc, 0, lc}; // Point central
Point(7) = {xc, yc - r, 0, lc}; // Point bottom
// Lines of the rectangle
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
// Circle
Circle(5) = {7, 6, 5};
Circle(6) = {5, 6, 7};
// Surface of the rectangle
Curve Loop(1) = {1, 2, 3, 4};
//Plane Surface(1) = {1};
// Surface of the circle
Curve Loop(2) = {5, 6};
//Plane Surface(2) = {2};
Plane Surface(1) = {1,2};
// Setting the mesh
//Transfinite Surface {1};
// Subtract the circle from the rectangle
//BooleanDifference{ Plane Surface{1}; Delete; }{ Plane Surface{2}};
Curve Loop(2) = {5, 6, 7};
is changed to Curve Loop(2) = {5, 6};
- curve 7 does not exist.
Plane Surface(1) = {1,2}
is used to create a surface with a hole. Transfinite Surface {1}
has a sense only if all curves in the surface are also transfinite.
A use of BooleanDifference
is also possible, however it requires SetFactory("OpenCASCADE");
in the beginning :
SetFactory("OpenCASCADE");
Mesh.MshFileVersion = 2.2;
// Size of the mesh
lc = 0.25;
// Points
Point(1) = {0, 0, 0, lc};
Point(2) = {8, 0, 0, lc};
Point(3) = {8, 2, 0, lc};
Point(4) = {0, 2, 0, lc};
// Circle
xc = 4; // Coord x
yc = 1; // Coord y
r = 0.2; // radius of the circle
Point(5) = {xc, yc + r, 0, lc}; // Point top
Point(6) = {xc, yc, 0, lc}; // Point central
Point(7) = {xc, yc - r, 0, lc}; // Point bottom
// Lines of the rectangle
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
// Circle
Circle(5) = {7, 6, 5};
Circle(6) = {5, 6, 7};
// Surface of the rectangle
Curve Loop(1) = {1, 2, 3, 4};
Plane Surface(1) = {1};
// Surface of the circle
Curve Loop(2) = {5, 6};
Plane Surface(2) = {2};
// Subtract the circle from the rectangle
BooleanDifference{ Surface{1}; Delete; }{ Surface{2};Delete;}
本文标签: GMSH with the obstacleStack Overflow
版权声明:本文标题:GMSH with the obstacle - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741429937a2378297.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论