Changeset 17379


Ignore:
Timestamp:
03/04/14 11:58:23 (11 years ago)
Author:
bdef
Message:

BUG: Fix in exportVTK to deal with simulation without results

Location:
issm/trunk-jpl/src/m
Files:
2 deleted
2 edited

Legend:

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

    r17146 r17379  
    3939%this is the result structure
    4040res_struct=model.results;
    41 %Getting all the solutions of the model
    42 solnames=fields(res_struct);
    43 num_of_sols=length(solnames);
    44 num_of_timesteps=1;
    45 %building solution structure
    46 for i=1:num_of_sols
    47         sol_struct{i}=res_struct.(solnames{i});
    48         %looking for multiple time steps
    49         if(size(sol_struct{i},2)>num_of_timesteps);
    50                 num_of_timesteps=size(sol_struct{i},2);
     41%checking for results
     42if (length(fields(res_struct))>0);
     43        %Getting all the solutions of the model
     44        solnames=fields(res_struct);
     45        num_of_sols=length(solnames);
     46        num_of_timesteps=1;
     47        %building solution structure
     48        for i=1:num_of_sols
     49                sol_struct{i}=res_struct.(solnames{i});
     50                %looking for multiple time steps
     51                if(size(sol_struct{i},2)>num_of_timesteps);
     52                        num_of_timesteps=size(sol_struct{i},2);
    5153  end
     54 end
     55else
     56        num_of_timesteps=1;
    5257end
    53 
    5458for step=1:num_of_timesteps;
    5559       
     
    8589
    8690        %loop over the different solution structures
    87         for j=1:num_of_sols
    88                 %dealing with results on different timesteps
    89                 if(size(sol_struct{j},2)>timestep);
    90                         timestep = step;
    91                 else
    92                         timestep = size(sol_struct{j},2);
     91        if (exist('num_of_sols'));
     92                for j=1:num_of_sols
     93                        %dealing with results on different timesteps
     94                        if(size(sol_struct{j},2)>timestep);
     95                                timestep = step;
     96                        else
     97                                timestep = size(sol_struct{j},2);
     98            end
     99                       
     100                        %getting the number of fields in the solution
     101                        fieldnames=fields(sol_struct{j}(timestep));
     102                        num_of_fields=length(fieldnames);
     103                       
     104                        %check which field is a real result and print
     105                        for k=1:num_of_fields
     106                                if ((numel(sol_struct{j}(timestep).(fieldnames{k})))== ...
     107                                                num_of_points);
     108                                        %paraview does not like NaN, replacing
     109                                        nanval=find(isnan(sol_struct{j}(timestep).(fieldnames{k})));
     110                                        sol_struct{j}(timestep).(fieldnames{k})(nanval)=-9999;
     111                                        %also checking for verry small value that mess up
     112                                        smallval=(abs(sol_struct{j}(timestep).(fieldnames{k}))<1.0e-20);
     113                                        sol_struct{j}(timestep).(fieldnames{k})(smallval)=0.0;
     114                                        fprintf(FID,'SCALARS %s float 1 \n',fieldnames{k});
     115                                        fprintf(FID,'LOOKUP_TABLE default\n');
     116                                        s='%e\n';
     117                                        fprintf(FID,s,sol_struct{j}(timestep).(fieldnames{k}));
     118                    end         
     119            end
    93120          end
    94 
    95                 %getting the number of fields in the solution
    96                 fieldnames=fields(sol_struct{j}(timestep));
    97                 num_of_fields=length(fieldnames);
    98                
    99                 %check which field is a real result and print
    100                         for k=1:num_of_fields
    101                         if ((numel(sol_struct{j}(timestep).(fieldnames{k})))== ...
    102                                         num_of_points);
    103                                 %paraview does not like NaN, replacing
    104                                 nanval=find(isnan(sol_struct{j}(timestep).(fieldnames{k})));
    105                                 sol_struct{j}(timestep).(fieldnames{k})(nanval)=-9999;
    106                                 %also checking for verry small value that mess up
    107                                 smallval=(abs(sol_struct{j}(timestep).(fieldnames{k}))<1.0e-20);
    108                                 sol_struct{j}(timestep).(fieldnames{k})(smallval)=0.0;
    109                                 fprintf(FID,'SCALARS %s float 1 \n',fieldnames{k});
    110                                 fprintf(FID,'LOOKUP_TABLE default\n');
    111                                 s='%e\n';
    112                                 fprintf(FID,s,sol_struct{j}(timestep).(fieldnames{k}));
    113         end             
    114           end
    115         end
    116        
     121  end
    117122        %loop on arguments, if something other than result is asked, do
    118123        %it now
  • issm/trunk-jpl/src/m/exp/expdisp.m

    r16772 r17379  
    4646for i=1:length(domain),         
    4747        if domain(i).nods==1
    48                 plot(domain(i).x*unitmultiplier,domain(i).y*unitmultiplier,'ok','MarkerSize',10);
     48                plot(domain(i).x*unitmultiplier,domain(i).y*unitmultiplier,'o','MarkerEdgeColor','k','MarkerFaceColor','r','MarkerSize',10);
    4949        else
    5050                if (isnumeric(linestyle))
Note: See TracChangeset for help on using the changeset viewer.