1 classdef OperatorsDefault < handle
2 %classdef OperatorsDefault < handle
3 %
Fem operators can be obtained from stored components.
5 % This
class helps storing
Fem system components for accelerating the
6 %
operator evaluation,
if it is done multiple times. Since the
7 % compontents are accessible, it is also useful
for the reduced data
8 % generation. Note that
this is compatible with the
function
11 % The components can be assembled with the method
13 % object, the components are stored in operators.A_comp and
14 % operators.f_comp. To obtain the
Fem system simply call [A, f] =
15 % operators(model, model_data).
17 % In stokes problems, it can only be used
for linear terms.
19 properties (SetAccess=
private)
23 componentsAssembled = 0;
28 function this = OperatorsDefault()
29 %
function this = OperatorsDefault()
30 % Only initializing
new object.
33 function varargout = evaluate(
this, model, model_data)
34 %
function varargout = evaluate(
this, model, model_data)
35 % Operator evaluation. Returns a full
Fem system.
37 % If the components are stored, the system is computed via
38 % linear combinations of the components,
else the assembly
39 % routine of model is called.
42 % varargout: The first output represents the system matrix,
43 % the second output (only
if requested) the right-hand side
44 % vector. The field model.decomp_mode has no influence.
46 if this.componentsAssembled
47 model.decomp_mode = 2;
48 [A_coeff, f_coeff] = model.operators(model, model_data);
49 % the following is needed because dirichlet dofs are
50 % ignored in assembly of components
for reduced data
51 if model.has_nonlinearity
52 Qr_dir = length(model_data.bc_info.dirichlet_dof_vector_components);
53 QA_nonlin = length(model.matrix_nonlin_indices);
54 A_coeff(1:Qr_dir*QA_nonlin) = 0;
56 varargout{1} = lincomb_sequence(this.A_comp, A_coeff);
57 dirichlet_gids = model_data.bc_info.dirichlet_gids;
58 varargout{1} = varargout{1} + sparse(dirichlet_gids, dirichlet_gids, ...
59 ones(size(dirichlet_gids)), model_data.df_info.ndofs, ...
60 model_data.df_info.ndofs) + eps*speye(model_data.df_info.ndofs);
62 r_dir_coeff = model.dirichlet_values([], [], [], [], model);
63 r_dir = lincomb_sequence(...
64 model_data.bc_info.dirichlet_dof_vector_components, ...
66 f_coeff(end+1-(1:length(r_dir_coeff)*length(A_coeff))) = 0;
67 varargout{2} = lincomb_sequence(this.f_comp, f_coeff) + r_dir;
70 model.decomp_mode = 0;
71 [varargout{1:nargout}] = model.operators(model, model_data);
75 function this = assemble_components(
this, model, model_data)
76 %
function this = assemble_components(
this, model, model_data)
77 % Calls the assembly routine of model and stores all
79 model.decomp_mode = 1;
80 [this.A_comp, this.f_comp] = model.operators(model, model_data);
81 this.componentsAssembled = 1;
84 function this = clear_components(
this)
85 %
function this = clear_components(
this)
86 % Deletes all components.
89 this.componentsAssembled = 0;
92 function varargout = subsref(
this, S)
93 %
function varargout = subsref(
this, S)
96 % This enables an
operator evaluation via operators(model,
98 if strcmp(S(1).type,
'()')
99 [varargout{1:nargout}] = evaluate(
this, S(1).subs{:});
101 [varargout{1:nargout}] = builtin(
'subsref',
this, S);
Fem operators can be obtained from stored components.