rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
conv_flux_gdl2.m
Go to the documentation of this file.
1 function [flux, lambda] = conv_flux_gdl2(glob,U,params)
2 %function [flux[, lambda]] = conv_flux_gdl2(glob,U,params)
3 % Function computing the convective flux `f(u)` of a convection problem.
4 %
5 % required fields of params:
6 % t: real time value in case of time-dependent flux
7 % lambda : factor for velocity computation: `v = - \lambda \nabla p`
8 % a velocity field is used, which is computed from an
9 % elliptic problem for the pressure by compute_pressure_gdl2() (some
10 % gdl-elements in a row, Neumann-0 and dirichlet conditions between
11 % 4 and 1 for the pressure, linear decreasing along the channel)
12 % (reasonable domain '[0,1e-3] x [0,0.25e-3]')
13 %
14 
15 % Bernard Haasdonk 4.4.2006
16 
17 % glob column check
18 if params.debug
19  if ~isempty(glob) && size(glob,1) < size(glob,2)
20  warning('coordinates in variable glob are given row-wise, but expected them to be column-wise');
21  if params.debug > 2
22  keyboard;
23  end
24  end
25 end
26 
27 % determine affine_decomposition_mode as integer
28 decomp_mode = params.decomp_mode;
29 
30 
31 if isempty(glob)
32  X = [];
33  Y = [];
34 else
35  X = glob(:,1);
36  Y = glob(:,2);
37 end
38 
39 % load pressure from file and generate velocity field
40 p = load(fullfile(rbmatlabhome,'datafunc','data','gdl_pressure2.mat'),...
41  'p','params');
42 [ux, uy] = evaluate_gradient(X,Y,p.p,p.params);
43 %if iscell(ux)
44 % lin_flux = cellfun(@(X,Y)([-X*params.lambda, -Y*params.lambda]), ...
45 % ux, uy, 'UniformOutput', false);
46 %else
47  lin_flux = [-ux*params.lambda, -Y*params.lambda];
48 %end
49 
50 if decomp_mode == 2
51  flux = 1;
52  lambda = [];
53 elseif decomp_mode < 2
54  % inverse of maximum absolute velocity value
55  % correct up to a constant factor
56  lambda = max(max(lin_flux))^-1;
57  if ~isempty(lin_flux) % otherwise size 0/0 => 0/1 !!!!!
58  flux = [ lin_flux(:,1).* U(:), lin_flux(:,2).* U(:) ];
59  else
60  flux = ones(0,2);
61  end;
62  if decomp_mode == 1
63  flux = { flux };
64  end
65 else
66  error('unknown decomp_mode');
67 end
68 
69 
function [ flux , lambda ] = conv_flux_gdl2(glob, U, params)
Function computing the convective flux of a convection problem.