rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
generic_fem_model_adapter.m
Go to the documentation of this file.
1 function model = generic_fem_model_adapter(model)
2 %function model = generic_fem_model_adapter(model)
3 % Initializes a default linear and stationary model for more generic
4 % fem discretization by modifying model generated by
5 % lin_stat_model_default.
6 %
7 % model has to be a elliptic_discrete_model.
8 
9 % IM 21.07.2016
10 
11 if nargin == 0
12  model = lin_stat_model_default;
13 end
14 
15 %% discretization
16 model.df_type = 'lagrangian';
17 
18 %% functionality
19 % overwrite fields
20 model.gen_model_data = @stokes_gen_model_data;
21 model.detailed_simulation = @stokes_detailed_simulation;
22 model.operators = @Fem.Assembly.operator;
23 model.get_inner_product_matrix = ...
24  @(detailed_data) detailed_data.df_info.h10_inner_product_matrix;
25 model.gen_reduced_data = @stokes_gen_reduced_data;
26 model.reduced_data_subset = @stokes_reduced_data_subset;
27 model.set_rb_in_detailed_data = @gfem_model_set_rb; % see below
28 model.rb_simulation = @stokes_rb_simulation;
29 model.rb_reconstruction = @stokes_rb_reconstruction;
30 
31 % new fields
32 model.orthonormalize = @VecMat.gram_schmidt_reiterate;
33 model.disable_caching = 1;
34 
35 %% data functions
36 % new fields
37 model.has_nonlinearity = 0;
38 
39 % collect volume integral kernels
40 % for matrix
41 mvik = {};
42 if model.has_diffusivity
43  mvik = [mvik, {@Fem.IntegralKernels.matrix_diffusion}];
44 end
45 if model.has_advection
46  mvik = [mvik, {@Fem.IntegralKernels.matrix_advection}];
47 end
48 if model.has_reaction
49  mvik = [mvik, {@Fem.IntegralKernels.matrix_reaction}];
50 end
51 
52 model.has_volume_integral_matrix = ~isempty(mvik);
53 if model.has_volume_integral_matrix
54  model.matrix_volume_int_kernel = mvik;
55 end
56 
57 % for rhs
58 model.has_volume_integral_rhs = model.has_source;
59 if model.has_volume_integral_rhs
60  model.rhs_volume_int_kernel = {@Fem.IntegralKernels.rhs_source};
61 end
62 
63 % collect boundary integral kernels
64 % for matrix
65 mbik = {};
66 if model.has_advection && model.has_neumann_values
67  mbik = [mbik, {@Fem.IntegralKernels.matrix_neumann}];
68 end
69 if model.has_robin_values
70  mbik = [mbik, {@Fem.IntegralKernels.matrix_robin}];
71 end
72 
73 model.has_boundary_integral_matrix = ~isempty(mbik);
74 if model.has_boundary_integral_matrix
75  model.matrix_boundary_int_kernel = mbik;
76 end
77 
78 % for rhs
79 rbik = {};
80 if model.has_neumann_values
81  rbik = [rbik, {@Fem.IntegralKernels.rhs_neumann}];
82 end
83 if model.has_robin_values
84  rbik = [rbik, {@Fem.IntegralKernels.rhs_robin}];
85 end
86 
87 model.has_boundary_integral_rhs = ~isempty(rbik);
88 if model.has_boundary_integral_rhs
89  model.rhs_boundary_int_kernel = rbik;
90 end
91 
92 % collect coefficient functions
93 old_decomp_mode = model.decomp_mode;
94 model.decomp_mode = 2;
95 
96 % for matrix
97 if model.has_volume_integral_matrix
98 
99  mvc = {};
100  if model.has_diffusivity
101  mvc = [mvc, {@(params)model.diffusivity_tensor([], [], [], ...
102  params)}];
103  end
104  if model.has_advection
105  mvc = [mvc, {@(params)model.velocity([], [], [], params)}];
106  end
107  if model.has_reaction
108  mvc = [mvc, {@(params)model.reaction([], [], [], params)}];
109  end
110 
111  model.matrix_volume_coeffs = mvc;
112 end
113 
114 if model.has_boundary_integral_matrix
115 
116  mbc = {};
117  if model.has_advection && model.has_neumann_values
118  mbc = [mbc, mvc(2)];
119  end
120  if model.has_robin_values
121  if model.has_advection
122  mbc = [mbc, {@(params)[1; model.velocity([], [], [], ...
123  params)]}];
124  else
125  mbc = [mbc, {@(params)1}];
126  end
127  end
128 
129  model.matrix_boundary_coeffs = mbc;
130 end
131 
132 % for rhs
133 if model.has_volume_integral_rhs
134  model.rhs_volume_coeffs = {@(params)model.source([], [], [], ...
135  params)};
136 end
137 
138 if model.has_boundary_integral_rhs
139 
140  rbc = {};
141  if model.has_neumann_values
142  rbc = [rbc, {@(params)model.neumann_values([], [], [], [], ...
143  params)}];
144  end
145  if model.has_robin_values
146  rbc = [rbc, {@(params)model.robin_values([], [], [], [], ...
147  params)}];
148  end
149 
150  model.rhs_boundary_coeffs = rbc;
151 end
152 
153 model.decomp_mode = old_decomp_mode;
154 
155 end %function
156 
157 %% auxiliary function
158 function detailed_data = gfem_model_set_rb(detailed_data, RB)
159 % this function subtracts dirichlet condition from basis functions
160 
161 if ~isempty(RB)
162  RB(detailed_data.bc_info.dirichlet_gids, :) = 0;
163 end
164 
165 detailed_data.RB = RB;
166 
167 end
function model = generic_fem_model_adapter(model)
Initializes a default linear and stationary model for more generic fem discretization by modifying mo...
function local_model = elliptic_discrete_model(model)
function creating a model with local functions out of a model with global functions. See detailed description for explanation.
function sim_data = stokes_detailed_simulation(model, model_data)
Performs a detailed simulation of a (Navier-)stokes problem.