We present a program to solve the time dependent 2-D heat equation using
the P1 finite element method for space discretization and
one of the available time integration schemes for time discretization.
To validate the code, we test the exact solution
u(x,y) = exp(-t)*exp(x+y)
This gives as a source term, in the case where all coefficients are
equal to 1:
f(x,y) = -3*exp(-t)*exp(x+y)
- We start, as usual, by including the main header
file of the library, and the header for thermal problems.
The program has, as argument the mesh file and the time step.
We construct a Mesh
instance with the flag that enables eliminating imposed boundary conditions.
Note that the final time value is also set by using the OFELI global
variable theFinalTime.
#include "OFELI.h"
#include "Therm.h"
using namespace OFELI;
int main(int argc, char *argv[])
{
theFinalTime = 1.;
Mesh ms(argv[1],true);
theTimeStep = atof(argv[2]);
|