function [rho_rhs,u_rhs,v_rhs,p_rhs] = ODEs_RHS(rho,u,v,p)

Globals2D;

% local Lax-Friedrichs flux - strong form - fact that u_0 = v_0 = 0 used for simplification

% computing fluxes on the boundaries within the elements
rho_flux = u(vmapM) .* n_x(:) + v(vmapM) .* n_y(:);
u_flux = p(vmapM) .* n_x(:);
v_flux = p(vmapM) .* n_y(:);
p_flux = u(vmapM) .* n_x(:) + v(vmapM) .* n_y(:);

% computing numerical fluxes
rho_numerical_flux = ((u(vmapM) + u(vmapP)) .* n_x(:) + (v(vmapM) + v(vmapP)) .* n_y(:) + (rho(vmapM) - rho(vmapP)) * a_0) / 2;
u_numerical_flux = ((p(vmapM) + p(vmapP)) .* n_x(:) + (u(vmapM) - u(vmapP)) * a_0) / 2;
v_numerical_flux = ((p(vmapM) + p(vmapP)) .* n_y(:) + (v(vmapM) - v(vmapP)) * a_0) / 2;
p_numerical_flux = ((u(vmapM) + u(vmapP)) .* n_x(:) + (v(vmapM) + v(vmapP)) .* n_y(:) + (p(vmapM) - p(vmapP)) * a_0) / 2;

% imposing boundary condition (unlimited domain) - postup Toulorge zalozeny na diagonalizaci matice A = n_x * A_1 + n_y * A_2
%for i = 1:length(mapB)
%   node_position_faces = mapB(i);
%   node_position_total = vmapB(i);
%   variables_vector = [rho(node_position_total); u(node_position_total); v(node_position_total); p(node_position_total)];
%   numerical_flux_face = TDplusTinv_flux_cell{node_position_faces} * variables_vector;
%   rho_numerical_flux(node_position_faces) = numerical_flux_face(1);
%   u_numerical_flux(node_position_faces) = numerical_flux_face(2);
%   v_numerical_flux(node_position_faces) = numerical_flux_face(3);
%   p_numerical_flux(node_position_faces) = numerical_flux_face(4);
%end
% imposing wall boundary condition - replacement for NRBC
scalar_product = u(vmapB) .* n_x(mapB) + v(vmapB) .* n_y(mapB);
u_modified = u(vmapB) - scalar_product .* n_x(mapB);
v_modified = v(vmapB) - scalar_product .* n_y(mapB);
rho_numerical_flux(mapB) = u_modified .* n_x(mapB) + v_modified .* n_y(mapB);
u_numerical_flux(mapB) = p(vmapB) .* n_x(mapB);
v_numerical_flux(mapB) = p(vmapB) .* n_y(mapB);
p_numerical_flux(mapB) = u_modified .* n_x(mapB) + v_modified .* n_y(mapB);

% resizing both normal and numerical fluxes to appropiate arrays
rho_flux = reshape(rho_flux,N_faces * N_fp,K);
u_flux = reshape(u_flux,N_faces * N_fp,K);
v_flux = reshape(v_flux,N_faces * N_fp,K);
p_flux = reshape(p_flux,N_faces * N_fp,K);

rho_numerical_flux = reshape(rho_numerical_flux,N_faces * N_fp,K);
u_numerical_flux = reshape(u_numerical_flux,N_faces * N_fp,K);
v_numerical_flux = reshape(v_numerical_flux,N_faces * N_fp,K);
p_numerical_flux = reshape(p_numerical_flux,N_faces * N_fp,K);

% building the right-hand side of the ODE system
[u_x,u_y] = Grad2D(u); [v_x,v_y] = Grad2D(v); [p_x,p_y] = Grad2D(p);
rho_rhs = -u_x - v_y + LIFT * (Fscale .* (rho_flux - rho_numerical_flux));
u_rhs = -p_x + LIFT * (Fscale .* (u_flux - u_numerical_flux));
v_rhs = -p_y + LIFT * (Fscale .* (v_flux - v_numerical_flux));
p_rhs = -u_x - v_y + LIFT * (Fscale .* (p_flux - p_numerical_flux));

end