rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
fv_conv_flux_linearization_matrix.m
1 function flux_lin_mat = fv_conv_flux_linearization_matrix(model,model_data,U)
2 %function flux_lin_mat = fv_conv_flux_linearization_matrix(model,model_data,[U])
3 %
4 % function computing the linearized flux matrix of a convection problem.
5 % simply reformatting the grid data suitably for pointwise evaluation
6 % by conv_flux_linearization. As evaluation points the points of suitable
7 % gauss-quadratures are chosen. The degree can be chosen in the
8 % model structure.
9 %
10 % required fields of model as required by conv_flux
11 %
12 % Function supports affine decomposition, i.e. different operation modes
13 % guided by optional field decomp_mode in model. See also the
14 % contents.txt for general explanation
15 %
16 % optional fields of model:
17 % mu_names : names of fields to be regarded as parameters in vector mu
18 % flux_quad_degree: degree of quadrature to be used for face-integrals.
19 %
20 % in 'coefficient' mode, U and the grid are empty.
21 
22 % Bernard Haasdonk 11.4.2006
23 
24 % determine affine_decomposition_mode as integer
25 decomp_mode = model.decomp_mode;
26 
27 grid = model_data.grid;
28 
29 flux_lin_mat = [];
30 
31 if decomp_mode > 0
32  error('dont know how to handle decompositions in fv_conv_flux_linearization_matrix')
33 % nfaces = size(grid.ECX,2);
34 % UU = repmat(U,1,nfaces);
35 end;
36 
37 if decomp_mode < 2
38  nfaces = size(grid.ECX,2);
39  UU = repmat(U,1,nfaces);
40 end;
41 
42 if ~isempty(model.flux_quad_degree)
43  model.flux_quad_degree = 1;
44 end;
45 
46 %if decomp_mode == 0
47 % f = conv_flux(model, UU(:),grid.ECX(:), grid.ECY(:) );
48 % compute f by quadratures
49 [elids, edgeids] = ind2sub(size(grid.VI),1:length(grid.VI(:)));
50 PP = edge_quad_points(grid,elids, edgeids,model.flux_quad_degree);
51 [ff_lin, lambda] = ...
52  model.conv_flux_derivative_ptr(PP, ...
53  repmat(UU(:),model.flux_quad_degree,1), ...
54  model);
55 f.Vx = edge_quad_eval_mean(grid,elids,edgeids,...
56  model.flux_quad_degree,ff_lin(:,1));
57 f.Vy = edge_quad_eval_mean(grid,elids,edgeids,...
58  model.flux_quad_degree,ff_lin(:,2));
59 %f.lambda = ff_lin.lambda;
60 flux_lin_mat.Vx = reshape(f.Vx,size(UU));
61 flux_lin_mat.Vy = reshape(f.Vy,size(UU));
62 %elseif decomp_mode == 1
63 % % f = conv_flux(model, UU(:),grid.ECX(:), grid.ECY(:) );
64 % [elids, edgeids] = ind2sub(size(grid.VI),1:length(grid.VI(:)));
65 % PP = edge_quad_points(grid,elids, edgeids,model.flux_quad_degree);
66 % ff_lin = conv_flux_linearization(model, repmat(UU(:),model.flux_quad_degree,1), ...
67 % PP(1,:), PP(2,:) );
68 % f = cell(length(ff_lin),1);
69 % for q = 1:length(ff);
70 % f{q}.Fx = edge_quad_eval_mean(grid,elids,edgeids,...
71 % model.flux_quad_degree,ff{q}.Fx);
72 % f{q}.Fy = edge_quad_eval_mean(grid,elids,edgeids,...
73 % model.flux_quad_degree,ff{q}.Fy);
74 % flux_lin_mat{q}.Fx = reshape(f{q}.Fx,size(UU));
75 % flux_lin_mat{q}.Fy = reshape(f{q}.Fy,size(UU));
76 % end;
77 %else % simply get coefficients from conv_flux and forward
78 % % flux_lin_mat = conv_flux(model, UU(:),grid.ECX(:), grid.ECY(:) );
79 % flux_lin_mat = conv_flux(model, [],[],[] );
80 %end;
81 
82 %if decomp_mode == 0
83 % error('other modes than ''complete'' are currently not implemented! ');
84 % flux_lin_mat.lambda = f.lambda;
85 %end;
86 
87