rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
gen_reduced_model.m
Go to the documentation of this file.
1 function rmodel = gen_reduced_model(dmodel, bg_descr)
2 % function rmodel = gen_reduced_model(dmodel, bg_descr)
3 % generates an IReducedModel instance from a description structure.
4 %
5 % This function constructs the correct IReducedModel instance for a BasisGenDescr
6 % structure. The field 'rb_problem_type' should contain the package name of the
7 % 'ReducedModel' class. If e.g. 'descr.rb_problem_type' equals the string
8 % 'LinEvol', an object of type LinEvol.ReducedModel is returned.
9 %
10 % The class type of the returned object can also be chosen explictly by
11 % specifying the field 'descr.rmodel_constructor'.
12 %
13 % Parameters:
14 % bg_descr: a Matlab structure of type BasisGenDescr.
15 
16 if nargin == 1 || isempty(bg_descr);
17  descr = dmodel.descr;
18  fns = fieldnames(descr);
19  rbfnsI = cellfun(@(X) length(X)>3 && isequal(X(1:3), 'RB_'), fns);
20  rbfns = fns(rbfnsI);
21  for i = 1:length(rbfns)
22  rbfn = rbfns{i};
23  bg_descr.(rbfn(4:end)) = descr.(rbfn);
24  descr = rmfield(descr, rbfn);
25  end
26  bg_descr.rb_problem_type = descr.rb_problem_type;
27 end
28 
29 if ~isfield(bg_descr, 'rb_problem_type')
30  error('BasisGenDescr does not have the required field ''rb_problem_type''');
31 end
32 
33 if ~isfield(bg_descr, 'rmodel_constructor') || isempty(bg_descr.rmodel_constructor)
34  bg_descr.rmodel_constructor = eval(['@', bg_descr.rb_problem_type, '.ReducedModel']);
35 end
36 
37 if ~isfield(bg_descr, 'detailed_data_constructor') || isempty(bg_descr.detailed_data_constructor)
38  bg_descr.detailed_data_constructor = eval(['@', bg_descr.rb_problem_type, '.DetailedData']);
39 end
40 
41 if ~isfield(bg_descr, 'reduced_data_constructor') || isempty(bg_descr.reduced_data_constructor)
42  bg_descr.reduced_data_constructor = eval(['@', bg_descr.rb_problem_type, '.ReducedData']);
43 end
44 
45 rmodel = bg_descr.rmodel_constructor(dmodel, bg_descr);
46 
47 end
Struct with control fields for the reduced basis generation.
Definition: dummyclasses.c:56
This is the interface for a reduced model providing methods to compute low dimensional reduced simula...
Definition: IReducedModel.m:17
function rmodel = gen_reduced_model(dmodel,BasisGenDescr bg_descr)
generates an IReducedModel instance from a description structure.