\input{tutorial-preamble.tex}

\title{Basic Usage Tutorial}

\begin{document}

%\frontmatter

% Render pretty title page if not building HTML
\ifdefined\HCode
\begin{center}
    \includegraphics[width=0.1\textwidth]{img/icon-blue.png}
\end{center}
\maketitle
\begin{center}
       \huge{Nektar++ Tutorial}
\end{center}
\else
\titlepage
\fi

\clearpage

\chapter{Introduction}

This tutorial is aimed to guide the user in the basic usage of the \nektar programme. 
If you are totally new to UNIX based operating systems (Linux, OSX, etc), you may find necessary information by visiting \texttt{https://www.doc.ic.ac.uk/~wjk/UnixIntro/}.

\nektar has to be installed on the system first before proceeding with the tutorial.
You may download \nektar by 
visiting \href{http://www.nektar.info}{http://www.nektar.info}, where you can
also find the
\href{http://www.nektar.info/downloads/8}{User-Guide} with the
instructions to install the library.

This tutorial requires:
\begin{itemize}
    \item \nektar ADRSolver
    \item \nektar IncNavierStokesSolver
\end{itemize}

\section*{Goals}
After the completion of this tutorial, you will be familiar with:
\vspace{-0.5cm}
\begin{itemize}
\item Adding the \nektar executables into path
\item Moving files around the system using terminal
\item Basic usage of \nektar executables
\end{itemize}

\begin{tutorialtask}
Prepare for the tutorial. Make sure that you have:
\begin{itemize}
  \item Installed and tested \nektar v\nekver from a binary package, or compiled it from
      source. By default binary packages will install all executables in
      \inlsh{/usr/bin}. If you compile from source they will be in the
      sub-directory \inlsh{dist/bin} of the \inlsh{build} directory you 
      created in the \nektar source tree. We will refer to the directory
      containing the executables as \inlsh{\$NEK} for the remainder of the
      tutorial.
\end{itemize}
      
\end{tutorialtask}



\chapter{Adding executables into Path}
\label{path}

We have to add the path of the executables of \nektar into the system before we are able to use the command.

\begin{tutorialtask}
Adding the path of executables using the command:
\tutorialcommand{export PATH=\${PATH}:\$NEK/build/dist/bin/}
Using 'printenv PATH' command allows all paths to be shown
\tutorialcommand{printenv PATH}
The system should return the directory of the ADRSolver using the 'which' command.
\tutorialcommand{which ADRSolver}
\end{tutorialtask}

Now the path of the executables is recognised by the system and hence commands such as 'ADRSolver' and 'IncNavierStokesSolver' can be used in the terminal.


\chapter{Basic usage of executables}

Now we will try to use the executables of \nektar.

\begin{tutorialtask}
We will first create a directory called 'mytest' and change into the directory.
\tutorialcommand{mkdir mytest}
\tutorialcommand{cd mytest}

Then we copy the .xml files that can be executed by \nektar to the current directory that we are in using the command 
\tutorialcommand{cp \$NEK/nektar++/solvers/ADRSolver/Tests/Helmholtz2D\_modal.xml .}
Do not forget to add the dot behind the directory as it indicates that the file Helmholtz2D\_model.xml is copied over to the current directory.

We can therefore run the executables using command
\tutorialcommand{ADRSolver Helmholtz2D\_modal.xml}

By typing the command
\tutorialcommand{ls}
We can see that a .fld file named Helmholtz2D\_modal.fld is generated. This is the result of running the .xml. You may wish to see the content of the .fld file by using command
\tutorialcommand{more Helmholtz2D\_modal.fld}

\end{tutorialtask}

As soon as the file finishes running, we should see the following
screen output:
%
\begin{lstlisting}[style=BashInputStyle]
=======================================================================
	        EquationType: Helmholtz
	        Session Name: Helm_mesh
	        Spatial Dim.: 2
	  Max SEM Exp. Order: 5
	      Expansion Dim.: 2
	     Projection Type: Continuous Galerkin
	              Lambda: 2.5
	    Forcing func [0]: -(Lambda + 2*PI*PI)*cos(PI*x)*cos(PI*y)
=======================================================================
Writing: "Helm_mesh.fld"
Writing: "Helm_mesh.fld"
-------------------------------------------
Total Computation Time = 0s
-------------------------------------------
L 2 error (variable u) : 0.000159378
L inf error (variable u) : 0.000454467
\end{lstlisting}

This indicates that the file has been executed successfully and the calculations have been done.




\chapter{Summary}
You should be now familiar with the following topics:
\vspace{-0.5cm}
\begin{itemize}
\item Adding directory of commands into the path;
\item Moving files around the directories in terminal
\item Run the ADR solver

\end{itemize}


\section{Additional Exercises}
\begin{enumerate}
\item Try to install Gmesh, a mesh generating tool that can be used alongside with \nektar. You may obtain Gmesh by visiting \texttt{http://gmsh.info/}. After the installation of Gmesh, try to add 'gmsh' into PATH.
\item Try to copy the file ChanFlow\_m8.xml from the directory '\$NEK/solvers/IncNavierStokesSolver/Tests/' into the 'mytest' directory
\item Run the ChanFlow\_m8.xml file using command 'IncNavierStokesSolver'

\end{enumerate}



\end{document}
