Changeset 405 for trunk/src/calc_field.m


Ignore:
Timestamp:
May 1, 2012, 10:08:36 PM (12 years ago)
Author:
sommeria
Message:

many bugs corrected: composition of 2 input fields, arrow colors from different scalar fields...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field.m

    r404 r405  
    7777end
    7878FieldList=FieldList(check_calc==1);
    79 if isempty(FieldList)
    80     DataOut=DataIn;
    81     return
    82 end
     79% if isempty(FieldList)
     80%     DataOut=DataIn;
     81%     return
     82% end
    8383if isfield(DataIn,'Z')&& isequal(size(DataIn.Z),size(DataIn.X))
    8484    nbcoord=3;
     
    9393%% interpolation with new civ data
    9494if isfield(DataIn,'SubRange') && isfield(DataIn,'Coord_tps') && (exist('Coord_interp','var') || check_grid ||check_der)
    95     %create a default grid if needed
    96     if  ~exist('Coord_interp','var')
    97         coord_x=DataIn.XMin:DataIn.Mesh:DataIn.XMax;
    98         coord_y=DataIn.XMin:DataIn.Mesh:DataIn.YMax;
    99         [XI,YI]=meshgrid(coord_x,coord_y);
    100         XI=reshape(XI,[],1);
    101         YI=reshape(YI,[],1);
    102         Coord_interp=[XI YI];
    103     end
     95   
    10496    DataOut.ListGlobalAttribute=DataIn.ListGlobalAttribute; %reproduce global attribute
    10597    for ilist=1:numel(DataOut.ListGlobalAttribute)
     
    113105    XMin=min(min(DataIn.SubRange(1,:,:)));
    114106    YMin=min(min(DataIn.SubRange(2,:,:)));
    115 %     check_der=0;
    116 %     check_val=0;
     107    %create a default grid if needed
     108    if  ~exist('Coord_interp','var')
     109        if ~isfield(DataIn,'Mesh')
     110            DataIn.Mesh=sqrt(2*(XMax-XMin)*(YMax-YMin)/numel(DataIn.Coord_tps));
     111            % adjust the mesh to a value 1, 2 , 5 *10^n
     112            ord=10^(floor(log10(DataIn.Mesh)));%order of magnitude
     113            if DataIn.Mesh/ord>=5
     114                DataIn.Mesh=5*ord;
     115            elseif DataIn.Mesh/ord>=2
     116                DataIn.Mesh=2*ord;
     117            else
     118                DataIn.Mesh=ord;
     119            end
     120        end
     121        coord_x=XMin:DataIn.Mesh:XMax;
     122        coord_y=YMin:DataIn.Mesh:YMax;
     123        [XI,YI]=meshgrid(coord_x,coord_y);
     124        XI=reshape(XI,[],1);
     125        YI=reshape(YI,[],1);
     126        Coord_interp=[XI YI];
     127    end
    117128    nb_sites=size(Coord_interp,1);
    118129    nb_coord=size(Coord_interp,2);
     
    124135                DataOut.V=zeros(nb_sites,1);
    125136            otherwise
    126   %          case{'vort','div','strain'}% case of spatial derivatives
     137                %          case{'vort','div','strain'}% case of spatial derivatives
    127138                DataOut.(FieldList{ilist})=zeros(nb_sites,1);
    128 %                 otherwise % case of a scalar
    129 %                     check_val=1;
    130 %                     DataOut.(FieldList{ilist})=zeros(size(Coord_interp,1));
     139                %                 otherwise % case of a scalar
     140                %                     check_val=1;
     141                %                     DataOut.(FieldList{ilist})=zeros(size(Coord_interp,1));
    131142        end
    132143    end
     
    142153        %                 ctrs=DataIn.Coord_tps(1:nbvec_sub,:,isub);%(=initial points) ctrs
    143154        nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for eacn interpolation point (in case of subdomain overlap)
    144         if check_val
     155        if check_grid
    145156            EM = tps_eval(Coord_interp(ind_sel,:),DataIn.Coord_tps(1:nbvec_sub,:,isub));%kernels for calculating the velocity from tps 'sources'
    146157        end
     
    164175                    VarAttributes{1}.Role='scalar';
    165176                    DataOut.V(ind_sel)=DataOut.V(ind_sel)+EM *DataIn.V_tps(1:nbvec_sub+3,isub);
    166                 case 'norm_vel' 
     177                case 'norm_vel'
    167178                    ListFields={'norm_vel'};
    168179                    VarAttributes{1}.Role='scalar';
Note: See TracChangeset for help on using the changeset viewer.