rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
conv_flux_forward_difference.m
Go to the documentation of this file.
1 function [flux_lin, lambda] = conv_flux_forward_difference(glob, U, params)
2 % function [flux_lin, lambda] = conv_flux_forward_difference(glob, U, params)
3 % function computing the derivative of a convective flux by forward
4 % difference.
5 %
6 % Return values:
7 % 'flux_lin' : is a matrix which row entries represent the velocity vectors
8 % in the edge midpoints.
9 % 'lambda' : is a bound such that
10 % ``\lambda \cdot \sup_u n_{jl} \cdot f'(u) \leq 1``
11 % e.g. `\lambda := \frac{1}{\sup|v(x,y)|}` for `f(u) = v \cdot u`.
12 % This is value only reasonable in 'decomp_mode==0', otherwise an
13 % empty variable is returned.
14 %
15 % Parameters:
16 % U : a vector with evaluations of a solution `u` which are passed as
17 % an argument to the flux function `f`
18 % glob : a matrix of row vectors for each coordinate dimension of the grid
19 % defining the coordinates where the flux function is evaluated, in
20 % case it is space dependent, i.e. we have something like `f(u,x)`.
21 % params : a structure with model parameters
22 %
23 %
24 epsilon = max(abs(U)) * 1e-2;
25 if epsilon < eps; % U completely 0
26  epsilon = 1e-2;
27 end;
28 
29 % glob column check
30 if params.debug
31  if ~isempty(glob) && size(glob,1) < size(glob,2)
32  warning('coordinates in variable glob are given row-wise, but expected them to be column-wise');
33  if params.debug > 2
34  keyboard;
35  end
36  end
37 end
38 
39 [fluxU,lambda] = params.conv_flux_ptr(glob,U,params);
40 fluxU2 = params.conv_flux_ptr(glob,U+epsilon,params);
41 
42 flux_lin = (fluxU2-fluxU)/epsilon;
43 
44 
function [ flux_lin , lambda ] = conv_flux_forward_difference(glob, U, params)
function computing the derivative of a convective flux by forward difference.