\documentclass[11pt,a4paper]{article}
\usepackage{bookman}
\usepackage[dvips]{graphicx}
\smallskip
\begin{document}
\title{pdnMesh - A Tutorial Introduction}
\author{Sarod Yatawatta}
\date{2001}
\maketitle
\tableofcontents
\listoffigures
\newpage
\begin{abstract}
pdnMesh is an automatic mesh generator that can be used for finite element analysis. It generates Delaunay triangulation of the data set and refines the mesh depending upon the requirement. It can also do post processing to visualise the solution.
\end{abstract} 
\section{\sf Introduction}
\par pdnMesh is a program that can be used for finite element analysis of  two dimensional problems. Given the problem definition, it automatically generates and refines the mesh whilst solving it. The user can give the parameters for mesh refinement as input. Once the solution has converged, i.e. if the mesh cannot be improved further, pdnMesh will generate a contour plot as well as a data file of the mesh.
\par The program will generate three files as output.
\begin{itemize}
\item {\tt cont.eps} The contour plot - encapsulated postscript file
\item {\tt mesh.eps} The mesh - ancapsulated postscript file
\item {\tt data.in} The data file to be used by any other program - text
\end{itemize}
\par The program accepts following command line input.
\begin{itemize}
\item {\tt -h, -?} Print help and information.
\item{\tt -v} Print verbose output.
\item{\tt -a  value} Minimum area of a triangle that can be divided is set to {\tt \it value}.
\item{\tt -s value} The priority for adaptive refinement of each triangle will be set  to {\tt \it value}.
\item{\tt -c value} The number of contour levels in the contour plot will be set to {\tt \it value}.
\item{\tt -b value} The minimum badness for any triangle to be split will be set  to {\tt \it value}.
\item{\tt -nx} The solution will not be displayed on screen. Using this option, the program can be run in console mode.
\item{\tt -i file} The input will be taken from the name given by {\tt \it file}. The program must be supplied with a valid file name with the path relative to current directory.
\end{itemize} 
\section{\sf A Simple Example}
\par We will now consider solving a simple problem using pdnMesh. We will consider a small solenoid and plot its field pattern. The solution will be as given in figure~\ref{fig:1}.		
\begin{center}
\begin{figure}[h]
\hspace*{1.4in}
\includegraphics[scale=0.4]{ex1.eps}
\caption{\label{fig:1}The solenoid field}	
\end{figure}
\end{center}
The problem can be defined as seen in figure~\ref{fig:2}
\begin{figure}[h]
\hspace*{1.5in}
\includegraphics[scale=0.4]{exdraw.eps}
\caption{\label{fig:2}The problem definition}	
\end{figure}
\subsection{ \sf Points}
\par There are eight points numbered 0 to 7. Correspondingly, there are eight edges. Generally points should be numbered such that the ascending order is anti clockwise.
\par In the data file, the first lines should give the detail of individual points. Hence the first portion of the file may look like as given in figure~\ref{list:1}. However, comments starting with a '\#'and empty lines will be ignored.
\begin{center}
\begin{figure}[h]
\begin{verbatim}
#this is a comment
8
0 -8 -8 0 1
1  8 -8 0 1
2 8 8  0 1
3 -8 8 0 1
4 1 1 30 1  #this part is a comment, not the full line 
5 -1 1 30 1
6 -1 -1 -30 1
7 1 -1 -30 1
\end{verbatim}
\caption{\label{list:1}The point data}
\end{figure}
\end{center}
The first line should give the number of points. Then data about each point follows line by line. In each line, the format is\\
\texttt{\footnotesize (point number) (x coordinate) (y coordinate) (the potential) (fixed or variable)}\\
\par Point and line numbering should start from 0. Each point may have a known, fixed potential or an unknown, variable potential. If the potential is known, 1 should be given as the last entry of each line. In this example all points have fixed potentials. Note that points 4 and 5 have a potential of 30 and points 6 and 7 have a potential of -30. All other points have zero potential. 
\subsection{ \sf Edges}
\par Next, the input should specify the edge data. First line should be the number of edges. Do not insert any blank line between point data and edge data. The detail is given in figure~\ref{list:2}
\begin{center}
\begin{figure}[h]
\begin{verbatim}
8
0 0 1 1
1 1 2 1
2 2 3 1
3 3 0 1
4 4 5 1
5 5 6 0
6 6 7 1
7 7 4 0
\end{verbatim}
\caption{\label{list:2}The edge data}
\end{figure}
\end{center}
\par For each edge, the following should be specified.\\
\texttt{\footnotesize (edge number) (point 1) (point 2) (Dirichlet or Neumann)}\\
Edges can either be Dirichlet or Neumann depending on the boundary condition. For Dirichlet edges, the potential is fixed and for Neumann edges the gradient of the potential is fixed. Hence for a Dirichlet edge, any point upon which will have fixed potential. We give 1 for a Dirichlet edge and the potential of any point is linearly interpolated from the edge points. For a Neumann edge we give 0.
\par For material edges, that need not satisfy any boundary condition we give 0 as well. Moreover, it should be remembered to have all edges of the outer boundary with fixed potential for a unique solution. Otherwise the program will warn you about singular matrices.
\par In figure~\ref{list:2}, edges 5 and 7 are not Dirichlet but that does not mean that they are Neumann. Moreover, edge 4 will have a potential of 30 because its end points both have the same potential. The same is true for edge 5. Both these edges represent the surface currents running on the periphary of the solenoid.
\subsection{ \sf Boundaries}
\par Finally, in the input file, we should specify the boundary detail. Boundaries need not be closed except the outer one, but almost always they are closed. Boundaries are required to define the shape of the problem as well as the material properties of the problem. 
\par For instance, in this problem, There are two boundaries as given in figure~\ref{fig:1}. The point set 0, 1, 2, and 3 specify the outer boundary and the point set 4, 5, 6 and 7 represent the solenoid core. 
\par Always, the outer boundary will be need to be specified and this should be done before other boundaries. 
\par For any material, two parameters must be specified. For instance, in an electro-magnetic problem, they can be the permeability $\mu$ and the current density $J$ and for an electrostatic problem, they can be the permittivity $\epsilon$ and the charge density $\rho$. In fact, for an electro-magnetic problem, the inverse of the permeability should be given. For any other problem, the values need to be given can be determined depending on the differential equation as in ~\ref{eq:1}.
\begin{eqnarray}
\epsilon  ( { \frac { {\partial}^2 \phi }{{\partial x}^2} +
                    \frac { {\partial}^2 \phi }{{\partial y}^2 }  }   ) = -\rho(x,y) \\\label{eq:1}
\frac{1}{\mu} ( { \frac { {\partial}^2 A}{{\partial x}^2} +
                    \frac { {\partial}^2 A}{{\partial y}^2 }  }   ) = -J(x,y) \\\nonumber					  \label{eq:2}
\end{eqnarray}
\par Somtimes the detail within a boundary may not be important or interesting. For example, within a small conductor, the potential variation can be considered negligible. Hence, the triangles within this boundary can be removed and this reduces the size of the problem. This can be done by giving 0 as a parameter in the boundary detail spacifiaction.
\begin{center}
\begin{figure}[h]
\begin{verbatim}
2
4 1 1 0 
0
1
2
3
4 1 0.1 0
4
5
6
7
\end{verbatim}
\caption{\label{list:3}The boundary data}
\end{figure}
\end{center}
\par The boundary data for this problem is given in figure~\ref{list:3}. First the number of boundaries is specified. Next the outer boundary detail is given. The outer boundary has four edges, it is closed, the triangles will not be deleted, its 1/permeability is 1.0 and its current density is 0. Next, the numbers of the edges in that boundary is given line by line. The general format for boundary information is\\
\texttt{\footnotesize (number of edges) (remove triangles?) (1/permeability) (current density)}\\
Hence, we can see that the inner boundary has 0.1 as its 1/permeability value and 0 as its current density.
The complete data file is given in figure~\ref{list:4}
\begin{center}
\begin{figure}[h]
\begin{verbatim}
8
0 -8 -8 0 1
1  8 -8 0 1
2 8 8  0 1
3 -8 8 0 1
4 1 1 30 1
5 -1 1 30 1
6 -1 -1 -30 1
7 1 -1 -30 1
8
0 0 1 1
1 1 2 1
2 2 3 1
3 3 0 1
4 4 5 1
5 5 6 0
6 6 7 1
7 7 4 0
2
4 1 1 0 
0
1
2
3
4 1 0.1 0
4
5
6
7
\end{verbatim}
\caption{\label{list:4}The data file}
\end{figure}
\end{center}
Now, we can run pdnMesh and give this file as its input and see if we get the answer. First run it by typing\\
\texttt{./pdnmesh -i your\_file}\\
and observe the output. If you need a more refined mesh try giving a high splitting priority as follows.\\
\texttt{./pdnmesh -s 0.6 -i your\_file}\\
Now you will see a more refined solution.
\par As an extension, we could introduce an iron block close to the solenoid to observe the change in the field pattern. The new data file is given in figure~\ref{list:5}. Now we have three boundaries and 12 points.
\begin{center}
\begin{figure}[h]
\begin{verbatim}
12
0 -8 -8 0 1
1  8 -8 0 1
2 8 8  0 1
3 -8 8 0 1
4 1 1 30 1
5 -1 1 30 1
6 -1 -1 -30 1
7 1 -1 -30 1
8 3 -1 0 0
9 6 -1 0 0
10 6 1 0 0
11 3 1 0 0
12
0 0 1 1
1 1 2 1
2 2 3 1
3 3 0 1
4 4 5 1
5 5 6 0
6 6 7 1
7 7 4 0
8 8 9 0
9 9 10 0
10 10 11 0
11 11 8 0
3
4 1 1 0
0
1
2
3
4 1 0.1 0
4
5
6
7
4 1 0.01 0
8
9
10
11
\end{verbatim}
\caption{\label{list:5}The new data file}
\end{figure}
\end{center}
The solution will look like the one given in figure~\ref{fig:3}
\begin{figure}
\hspace*{1.4in}
\includegraphics[scale=0.4]{ex2.eps}
\caption{\label{fig:3}The solenoid field with an iron block}	
\end{figure}
\par There is a perl script called 'd2m' supplied with this program that can be used to convert Drawing Interchange Fromat Files or DXF files to input files similar to ~\ref{list:5}. It should be kept in mind that each boundary should be on a seperate layer in the DXF file. Moreover, the outer boundary should be on a layer named 'default'.
\section{\sf Installation}
\par The program can be downloaded from {\tt http://pdnmesh.sourceforge.net} in binary form as well as in source form. It is adviced to get the source distribution. The program at the moment needs OpenGL/Mesa and glut for visual display. Mesa can be downloaded from  {\tt http://www.mesa3d.org} and glut can be downloaded from {\tt  http://reality.sgi.com/mjk/glut3}. 
\par Once you have installed the dependencies, it is just typing\\
{\tt tar -xzvf pdnmesh-*.*.*.tar.gz}\\
{\tt cd pdnmesh-*.*.*/}\\
{\tt ./configure }\\
{\tt make }\\
{\tt make install}\\
\section{\sf Epilogue}
This documens is in the process of completion. Please send your comments to {\tt sarod@cs.pdn.ac.lk}.
\end{document}
