Skip to content

Instantly share code, notes, and snippets.

@inducer
Last active March 27, 2020 19:16
Show Gist options
  • Save inducer/7e8eb5321f9a1b9aea3d52515e91058a to your computer and use it in GitHub Desktop.
Save inducer/7e8eb5321f9a1b9aea3d52515e91058a to your computer and use it in GitHub Desktop.
Unstructured mesh for a domain in TikZ
\newcommand{\meshnodes}{
\coordinate (a) at (4.53,2.86) ;
\coordinate (b) at (2.91,3.55) ;
\coordinate (c) at (2.25,1.8) ;
\coordinate (d) at (-0.3,3.25) ;
\coordinate (e) at (1.31,4.17) ;
\coordinate (f) at (1.19,0.43) ;
\coordinate (g) at (2.77,0.7) ;
\coordinate (h) at (3.96,3.54) ;
\coordinate (i) at (0.05,1.17) ;
\coordinate (j) at (2,3.1) ;
\coordinate (k) at (3,4.7) ;
\coordinate (m) at (3.93,1.65) ;
\coordinate (n) at (1.78,0.76) ;
\coordinate (o) at (0.40,4.4) ;
\coordinate (p) at (0.8,2.5) ;
\coordinate (q) at (4.72,1.32) ;
\coordinate (r) at (3.02,2.27) ;
\coordinate (s) at (0.98,1.83) ;
\coordinate (t) at (-0.3,1.8) ;
}
\newcommand{\withmeshtris}[1]{
#1 cgn #1 snf #1 jsc #1 pjs
#1 pts #1 sif #1 sit #1 dtp
#1 odp #1 epj #1 jcb #1 oep
#1 rcg #1 crb #1 kbh #1 rah
#1 ejb #1 rgm #1 ram #1 qam
#1 ekb #1 gqm #1 scn #1 bhr
}
\newcommand{\drawtriangle}[3]
{\draw (#1) -- (#2) -- (#3) -- (#1);}
\newcommand{\meshtris}{
\withmeshtris\drawtriangle
}
\def\drawnodenames{
\foreach \i in {a,b,c,d,e,f,g,h,i,j,k,m,n,o,p,q,r,s,t}
\node at (\i) {\i};
}
\input{media/unstructuredmesh.tex}
\begin{center}
\begin{tikzpicture}
\meshnodes
\meshtris
%\drawnodenames
\node [left=1cm of d] {$\Omega$};
\draw [fill=blue!30] (c) -- (n) -- (g) ;
\node [below=5mm of g,xshift=-5mm] (ellabel) {$\D_k$};
\draw [thick,->,shorten >=5mm] (ellabel) -- (c) ;
\end{tikzpicture}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment