Skip to content

Various implementations for two dimensional heat equation

License

Notifications You must be signed in to change notification settings

csccva/heat-equation

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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. 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 build simple 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

Languages

  • C++ 50.5%
  • Fortran 33.2%
  • C 10.4%
  • Makefile 4.5%
  • Cuda 1.4%