Index: /issm/trunk/src/m/classes/public/qmu/qmu_correlation.m
===================================================================
--- /issm/trunk/src/m/classes/public/qmu/qmu_correlation.m	(revision 2205)
+++ /issm/trunk/src/m/classes/public/qmu/qmu_correlation.m	(revision 2205)
@@ -0,0 +1,50 @@
+function factors=qmu_correlation(md,variablename,responsename)
+%QMU_CORRELATION - compute correlation between qmu output and a certain input variable.
+%
+%   Usage:
+%      factors=qmu_correlation(md,variablename,responsename)
+%
+%
+%   Example: mass_flux_drag_correlation=qmu_correlation(md,'drag','mass_flux');
+%
+
+if ~isfield(md.dakotaresults,'dresp_dat'),
+	error('qmu_correlation error message: could not find dresp_dat field in dakota results. you need to run montecarlo before computing correlations');
+end
+	
+data=md.dakotaresults.dresp_dat;
+
+%go through all the rows and figure which one we are interested in.
+found=0;
+for i=1:numel(data),
+	if strcmpi(data(i).descriptor,responsename),
+		found=i;
+		break;
+	end
+end
+if found==0,
+	error(['qmu_correlation error message: could not find data descriptor for response ' responsename]);
+end
+
+%get the response samples.
+response_samples=data(found).sample;
+
+%now go through variables, and compute correlation coefficient each time: 
+variablenamelength=length(variablename);
+index=[];
+for i=1:numel(data),
+	if strncmpi(variablename,data(i).descriptor,variablenamelength),
+		%this observation is one we are looking for.
+		index=[index;i];
+	end
+end
+
+if isempty(index),
+	error(['qmu_correlation error message: could not find correlation descriptor for variable ' variablename]);
+end
+
+factors=zeros(numel(index),1);
+for i=1:numel(index),
+	matrix=corrcoef(data(index(i)).sample,response_samples);
+	factors(i)=matrix(2,1);
+end
Index: /issm/trunk/src/m/classes/public/qmu/qmu_importancefactors.m
===================================================================
--- /issm/trunk/src/m/classes/public/qmu/qmu_importancefactors.m	(revision 2205)
+++ /issm/trunk/src/m/classes/public/qmu/qmu_importancefactors.m	(revision 2205)
@@ -0,0 +1,70 @@
+function factors=qmu_importancefactors(md,variablename,responsename)
+%QMU_IMPORTANCEFACTORS - compute importance factors for a certain variable and response.
+%
+%   Usage:
+%      factors=qmu_importancefactors(md,variablename,responsename)
+%
+%
+%   Example: factors=qmu_importancefactors(md,'drag','max_vel');
+%
+
+
+variablenamelength=length(variablename);
+
+%go through all response functions and find the one corresponding to the correct responsename
+responsefunctions=md.dakotaresults.dresp_out;
+found=0;
+for i=1:length(responsefunctions),
+	if strcmpi(responsefunctions(i).descriptor,responsename),
+		found=i;
+		break;
+	end
+end
+if ~found,
+	error('qmu_importancefactors error message: could not find correct response function');
+end
+responsefunctions=responsefunctions(found);
+nfun=size(responsefunctions.var,1);
+
+%Now recover response to the correct design variable
+importancefactors=zeros(1,0);
+count=0;
+for i=1:nfun,
+	desvar=responsefunctions.var{i};
+	if strncmpi(desvar,variablename,variablenamelength),
+		importancefactors(end+1)=responsefunctions.impfac(i);
+		count=count+1;
+	end
+end
+
+if count==0,
+	error('qmu_importancefactors error message: could not find to response functions with corresponding design variable');
+end
+
+if count==1, %we have scalar
+	factors=importancefactors;
+	return;
+else
+	%Ok, get partitioning, unless already supplied
+	if isempty(md.part),
+		[epart npart]=MeshPartition(md,md.npart);
+	else
+		npart=md.part+1;
+	end
+
+	%distribute importance factor
+	factors=importancefactors(npart)';
+end
+
+if numel(factors)==md.numberofgrids,
+	%get areas for each vertex.
+	aire=GetAreas(md.elements,md.x,md.y);
+	num_elements_by_node=md.nodeconnectivity(:,end);
+	grid_aire=zeros(md.numberofgrids,1);
+	for i=1:md.numberofgrids,
+		for j=1:num_elements_by_node(i),
+			grid_aire(i)=grid_aire(i)+aire(md.nodeconnectivity(i,j));
+		end
+	end
+	factors=factors./grid_aire;
+end
Index: /issm/trunk/src/m/classes/public/tres.m
===================================================================
--- /issm/trunk/src/m/classes/public/tres.m	(revision 2204)
+++ /issm/trunk/src/m/classes/public/tres.m	(revision 2205)
@@ -11,4 +11,7 @@
 	md.vx=md.results.diagnostic.vx;
 	md.vy=md.results.diagnostic.vy;
+	if isfield(md.results.diagnostic,'vz'),
+		md.vz=md.results.diagnostic.vz;
+	end
 	md.vel=md.results.diagnostic.vel;
 	md.pressure=md.results.diagnostic.pressure;
@@ -21,4 +24,8 @@
 	md.vx=md.results.steadystate.vx;
 	md.vy=md.results.steadystate.vy;
+	if isfield(md.results.diagnostic,'vz'),
+		md.vz=md.results.steadystate.vz;
+	end
+
 	md.vel=md.results.steadystate.vel;
 	md.pressure=md.results.steadystate.pressure;
