# Gmsh 操作指南Ⅱ—GUI操作

Please refresh the page if equations are not rendered correctly.
---------------------------------------------------------------

[TOC]

# Gmsh 操作指南—GUI操作

## **1. 几何区域构建 **

1. File-> New -> 输入文件名"cylinder"-> 默认使用 OpenCASCADE 几何核心
2. 新建参数：Modules->Geometry->Elementary entities->Add->Parameter 添加参数 d 与 cos
d=diameter=1
cos=cos45=0.70710678


1. 添加点: Modules->Geometry->Elementary entities->Add->Point, 添加点(0,0,0), 并依次添加点
Point(2) = {d/2*cos, d/2*cos, 0, 1.0};
Point(3) = {-d/2*cos, d/2*cos, 0, 1.0};
Point(4) = {-d/2*cos, -d/2*cos, 0, 1.0};
Point(5) = {d/2*cos, -d/2*cos, 0, 1.0};

Point(6) = {2*d*cos, 2*d*cos, 0, 1.0};
Point(7) = {-2*d*cos, 2*d*cos, 0, 1.0};
Point(8) = {-2*d*cos, -2*d*cos, 0, 1.0};
Point(9) = {2*d*cos, -2*d*cos, 0, 1.0};

Point(10)={-10*d, -10*d,  0,  1.0};
Point(11)={-10*d, 10*d,  0,  1.0};
Point(12)={15*d, 10*d,  0,  1.0};
Point(13)={15*d, -10*d,  0,  1.0};

Point(14) = {2*d*cos, 10*d, 0, 1.0};
Point(15) = {-2*d*cos, 10*d, 0, 1.0};
Point(16)= {-2*d*cos, -10*d, 0, 1.0};
Point(17) = {2*d*cos, -10*d, 0, 1.0};

Point(18)={-10*d, -2*d*cos,  0,  1.0};
Point(19)={-10*d, 2*d*cos,  0,  1.0};
Point(20)={15*d, 2*d*cos,  0,  1.0};
Point(21)={15*d, -2*d*cos,  0,  1.0};


​ 方法2：通过：Modules->Geometry->Edit script 编辑脚本添加上述点，保存脚本(此方法操作更加方便)

// Gmsh project created on Tue Jun 20 11:24:34 2023
//+
d = DefineNumber[ 1, Name "Parameters/d" ];
//+
cos = DefineNumber[ 0.70710678, Name "Parameters/cos" ];
//+
Point(1) = {0, 0, 0, 1.0};
Point(2) = {0.353553339, 0.35355339, 0, 1.0};
Point(3) = {-0.353553339, 0.35355339, 0, 1.0};
Point(4) = {-0.353553339, -0.35355339, 0, 1.0};
Point(5) = {0.353553339, -0.35355339, 0, 1.0};

Point(6) = {1.41421356, 1.41421356, 0, 1.0};
Point(7) = {-1.41421356, 1.41421356, 0, 1.0};
Point(8) = {-1.41421356, -1.41421356, 0, 1.0};
Point(9) = {1.41421356, -1.41421356, 0, 1.0};

Point(10) = {-10, -10, 0, 1.0};
Point(11) = {-10, 10, 0, 1.0};
Point(12) = {15, 10, 0, 1.0};
Point(13) = {15, -10, 0, 1.0};

Point(14) = {1.41421356, 10, 0, 1.0};
Point(15) = {-1.41421356, 10, 0, 1.0};
Point(16) = {-1.41421356, -10, 0, 1.0};
Point(17) = {1.41421356, -10, 0, 1.0};

Point(18) = {-10, -1.41421356, 0, 1.0};
Point(19) = {-10, 1.41421356, 0, 1.0};
Point(20) = {15, 1.41421356, 0, 1.0};
Point(21) = {15, -1.41421356, 0, 1.0};


## 2. 二维网格生成

1. Recombine: Modules->Mesh->Define->Recombine

Recombine 的主要目的是为了尽可能地使用方形网格，Gmsh 默认是三角网格。

1. 对线进行网格划分：定义每条线的网格划分数量，用来控制网格质量。Modules->Mesh->Define->Transfinite->Curve

• A 组：61 number of points, Progression Type, 1 parameter, (均匀)
• B 组：81 number of points, Progression Type, 1 parameter, (均匀)
• C 组：31 number of points, Progression Type, 1 parameter, (均匀)
• D 组：31 number of points, Progression Type, 0.9 parameter, (非均匀) 跟直线方向定义有关，如果网格加密方向相反，参数改为 1.1
1. 对面进行网格划分：Modules->Mesh->Define->Transfinite->surfaces 依次选取所有面
2. 选择 Modules->Mesh->2D 生成网格，进行检查。

1. 拉伸面，将其从二维变成三维。（因为 OpenFoam 的二维求解在第三个方向上至少需要一层网格） Modules->Geometry->Elementary entities->Extrude->Translate

1. 将Mesh layers 改为想要的数量，或者直接编辑脚本，可以改变层间厚度的网格层数

## 3. 几何面的分组标记

• 点击 Modules->Mesh->1D 恢复线框图
• Modules->Geometry->Physical group->Add->Point/ Curve/ Surface/ Volume

## 4. 保存网格

1. 再次生成三维网格
• 点击 Modules->Mesh->3D
• File->Export
导出inp文件，并在Abaqus中打开：
Everything not saved will be lost.