**1. Introduction**

In a domain <sup>Ω</sup> in *<sup>n</sup>*, *<sup>n</sup>* <sup>¼</sup> 1, 2, 3, consider a partial differential equation of the form of

$$\nabla \cdot (-\kappa \nabla u) + \chi \cdot \nabla u + \mu u = f \quad \text{in } \Omega,\tag{1}$$

where the unknown function *u*, reaction coefficient *μ* and the given function *f* are scalar functions ð Þ Ω ! . Diffusion coefficient *κ* and the (convergence free) advection coefficient *γ* are defined in Ω and give (normally piecewise constant) values in *<sup>n</sup>*�*<sup>n</sup>* and *<sup>n</sup>*, respectively. Eq. (1) is called a diffusion–advection-reaction equation and has immense applications in science and engineering. Transport of heat, momentum and energy, solid mechanics, CO2 sequestration, computational fluid dynamics and biophysics are a few number of research fields that as a part of the solution strategy need to solve (1) numerically.

After several steps, numerical solution of Eq. (1) is obtained by solving a linear system

$$\mathcal{A}\mathfrak{x} = \mathfrak{b} \tag{2}$$

6.Generalization to more complex equations such as Eq. (25) now becomes

*A Numerical Simulator Based on Finite Element Method for Diffusion-Advection-Reaction…*

We finish this chapter by introducing the necessary topics to have an independent and efficient simulator in Section 7. Most of the topics presented here are fully

Implementation of FEM is began with mesh generation which is dividing the main domain into several subdomains or elements. Each element is finite (finite

straightforward and solving strategy is given in Section 6.

discussed in [1–3] which are of great value for further reading.

**2. Mesh generation**

*DOI: http://dx.doi.org/10.5772/intechopen.98291*

**Figure 1.**

**99**

*Creating a geometry and generating its mesh shown in Figure 2.*

where A and *b* are called stiffness matrix and right hand side vector, respectively. In practice each term of diffusion, advection or reaction is accumulated separately in the stiffness matrix.

Several challenges make finding the numerical solution of (1) difficult. 3 of the most important are 1) complex geometry of Ω, 2) heterogeneity and high contrast in coefficient *κ* that produce very ill-conditioned linear systems and 3) large scale domains. A very common numerical method to solve (1) is FEM that uses a mesh representing the complex geometries accurately and overcomes the first issue. We can employ powerful linear solvers such as multigrid or multiscale methods to resolve the effect of heterogeneity and high contrast in *κ* in the linear system. Finally a careful implementation in parallel machines reduces computational time of large scale simulations considerably. However, lots of effort and research are still needed to propose a method obtaining a reliable solution in a reasonable time for real problems. Other issues such as uncertainties in the data or nonlinear coupled system of equations should be addressed, as well.

Considering a positive definite *κ* we explain (and implement) how to obtain a finite element solution of (1) through the following steps.


*A Numerical Simulator Based on Finite Element Method for Diffusion-Advection-Reaction… DOI: http://dx.doi.org/10.5772/intechopen.98291*

6.Generalization to more complex equations such as Eq. (25) now becomes straightforward and solving strategy is given in Section 6.

We finish this chapter by introducing the necessary topics to have an independent and efficient simulator in Section 7. Most of the topics presented here are fully discussed in [1–3] which are of great value for further reading.
