rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
DivergenceSpace.m
1 classdef DivergenceSpace < ILocalizedOperator & ISeparableOperator
2 
3  properties (Constant)
4  id = 'L_divergence';
5 
6  ret_vars = {'pressure'};
7  arg_vars = {'velocity'};
8  arg_vars_short = {'U'};
9  end
10 
11  methods
12  function [INC, INCoff, J] = apply(this, descr, model_data, sim_data, NU_ind)
13  %function INC = apply(model, model_data, sim_data, NU_ind)
14 
15  grid = model_data.grid;
16 
17  U = sim_data.U;
18 
19  if nargin <= 4 || isempty(NU_ind)
20  NU_ind = 1:grid.nelements;
21  end
22 
23  INC = sum(U(model_data.gEI(NU_ind,:)).*(grid.NX(NU_ind,:)+grid.NY(NU_ind,:)), 2) ...
24  - model_data.opdata.S_upper + model_data.opdata.S_lower;
25 
26  INCoff = [];
27 
28  if nargout > 2
29  [J] = full_matrix(this, descr, model_data, sim_data);
30  end
31  end
32 
33  end
34 
35  methods
36 
37  function [LL, bb] = full_matrix(this, descr, model_data, params)
38 
39  grid = model_data.grid;
40  n = model_data.grid.nelements;
41  if nargin <=3
42  params = [];
43  end
44  if ~isfield(params, 'm')
45  params.m = model_data.gn_edges;
46  end
47  if ~isfield(params, 'Uoff')
48  params.Uoff = 0;
49  end
50 
51  sp3i = repmat(1:n, 1, 4);
52  sp3j = model_data.gEI + params.Uoff;
53  sp3vals = grid.NX + grid.NY;
54  LL = sparse(sp3i,sp3j,sp3vals, n, params.m);
55 
56  bb = -model_data.opdata.S_upper + model_data.opdata.S_lower;
57  end
58 
59  function [LL_comps, bb_comps] = components(this, descr, model_data)
60  [LL,bb] = full_matrix(this, descr, model_data);
61  LL_comps = {LL};
62  bb_comps = {bb};
63  end
64 
65  function [LL_coeffs, bb_coeffs] = coefficients(this, descr)
66  LL_coeffs = 1;
67  bb_coeffs = 1;
68  end
69 
70  function ret_size = ret_size(this, model_data, NU_ind)
71  if nargin == 2 || isempty(NU_ind)
72  ret_size = model_data.grid.nelements;
73  else
74  ret_size = length(NU_ind);
75  end
76  end
77 
78  function arg_size = arg_size(this, model_data, NU_ind)
79  arg_size = model_data.gn_edges;
80  end
81 
82  function ipm = inner_product_matrix(this, model_data)
83  ipm = speye(size(model_data.W));
84  end
85 
86  function eind = compute_TM_global(this, grid, TM)
87  eind = ILocalizedOperator.compute_TM_global_edge(grid, TM);
88  end
89 
90 
91  function [LL, bb] = gram_projection(this, model, detailed_data)
92 
93  dd_vel = get_by_description(detailed_data, 'velocity');
94  dd_prs = get_by_description(detailed_data, 'pressure');
95  RB_vel = dd_vel.RB;
96  RB_prs = dd_prs.RB;
97  Nvel = get_by_description(model.N, 'velocity');
98  Nprs = get_by_description(model.N, 'pressure');
99 
100  model_data = dd_vel.model_data;
101  jn = model_data.gn_edges;
102  jm = model_data.grid.nelements;
103  ii = model_data.gEI;
104  jj = repmat((1:jm)', 1, 4);
105  spvals = model_data.grid.NX + model_data.grid.NY;
106  Jump = sparse(ii(:), jj(:), spvals(:), jn, jm);
107  RB_prs_jump = Jump * RB_prs(:,1:Nprs);
108 
109  [~,bb] = full_matrix(this, model.descr, model_data);
110 
111 % diamondW = model_data.diamondW;
112 % LL = RB_prs_jump' * diamondW * RB_vel;
113  LL = RB_prs_jump' * RB_vel(:,1:Nvel);
114 
115 % bb = RB_prs' * model_data.W * bb;
116  bb = RB_prs(:,1:Nprs)' * bb;
117  end
118 
119  function [LL_comps, bb_comps] = gram_project_components(this, rmodel, detailed_data)
120  [LL, bb] = gram_projection(this, rmodel, detailed_data);
121  LL_comps = {LL};
122  bb_comps = {bb};
123  end
124  end
125 
126 end
Interface for a localized operator that fulfills the so-called -independent DOF dependence.