Gmsh(1) 简介

Gmsh: 三维网格生成软件(开源-免费)

我在德国留学期间,在课题组做了一个关于gmsh的讲座同时在我们课题组的gitlab上写了相应的教程。因为那个gitlab只能我们内部访问,因此直接将这几个教程搬过来,先凑合着看,等我有空了再改成中文版!

Introduction

Gmsh is a free 3D finite element mesh generator with a built-in CAD engine and post-processor. Its design goal is to provide a fast, light and user-friendly meshing tool with parametric input and advanced visualization capabilities. Gmsh is built around four modules: geometry, mesh, solver and post-processing. The specification of any input to these modules is done either interactively using the graphical user interface or in ASCII text files using Gmsh's own scripting language.

Install

It very easy to install Gmsh on your system. Just download and double click. It's not only a free but also a cross platform software.😎

Windows (32 bit),
Linux,
MacOS.

Of course, it can be installed from source, but I don't recommend it so far.

simple structure of a .geo file

The .geo file, in fact, is a Gmsh's scripting file. I just call this language as Gs=Gmsh's scripting. Gs files support both C and C++ style comments.

lc = 1e-2;

//points
Point(1) = {0, 0, 0, lc};
Point(2) = {.1, 0,  0, lc} ;
Point(3) = {.1, .3, 0, lc} ;
Point(4) = {0,  .3, 0, lc} ;

//lines
Line(1) = {1,2} ;
Line(2) = {3,2} ;
Line(3) = {3,4} ;
Line(4) = {4,1} ;

//line looped by points
Line Loop(1) = {4,1,-2,3} ;

//Plane surface is composed by line loop
Plane Surface(1) = {1} ;

//marke a specific point, line or surface
//format: Physical Point(number_label) = {point_index1,point_index_2};
Physical Point(1) = {1,2} ;

//label as a text
MY_LINE = 2;
Physical Line(MY_LINE) = {1,2} ;
Physical Line("My second line (automatic physical id)") = {3} ;
Physical Line("My third line (physical id 5)", 5) = {4} ;
Physical Surface("My surface") = {1} ;

How to display .geo

  • double-click will automatically show the geometry in Gmsh GUI.
  • command line: gmsh step-1.geo
  • result

generate mesh from .geo file

using following to mesh a .geo file.
gmsh my.geo -2 -o my.msh

export to figure file

gmsh support several figure format, e.g. eps,pdf,svg...

  • crop or cut the blank margins of a eps file: epstool --copy --bbox my.eps my_new.eps
  • convert eps to pdf: epstopdf my_new.eps
  • convert pdf to svg: pdf2svg my_new.pdf my.svg
step-1-box

代码

lc = 1e-2;

//points
Point(1) = {0, 0, 0, lc};
Point(2) = {.3, 0,  0, lc} ;
Point(3) = {.3, .3, 0, lc} ;
Point(4) = {0,  .3, 0, lc} ;

//+
Line(1) = {4, 1};
//+
Line(2) = {1, 2};
//+
Line(3) = {3,2};
//+
Line(4) = {3, 4};
//+

//+
Line Loop(1) = {1, 2, -3, 4};
//+
Plane Surface(1) = {1};

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,418评论 0 10
  • 引语 幸福不是一群人, 幸福是一个人睡觉的时候, 另一人帮你盖上被子。 我是一...
    8532b7bc93b9阅读 316评论 2 3
  • 旅程 写下这段文字,是我舒服的抱着笔记本电脑躺在床上的状态。 没有去参与十一国庆长假高速大堵车,也没有短途几日游的...
    01bbe83ab4b0阅读 520评论 0 0
  • 我觉得家里的气氛有些怪,好久没见的爸爸突然就回来了,他终于在家待着了,但是白天也不上班,是李姨说过的失业吗?爸爸失...
    紫渚阅读 359评论 3 3
  • 我家小店的格局,是和别处不同的:店门口搭了一个棚子,下面摆着几副牌桌,可以随时供过往的人休息。我们村的小店一共就三...
    卡蜜儿陈阅读 665评论 4 3