Skip to content
GitLab
Explore
Sign in
Jussi Enkovaara
MPI
Compare revisions
7879787674b7c813dfe039f4fb917a74027a8fae to ade124f418b3fb3799d9a9e07b8251306530a3a5
Commits on Source (3)
Describe the heat equation in a bit more detail
· 7ef789b8
Jussi Enkovaara
authored
Jul 03, 2018
7ef789b8
Add th LICENSE
· 4043f6b9
Jussi Enkovaara
authored
Jul 03, 2018
4043f6b9
Merge branch 'master' of
https://repository.prace-ri.eu/git/jussi.enkovaara/MPI
· ade124f4
Jussi Enkovaara
authored
Jul 03, 2018
ade124f4
Hide whitespace changes
Inline
Side-by-side
heat-equation/LICENSE.txt
0 → 100644
View file @
ade124f4
Copyright (C) 2018 CSC - IT Center for Science Ltd.
Licensed under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
Code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
Copy of the GNU General Public License can be obtained from
<http://www.gnu.org/licenses/>.
heat-equation/README.md
0 → 100644
View file @
ade124f4
Two dimensional heat equation
=============================
This folder contains a code which solves two dimensional heat equation
with MPI parallelization. The code features non-blocking point-to-point
communication, user defined datatypes, collective communication,
and parallel I/O with MPI I/O.
Heat (or diffusion) equation is
<!-- Equation
\f
rac{
\p
artial u}{
\p
artial t} =
\a
lpha
\n
abla^2 u
-->
![
img
](
http://quicklatex.com/cache3/d2/ql_b3f6b8bdc3a8862c73c5a97862afb9d2_l3.png
)
where
**u(x, y, t)**
is the temperature field that varies in space and time,
and α is thermal diffusivity constant. The two dimensional Laplacian can be
discretized with finite differences as
<!-- Equation
\b
egin{align
*
}
\n
abla^2 u &=
\f
rac{u(i-1,j)-2u(i,j)+u(i+1,j)}{(
\D
elta x)^2}
\\
&+
\f
rac{u(i,j-1)-2u(i,j)+u(i,j+1)}{(
\D
elta y)^2}
\e
nd{align
*
}
-->
![
img
](
http://quicklatex.com/cache3/2d/ql_59f49ed64dbbe76704e0679b8ad7c22d_l3.png
)
Given an initial condition (u(t=0) = u0) one can follow the time dependence of
the temperature field with explicit time evolution method:
<!-- Equation
u^{m+1}(i,j) = u^m(i,j) +
\D
elta t
\a
lpha
\n
abla^2 u^m(i,j)
-->
![
img
](
http://quicklatex.com/cache3/9e/ql_9eb7ce5f3d5eccd6cfc1ff5638bf199e_l3.png
)
Note: Algorithm is stable only when
<!-- Equation
\D
elta t <
\f
rac{1}{2
\a
lpha}
\f
rac{(
\D
elta x
\D
elta y)^2}{(
\D
elta x)^2 (
\D
elta y)^2}
-->
![
img
](
http://quicklatex.com/cache3/d1/ql_0e7107049c9183d11dbb1e81174280d1_l3.png
)
The two dimensional grid is decomposed along both dimensions, and the
communication of boundary data is overlapped with computation. Restart files
are written and read with MPI I/O.
Compilation instructions
------------------------
For building and running the example one needs to have the
[
libpng
](
http://www.libpng.org/pub/png/libpng.html
)
library installed. In
addition, working MPI environment is required. For Python version mpi4py and
matplotlib are needed.
Move to proper subfolder (C or Fortran) and modify the top of the
**Makefile**
according to your environment (proper compiler commands and compiler flags).
Code can be build simple with
**make**
How to run
----------
The number of MPI ranks has to be a factor of the grid dimension (default
dimension is 200). The default initial temperature field is a disk. Initial
temperature field can be read also from a file, the provided
**bottle.dat**
illustrates what happens to a cold soda bottle in sauna.
*
Running with defaults: mpirun -np 4 ./heat_mpi
*
Initial field from a file: mpirun -np 4 ./heat_mpi bottle.dat
*
Initial field from a file, given number of time steps:
mpirun -np 4 ./heat_mpi bottle.dat 1000
*
Defauls pattern with given dimensions and time steps:
mpirun -np 4 ./heat_mpi 800 800 1000
The program produces a series of heat_XXXX.png files which show the
time development of the temperature field