rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
fv_conv_diff_explicit_space.m
Go to the documentation of this file.
1 function [INC, fluxes] = fv_conv_diff_explicit_space(U,NU_ind,grid,model)
2 % function INC =
3 % fv_conv_diff_explicit_space(U,NU_ind,grid,model)
4 %
5 % function applying an FV-space-discretization operator starting from old
6 % values U corresponding to the geometry given in grid producing a
7 % new vector of elementwise scalars NU but only on for the
8 % subelements with numbers given in NU_ind. If NU_ind is empty, all
9 % new values NU are determined, i.e. length(NU) = length(U) =
10 % grid.nelements
11 %
12 % By this, the operator evaluation can be performed in a localized
13 % way, i.e. used for empirical interpolation in rb_nonlin_evol_simulation
14 %
15 % usual timestepping can be performed afterwards by (NU = Id - deltat *
16 % INC).
17 %
18 % required fields of model:
19 % verbose: a verbosity level
20 
21 % Martin Drohmann 9.12.2007 based on fv_conv_explicit_space by Bernard
22 % Haasdonk
23 
24 % compute flux at dirichlet and inner edges. Neuman and
25 % cut-edges are not set.
26 
27 num_diff_flux = fv_num_diff_flux(U,grid,model);
28 num_conv_flux = fv_num_conv_flux(U,grid,model);
29 % TODO: Vorzeichen korrigieren
30 num_flux_mat = num_diff_flux.G - num_conv_flux.G;
31 
32 % if no subset is specified: compute all elements
33 if isempty(NU_ind)
34  NU_ind = 1:grid.nelements;
35 end;
36 
37 %if model.verbose>=5
38 % fprintf('.');
39 %end;
40 
41 neu_NB_ind = find(grid.NBI == -2);
42 UU = repmat(U,1,grid.nneigh);
43 
44 % determine neumann-boundary values at end as computed flux is required
45 % in case of outflow-conditions
46 if ~isempty(neu_NB_ind)
47 
48  % in case of file access, the correct filename must be set here
49  % the following is only relevant in case of use of a
50  % model.use_velocitymatrix_file and filecaching mode 2
51  if isfield(model,'filecache_velocity_matrixfile_extract') ...
52  && (model.filecache_velocity_matrixfile_extract == 2);
53  model.velocity_matrixfile = ...
54  velocity_matrixfile_extract(...
55  grid.ECX(neu_NB_ind),...
56  grid.ECY(neu_NB_ind),...
57  'neumann_bnd', ...
58  model);
59  end;
60 
61  FNneu = neuman_values( ...
62  grid.ECX(neu_NB_ind),...
63  grid.ECY(neu_NB_ind),...
64  UU(neu_NB_ind),...
65  grid.NX(neu_NB_ind),...
66  grid.NY(neu_NB_ind), ...
67  model);
68 
69 
70  % set overall neumann boundary values
71  num_flux_mat(neu_NB_ind) = grid.EL(neu_NB_ind) .* FNneu;
72 end;
73 
74 %keyboard
75 % for to_be_computed elements, we need all fluxes!
76 if ~isempty(find(isnan(num_flux_mat(NU_ind,:)),1))
77  error('not all fluxes specified, NaN occuring !!');
78 end;
79 
80 %NU = U(NU_ind) - model.dt * grid.Ainv(NU_ind) .* ...
81 % sum( num_flux_mat(NU_ind), 2);
82 reaction = grid.A .* reaction_term(grid.CX, grid.CY, U, model);
83 INC = grid.Ainv(NU_ind) .* sum( num_flux_mat(NU_ind,:), 2) - reaction;
84 fluxes = [];
85 if model.debug == 1
86  fluxes = [num_conv_flux.G(3161,:), num_diff_flux.G(3161,:), reaction(3161);
87  num_conv_flux.G(3200,:), num_diff_flux.G(3200,:), reaction(3200);
88  num_conv_flux.G(3121,:), num_diff_flux.G(3121,:), reaction(3121);
89  num_conv_flux.G(3160,:), num_diff_flux.G(3160,:), reaction(3160);
90  num_conv_flux.G(1601,:), num_diff_flux.G(1601,:), reaction(1601);
91  num_conv_flux.G(1640,:), num_diff_flux.G(1640,:), reaction(1640);
92  num_conv_flux.G(1602,:), num_diff_flux.G(1602,:), reaction(1602);
93  num_conv_flux.G(1639,:), num_diff_flux.G(1639,:), reaction(1639)];
94 end
95 
96 % if model.verbose >= 10
97 % plot_fv_data([U,NU],model,'U(n) and U(n+1)');
98 % keyboard;
99 % end;
100 
101