Developed from scratch in C++20. This project is a sophisticated numerical simulator designed to solve 2D non-stationary heat transfer problems in solids using the Finite Element Method (MES). It models temperature distribution over time by solving the Fourier equation, accounting for both thermal conductivity and convection (third-kind boundary conditions).
To address the challenge of modeling irregular real-world mesh elements where global shape functions are mathematically impractical, this project employs a standardized square Universal Element with deterministic shape functions that interpolate discrete node values into a continuous field. By utilizing a Jacobian Transformation, the system maps this local (ฮพ,ฮท) coordinate space to the global (x,y) geometry, using the determinant of the Jacobian as a scaling factor to accurately translate thermal properties from the virtual square back to the real, irregular physical geometry.
The simulation aggregates local element properties into a global system of equations:
- Matrix [H] (Conductivity Matrix): Represents the ability of the material to conduct heat. It is calculated by integrating shape function gradients.
- Matrix [C] (Heat Capacity Matrix): Represents the thermal inertia of the material (how much energy it stores).
- Vector {P} (Load Vector): Accounts for external influences, specifically heat flux from convection at the boundaries.
At each time step, the solver calculates the temperature vector {t} by solving:
- Mathematical Modeling: Implementation of the Fourier heat equation for isotropic materials.
- Mesh Parsing: Custom parser for Abaqus-style
.txtfiles containing node coordinates, element connectivity, and boundary condition (BC) flags. - Universal Element: Implementation of isoparametric 4-node quadrilateral elements.
- Numerical Integration: Gauss quadrature implementation with support for various integration point schemes.
- Time-Dependent Simulation: Non-stationary solver using the heat capacity matrix [C] and specific time-stepping.
- Custom Linear Solver: Built-in Gaussian Elimination algorithm with partial pivoting.
To select a specific mesh or change the precision of the simulation, simply modify the #define TEST (to choose the file) and #define NPC (to set the number of integration points) values in the header.h file.
#define TEST 2
#define NPC 3
#define NPCBC 2The program expects a text file with the following structure:
SimulationTime 500
SimulationStepTime 50
Conductivity 25
Alfa 300
Tot 1200
InitialTemp 100
Density 7800
SpecificHeat 700
Nodes number 16
Elements number 9
*Node
1, 0.100000001, 0.00499999989
2, 0.0666666701, 0.00499999989
...
*Element, type=DC2D4
1, 1, 2, 6, 5
2, 2, 3, 7, 6
...
*BC
1, 2, 3, 4, 5, 8, 9, 12, 13, 14, 15, 16
- Ensure your input mesh files are located in the
../grids/directory relative to the executable. - Compile using a C++20 compliant compiler:
g++ main.cpp -o FEM_Simulator
- Run the application:
./FEM_Simulator