rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
stokes_rb_supremizer_extension.m
1 function [RBext, dummy] = stokes_rb_supremizer_extension(model, detailed_data)
2 %function [RBext, dummy] = stokes_rb_supremizer_extension(model, detailed_data)
3 %
4 % Simple routine computing snapshot and supremizer enrichment for basis
5 % generation.
6 
7 % IM 19.06.2013
8 
9 dummy = [];
10 
11 sim_data = detailed_simulation(model, detailed_data);
12 
13 U = model.get_dofs_from_sim_data(sim_data);
14 
15 ndofs = detailed_data.df_info.ndofs;
16 vel_ndofs = detailed_data.df_info.values{1}.ndofs;
17 dirichlet_gids = detailed_data.bc_info.dirichlet_gids;
18 vel_dofinds = 1:vel_ndofs;
19 
20 U(dirichlet_gids) = 0;
21 
22 % inner product on velocity space
23 if isfield(detailed_data, 'W')
24  K = detailed_data.W;
25 else
26  K = model.get_inner_product_matrix(detailed_data);
27 end
28 
29 K = getMatrix(K) + eps*speye(ndofs);
30 K(dirichlet_gids, :) = 0;
31 K(:, dirichlet_gids) = 0;
32 K_dirichlet = sparse(dirichlet_gids, dirichlet_gids, ones(length(dirichlet_gids), 1), ndofs, ndofs);
33 K = K + K_dirichlet;
34 
35 % further matrices
36 A = detailed_data.operators(model, detailed_data);
37 
38 % compute supremizer function
39 U_pre = U;
40 U_pre(vel_dofinds) = 0;
41 
42 r = A * U_pre;
43 spF = K \ r;
44 
45 spF = spF(vel_dofinds);
46 U_pre(vel_dofinds) = [];
47 % return results
48 RBext = VecMat.CompositeMatrixDefault(2);
49 
50 RBext = set(RBext, [U(vel_dofinds), spF], 1);
51 RBext = set(RBext, U_pre, 2);
52 end