File: how-to-mesh-gmsh.tex

package info (click to toggle)
rheolef 7.1-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 77,392 kB
  • sloc: cpp: 105,337; sh: 16,014; makefile: 5,293; python: 1,359; xml: 221; yacc: 218; javascript: 202; awk: 61; sed: 5
file content (85 lines) | stat: -rw-r--r-- 2,739 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
\subsection{Unidimensional mesh with {\tt gmsh}}
% =============================================

The simplest unidimensional mesh is a line:
\fiindex{\filesuffix{.msh} gmsh mesh}%
\fiindex{\filesuffix{.mshcad} gmsh geometry}%
\pindex{gmsh}%
\exindex{line.mshcad}%
\cindex{geometry!line}%
\myexamplenocxx{line.mshcad}%
The mesh generation command writes:
\begin{verbatim}
  gmsh -1 line.mshcad -format msh2 -o line.msh
\end{verbatim}
\pindex{msh2geo}%
\fiindex{\filesuffix{.geo} mesh}%
Then, the conversion to \filesuffix{.geo} format and the visualization:
\begin{verbatim}
  msh2geo line.msh > line.geo
  geo line
\end{verbatim}

% =============================================
\subsection{Bidimensional mesh with {\tt gmsh}}
% =============================================
\label{sec-gmsh}%
  \begin{figure}[htb]
     \mbox{} \hspace{-1cm}
     \begin{tabular}{ccc}
          \includegraphics[width=7cm]{square-gmsh-geo.pdf} &
	  \hspace{0.56cm}
          \includegraphics[width=8cm]{cube-gmsh-geo.png} &
          \stereoglasses
     \end{tabular}
     \caption{Visualization of the \code{gmsh} meshes \file{square.geo} and \file{cube.geo}.}
     \label{fig-gmsh-meshes}
  \end{figure}
We first create a \reffile{square.mshcad} file:
\cindex{geometry!square}%
\myexamplenocxx{square.mshcad}%
  This is an uniform mesh with element size \var{h} = 0.1.
  We refer to the \code{gmsh} documentation~\cite{gmsh} for the 
  complete file format description.
  Next, enter the mesh generator commands:
\begin{verbatim}
  gmsh -2 square.mshcad -format msh2 -o square.msh
\end{verbatim}
  Then, enter the translation command:
\pindex{msh2geo}%
\fiindex{\filesuffix{.geo} mesh}%
\begin{verbatim}
  msh2geo square.msh > square.geo
\end{verbatim}
  This command creates a \file{square.geo} file.
  Look at the mesh via the command:
\begin{verbatim}
  geo square
\end{verbatim}
  Remark that the domain names, defined in the .mshcad file,
  are included in the gmsh .msh input file and are
  propagated in the .geo by the format conversion.

% =============================================
\subsection{Tridimensional mesh with {\tt gmsh}}
% =============================================

First, create a \reffile{cube.mshcad} file:
\exindex{cube.mshcad}%
\cindex{geometry!cube}%
\myexamplenocxx{cube.mshcad}%
Next, enter the mesh generator commands:
\begin{verbatim}
        gmsh -3 cube.mshcad -format msh2 -o cube.msh
\end{verbatim}
Then, enter the translation command:
\begin{verbatim}
        msh2geo cube.msh > cube.geo
\end{verbatim}
This command creates a \file{cube.geo} file.
Look at the mesh via the command:
\begin{verbatim}
        geo cube
        geo cube.geo -cut
\end{verbatim}
The second command allows one to see inside the mesh.