본문으로 바로가기

gmsh를 이용한 meshing

category Devlogs 2024. 3. 15. 10:39

자.. 우선 gmsh 의 입력 geometry를 작성..

이건 cube 형태의 geometry..

//test.geo
Point(1) = {1, 0, 0, 1.0};
Point(2) = {1, 1, 0, 1.0};
Point(3) = {0, 1, 0, 1.0};
Point(4) = {0, 0, 1, 1.0};
Point(5) = {1, 0, 1, 1.0};
Point(6) = {1, 1, 1, 1.0};
Point(7) = {0, 1, 1, 1.0};
Point(8) = {0, 0, 0, 1.0};
Line(1) = {7, 6};
Line(2) = {6, 5};
Line(3) = {5, 1};
Line(4) = {1, 8};
Line(5) = {8, 3};
Line(6) = {3, 7};
Line(7) = {7, 4};
Line(8) = {4, 8};
Line(9) = {4, 5};
Line(10) = {2, 1};
Line(11) = {2, 6};
Line(12) = {2, 3};
Line Loop(1) = {6, 1, -11, 12};
Plane Surface(1) = {1};
Line Loop(2) = {11, 2, 3, -10};
Plane Surface(2) = {2};
Line Loop(3) = {2, -9, -7, 1};
Plane Surface(3) = {-3};
Line Loop(4) = {6, 7, 8, 5};
Plane Surface(4) = {-4};
Line Loop(5) = {8, -4, -3, -9};
Plane Surface(5) = {5};
Line Loop(6) = {10, 4, 5, -12};
Plane Surface(6) = {6};
Physical Surface(1) = {4, 3, 2, 6};
Physical Surface(2) = {1};
Physical Surface(3) = {5};
Surface Loop(1) = {6, 2, 1, 4, 3, 5};
Volume(1) = {1};

 

이제 gmsh 옵션으로.. 2d (-2), 알고리즘은 meshadapt를.. 아웃풋 포맷은 LsDyna의 key 포맷으로..
요소 최소/최대 사이즈를 지정하면..

gmsh.exe test.geo -2 -algo meshadapt -o test.key -format key -clmin 0.01 -clmax 0.05
...
Info    : Meshing 2D...
Info    : Meshing surface 1 (Plane, Frontal Quad)
Info    : Meshing surface 2 (Plane, Frontal Quad)
Info    : Meshing surface 3 (Plane, Frontal Quad)
Info    : Meshing surface 4 (Plane, Frontal Quad)
Info    : Meshing surface 5 (Plane, Frontal Quad)
Info    : Meshing surface 6 (Plane, Frontal Quad)
Info    : Done meshing 2D (0.109375 s)
Info    : 2402 nodes 5048 elements
Info    : Writing 'test.key'...
Info    : Done writing 'test.key'


짜잔~


요렇게 생성이 됨.

자.. 이제 quad 메싱은 맨 위의 입력 geom 파일 끝 줄에 아래를 추가..

Recombine Surface "*";


다음.. 아래와 같이..하고 algorithm은 delquad를 사용하여 매싱을 하면..

gmsh.exe test.geo -2 -algo delquad -o test.key -format key -clmin 0.01 -clmax 0.05
...
Info    : Meshing surface 6 (Plane, Frontal Quad)
Info    : Blossom: 1160 internal 76 closed
Info    : Blossom recombination completed (0 s): 400 quads, 0 triangles, 0 invalid quads, 0 quads with Q < 0.1, avg Q = 1, min Q = 1
Info    : Done meshing 2D (0.09375 s)
Info    : 2402 nodes 2648 elements
Info    : Writing 'test.key'...
Info    : Done writing 'test.key'

 


오… 꽤 쓸만함..

근데.. 문제는 gmsh의 경우 tria + quad 의 mixed 는 안된다고함..
단 한 surface는 tria를.. 다른 surface는 quad 는 가능함..

무슨 말이냐하면.. 아래와 같이 특정 1번 surface만 recombine을 적용하면..

//Recombine Surface "*";
Recombine Surface{1};

 

한면만 quad로 meshing이된다..

다음 tetra 는 직접 step 캐드 파일로부터 해봄..
다음과 같은 test.step 파일이 있을때..

 

아래와 같이 geom 파일을 작성하고..

// stl2msh.geo
Merge "test.step";
Surface Loop(1) = 1;
Volume(1) = 1;
Physical Volume("obj") = {1};
 
//Mesh.Algorithm3D = 4; //(1=tetgen, 4=netgen, 7=MMG3D, 9=R-tree)
Mesh.Recombine3DAll=1;
Mesh.Smoothing=0;
Mesh.Optimize=1;
Mesh.OptimizeNetgen=1;

 

gmsh를 아래와 같이 돌리면..

gmsh.exe stl2msh.geo -3 -o test.key -format key -clmax 1.0 -clmin 0.1

 


짜잔.. 잘 된것 같은데.. 문제는 형상이 몇개 빠진듯.. -_-;;
암튼.. 메시 사이즈를 0.4 정도로 주고 다시 해보면..


잘되는듯하다..

gmsh의 경우 hexa가 안되는게 제일 문제..

종합해보면..

1. quad, tria 지원 (mixed 미지원)
2. tetra 지원
3. hexa 미지원

아래는 각 메시 라이브러리별 지원 항목..


Korea Tcl/Tk Community
블로그 이미지 ihmin 님의 블로그
VISITOR 오늘 / 전체