rbmatlab 0.10.01
discfunc/fv/fv_space_operator.m
Go to the documentation of this file.
00001 function [INC, fluxes] = fv_space_operator(model,model_data,U,NU_ind,weights)
00002 % function INC =
00003 %      fv_space_operator(model,model_data,U,NU_ind,grid,weights)
00004 %
00005 % function applying an FV-space-discretization operator starting from old
00006 % values U corresponding to the geometry given in model_data.grid producing a
00007 % new vector of elementwise scalars NU but only on for the subelements with
00008 % numbers given in NU_ind. If NU_ind is empty, all new values NU are
00009 % determined, i.e. length(NU) = length(U) = grid.nelements
00010 %
00011 % By this, the operator evaluation can be performed in a localized
00012 % way, i.e. used for empirical interpolation in e.g. rb_nonlin_evol_simulation
00013 %
00014 % usual timestepping can be performed afterwards by (NU = Id - deltat *
00015 % INC).
00016 %
00017 % required fields of model:
00018 %            verbose:   a verbosity level
00019 % model shall set the fields:
00020 %            diff_weight:    weight for diffusive flux component
00021 %            conv_weight:    weight for convective flux component
00022 %            reac_weight:    weight for reaction term
00023 
00024 % Martin Drohmann 9.12.2007 based on fv_conv_explicit_space by Bernard
00025 % Haasdonk
00026 
00027 % compute flux at dirichlet and inner edges. Neuman and
00028 % cut-edges are not set.
00029 
00030 grid = model_data.grid;
00031 
00032 %if ~model.debug
00033 %  warning('off', 'MATLAB:structOnObject');
00034 %end
00035 %smodel = struct(model);
00036 smodel = model;
00037 
00038 if weights.diff_weight ~= 0
00039   num_diff_flux = model.num_diff_flux_ptr(smodel,model_data,U,NU_ind);
00040   num_flux_mat  = weights.diff_weight * num_diff_flux.G;
00041 else
00042   num_flux_mat = zeros(size(grid.NBI));
00043 end
00044 if weights.conv_weight ~= 0
00045   num_conv_flux = model.num_conv_flux_ptr(smodel,model_data,U);
00046   num_flux_mat  = num_flux_mat + weights.conv_weight * num_conv_flux.G;
00047 end
00048 
00049 % if no subset is specified: compute all elements
00050 if isempty(NU_ind)
00051   NU_ind = 1:grid.nelements;
00052 end
00053 
00054 %if model.verbose>=5
00055 %  fprintf('.');
00056 %end;
00057 
00058 neu_NB_ind = find(grid.NBI == -2);
00059 UU = repmat(U,1,grid.nneigh);
00060 
00061 % determine neumann-boundary values at end as computed flux is required
00062 % in case of outflow-conditions
00063 if ~isempty(neu_NB_ind>0)
00064   % in case of file access, the correct filename must be set here
00065   % the following is only relevant in the case where a
00066   % model.use_velocitymatrix_file and filecaching mode 2 are selected
00067   if model.filecache_velocity_matrixfile_extract == 2;
00068         model.velocity_matrixfile = ... 
00069           velocity_matrixfile_extract(...
00070               model, ...
00071               'neumann_bnd', ...
00072               grid.ECX(neu_NB_ind),...
00073               grid.ECY(neu_NB_ind));
00074   end
00075 
00076   FNneu = model.neumann_values_ptr( ...
00077       [grid.ECX(neu_NB_ind), grid.ECY(neu_NB_ind)],...
00078       UU(neu_NB_ind),...
00079       [grid.NX(neu_NB_ind),grid.NY(neu_NB_ind)], model);
00080   
00081   % set overall neumann boundary values
00082   num_flux_mat(neu_NB_ind) = grid.EL(neu_NB_ind) .* FNneu;
00083 end;
00084 
00085 % for to_be_computed elements, we need all fluxes!
00086 if ~isempty(find(isnan(num_flux_mat(NU_ind,:)),1))
00087   error('not all fluxes specified, NaN occuring !!');
00088 end;
00089 
00090 %NU = U(NU_ind) - model.dt * grid.Ainv(NU_ind) .* ... 
00091 %     sum( num_flux_mat(NU_ind), 2); 
00092 INC = grid.Ainv(NU_ind,:) .* sum( num_flux_mat(NU_ind,:), 2);
00093 
00094 react = zeros(1,grid.nelements);
00095 if weights.react_weight ~= 0
00096   react = reaction(model, grid.CX, grid.CY, U);
00097   INC   = INC + weights.react_weight * react(NU_ind,:);
00098 end
00099 fluxes = [];
00100 
00101 %  if model.verbose >= 10
00102 %    plot_fv_data([U,NU],model,'U(n) and U(n+1)');
00103 %    keyboard;
00104 %  end;
 All Classes Namespaces Files Functions Variables