6_parallel.tex 3.59 KB
 Timo Koch committed Dec 18, 2018 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 \section{Parallel Computation} \label{sec:parallelcomputation} This section explains how \Dumux can be used on multicore / multinode systems. There are different concepts and methods for parallel programming, which are often grouped in \textit{shared-memory} and \textit{distributed-memory} approaches. The parallelization in \Dumux is based on the model supported by Dune which is currently based on \textit{Message Passing Interface} (MPI) (distributed-memory approach). The main idea behind the MPI parallelization is the concept of \textit{domain decomposition}. For parallel simulations, the computational domain is split into subdomains and one process (\textit{rank}) is used to solve the local problem of each subdomain. During the global solution process, some data exchange between the ranks/subdomains is needed. MPI is used to send data to other ranks and to receive data from other ranks. The domain decomposition in Dune is handled by the grid managers. The grid is partitioned and distributed on several nodes. Most grid managers contain own domain decomposition methods to split the computational domain into subdomains. Some grid managers also support external tools like METIS, ParMETIS, PTScotch or ZOLTAN for partitioning.  Dennis Gläser committed Dec 20, 2018 20 On the other hand, linear algebra types such as matrices and vectors  Timo Koch committed Dec 18, 2018 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 do not know that they are in a parallel environment. Communication is then handled by the components of the parallel solvers. Currently, the only parallel solver backend is \texttt{Dumux::AMGBackend}, a parallel AMG-preconditioned BiCGSTAB solver. In order for \Dumux simulation to run in parallel, an MPI library (e.g. OpenMPI, MPICH or IntelMPI) implementation must be installed on the system. \subsection{Prepare a Parallel Application} Not all parts of \Dumux can be used in parallel. In order to switch to the parallel \texttt{Dumux::AMGBackend} solver backend include the respective header \begin{lstlisting}[style=DumuxCode] #include \end{lstlisting} Second, the linear solver must be switched to the AMG backend \begin{lstlisting}[style=DumuxCode] using LinearSolver = Dumux::AMGBackend; \end{lstlisting} and the application must be recompiled. The parallel \texttt{Dumux::AMGBackend} instance has to be constructed with a \texttt{Dune::GridView} object and a mapper, in order to construct the parallel index set needed for communication. \begin{lstlisting}[style=DumuxCode] auto linearSolver = std::make_shared(leafGridView, fvGridGeometry->dofMapper()); \end{lstlisting} \subsection{Run a Parallel Application} The starting procedure for parallel simulations depends on the chosen MPI library. Most MPI implementations use the \textbf{mpirun} command \begin{lstlisting}[style=Bash] mpirun -np \end{lstlisting} where \textit{-np} sets the number of cores (\texttt{n\_cores}) that should be used for the computation. On a cluster you usually have to use a queuing system (e.g. slurm) to submit a job. Check with your cluster administrator how to run parallel applications on the cluster. \subsection{Handling Parallel Results} For serial computations, \Dumux produces single vtu-files as default output format.  Dennis Gläser committed Dec 20, 2018 65 66 During a simulation, one VTU file is written for every output step. In the parallel case, one VTU file for each step and processor is created.  Timo Koch committed Dec 18, 2018 67 68 For parallel computations, an additional variable \texttt{"process rank"} is written into the file. The process rank allows the user to inspect the subdomains  Dennis Gläser committed Dec 20, 2018 69 after the computation. The parallel VTU files are combined in a single pvd file  Timo Koch committed Dec 18, 2018 70 like in sequential simulations that can be opened with e.g. ParaView.