source: issm/trunk/src/m/qmu/preqmu.m

Last change on this file was 25836, checked in by Mathieu Morlighem, 4 years ago

merged trunk-jpl and trunk for revision 25834

File size: 5.2 KB
Line 
1function md=preqmu(md,options)
2%QMU - apply Quantification of Margins and Uncertainties techniques
3% to a solution sequence (like stressbalance.m, progonstic.m, etc ...),
4% using the Dakota software from Sandia.
5%
6% options come from the solve.m routine. They can include Dakota options:
7%
8% qmufile: input file for Dakota
9% ivar: selection number for variables input (if several are specified in variables)
10% iresp: same thing for response functions
11% imethod: same thing for methods
12% iparams: same thing for params
13
14disp('preprocessing dakota inputs');
15qmufile = getfieldvalue(options,'qmufile','qmu');
16ivar = getfieldvalue(options,'ivar',1);
17iresp = getfieldvalue(options,'iresp',1);
18imethod = getfieldvalue(options,'imethod',1);
19iparams = getfieldvalue(options,'iparams',1);
20
21%when running in library mode, the in file needs to be called md.miscellaneous.name.qmu.in
22qmufile=[md.miscellaneous.name];
23
24%retrieve variables and resposnes for this particular analysis.
25variables=md.qmu.variables(ivar);
26responses=md.qmu.responses(iresp);
27
28%expand variables and responses
29variables=expandvariables(md,variables);
30responses=expandresponses(md,responses);
31
32%go through variables and responses, and check they don't have more than the number of partitions. Also determine numvariables and numresponses
33numvariables=0;
34variable_fieldnames=fieldnames(variables);
35for i=1:length(variable_fieldnames),
36 field_name=variable_fieldnames{i};
37 fieldvariables=variables.(field_name);
38 for j=1:numel(fieldvariables)
39 if strncmpi(fieldvariables(j).descriptor,'scaled_',7),
40 npart=qmupart2npart(fieldvariables(j).partition);
41 nt=fieldvariables(j).nsteps;
42 if nt==1,
43 if str2int(fieldvariables(j).descriptor,'last')>npart,
44 error('preqmu error message: one of the expanded variables has more values than the number of partitions ');
45 end
46 end
47 end
48 end
49 numvariables=numvariables+numel(variables.(field_name));
50end
51
52numresponses=0;
53response_fieldnames=fieldnames(responses);
54for i=1:length(response_fieldnames),
55 field_name=response_fieldnames{i};
56 fieldresponses=responses.(field_name);
57 for j=1:numel(fieldresponses)
58 if strncmpi(fieldresponses(j).descriptor,'scaled_',7),
59 npart=partition_npart(fieldresponses(j).partition);
60 if str2int(fieldresponses(j).descriptor,'last')>npart,
61 error('preqmu error message: one of the expanded responses has more values than the number of partitions');
62 end
63 end
64 end
65 numresponses=numresponses+numel(responses.(field_name));
66end
67
68%create in file for dakota
69dakota_in_data(md.qmu.method(imethod),variables,responses,md.qmu.params(iparams),qmufile,md.qmu.correlation_matrix);
70
71%build a list of variables and responses descriptors. the list is not expanded.
72variabledescriptors={};
73variable_fieldnames=fieldnames(md.qmu.variables(ivar));
74for i=1:length(variable_fieldnames),
75 field_name=variable_fieldnames{i};
76 fieldvariables=md.qmu.variables(ivar).(field_name);
77 for j=1:numel(fieldvariables)
78 variabledescriptors{end+1}=fieldvariables(j).descriptor;
79 end
80end
81
82responsedescriptors={};
83response_fieldnames=fieldnames(md.qmu.responses(iresp));
84for i=1:length(response_fieldnames),
85 field_name=response_fieldnames{i};
86 fieldresponses=md.qmu.responses(iresp).(field_name);
87 for j=1:numel(fieldresponses)
88 responsedescriptors{end+1}=fieldresponses(j).descriptor;
89 end
90end
91
92%build a MatArray of variable partitions:
93variablepartitions={};
94variablepartitions_npart=[];
95variablepartitions_nt=[];
96variable_fieldnames=fieldnames(md.qmu.variables(ivar));
97for i=1:length(variable_fieldnames),
98 field_name=variable_fieldnames{i};
99 fieldvariable=md.qmu.variables(ivar).(field_name);
100 if fieldvariable.isscaled() | fieldvariable.isdistributed();
101 variablepartitions{end+1}=fieldvariable.partition;
102 variablepartitions_npart(end+1)=qmupart2npart(fieldvariable.partition);
103 if isprop(fieldvariable,'nsteps'),
104 variablepartitions_nt(end+1)=fieldvariable.nsteps;
105 else
106 variablepartitions_nt(end+1)=1;
107 end
108 else
109 variablepartitions{end+1}=[];
110 variablepartitions_npart(end+1)=0;
111 variablepartitions_nt(end+1)=1;
112 end
113end
114
115%build a MatArray of response partitions:
116responsepartitions={};
117responsepartitions_npart=[];
118response_fieldnames=fieldnames(md.qmu.responses(iresp));
119for i=1:length(response_fieldnames),
120 field_name=response_fieldnames{i};
121 fieldresponse=md.qmu.responses(iresp).(field_name);
122 if fieldresponse.isscaled();
123 responsepartitions{end+1}=fieldresponse.partition;
124 responsepartitions_npart(end+1)=qmupart2npart(fieldresponse.partition);
125 else
126 responsepartitions{end+1}=[];
127 responsepartitions_npart(end+1)=0;
128 end
129end
130
131
132%register the fields that will be needed by the Qmu model.
133md.qmu.numberofresponses=numresponses;
134md.qmu.variabledescriptors=variabledescriptors;
135md.qmu.variablepartitions=variablepartitions;
136md.qmu.variablepartitions_npart=variablepartitions_npart;
137md.qmu.variablepartitions_nt=variablepartitions_nt;
138md.qmu.responsedescriptors=responsedescriptors;
139md.qmu.responsepartitions=responsepartitions;
140md.qmu.responsepartitions_npart=responsepartitions_npart;
141
142
143%now, we have to provide all the info necessary for the solutions to compute the responses. For ex, if mass_flux
144%is a response, we need a profile of points. For a misfit, we need the observed velocity, etc ...
145md=process_qmu_response_data(md);
146
Note: See TracBrowser for help on using the repository browser.