Changeset 19197
- Timestamp:
- 03/16/15 10:23:06 (10 years ago)
- Location:
- issm/trunk-jpl/src/m/contrib/paraview
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/contrib/paraview/enveloppeVTK.m
r18746 r19197 51 51 if(size(sol_struct{i},2)>num_of_timesteps); 52 52 num_of_timesteps=size(sol_struct{i},2); 53 outstep=model.timestepping.time_step*model.settings.output_frequency 54 end 53 55 end 54 end55 56 else 56 57 num_of_timesteps=1; … … 59 60 60 61 timestep=step; 61 62 62 fid = fopen(strcat(path,filesep,name,filesep,'timestep.vtk',int2str(timestep),'.vtk'),'w+'); 63 63 fprintf(fid,'# vtk DataFile Version 2.0 \n'); … … 85 85 if exist('low_elt_num') 86 86 triaconnect=zeros(num_of_elt,3); 87 triaconnect(1:low_elt_num,:)= ... 88 model.mesh.elements(find(isnan(model.mesh.lowerelements)),1:3); 89 upshift=-min(min(model.mesh.elements(find(isnan(model.mesh.upperelements)),4:6)))... 90 +1+max(max(model.mesh.elements(find(isnan(model.mesh.lowerelements)),1:3))); 87 triaconnect(1:low_elt_num,:)=model.mesh.elements(find(isnan(model.mesh.lowerelements)),1:3); 88 upshift=-min(min(model.mesh.elements(find(isnan(model.mesh.upperelements)),4:6)))+1+max(max(model.mesh.elements(find(isnan(model.mesh.lowerelements)),1:3))); 91 89 triaconnect(1+low_elt_num:num_of_elt,:)=model.mesh.elements(find(isnan(model.mesh.upperelements)),4:6)+upshift; 92 90 fprintf(fid,s,[(3)*ones(num_of_elt,1) triaconnect-1]'); … … 109 107 timestep = size(sol_struct{j},2); 110 108 end 111 112 109 %getting the number of fields in the solution 113 fieldnames=fields(sol_struct{j}(timestep)); 114 num_of_fields=length(fieldnames); 115 110 resfields=fields(sol_struct{j}(timestep)); 111 num_of_fields=length(resfields); 116 112 %check which field is a real result and print 117 113 for k=1:num_of_fields 118 if ((numel(sol_struct{j}(timestep).( fieldnames{k})))==tot_points);114 if ((numel(sol_struct{j}(timestep).(resfields{k})))==tot_points); 119 115 %paraview does not like NaN, replacing 120 nanval=find(isnan(sol_struct{j}(timestep).( fieldnames{k})));121 sol_struct{j}(timestep).( fieldnames{k})(nanval)=-9999;116 nanval=find(isnan(sol_struct{j}(timestep).(resfields{k}))); 117 sol_struct{j}(timestep).(resfields{k})(nanval)=-9999; 122 118 %also checking for verry small value that mess up 123 smallval=(abs(sol_struct{j}(timestep).( fieldnames{k}))<1.0e-20);124 sol_struct{j}(timestep).( fieldnames{k})(smallval)=0.0;125 fprintf(fid,'SCALARS %s float 1 \n', fieldnames{k});119 smallval=(abs(sol_struct{j}(timestep).(resfields{k}))<1.0e-20); 120 sol_struct{j}(timestep).(resfields{k})(smallval)=0.0; 121 fprintf(fid,'SCALARS %s float 1 \n',resfields{k}); 126 122 fprintf(fid,'LOOKUP_TABLE default\n'); 127 123 s='%e\n'; 128 fprintf(fid,s,sol_struct{j}(timestep).( fieldnames{k})(IsEnveloppe));124 fprintf(fid,s,sol_struct{j}(timestep).(resfields{k})(IsEnveloppe)); 129 125 end 130 126 end … … 149 145 s='%e\n'; 150 146 fprintf(fid,s,res_struct.(fieldnames{k})(IsEnveloppe)); 151 end 147 %check for forcings 148 elseif (size(res_struct.(fieldnames{k}),1)==tot_points+1); 149 %paraview does not like NaN, replacing 150 nanval=find(isnan(res_struct.(fieldnames{k}))); 151 res_struct.(fieldnames{k})(nanval)=-9999; 152 %also checking for verry small value that mess up 153 smallval=(abs(res_struct.(fieldnames{k}))<1.0e-20); 154 res_struct.(fieldnames{k})(smallval)=0.0; 155 if (size(res_struct.(fieldnames{k}),2)==num_of_timesteps), 156 fprintf(fid,'SCALARS %s float 1 \n',fieldnames{k}); 157 fprintf(fid,'LOOKUP_TABLE default\n'); 158 s='%e\n'; 159 fprintf(fid,s,res_struct.(fieldnames{k})(IsEnveloppe,timestep)); 160 else, 161 %forcing and results not on the same timestep,need some treatment 162 fprintf(fid,'SCALARS %s float 1 \n',fieldnames{k}); 163 fprintf(fid,'LOOKUP_TABLE default\n'); 164 index=1 165 currenttime=((timestep-1)*outstep)+model.timestepping.start_time+model.timestepping.time_step 166 while (res_struct.(fieldnames{k})(end,index)<=currenttime); 167 index=index+1 168 end 169 uptime=res_struct.(fieldnames{k})(end,index); 170 uplim=res_struct.(fieldnames{k})(IsEnveloppe,index); 171 uptime 172 while (res_struct.(fieldnames{k})(end,index)>=currenttime); 173 index=index-1 174 end 175 lowtime=res_struct.(fieldnames{k})(end,index); 176 lowlim=res_struct.(fieldnames{k})(IsEnveloppe,index); 177 lowtime 178 interp=lowlim+(uplim-lowlim)*((currenttime-lowtime)/(uptime-lowtime)) 179 s='%e\n'; 180 fprintf(fid,s,interp); 181 end 182 end 152 183 end 153 184 end -
issm/trunk-jpl/src/m/contrib/paraview/exportVTK.m
r19157 r19197 59 59 if(size(sol_struct{i},2)>num_of_timesteps); 60 60 num_of_timesteps=size(sol_struct{i},2); 61 end 61 end 62 outstep=model.timestepping.time_step*model.settings.output_frequency; 62 63 end 63 64 else … … 145 146 s='%e\n'; 146 147 fprintf(fid,s,res_struct.(fieldnames{k})); 147 end 148 %check for forcings 149 elseif (size(res_struct.(fieldnames{k}),1)==num_of_points+1); 150 %paraview does not like NaN, replacing 151 nanval=find(isnan(res_struct.(fieldnames{k}))); 152 res_struct.(fieldnames{k})(nanval)=-9999; 153 %also checking for verry small value that mess up 154 smallval=(abs(res_struct.(fieldnames{k}))<1.0e-20); 155 res_struct.(fieldnames{k})(smallval)=0.0; 156 if (size(res_struct.(fieldnames{k}),2)==num_of_timesteps), 157 fprintf(fid,'SCALARS %s float 1 \n',fieldnames{k}); 158 fprintf(fid,'LOOKUP_TABLE default\n'); 159 s='%e\n'; 160 fprintf(fid,s,res_struct.(fieldnames{k})(1:end-1,timestep)); 161 else, 162 %forcing and results not on the same timestep,need some treatment 163 fprintf(fid,'SCALARS %s float 1 \n',fieldnames{k}); 164 fprintf(fid,'LOOKUP_TABLE default\n'); 165 index=1; 166 currenttime=((timestep-1)*outstep)+model.timestepping.start_time; 167 while (res_struct.(fieldnames{k})(end,index)<=currenttime); 168 if index==size(res_struct.(fieldnames{k}),2) 169 break 170 end 171 index=index+1; 172 end 173 uptime=res_struct.(fieldnames{k})(end,index); 174 uplim=res_struct.(fieldnames{k})(1:end-1,index); 175 while (res_struct.(fieldnames{k})(end,index)>=currenttime); 176 if index==1 177 break 178 end 179 index=index-1; 180 end 181 lowtime=res_struct.(fieldnames{k})(end,index); 182 lowlim=res_struct.(fieldnames{k})(1:end-1,index); 183 if uptime==currenttime, 184 interp=uplim; 185 elseif lowtime==currenttime, 186 interp=lowlim; 187 else 188 interp=lowlim+(uplim-lowlim)*((currenttime-lowtime)/(uptime-lowtime)); 189 end 190 s='%e\n'; 191 fprintf(fid,s,interp); 192 end 193 end 148 194 end 149 195 end
Note:
See TracChangeset
for help on using the changeset viewer.