% Code designed to solve different kind of fluids problems in a quadrilateral
% 2D domain.
clc;clear;close all
addpath('Functions/main')

disp('This program solves different kinds of flow problems for 2D quadrilateral domains.')
fprintf('\nPlease select the type of problem to solve:\n')

prob = cinput('[1] Steady problem\n[2] Unsteady problem\n>> ',11);
           
fprintf('\nDefine the domain:\n')
dom(1) = cinput('x1 >> ',0);
dom(2) = cinput('x2 >> ',2);
dom(3) = cinput('y1 >> ',0);
dom(4) = cinput('y2 >> ',3);

fprintf('\nSelect the discretization step: \n')
nx = cinput('Elements in x >> ',20);
ny = cinput('Elements in y >> ',30);

eType = cinput('\nSelect the type of element to use: \n[0] for quadrilateral\n[1] for triangles\n>> ',0);
eDeg  = cinput('\nSelect the order of interpolation: \n[1] for linear\n[2] for quadratic\n>> ',1);
elem  = SetReferenceElement(eType,eDeg);

[X,T]   = createRectangleMesh(dom,eType,eDeg,nx,ny);
[XB,TB] = boundaryNodes(eDeg,nx,ny);

fprintf('\nSelect the boundary condition for every boundary (1 = Dirichlet, 2 = Neumann):')
bType(1) = cinput('\n?_1 >> ',2);
bType(2) = cinput('?_2 >> ',1);
bType(3) = cinput('?_3 >> ',2);
bType(4) = cinput('?_4 >> ',1);
bType(5) = cinput('?_5 >> ',2);

fprintf('\nSelect the prescribed value for every boundary')
bVal(1) = cinput('\n?_1 >> ',0);
bVal(2) = cinput('?_2 >> ',1);
bVal(3) = cinput('?_3 >> ',0);
bVal(4) = cinput('?_4 >> ',0);
bVal(5) = cinput('?_5 >> ',0);

switch prob
    case 1;     main_steadyconv;
    case 2;     main_unsteadyconv;
    otherwise;  error('Problem type not defined.');
end

