This solver is designed to compute the 1D linear convection equation using the Finite Element Method (FEM). Convection equations model the propagation of quantities like heat or fluid, and FEM provides a structured way to discretize and solve such PDEs over irregular or complex geometries.
The 1D linear convection equation is given by:
where
The spatial domain
where
Applying the Galerkin method, the weak form of the 1D convection equation is derived by multiplying the original equation with a test function and integrating over the domain. The weak form is:
Substituting the velocity field into the weak form leads to the formation of the inertia (Mass) matrix
The matrices are:
Inertia Matrix M:
Convection Matrix K:
This equation is discretized in both space and time.
The global inertia and convection matrices are assembled for the entire domain. These matrices represent the spatial derivatives of the solution, while the time-stepping technique handles time integration.
The 1D domain is divided into elements with nodes at each boundary. In our example, we use 41 grid points between
The time-stepping loop solves the system iteratively using the explicit forward Euler method. At each time step, the system of equations is updated using the matrix formulation, and the solution is advanced in time:
Substituting into the weak form and rearranging yields the update rule for each time step:
Thus, the FEM-based linear convection solution is advanced in time by solving this linear system at each time step, with
Dirichlet boundary conditions are implicitly assumed by the use of fixed values at the boundaries. At
This FEM-based solver provides a structured approach to solving the 1D linear convection equation, making it highly flexible for different geometries and boundary conditions. By saving the solution in Gmsh or another visualization tool, the results can be easily analyzed.
Licensed under the Creative Commons Attribution-NoDerivatives 4.0 International License.
To view a copy of this license, visit https://creativecommons.org/licenses/by-nd/4.0/.