Gmsh(1) 簡介

Gmsh: 三維網(wǎng)格生成軟件(開源-免費)

我在德國留學(xué)期間,在課題組做了一個關(guān)于gmsh的講座同時在我們課題組的gitlab上寫了相應(yīng)的教程。因為那個gitlab只能我們內(nèi)部訪問,因此直接將這幾個教程搬過來,先湊合著看,等我有空了再改成中文版!

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};

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,871評論 0 10
  • 引語 幸福不是一群人, 幸福是一個人睡覺的時候, 另一人幫你蓋上被子。 我是一...
    8532b7bc93b9閱讀 382評論 2 3
  • 旅程 寫下這段文字,是我舒服的抱著筆記本電腦躺在床上的狀態(tài)。 沒有去參與十一國慶長假高速大堵車,也沒有短途幾日游的...
    01bbe83ab4b0閱讀 596評論 0 0
  • 我覺得家里的氣氛有些怪,好久沒見的爸爸突然就回來了,他終于在家待著了,但是白天也不上班,是李姨說過的失業(yè)嗎?爸爸失...
    紫渚閱讀 423評論 3 3
  • 我家小店的格局,是和別處不同的:店門口搭了一個棚子,下面擺著幾副牌桌,可以隨時供過往的人休息。我們村的小店一共就三...
    卡蜜兒陳閱讀 730評論 4 3

友情鏈接更多精彩內(nèi)容