function [P, E] = MeshGeneration2D(x_l, x_r, y_l, y_r, n_elem_x, n_elem_y)

% generates mesh for dGFEM - the computational domain must be a rectangle with borders given by x_l, x_r, y_l, y_r
% numbers of elements in both directions are given by n_elem_x and n_elem_y

% NEFUNGUJE, protoze delaunay nevytvori matici E tak, aby vrcholy tvorici trojuhelniky
% byly proti smeru hodinovych rucicek, jak to ma byt ve vystupu z napr Gmsh

x = linspace(x_l, x_r, n_elem_x + 1);
y = linspace(y_l, y_r, n_elem_y + 1);
[X,Y] = meshgrid(x,y);
X = X'; X = X(:);
Y = Y'; Y = Y(:);
tri = delaunay(X,Y);

P = [X'; Y'];
E = tri';

end