rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
fv_diff_explicit_space.m
Go to the documentation of this file.
1 function INC = fv_diff_explicit_space(U,NU_ind,grid,params)
2 % function INC =
3 % fv_diff_explicit_space(U,NU_ind,grid,params)
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 params:
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_flux = fv_num_diff_flux(U,grid,params);
28 num_flux_mat = num_flux.G;
29 
30 % if no subset is specified: compute all elements
31 if isempty(NU_ind)
32  NU_ind = 1:grid.nelements;
33 end;
34 
35 %if params.verbose>=5
36 % fprintf('.');
37 %end;
38 
39 neu_NB_ind = find(grid.NBI == -2);
40 UU = repmat(U,1,grid.nneigh);
41 
42 % determine neumann-boundary values at end as computed flux is required
43 % in case of outflow-conditions
44 if ~isempty(neu_NB_ind)
45 
46  FNneu = neuman_values( ...
47  grid.ECX(neu_NB_ind),...
48  grid.ECY(neu_NB_ind),...
49  UU(neu_NB_ind),...
50  grid.NX(neu_NB_ind),...
51  grid.NY(neu_NB_ind), ...
52  params);
53 
54  % set overall neumann boundary values
55  num_flux_mat(neu_NB_ind) = grid.EL(neu_NB_ind) .* FNneu;
56 end;
57 
58 
59 % for to_be_computed elements, we need all fluxes!
60 if ~isempty(find(isnan(num_flux_mat(NU_ind,:)),1))
61  error('not all fluxes specified, NaN occuring !!');
62 end;
63 
64 %NU = U(NU_ind) - params.dt * grid.Ainv(NU_ind) .* ...
65 % sum( num_flux_mat(NU_ind), 2);
66 if isequal(params.name_diffusivity_tensor, 'richards')
67 
68 % x_hill = params.geometry_transformation_spline_x;
69 % y_hill = params.geometry_transformation_spline_y;
70 % y_hill(2) = params.hill_height;
71  p_mu = spline_select(params);
72  [ breaks, coeffs, pieces, order ] = unmkpp(p_mu);
73  p_mu_int = mkpp(breaks, [coeffs(1:order), 0] ./ [order:-1:1, 1]);
74  Ainv = ppval(p_mu_int, grid.X(grid.VI(:,2)))' ...
75  - ppval(p_mu_int, grid.X(grid.VI(:,3)))';
76  Ainv = (( grid.Y(grid.VI(:,2)) - grid.Y(grid.VI(:,1)) )' ...
77  .* Ainv) + grid.A;
78  Ainv = 1 ./ Ainv;
79 
80  INC = Ainv(NU_ind) .* sum ( num_flux_mat(NU_ind,:), 2);
81 else
82  INC = grid.Ainv(NU_ind) .* sum( num_flux_mat(NU_ind,:), 2);
83 end
84 
85 % if params.verbose >= 10
86 % plot_fv_data([U,NU],params,'U(n) and U(n+1)');
87 % keyboard;
88 % end;
89 
90 % TO BE ADJUSTED TO NEW SYNTAX
91 %| \docupdate