1
// Copyright (C) 2002 Johan Hoffman and Anders Logg.
2
// Licensed under the GNU GPL Version 2.
4
#include "ProblemConvDiff.hh"
5
#include "EquationConvDiff_cG1dG0.hh"
6
#include "EquationConvDiff2d_cG1dG0.hh"
9
//-----------------------------------------------------------------------------
10
const char *ProblemConvDiff::Description()
12
if ( space_dimension == 2 )
13
return "Convection-Diffusion equation (2D)";
15
return "Convection-Diffusion equation (3D)";
17
//-----------------------------------------------------------------------------
18
void ProblemConvDiff::Solve()
29
if ( space_dimension == 2 )
30
equation = new EquationConvDiff2d_cG1dG0();
32
equation = new EquationConvDiff_cG1dG0();
35
GlobalField Up(grid,&up);
36
GlobalField U(grid,&u);
37
GlobalField f(grid,"source");
38
GlobalField eps(grid,"diffusivity");
39
GlobalField bx(grid,"x-convection");
40
GlobalField by(grid,"y-convection");
41
GlobalField bz(grid,"z-convection");
43
// Attach fields to equation
44
equation->AttachField(0,&Up);
45
equation->AttachField(1,&eps);
46
equation->AttachField(2,&f);
47
equation->AttachField(3,&bx);
48
equation->AttachField(4,&by);
49
if ( space_dimension == 3 )
50
equation->AttachField(5,&bz);
52
// Set up the discretiser
53
Discretiser discretiser(grid,equation);
55
// Prepare time stepping
56
settings->Get("start time",&T0);
57
settings->Get("final time",&T);
60
real dt = grid->GetSmallestDiameter();
63
U.SetLabel("u","Temperature");
66
// Start time stepping
72
// Set solution to previous solution
76
display->Progress(0,(t-T0)/(T-T0),"i=%i t=%f",time_step,t);
77
display->Message(0,"||u0||= %f ||u1|| = %f",up.Norm(),u.Norm());
79
// Set time and time-step
81
equation->SetTimeStep(dt);
83
// Discretise equation
84
discretiser.Assemble(&A,&b);
86
// Solve the linear system
87
solver.Solve(&A,&u,&b);
96
//-----------------------------------------------------------------------------