heated_plate_parfor, a MATLAB code which solves the steady state heat equation in a 2D rectangular region, using the parfor() feature to run in parallel.
The final estimate of the solution is written to a file in a format suitable for display by GRID_TO_BMP().
The sequential version of this program needs approximately 18/epsilon iterations to complete.
The physical region, and the boundary conditions, are suggested by this diagram:
W = 0 +------------------+ | | W = 100 | | W = 100 | | +------------------+ W = 100
The region is covered with a grid of M by N nodes, and an N by N array W is used to record the temperature. The correspondence between array indices and locations in the region is suggested by giving the indices of the four corners:
I = 0 [0][0]-------------[0][N-1] | | J = 0 | | J = N-1 | | [M-1][0]-----------[M-1][N-1] I = M-1
The steady state solution to the discrete heat equation satisfies the following condition at an interior grid point:
W[Central] = (1/4) * ( W[North] + W[South] + W[East] + W[West] )where "Central" is the index of the grid point, "North" is the index of its immediate neighbor to the "north", and so on.
Given an approximate solution of the steady state heat equation, a "better" solution is given by replacing each interior point by the average of its 4 neighbors - in other words, by using the condition as an ASSIGNMENT statement:
W[Central] <= (1/4) * ( W[North] + W[South] + W[East] + W[West] )
If this process is repeated often enough, the difference between successive estimates of the solution will go to zero.
This program carries out such an iteration, using a tolerance specified by the user, and writes the final estimate of the solution to a file that can be used for graphic processing.
Depending on the situation, the function could be executed in parallel:
heated_plate_parfor ( epsilon, output_filename )where
The information on this web page is distributed under the MIT license.
heated_plate_parfor is available in a MATLAB version.
collatz_parfor, a MATLAB code which seeks the maximum Collatz sequence between 1 and N, running in parallel using the parfor() command.
heated_plate_parfor, a MATLAB code which solves the steady (time independent) heat equation in a 2D rectangular region, using parfor() to run in parallel.
hello_parfor, a MATLAB code which prints out "Hello, world!" multiple times, using parfor() for parallel execution.
high_card_parfor, a MATLAB code which uses the parfor() statement to compute in parallel the statistics for a card game in which you are required to guess the location of the highest card.
matrix_assemble_parfor, a MATLAB code which uses parfor() for parallel execution to assemble the Hilbert matrix in a parallel loop.
md_parfor, a MATLAB code which carries out a molecular dynamics simulation, running in parallel using the parfor() feature.
ode_sweep_parfor, a MATLAB code which uses parfor() to parallelize the computation of a grid of solutions to a parameterized system of ordinary differential equations (ODE).
prime_parfor, a MATLAB code which counts the number of primes between 1 and N; running in parallel using the parfor() feature.
quad_parfor, a MATLAB code which estimates an integral using quadrature; running in parallel using the parfor() feature.
satisfy_parfor, a MATLAB code which demonstrates, for a particular circuit, an exhaustive search for solutions of the circuit satisfiability problem, running in parallel using the parfor() feature.
sparse_parfor, a MATLAB code which demonstrates how a sparse matrix can be constructed by evaluating individual blocks in parallel with the parfor() command, and then assembled (on a single processor) using the sparse() command.