Computational Science Based on HPC
Functions
thermopara.h File Reference

This file contains the implementation of the parallel version of the heat transfer simulation in 1D and 2D. More...

#include "thermoutils.h"

Go to the source code of this file.

Functions

long double _get_value_1D_mpi (double time_step, double space_step, long long x, unsigned long long t, long long precision)
 This is a function calculates the value of specific point in the space at specific time in 1D.
 
long double _get_value_1D_openmp (double time_step, double space_step, long long x, unsigned long long t, long long precision)
 This is a function calculates the value of specific point in the space at specific time in 1D.
 
long double _get_value_2D_mpi (double time_step, double length, double space_step_x, double width, double space_step_y, long long x, long long y, unsigned long long t, long long precision)
 This is a function calculates the value of specific point in the space at specific time in 2D.
 
long double _get_value_2D_openmp (double time_step, double length, double space_step_x, double width, double space_step_y, long long x, long long y, unsigned long long t, long long precision)
 This is a function calculates the value of specific point in the space at specific time in 2D.
 
int _simulate_heat_transfer_1D_MPI (double time_step, double time_limit, double space_step, long long precision)
 This is a function that simulates the heat transfer in 1D object as wire, and each core writes the result to a separate file.
 
int _simulate_heat_transfer_1D_OPENMP (double time_step, double time_limit, double space_step, long long precision)
 This is a function that simulates the heat transfer in 1D object as wire, and writes the result to a file.
 
int _simulate_heat_transfer_2D_MPI (double time_step, double time_limit, double space_step_x, double space_step_y, long long precision)
 This is a function that simulates the heat transfer in 2D object, and each core writes the result to a separate file.
 
int _simulate_heat_transfer_2D_OPENMP (double time_step, double time_limit, double space_step_x, double space_step_y, long long precision)
 This is a function that simulates the heat transfer in 2D object, and each core writes the result to a separate file.
 
double _execution_time_heat_transfer_1D_MPI (double time_step, double time_limit, double space_step, long long precision)
 This is a function that simulates the heat transfer in 1D object as wire, and return the execution time without I/O.
 
double _execution_time_heat_transfer_1D_OPENMP (double time_step, double time_limit, double space_step, long long precision)
 This is a function that simulates the heat transfer in 1D object as wire, and return the execution time without I/O.
 
double _execution_time_heat_transfer_2D_MPI (double time_step, double time_limit, double space_step_x, double space_step_y, long long precision)
 This is a function that simulates the heat transfer in 2D object, and return the execution time without I/O.
 
double _execution_time_heat_transfer_2D_OPENMP (double time_step, double time_limit, double space_step_x, double space_step_y, long long precision)
 This is a function that simulates the heat transfer in 2D object, and return the execution time without I/O.
 

Detailed Description

This file contains the implementation of the parallel version of the heat transfer simulation in 1D and 2D.

In the 1D heat equation, we make a model that thermal energy flow in a 1D object so we place the object along the x-axis. We show that an object has a fixed length and lies along an interval [0, 1] under the condition of both time and thermal energy we have some conditions that affect the temperature that is time and point of x on the object. We also have thermal diffusivity that shows the rate of the temperature to be transferred to the object(how quickly the heat moves throw the object) As, we separated variables of the thermal energy problem to calculate u(x, t) we make this function separated to the function of x-axis X(x) and function of time T(t) u(x, t) = X(t) T(t) Then, we calculate the change throw the time t to get the equation u(x,t)= ∑b(n) * sin(nΠx/L) b(n)= (2/L) ∫f(x)*sin(nΠx/L)dx In addition, parallelizing this functions will be done by using OpenMP and MPI.

In the 2D heat equation, we make a model that thermal energy flow in a 2D object, so we place the object on xy-plane under the condition of time. We represent the object by [0, a] x [0, b] as a is the length on x-axis and b is the width on y-axis, so, the tempertaure affected by function of x-axis X(x) and and y-axis Y(y) and time T(t). represented by u(x, y, t) = X(x) Y(y) T(t) Then, we separated the variables as 1D to get in each one of them the constant change as we get u(t) by using the diffusivity on u(xx) and u(yy) u(t) = c^2 (u(xx) + u(yy)) So, we get final equation to be as u(x,y,t)= ∑∑A(mn) sin(μ(m)x)sin(υ(n)y) exp(-λ(mn)t) μ(m)= mΠ/a , υ(n)=nΠ/b , λ(mn) = c√μ(m)^2 + υ(n)^2 A(mn)= 4/ab∫∫f(x,y)sin(μ(m)x)sin(υ(n)y) dy dx In addition, parallelizing this functions will be done by using OpenMP and MPI.

Function Documentation

◆ _execution_time_heat_transfer_1D_MPI()

double _execution_time_heat_transfer_1D_MPI ( double  time_step,
double  time_limit,
double  space_step,
long long  precision 
)

This is a function that simulates the heat transfer in 1D object as wire, and return the execution time without I/O.

In this simulation, we simulate heat propagation in 1D object as wire and the change in its tempreture over time using fourier transform. Then we parallelize the function using MPI, as we divide the object into equal parts and each core calculates the temperature of its part. Then, we return the execution time without I/O.

Parameters
time_stepThe rate of change of the time.
time_limitThe time that we want to measure the temperature of the object after.
space_stepThe rate of change of the space.
precisionThe number of vectors we use in the calculations.
Returns
execution time without I/O.

◆ _execution_time_heat_transfer_1D_OPENMP()

double _execution_time_heat_transfer_1D_OPENMP ( double  time_step,
double  time_limit,
double  space_step,
long long  precision 
)

This is a function that simulates the heat transfer in 1D object as wire, and return the execution time without I/O.

In this simulation, we simulate heat propagation in 1D object as wire and the change in its tempreture over time using fourier transform. Then, we parallelize the function using OPENMP, as we provide specific number of threads and make the iterations of the loop are divided into equal-sized chunks, and each chunk is assigned to a thread. Then, return the execution time without I/O.

Parameters
time_stepThe rate of change of the time.
time_limitThe time that we want to measure the temperature of the object after.
space_stepThe rate of change of the space.
precisionThe number of vectors we use in the calculations.
Returns
execution time without I/O.

◆ _execution_time_heat_transfer_2D_MPI()

double _execution_time_heat_transfer_2D_MPI ( double  time_step,
double  time_limit,
double  space_step_x,
double  space_step_y,
long long  precision 
)

This is a function that simulates the heat transfer in 2D object, and return the execution time without I/O.

In this simulation, we simulate heat propagation in 2D object as square or rectangle and the change in its tempreture over time using fourier transform. Then we parallelize the function using MPI, as we divide the object into equal parts and each core calculates the temperature of its part.

Parameters
time_stepThe rate of change of the time.
time_limitThe time that we want to measure the temperature of the object after.
space_step_xThe rate of change of the space in x-axis.
space_step_yThe rate of change of the space in y-axis.
precisionThe number of vectors we use in the calculations.
Returns
execution time without I/O. the output file contains paragraphs each one represent the time slot, each row represent the temperature at this point of the 2D object on x-axis (length), and the column represent the temperature at this point at that time on y-axis (width). The number of rows in each paragraph (time slot) equals length* space_step_x, and the number of columns equals width* space_step_y.

◆ _execution_time_heat_transfer_2D_OPENMP()

double _execution_time_heat_transfer_2D_OPENMP ( double  time_step,
double  time_limit,
double  space_step_x,
double  space_step_y,
long long  precision 
)

This is a function that simulates the heat transfer in 2D object, and return the execution time without I/O.

In this simulation, we simulate heat propagation in 2D object as square or rectangle and the change in its tempreture over time using fourier transform. Then, we parallelize the function using OPENMP, as we provide specific number of threads and make the iterations of the loop are divided into equal-sized chunks, and each chunk is assigned to a thread. Then, return the execution time without I/O.

Parameters
time_stepThe rate of change of the time.
time_limitThe time that we want to measure the temperature of the object after.
space_step_xThe rate of change of the space in x-axis.
space_step_yThe rate of change of the space in y-axis.
precisionThe number of vectors we use in the calculations.
Returns
the execution time without I/O.

◆ _get_value_1D_mpi()

long double _get_value_1D_mpi ( double  time_step,
double  space_step,
long long  x,
unsigned long long  t,
long long  precision 
)

This is a function calculates the value of specific point in the space at specific time in 1D.

In this function, we calculate the temperature of point x at time t given the rate of change of x and t, using fourier transform and the number of times we sum the series depend on the number of precision provided.

Parameters
time_stepThe rate of change of the time.
space_stepThe rate of change of the space.
xThe point we want to calculate the temperature at.
tThe current time we are at.
precisionThe number of vectors we use in the calculations.
Returns
sum we calculated.

◆ _get_value_1D_openmp()

long double _get_value_1D_openmp ( double  time_step,
double  space_step,
long long  x,
unsigned long long  t,
long long  precision 
)

This is a function calculates the value of specific point in the space at specific time in 1D.

In this function, we calculate the temperature of point x at time t given the rate of change of x and t, using fourier transform and the number of times we sum the series depend on the number of precision provided. Then we parallelize the for loop using OpenMP as we provide specific number of threads and make the iterations of the loop are divided into equal-sized chunks, and each chunk is assigned to a thread. the shared data that all the threads need to access is the sum, x_real, t_real, precision. the private data that each thread need to access is the exponential, spaceXTerm, coeff.

Parameters
time_stepThe rate of change of the time.
space_stepThe rate of change of the space.
xThe point we want to calculate the temperature at.
tThe current time we are at.
precisionThe number of vectors we use in the calculations.
Returns
sum we calculated.

◆ _get_value_2D_mpi()

long double _get_value_2D_mpi ( double  time_step,
double  length,
double  space_step_x,
double  width,
double  space_step_y,
long long  x,
long long  y,
unsigned long long  t,
long long  precision 
)

This is a function calculates the value of specific point in the space at specific time in 2D.

In this function, we calculate the temperature of point x and y at time t given the rate of change of x, y and t, using fourier transform and the number of times we sum the series depend on the number of precision provided.

Parameters
time_stepThe rate of change of the time.
lengthThe length of the object.
space_step_xThe rate of change of the space in x-axis.
widthThe width of the object.
space_step_yThe rate of change of the space in y-axis.
xThe point in x-axis we want to calculate the temperature at.
yThe point in y-axis we want to calculate the temperature at.
tThe current time we are at.
precisionThe number of vectors we use in the calculations.
Returns
sum we calculated.

◆ _get_value_2D_openmp()

long double _get_value_2D_openmp ( double  time_step,
double  length,
double  space_step_x,
double  width,
double  space_step_y,
long long  x,
long long  y,
unsigned long long  t,
long long  precision 
)

This is a function calculates the value of specific point in the space at specific time in 2D.

In this function, we calculate the temperature of point x and y at time t given the rate of change of x, y and t, using fourier transform and the number of times we sum the series depend on the number of precision provided. Then we parallelize the for loop using OpenMP as we provide specific number of threads and make the iterations of the loop are divided into equal-sized chunks, and each chunk is assigned to a thread. the shared data that all the threads need to access is the sum, x_real, t_real, precision. the private data that each thread need to access is the exponential, spaceXTerm, coeff.

Parameters
time_stepThe rate of change of the time.
lengthThe length of the object.
space_step_xThe rate of change of the space in x-axis.
widthThe width of the object.
space_step_yThe rate of change of the space in y-axis.
xThe point in x-axis we want to calculate the temperature at.
yThe point in y-axis we want to calculate the temperature at.
tThe current time we are at.
precisionThe number of vectors we use in the calculations.
Returns
sum we calculated.

◆ _simulate_heat_transfer_1D_MPI()

int _simulate_heat_transfer_1D_MPI ( double  time_step,
double  time_limit,
double  space_step,
long long  precision 
)

This is a function that simulates the heat transfer in 1D object as wire, and each core writes the result to a separate file.

In this simulation, we simulate heat propagation in 1D object as wire and the change in its tempreture over time using fourier transform. Then we parallelize the function using MPI, as we divide the object into equal parts and each core calculates the temperature of its part.

Parameters
time_stepThe rate of change of the time.
time_limitThe time that we want to measure the temperature of the object after.
space_stepThe rate of change of the space.
precisionThe number of vectors we use in the calculations.
Returns
0 if there is no error happened interrupted the calculations, each core writes the output to text file named simulate_heat_transfer_1D_MPI_"core num"_ + current time, the row represent the time, and the column represent the temperature at this point at that time.

◆ _simulate_heat_transfer_1D_OPENMP()

int _simulate_heat_transfer_1D_OPENMP ( double  time_step,
double  time_limit,
double  space_step,
long long  precision 
)

This is a function that simulates the heat transfer in 1D object as wire, and writes the result to a file.

In this simulation, we simulate heat propagation in 1D object as wire and the change in its tempreture over time using fourier transform. Then, we parallelize the function using OPENMP, as we provide specific number of threads and make the iterations of the loop are divided into equal-sized chunks, and each chunk is assigned to a thread. Then, we write the result to a file.

Parameters
time_stepThe rate of change of the time.
time_limitThe time that we want to measure the temperature of the object after.
space_stepThe rate of change of the space.
precisionThe number of vectors we use in the calculations.
Returns
0 if there is no error happened interrupted the calculations, writes the output to text file named simulate_heat_transfer_1D_OPENMP_ + current time, the row represent the time, and the column represent the temperature at this point at that time.

◆ _simulate_heat_transfer_2D_MPI()

int _simulate_heat_transfer_2D_MPI ( double  time_step,
double  time_limit,
double  space_step_x,
double  space_step_y,
long long  precision 
)

This is a function that simulates the heat transfer in 2D object, and each core writes the result to a separate file.

In this simulation, we simulate heat propagation in 2D object as square or rectangle and the change in its tempreture over time using fourier transform. Then we parallelize the function using MPI, as we divide the object into equal parts and each core calculates the temperature of its part.

Parameters
time_stepThe rate of change of the time.
time_limitThe time that we want to measure the temperature of the object after.
space_step_xThe rate of change of the space in x-axis.
space_step_yThe rate of change of the space in y-axis.
precisionThe number of vectors we use in the calculations.
Returns
0 if there is no error happened interrupted the calculations, and write the output to text file named simulate_heat_transfer_2D_MPI_"core num"_ + current time, the output file contains paragraphs each one represent the time slot, each row represent the temperature at this point of the 2D object on x-axis (length), and the column represent the temperature at this point at that time on y-axis (width). The number of rows in each paragraph (time slot) equals length* space_step_x, and the number of columns equals width* space_step_y.

◆ _simulate_heat_transfer_2D_OPENMP()

int _simulate_heat_transfer_2D_OPENMP ( double  time_step,
double  time_limit,
double  space_step_x,
double  space_step_y,
long long  precision 
)

This is a function that simulates the heat transfer in 2D object, and each core writes the result to a separate file.

In this simulation, we simulate heat propagation in 2D object as square or rectangle and the change in its tempreture over time using fourier transform. Then, we parallelize the function using OPENMP, as we provide specific number of threads and make the iterations of the loop are divided into equal-sized chunks, and each chunk is assigned to a thread. Then, we write the result to a file.

Parameters
time_stepThe rate of change of the time.
time_limitThe time that we want to measure the temperature of the object after.
space_step_xThe rate of change of the space in x-axis.
space_step_yThe rate of change of the space in y-axis.
precisionThe number of vectors we use in the calculations.
Returns
0 if there is no error happened interrupted the calculations, and write the output to text file named simulate_heat_transfer_2D_OPENMP_ + current time, the output file contains paragraphs each one represent the time slot, each row represent the temperature at this point of the 2D object on x-axis (length), and the column represent the temperature at this point at that time on y-axis (width). The number of rows in each paragraph (time slot) equals length* space_step_x, and the number of columns equals width* space_step_y.