Excercises_GeorgMandl/Sheet_6/jumps_flux.m
2026-01-14 18:42:17 +01:00

16 lines
No EOL
590 B
Matlab

% calculation of the flux jumps according to the chosen mesh
% nodes - corresponding to the mesh
% u - approximation
% flux_jumps - jump of the flux in each node of the mesh including the
% paramter function lambda
function flux_jumps = jumps_flux(nodes, u, lambda)
n_nodes = length(nodes);
flux_jumps = zeros(n_nodes,1);
diff_u = u(2:end) - u(1:end-1);
diff_x = nodes(2:end) - nodes(1:end-1);
eps = 1e-8;
for i = 2:n_nodes-1
flux_jumps(i) = diff_u(i)/diff_x(i)*lambda(nodes(i)+eps) - diff_u(i-1)/diff_x(i-1)*lambda(nodes(i)-eps);
end
end