% This program solves a convection-diffusion problem 
% in a square domain [0,2]x[0,3] 

clear; close all; clc


disp(' ')
disp('This program solves a convection-diffusion equation on domain [0,2]x[0,3]')
disp('u_t + a*Du + D.(nu*Du) + sigma*u = s')
disp(' ')
disp('Source term is considered.');
disp(' ')

% PDE coefficients
ax = cinput('Enter velocity in x-direction', 0.001);
ay = cinput('Enter velocity in y-direction', 0);
disp('Convection velocity is');
velo = [ax,ay]; 
disp(velo);
a = norm(velo); 
%disp(' ')
nu = cinput('Enter diffusion coefficient', 0.001);
disp(' ')
sigma = cinput('Enter reaction coefficient', 0.1);

dom = [0,2,0,3]; %Domain given in problem.

example.dom = dom; 
example.velo = velo; 
example.a = a; 
example.nu = nu; 
example.sigma = sigma;

% Element type
disp(' ')
elem = cinput('Enter type of elemet (0=Quadrilateral, 1=Triangular)', 0);
disp(' ')
p = cinput('Enter type of interpoltion (1=Linear, 2=Quadratic)', 1); 
referenceElement = SetReferenceElement(elem,p); 
disp(' ')
nx = cinput('Number of elements in x-direction (multiple of 5,', 20);
ny = cinput('Number of elements in y-direction (multiple of 10,', 20); 
[X,T] = CreateMesh(dom,nx,ny,referenceElement);
%PlotMesh(T,X,'b-');
example.nx=nx;
example.ny=ny;

%Type of problem to be solved.
disp(' ')
Ptype = cinput('Enter type of problem to be solved (1=Unsteady, 2=steady)', 1);


%Type of stabilization scheme.
disp(' ')
disp ('The following stabilization methods can be used:');
disp ('     [1] SUPG');
disp ('     [2] GLS');
methodSD = input ('Choose a method for solving the problem: ');
example.methodSD = methodSD; 

if Ptype==1;
%Time Discretisation
    disp(' ')
    disp ('The following Pade approximations can be used:');
    disp ('     [1] R11 : First stage scheme of second order ');
    disp ('     [2] R20 : Second stage scheme of first order ');
    disp ('     [3] R22 : Second stage scheme of fourth order');
    methodtm = input ('Choose a scheme for time discretization: ');
    example.methodtm = methodtm; 
end

npx = p*nx;
npy = p*ny;

example.Ptype = Ptype;
if Ptype==1;
    Super_main_unsteady
else
    Super_main_steady
end

