gmsh学习记录

最近学习gmsh所以记录一下,所有的都是一些零碎的点

1.

To perform the mesh generation, go to the mesh module (by selecting ‘Mesh’ in the tree)and choose the dimension (‘1D’ will mesh all the lines; ‘2D’ will mesh all the surfaces—as well as all the lines if ‘1D’ was not called before; ‘3D’ will mesh all the volumes—and all the surfaces if ‘2D’ was not called before).

2.

关于 t3.geo 的讲解,中文注释为自己理解的

/*********************************************************************
 *
 *  Gmsh tutorial 3
 *
 *  Extruded meshes, parameters, options
 *
 *********************************************************************/
Geometry.OldNewReg = 1;
// Again, we start by including the first tutorial:

Include "t1.geo";

// As in `t2.geo', we plan to perform an extrusion along the z axis.  But here,
// instead of only extruding the geometry, we also want to extrude the 2D
// mesh. This is done with the same `Extrude' command, but by specifying element
// 'Layers' (2 layers in this case, the first one with 8 subdivisions and the
// second one with 2 subdivisions, both with a height of h/2):
// 解释一下此处Layers{ {8,2}, {0.5,1} }的含义,
// {8,2}是指网格的在不同的Layer中的subdivisions的个数,在产生2D网格后可以数一下表层网格的层数,
// 其实下面(对应0.5这Layer)有8层网格,(对应1这Layer)有2层。
// {0.5,1}是h的相对高度,即0.5h 和 1h。

h = 0.1;

Extrude {0,0,h} {
  Surface{6}; Layers{ {8,2}, {0.5,1} };
}

// The extrusion can also be performed with a rotation instead of a translation,
// and the resulting mesh can be recombined into prisms (we use only one layer
// here, with 7 subdivisions). All rotations are specified by an axis direction
// ({0,1,0}), an axis point ({-0.1,0,0.1}) and a rotation angle (-Pi/2):
// Extrude{}中第一个参数{0,1,0}是指沿着y轴进行旋转。
// 第二个参数{-0.1,0,0.1}为指定的旋转点的一个,另外一个应该是可以省略了,
//因为第一个参数已经说明是沿着y轴进行旋转了,参考gmsh所显示的,另外的一个旋转点为{-0.1,0.3,0.1}。
// 第三个参数 -Pi/2 是旋转的角度。
// Recombine参数是将三角形(四面体)网格合并成矩形(矩形体)网格

Extrude { {0,1,0} , {-0.1,0,0.1} , -Pi/2 } {
  Surface{28}; Layers{7}; Recombine;
}

// Note that a translation ({-2*h,0,0}) and a rotation ({1,0,0}, {0,0.15,0.25},
// Pi/2) can also be combined. Here the angle is specified as a 'parameter',
// using the 'DefineConstant' syntax.  This parameter can be modified
// insteractively in the GUI, and can be exchanged with other codes using the
// ONELAB framework:

DefineConstant[ angle = {90, Min 0, Max 120, Step 1,
                         Name "Parameters/Twisting angle"} ];

out[] = Extrude { {-2*h,0,0}, {1,0,0} , {0,0.15,0.25} , angle * Pi / 180 } {
  Surface{50}; Layers{10}; Recombine;
};

// In this last extrusion command we retrieved the volume number programatically
// by using the return value (a list) of the Extrude command. This list contains
// the "top" of the extruded surface (in out[0]), the newly created volume (in
// out[1]) and the ids of the lateral surfaces (in out[2], out[3], ...)

// We can then define a new physical volume to save all the tetrahedra with a
// common region number (101):

Physical Volume(101) = {1, 2, out[1]};

// Let us now change some options... Since all interactive options are
// accessible in Gmsh's scripting language, we can for example make point tags
// visible or redefine some colors directly in the input file:

Geometry.PointNumbers = 1;
Geometry.Color.Points = Orange;
General.Color.Text = White;
Mesh.Color.Points = {255,0,0};

// Note that all colors can be defined literally or numerically, i.e.
// `Mesh.Color.Points = Red' is equivalent to `Mesh.Color.Points = {255,0,0}';
// and also note that, as with user-defined variables, the options can be used
// either as right or left hand sides, so that the following command will set
// the surface color to the same color as the points:

Geometry.Color.Surfaces = Geometry.Color.Points;

// You can use the `Help->Current options' menu to see the current values of all
// options. To save all the options in a file, use `File->Save as->Gmsh
// options'. To associate the current options with the current file use
// `File->Save Options->For Current File'. To save the current options for all
// future Gmsh sessions use `File->Save Options->As default'.
  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值