1 function model = multiscale_thermalblock_model(params)
4 % coupled to give overall params.Qa instead of params.B1*params.B2
7 % The coupling can be prescribed by a vector params.parameter_mapping
8 % e.g.
for B1=B2=3 and desired Qa=4:
9 % params.parameter_mapping = [4 2 3 1 2 1 3 1 1];
11 % If
this mapping is not given, a deterministically
12 % random ordering is prescribed
14 % a field Qa is required in params to indicate the number of
15 % desired components in a
17 % B. Haasdonk 7.3.2012
20 model.base_model = model;
21 model.base_Qa = length(model.mu_names);
25 % deterministic random assignment
26 if isfield(params,
'parameter_mapping')
27 model.parameter_mapping = params.parameter_mapping;
29 defaultStream = RandStream.getDefaultStream;
30 savedState = defaultStream.State;
31 RandStream.setDefaultStream(RandStream('mt19937ar','seed',100000));
32 model.parameter_mapping = floor(Qa * rand(1,model.base_Qa))+1;
33 defaultStream.State = savedState;
34 RandStream.setDefaultStream(defaultStream);
36 parameter_first_ids = [];
38 parameter_first_ids = [parameter_first_ids, ...
39 min(find(model.parameter_mapping==i))];
42 % assign new model parts:
43 model.parameter_first_ids = parameter_first_ids;
44 model.mu_names = model.mu_names(parameter_first_ids);
45 model.mu_ranges = model.mu_ranges(parameter_first_ids);
46 model.set_mu = @my_set_mu;
47 model.get_mu = @my_get_mu;
48 model.mus = model.mus(model.parameter_first_ids);
49 %model.operators = @my_operators;
50 model.name = 'multiscale_thermalblock';
54 model.yscale_uicontrols = 1.0;
58 multiscale_diffusivity_tensor_coefficients = @(dummy,params) ...
59 params.get_mu(params);
60 model.global_diffusivity_tensor = @(glob,params) ...
61 eval_affine_decomp_general(...
62 @multiscale_diffusivity_tensor_components, ...
63 multiscale_diffusivity_tensor_coefficients, glob,params);
64 model.diffusivity_tensor = @(varargin) ...
69 function mu = my_get_mu(model)
72 function model = my_set_mu(model,mu)
73 base_mu = mu(model.parameter_mapping);
74 model.base_model = model.base_model.set_mu(model.base_model,base_mu);
76 %model = set_mu_default(model,mu);
78 %function [A,b] = my_operators(model,glob)
79 %%model.base_model.decomp_mode = model.decomp_mode;
80 %%[A,b] = model.base_model.operators(model.base_model,glob);
81 %[A,b] = model.operators(model,glob);
82 %if model.decomp_mode == 0
84 %elseif model.decomp_mode == 1
85 % % reduce number of A components
86 % A_comp_new = cell(model.Qa,1);
88 %% A_comp_new{q} = zeros(size(A{q})); % initialize with 0;
89 % A_comp_new{q} = 0*A{q}; % initialize with 0, sparse
if required
91 %
for q = 1:model.base_Qa
92 % q2 = model.parameter_mapping(q);
93 % A_comp_new{q2} = A_comp_new{q2} + A{q};
97 % % select correct Qa coefficients
98 % A = A(model.parameter_first_ids);
101 function res = multiscale_diffusivity_tensor_components(glob,params)
102 % diffusion tensor: each row four entries a11,a_21,a_12,a_22.
103 % a11(x)=a22(x) = mu_i
if x in block i, a12=a21 = 0.
104 %
for each point in glob find global block number
105 % xi: range 0 ... B1-1
106 xi = floor(glob(:,1)*params.B1);
107 i = find(xi>=params.B1);
111 % xi: range 0 ... B1-1
112 yi = floor(glob(:,2)*params.B2);
113 i = find(yi>=params.B2);
117 block_index = yi*params.B1+xi+1;
118 mu_index = params.parameter_mapping(block_index);
119 zeroblock = zeros(size(glob,1),4);
120 %res = cell(1,params.number_of_blocks);
121 res = cell(1,params.Qa);
122 %for q = 1:params.number_of_blocks;
125 i = find(mu_index==q);
function demo_rb_gui(varargin)
reduced basis demo with sliders
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 res = discrete_volume_values(func, varargin)
Convert a volume function with global evaluation to local evaluation.
function model = thermalblock_model(params)
Thermal Block example similar as described in the book of A.T. patera and G. Rozza (just one paramete...
function res = thermalblock(step, params)
thermalblock example