rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
conv_flux_velocity_matrixfile.m
Go to the documentation of this file.
1 function [flux, lambda] = conv_flux_velocity_matrixfile(glob,U,params)
2 %function [flux[, lambda]] = conv_flux_velocity_matrixfile(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` a velocity
8 % field is used, which is computed from an elliptic problem for the
9 % pressure by compute_pressure_gdl2() (some gdl-elements in a row,
10 % Neumann-0 and dirichlet conditions between 4 and 1 for the pressure,
11 % linear decreasing along the channel) (reasonable domain
12 % '[0,1e-3] x [0,0.25e-3]')
13 % velocity_matrixfile: filename of the mat-file storing the velocity field
14 %
15 % optional fields of params:
16 % filecache_velocity_matrixfile_extract: a boolean value indicating whether a
17 % cached version of the velocity field exists.
18 %
19 
20 % Bernard Haasdonk 4.4.2006
21 
22 % glob column check
23 if params.debug
24  if ~isempty(glob) && size(glob,1) < size(glob,2)
25  warning('coordinates in variable glob are given row-wise, but expected them to be column-wise');
26  if params.debug > 2
27  keyboard;
28  end
29  end
30 end
31 
32 % determine affine_decomposition_mode as integer
33 decomp_mode = params.decomp_mode;
34 
35 if decomp_mode == 2 % i.e. 'coefficients'
36  flux = 1; % factor one for single component
37  lambda = [];
38 elseif decomp_mode < 2 % i.e. 'none' or 'components'
39 
40  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% loading flux matrix.
41  % load V.X: list of X-Koordinaten
42  % load V.Y: list of Y-Koordinaten
43  % load V.Vy: list of Y-component of velocity
44  % load V.Vx: list of Y-component of velocity
45  % load V.lambda: lambda for CFL computation
46 
47  fullfn = fullfile(rbmatlabhome,'datafunc','data',...
48  params.velocity_matrixfile);
49 
50  if ~exist(fullfn,'file') && ~cache('exist',fullfn)
51  error(['warning: velocity_matrixfile not existing. ',...
52  'Call gen_velocity_matrixfile with suitable' ...
53  ' divclean_mode.']);
54  end;
55 
56  % the following file extraction can be expensive, so the
57  % extraction can additionally be cached.
58 
59  if ~params.filecache_velocity_matrixfile_extract % expensive call
60  [flux_lin.Vx, flux_lin.Vy, lambda] = ...
61  velocity_matrixfile_extract(fullfn,glob(:,1),glob(:,2));
62  elseif params.filecache_velocity_matrixfile_extract==1
63  % cached functioncall
64  [flux_lin.Vx, flux_lin.Vy, lambda] = ...
65  filecache_function(@velocity_matrixfile_extract, ...
66  fullfn,glob(:,1),glob(:,2));
67  else % mode 2, i.e assume, that velocityfilename is set correctly to
68  % requested points
69  % V = load_cached(fullfn);
70  V = cache('load',fullfn);
71  % find integer indices such that V.X(j)==X(i) and V.Y(j) = Y(i)
72  % if whole flux-matrix is requested
73  if ~isequal(glob(:,1),V.X(:)) || ~isequal(glob(:,2),V.Y(:))
74  error('matrixfile does not fit to requested points!');
75  end;
76  % i = 1:length(X);
77  flux_lin.Vx = V.Vx;
78  flux_lin.Vy = V.Vy;
79  %NaN*ones(size(X));
80  % flux_lin.Vy = NaN*ones(size(X));
81  % flux_lin.Vx(i) = V.Vx(j);
82  % flux_lin.Vy(i) = V.Vy(j);
83  lambda = V.lambda;
84  end;
85 
86  flux = [ flux_lin.Vx.*U(:), flux_lin.Vy.*U(:) ];
87 
88  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end of loading flux matrix.
89  if decomp_mode == 1 % put single matrix into cell array
90  flux = {flux};
91  end;
92 else
93  error('unknown decomp_mode');
94 end
95 
function varargout = filecache_function(funcptr, varargin)
function used for file-caching other function calls.
function [ flux , lambda ] = conv_flux_velocity_matrixfile(glob, U, params)
function computing the convective flux of a convection problem.