 
 
 
 
 
 
 
  
In this section we will show how the convection-diffusion equation is implemented. We do this for the one-dimensional equation. See the users manual for the convection-diffusion (heat) equation:
 
where we take here for simplicity a prescribed temperature  at
 at  and
 and  .
Multiplication with a weighting function (=test function)
.
Multiplication with a weighting function (=test function)  and integration over the volume gives:
and integration over the volume gives:
![\begin{displaymath}
\int [ \rho C ( \dot{T} + \beta \frac{\partial T}{\partial ...
...t [ k \frac{\partial^2 T}{\partial {x}^2} h - a T h + f h ] dx
\end{displaymath}](img6.png) 
where  is
 is  at
 at  and
 and  but arbitrary otherwise.
Integration by parts of the conductive term, and moving everything to the right
gives for the residue
 but arbitrary otherwise.
Integration by parts of the conductive term, and moving everything to the right
gives for the residue  in the equation:
 in the equation:
![\begin{displaymath}
R = \int [ - \rho C ( \dot{T} + \beta \frac{\partial T}{\pa...
...artial x} \frac{\partial h}{\partial x} - a T h + f h ] dx = 0
\end{displaymath}](img9.png) 
where the boundary terms resulting from the integration by parts disappear
because  is 0 at
 is 0 at  and
 and  .
This form of the equilibrium equation is called the 'weak form'.
.
This form of the equilibrium equation is called the 'weak form'.
The weak form above is still perfectly equal to the heat equation.
Now, however, we start approximating with the finite element method.
The temperature field  is approximated with finite element interpolation
functions
 is approximated with finite element interpolation
functions  where
 where  denotes the node number.
In the standard galerkin approach, the same functions for the 
weighting field is used, so
 denotes the node number.
In the standard galerkin approach, the same functions for the 
weighting field is used, so  is approximated with
 is approximated with  .
Remark 1: we use indices
.
Remark 1: we use indices  for the weighting function to prevent conflicting
indices of the temperature and weighting functions.
Remark 2:
 for the weighting function to prevent conflicting
indices of the temperature and weighting functions.
Remark 2: can now be called a virtual temperature field, since it consists
of the same set of functions as the temperature field itself.
So:
 can now be called a virtual temperature field, since it consists
of the same set of functions as the temperature field itself.
So:
 
and:
 
where  is the position of node
 is the position of node  , and summation convention is used.
For a two-noded linear element this would be:
, and summation convention is used.
For a two-noded linear element this would be:
 
and:
 
The weighting functions are substituted in the weak form of the equilibrium equation:
![\begin{displaymath}
R = \int [ - \rho C ( \dot{T} + \beta \frac{\partial T}{\pa...
...}{\partial x} -
a T h(x_i) h_i(x) + f h(x_i) h_i(x) ] dx = 0
\end{displaymath}](img19.png) 
Now demanding that this is true for arbitrary nodal weighting function values  gives
for each
 gives
for each  :
:
![\begin{displaymath}
R = \int [ - \rho C ( \dot{T} + \beta \frac{\partial T}{\pa...
...partial h_i(x)}{\partial x} -
a T h_i(x) + f h_i(x) ] dx = 0
\end{displaymath}](img21.png) 
The time derivative  will be approximated with
the Euler backward scheme
 will be approximated with
the Euler backward scheme 
 .
Integrals are approximated by numerically integrating over a set of integration points. 
The temperature
.
Integrals are approximated by numerically integrating over a set of integration points. 
The temperature  in the last expression is understood to be interpolated
by the finite element interpolation functions, and so depends on the
nodal temperatures
 in the last expression is understood to be interpolated
by the finite element interpolation functions, and so depends on the
nodal temperatures  .
Thus the last expression gives a set of equations for the nodal temperatures
.
Thus the last expression gives a set of equations for the nodal temperatures  .
.
We now will discuss where the seperate terms in this expression are implemented
in the finite element program.
First we link terms from the expression for  with the program source:
 with the program source: 
| mathematical term | program | 
|  | element_rhside | 
|  | dens | 
|  | condif_capacity | 
|  | condif_flow | 
|  | condif_conductivity | 
|  | condif_absorption | 
|  | element_volume_force | 
|  | new_dof | 
|  | old_dof | 
|  | dtime | 
|  | inol | 
|  | h[inol] | 
|  | new_d | 
Different parts of  are implemented in different routines.
First, it will be collected in the variable element_rhside.
Later, element_rhside will be used to fill node_rhsidewhich contains the residue
 are implemented in different routines.
First, it will be collected in the variable element_rhside.
Later, element_rhside will be used to fill node_rhsidewhich contains the residue  for the nodes.
 for the nodes.
 is implemented in general.cc.
      The time derivative
 is implemented in general.cc.
      The time derivative  is evaluated lumped.
      The implementation of this term is marked by 
      the comment // inertia (lumped).
 is evaluated lumped.
      The implementation of this term is marked by 
      the comment // inertia (lumped).
 is 
      implemented in general.cc.
      The implementation of this term is marked 
      by the comment // convection with respect to mesh.
 is 
      implemented in general.cc.
      The implementation of this term is marked 
      by the comment // convection with respect to mesh.
 is implemented
      in general.cc.
      The implementation of this term is marked 
      by the comment // diffusive terms (with partial integration).
 is implemented
      in general.cc.
      The implementation of this term is marked 
      by the comment // diffusive terms (with partial integration).
 is implemented in condif.cc.
      The implementation of this term is marked 
      by the comment // absorption.
 is implemented in condif.cc.
      The implementation of this term is marked 
      by the comment // absorption.
 is implemented in elem.cc.
      The implementation of this term is marked 
      by the comment // element force.
 is implemented in elem.cc.
      The implementation of this term is marked 
      by the comment // element force.
 
 
 
 
 
 
