Changeset 18840
- Timestamp:
- 11/24/14 16:32:16 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/contrib/paraview/exportVTK.py
r18796 r18840 71 71 for solution in solnames: 72 72 #looking for multiple time steps 73 if ( len(res_struct.__dict__[solution])>num_of_timesteps):74 num_of_timesteps= len(res_struct.__dict__[solution])73 if (numpy.size(res_struct.__dict__[solution])>num_of_timesteps): 74 num_of_timesteps=numpy.size(res_struct.__dict__[solution]) 75 75 num_of_timesteps=int(num_of_timesteps/out_freq)+1 76 76 else: … … 113 113 for sol in solnames: 114 114 #dealing with results on different timesteps 115 if( len(res_struct.__dict__[sol])>timestep):115 if(numpy.size(res_struct.__dict__[sol])>timestep): 116 116 timestep = step 117 117 else: 118 timestep = len(res_struct.__dict__[sol])118 timestep = numpy.size(res_struct.__dict__[sol]) 119 119 120 120 #getting the fields in the solution 121 fieldnames=dict.keys(res_struct.__dict__[sol].__getitem__(timestep*out_freq-1).__dict__) 122 121 if(numpy.size(res_struct.__dict__[sol])>1): 122 fieldnames=dict.keys(res_struct.__dict__[sol].__getitem__(timestep*out_freq-1).__dict__) 123 else: 124 fieldnames=dict.keys(res_struct.__dict__[sol].__dict__) 123 125 #check which field is a real result and print 124 126 for field in fieldnames: 125 if ((numpy.size(res_struct.__dict__[sol].__getitem__(timestep*out_freq-1).__dict__[field]))==num_of_points): 127 if(numpy.size(res_struct.__dict__[sol])>1): 128 fieldstruct=res_struct.__dict__[sol].__getitem__(timestep*out_freq-1).__dict__[field] 129 else: 130 fieldstruct=res_struct.__dict__[sol].__dict__[field] 131 132 if ((numpy.size(fieldstruct))==num_of_points): 126 133 fid.write('SCALARS %s float 1 \n' % field) 127 134 fid.write('LOOKUP_TABLE default\n') 128 135 for node in range(0,num_of_points): 129 136 #paraview does not like NaN, replacing 130 if numpy.isnan( res_struct.__dict__[sol].__getitem__(timestep*out_freq-1).__dict__[field][node]):137 if numpy.isnan(fieldstruct[node]): 131 138 fid.write('%e\n' % -9999.9999) 132 139 #also checking for verry small value that mess up 133 elif (abs( res_struct.__dict__[sol].__getitem__(timestep*out_freq-1).__dict__[field][node])<1.0e-20):140 elif (abs(fieldstruct[node])<1.0e-20): 134 141 fid.write('%e\n' % 0.0) 135 142 else: 136 fid.write('%e\n' % res_struct.__dict__[sol].__getitem__(timestep*out_freq-1).__dict__[field][node])143 fid.write('%e\n' % fieldstruct[node]) 137 144 138 145 #loop on arguments, if something other than result is asked, do
Note:
See TracChangeset
for help on using the changeset viewer.