rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
fv_space_operator.m
Go to the documentation of this file.
1 function [INC, fluxes] = fv_space_operator(model,model_data,U,NU_ind,weights)
2 % function INC =
3 % fv_space_operator(model,model_data,U,NU_ind,grid,weights)
4 %
5 % function applying an FV-space-discretization operator starting from old
6 % values U corresponding to the geometry given in model_data.grid producing a
7 % new vector of elementwise scalars NU but only on for the subelements with
8 % numbers given in NU_ind. If NU_ind is empty, all new values NU are
9 % determined, i.e. length(NU) = length(U) = grid.nelements
10 %
11 % By this, the operator evaluation can be performed in a localized
12 % way, i.e. used for empirical interpolation in e.g. rb_nonlin_evol_simulation
13 %
14 % usual timestepping can be performed afterwards by (NU = Id - deltat *
15 % INC).
16 %
17 % required fields of model:
18 % verbose: a verbosity level
19 % model shall set the fields:
20 % diff_weight: weight for diffusive flux component
21 % conv_weight: weight for convective flux component
22 % reac_weight: weight for reaction term
23 
24 % Martin Drohmann 9.12.2007 based on fv_conv_explicit_space by Bernard
25 % Haasdonk
26 
27 % compute flux at dirichlet and inner edges. Neuman and
28 % cut-edges are not set.
29 
30 grid = model_data.grid;
31 
32 if ~model.debug
33  warning('off', 'MATLAB:structOnObject');
34 end
35 smodel = struct(model);
36 
37 % if no subset is specified: compute all elements
38 if isempty(NU_ind)
39  NU_ind = 1:grid.nelements;
40 end
41 
42 num_diff_flux.G=zeros(size(grid.NBI));
43 num_conv_flux.G=zeros(size(grid.NBI));
44 if weights.diff_weight ~= 0
45  num_diff_flux = model.num_diff_flux_ptr(smodel,model_data,U,NU_ind);
46  num_flux_mat = weights.diff_weight * num_diff_flux.G;
47 else
48  num_flux_mat = zeros(size(grid.NBI));
49 end
50 if weights.conv_weight ~= 0
51  num_conv_flux = model.num_conv_flux_ptr(smodel,model_data,U);
52  num_flux_mat = num_flux_mat + weights.conv_weight * num_conv_flux.G;
53 end
54 
55 %if model.verbose>=5
56 % fprintf('.');
57 %end;
58 
59 neu_NB_ind = find(grid.NBI == -2);
60 UU = repmat(U,1,grid.nneigh);
61 
62 % determine neumann-boundary values at end as computed flux is required
63 % in case of outflow-conditions
64 if ~isempty(neu_NB_ind>0)
65  % in case of file access, the correct filename must be set here
66  % the following is only relevant in the case where a
67  % model.use_velocitymatrix_file and filecaching mode 2 are selected
68  if model.filecache_velocity_matrixfile_extract == 2;
69  model.velocity_matrixfile = ...
70  velocity_matrixfile_extract(...
71  model, ...
72  'neumann_bnd', ...
73  grid.ECX(neu_NB_ind),...
74  grid.ECY(neu_NB_ind));
75  end
76 
77  FNneu = model.neumann_values_ptr( ...
78  [grid.ECX(neu_NB_ind), grid.ECY(neu_NB_ind)],...
79  UU(neu_NB_ind),...
80  [grid.NX(neu_NB_ind),grid.NY(neu_NB_ind)], model);
81 
82  % set overall neumann boundary values
83  num_flux_mat(neu_NB_ind) = grid.EL(neu_NB_ind) .* FNneu;
84 end;
85 
86 % for to_be_computed elements, we need all fluxes!
87 if ~isempty(find(isnan(num_flux_mat(NU_ind,:)),1))
88  error('not all fluxes specified, NaN occuring !!');
89 end;
90 
91 %NU = U(NU_ind) - model.dt * grid.Ainv(NU_ind) .* ...
92 % sum( num_flux_mat(NU_ind), 2);
93 INC = grid.Ainv(NU_ind,:) .* sum( num_flux_mat(NU_ind,:), 2);
94 
95 react = zeros(1,grid.nelements);
96 if weights.react_weight ~= 0
97  react = reaction(model, grid.CX, grid.CY, U);
98  INC = INC + weights.react_weight * react(NU_ind,:);
99 end
100 fluxes = [];
101 
102 % if model.verbose >= 10
103 % plot_fv_data([U,NU],model,'U(n) and U(n+1)');
104 % keyboard;
105 % end;
function r = verbose(level, message, messageId)
This function displays messages depending on a message-id and/or a level. Aditionally you can set/res...
Definition: verbose.m:17
function INC = fv_conv_explicit_space(U, NU_ind,gridbase grid, params)
fv_conv_explicit_space(U,NU_ind,grid,params) function applying an FV-space-discretization operator st...
function [ INC , fluxes ] = fv_space_operator(model, model_data, U, NU_ind, weights)
fv_space_operator(model,model_data,U,NU_ind,grid,weights)