Changeset 18840


Ignore:
Timestamp:
11/24/14 16:32:16 (10 years ago)
Author:
bdef
Message:

CHG: updating exportVTK

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/contrib/paraview/exportVTK.py

    r18796 r18840  
    7171                for solution in solnames:
    7272                        #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])
    7575                                num_of_timesteps=int(num_of_timesteps/out_freq)+1
    7676        else:
     
    113113                        for sol in solnames:
    114114                                #dealing with results on different timesteps
    115                                 if(len(res_struct.__dict__[sol])>timestep):
     115                                if(numpy.size(res_struct.__dict__[sol])>timestep):
    116116                                        timestep = step
    117117                                else:
    118                                         timestep = len(res_struct.__dict__[sol])
     118                                        timestep = numpy.size(res_struct.__dict__[sol])
    119119                               
    120120                                #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__)
    123125                                #check which field is a real result and print
    124126                                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):
    126133                                                fid.write('SCALARS %s float 1 \n' % field)
    127134                                                fid.write('LOOKUP_TABLE default\n')
    128135                                                for node in range(0,num_of_points):
    129136                                                        #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]):
    131138                                                                fid.write('%e\n' % -9999.9999)
    132139                                                        #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):
    134141                                                                fid.write('%e\n' % 0.0)
    135142                                                        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])
    137144                                       
    138145                #loop on arguments, if something other than result is asked, do
Note: See TracChangeset for help on using the changeset viewer.