source: issm/trunk/src/m/classes/public/importancefactors.m@ 2110

Last change on this file since 2110 was 2110, checked in by Eric.Larour, 15 years ago

Added MassFlux capabilities.

File size: 1.8 KB
Line 
1function factors=importancefactors(md,variablename,responsename)
2%IMPORTANCEFACTORS - compute importance factors for a certain variable and response.
3%
4% Usage:
5% factors=importancefactors(md,variablename,responsename)
6%
7%
8% Example: factors=importancefactors(md,'drag','max_vel');
9%
10
11
12variablenamelength=length(variablename);
13
14%go through all response functions and find the one corresponding to the correct responsename
15responsefunctions=md.dakotaresults.dresp_out;
16found=0;
17for i=1:length(responsefunctions),
18 if strcmpi(responsefunctions(i).descriptor,responsename),
19 found=i;
20 break;
21 end
22end
23if ~found,
24 error('importancefactors error message: could not find correct response function');
25end
26responsefunctions=responsefunctions(found);
27nfun=size(responsefunctions.var,1);
28
29%Now recover response to the correct design variable
30importancefactors=zeros(1,0);
31count=0;
32for i=1:nfun,
33 desvar=responsefunctions.var{i};
34 if strncmpi(desvar,variablename,variablenamelength),
35 importancefactors(end+1)=responsefunctions.impfac(i);
36 count=count+1;
37 end
38end
39
40if count==0,
41 error('importancefactors error message: could not find to response functions with corresponding design variable');
42end
43
44if count==1, %we have scalar
45 factors=importancefactors;
46 return;
47else
48 %Ok, get partitioning, unless already supplied
49 if isempty(md.part),
50 [epart npart]=MeshPartition(md,md.npart);
51 else
52 npart=md.part+1;
53 end
54
55 %distribute importance factor
56 factors=importancefactors(npart)';
57end
58
59if numel(factors)==md.numberofgrids,
60 %get areas for each vertex.
61 aire=GetAreas(md.elements,md.x,md.y);
62 num_elements_by_node=md.nodeconnectivity(:,end);
63 grid_aire=zeros(md.numberofgrids,1);
64 for i=1:md.numberofgrids,
65 for j=1:num_elements_by_node(i),
66 grid_aire(i)=grid_aire(i)+aire(md.nodeconnectivity(i,j));
67 end
68 end
69 factors=factors./grid_aire;
70end
Note: See TracBrowser for help on using the repository browser.