function u_rhs = ODEs_RHS(u,time_RK)

Globals1D;

% local Lax-Friedrichs flux - strong form

% computing flux on the boundaries within the elements
flux = (a_advec * u(vmapM)) .* n_x(:);

% computing numerical flux
numerical_flux = ((a_advec * (u(vmapM) + u(vmapP))) .* n_x(:) + (u(vmapM) - u(vmapP)) .* ((1 - alpha_flux) * abs(a_advec * n_x(:)))) / 2;

% imposing inflow condition
u_inflow = BC(x(vmapI),time_RK);
numerical_flux(mapI) = ((a_advec * (u(vmapI) + u_inflow)) .* n_x(mapI) + (u(vmapI) - u_inflow) .* ((1 - alpha_flux) * abs(a_advec * n_x(mapI)))) / 2;

% imposing outflow condition - we extrapolate u - therefore the numerical flux takes form
numerical_flux(mapO) = (a_advec * u(vmapO)) .* n_x(mapO);

% resizing both normal and numerical fluxes to appropiate arrays
flux = reshape(flux,N_fp * N_faces,K);
numerical_flux = reshape(numerical_flux,N_fp * N_faces,K);

% building the right-hand side of the ODE system
u_rhs = -a_advec * r_x .* (D_r * u) + LIFT * (Fscale .* (flux - numerical_flux));


% verze z knihy - local Lax-Friedrichs flux
%du = (u(vmapM) - u(vmapP)) .* (a_advec * n_x(:) - (1 - alpha_flux) * abs(a_advec * n_x(:))) / 2;
%uin = BC(time_RK);
%du(mapI) = (u(vmapI) - uin) .* (a_advec * n_x(mapI) - (1 - alpha_flux) * abs(a_advec * n_x(mapI))) / 2;
%du(mapO) = 0;
%
%du = reshape(du,N_fp * N_faces,K);
%
%u_rhs = -a_advec * r_x .* (D_r * u) + LIFT * (Fscale .* du);

end


% pro central flux:
% v danem uzlu je tok pocitan jako prumer reseni v danem uzlu na sousedicich elementech

% pro upwind flux:
% v danem uzlu je tok bran jako reseni z toho smeru, odkud "prichazi" informace - tedy pro a > 0 v L konci elementu se vezme reseni ze sousedniho elementu a v P konci elementu se vezme reseni uvnitr daneho elementu (pro a < 0 je to presne naopak, tj v L konci se vezme reseni z daneho elementu a v P konci se vezme reseni z elementu sousedniho)

% celkovy vyraz v integralu je pak hodnota v danem uzlu uvnitr elementu a od toho se odecte numericky tok (numerical flux)

% na outflow cast hranice je tok bran jako reseni v danem uzlu uvnitr daneho elementu, tedy du je tam nulove