rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
conv_flux_buckley_leverett.m
Go to the documentation of this file.
1 function [flux, lambda] = conv_flux_buckley_leverett(glob, U, params)
2 % function [flux, lambda] = conv_flux_buckley_leverett(glob, U, params)
3 % convective flux for Buckley-Leverett problem
4 %
5 % function computing the nonlinear convective flux of a Buckley-Leverett
6 % problem. ``f(x,u) = \frac{u^2}{u^2+ M (1-u^2)} \quad 0\leq u \leq 1``.
7 %
8 % required fields of params:
9 % bl_k : scaling factor for flux
10 % bl_M : steepness factor of curve.
11 % U : DoF vector of discrete solution
12 % grid : pointer to grid structure for neighbour
13 % information
14 %
15 % See also conv_flux_buckley_leverett_derivative().
16 %
17 
18 % glob column check
19 if params.debug
20  if ~isempty(glob) && size(glob,1) < size(glob,2)
21  warning('coordinates in variable glob are given row-wise, but expected them to be column-wise');
22  if params.debug > 2
23  keyboard;
24  end
25  end
26 end
27 
28 %grid = params.grid;
29 
30 %tmpU = repmat(U, 1, grid.nneigh);
31 %neiU = tmpU;
32 %real_nb_ind = grid.NBI > 0;
33 %neiU(real_nb_ind) = U(grid.NBI(real_nb_ind));
34 %U = 0.5 * (tmpU + neiU);
35 
36 X = glob(:,1);
37 Y = glob(:,2);
38 
39 flux = params.bl_k * U(:).^2./(U(:).^2 + params.bl_M * (1-U(:).^2));
40 %vf = @(X,Y) [2*((2*X(:)-pi/2)-(4/3*Y(:)-pi/2)).^2.*cos((2*X(:)-pi/2)...
41 % +(4/3*Y(:)-pi/2))+0.1,...
42 % 2*((2*X(:)-pi/2)-(4/3*Y(:)-pi/2)).^2.*sin((2*X(:)-pi/2)...
43 % +(4/3*Y(:)-pi/2))+0.1];
44 
45 %vf = @(X,Y) [...
46 % ((X(:)-Y(:))).^2.*cos((X(:)+Y(:))*pi/2)+0.1, ...
47 % ((X(:)-Y(:))).^2.*sin((X(:)+Y(:))*pi/2)+0.1 ...
48 % ];
49 
50 %vf = @(X,Y) [abs((X(:)-Y(:))).^0.5.*cos((X(:)+Y(:))*pi/2)+0.5, ...
51 % abs((X(:)-Y(:))).^0.5.*sin((X(:)+Y(:))*pi/2)+0.5];
52 %vvf = vf(X,Y);
53 %vvf(X(:)>Y(:),[1,2])=vvf(X(:)>Y(:),[2,1]);
54 
55 
56 flux = [ flux, flux ] .* [ones(size(flux)), params.conv_a*X(:)];
57 
58 lambda = 1/max(flux(:));
59 
60 if params.debug && ( max(U)+eps > 1 || min(U) - eps < 0 )
61  error('U is outside admissable bounds [0,1]');
62 end
63 
64 if params.decomp_mode>0
65  error('function is nonlinear and does not support affine decomposition!');
66 end
67 
function [ flux , lambda ] = conv_flux_buckley_leverett(glob, U, params)
convective flux for Buckley-Leverett problem