Skip to content

Various implementations for two dimensional heat equation

License

Notifications You must be signed in to change notification settings

cschpc/heat-equation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Two dimensional heat equation

Example implementations of two dimensional heat equation with various parallel programming approaches.

Heat (or diffusion) equation is

img

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

img

Given an initial condition (u(t=0) = u0) one can follow the time dependence of the temperature field with explicit time evolution method:

img

Note: Algorithm is stable only when

img

How to build

For building and running the example one needs to have the libpng library installed. Working MPI environment is required for all cases except for the serial one. In addition:

  • Hybrid MPI-OpenMP version requires MPI implementation with MPI_THREAD_MULTIPLE support
  • CUDA version requires CUDA environment and CUDA aware MPI

Move to proper subfolder and modify the top of the Makefile according to your environment (proper compiler commands and compiler flags). Code can be built simply with make

How to run

The number of MPI ranks has to be a factor of the grid dimension (default dimension is 2000). For GPU versions, number of MPI tasks per node has to be the same as number of GPUs per node.

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

About

Various implementations for two dimensional heat equation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published