1 function rho_sqr = stokes_sobolev_embedding_constant(model, model_data, tol, maxiter)
2 %
function rho_sqr = stokes_sobolev_embedding_constant(model, model_data, tol, maxiter)
8 disp(
'start sobolev embedding constant algorithm');
10 start_iteration = tic;
26 vel_index = get_index(model_data.df_info, 'velocity');
27 df_info = get(model_data.df_info, vel_index);
28 v =
Fem.DiscFunc([], df_info);
30 B = get(model.get_inner_product_matrix(model_data), vel_index) ...
31 + eps*speye(df_info.ndofs);
34 if model.has_dirichlet_values
35 dirichlet_gids = model_data.bc_info.dirichlet_gids;
36 B(dirichlet_gids, :) = [];
37 B(:, dirichlet_gids) = [];
41 int_dofs = setdiff(1:df_info.ndofs, dirichlet_gids);
44 tmodel.reaction = @(grid, eindices, loc, params) ones(length(eindices), 1);
45 tmodel.qdeg = 2*model.pdeg;
51 while abs(rho_old - rho_sqr) > tol
55 A =
Fem.Assembly.matrix_part(@
Fem.IntegralKernels.matrix_reaction, ...
56 tmodel, df_info) + eps*speye(df_info.ndofs);
57 if ~isempty(dirichlet_gids)
58 A(dirichlet_gids, :) = [];
59 A(:, dirichlet_gids) = [];
62 [v_int_dofs, rho_sqr] = eigs(A, B, 1, 'LM');
65 disp(['deviation to previous step: ', num2str(abs(rho_old - rho_sqr))]);
69 v.dofs(int_dofs) = v_int_dofs;
70 v1 = get_component(v, 1);
71 v2 = get_component(v, 2);
72 v1.dofs = v1.dofs.^2 + v2.dofs.^2;
73 factor = 1/l2_norm(v1);
75 tmodel.reaction = @(grid, eindices, loc, params) ...
76 factor * sum(evaluate(v, eindices, loc, params).^2, 2);
79 warning('stokes:sobolev_embedding_constant', ...
80 ['iteration maximum reached, norm(defect): ', num2str(abs(rho_old - rho_sqr))])
85 disp(['terminate sobolev embedding constant algorithm after ', ...
86 num2str(toc(start_iteration)), ' seconds']);
function r = verbose(level, message, messageId)
This function displays messages depending on a message-id and/or a level. Aditionally you can set/res...