# Changeset 896 for trunk/src/filter_tps.m

Ignore:
Timestamp:
May 23, 2015, 5:09:49 PM (8 years ago)
Message:

bug corrected in civ_series/patch

File:
1 edited

Unmodified
Removed
• ## trunk/src/filter_tps.m

 r809 %'filter_tps': find the thin plate spline coefficients for interpolation-smoothing %------------------------------------------------------------------------ % [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold) % [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomainSize,Rho,Threshold) % % OUTPUT: %======================================================================= function [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomain,Rho,Threshold) function [SubRange,NbCentre,Coord_tps,U_tps,V_tps,W_tps,U_smooth,V_smooth,W_smooth,FF] =filter_tps(Coord,U,V,W,SubDomainSize,Rho,Threshold) %% adjust subdomain decomposition warning off NbVec=size(Coord,1); NbCoord=size(Coord,2); NbVec=size(Coord,1);% nbre of vectors in the field to interpolate NbCoord=size(Coord,2);% space dimension MinCoord=min(Coord,[],1);%lower coordinate bounds MaxCoord=max(Coord,[],1);%upper coordinate bounds Range=MaxCoord-MinCoord; AspectRatio=Range(2)/Range(1); NbSubDomain=NbVec/SubDomain; NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1); NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1); NbSubDomain=NbSubDomainX*NbSubDomainY; NbSubDomain=NbVec/SubDomainSize;% estimated number of subdomains NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);% estimated number of subdomains in x NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1);% estimated number of subdomains in y NbSubDomain=NbSubDomainX*NbSubDomainY;% new estimated number of subdomains in a matrix shape partition in subdomains Siz(1)=Range(1)/NbSubDomainX;%width of subdomains Siz(2)=Range(2)/NbSubDomainY;%height of subdomains CentreX=linspace(MinCoord(1)+Siz(1)/2,MaxCoord(1)-Siz(1)/2,NbSubDomainX); CentreY=linspace(MinCoord(2)+Siz(2)/2,MaxCoord(2)-Siz(2)/2,NbSubDomainY); CentreX=linspace(MinCoord(1)+Siz(1)/2,MaxCoord(1)-Siz(1)/2,NbSubDomainX);% X positions of subdomain centres CentreY=linspace(MinCoord(2)+Siz(2)/2,MaxCoord(2)-Siz(2)/2,NbSubDomainY);% Y positions of subdomain centres [CentreX,CentreY]=meshgrid(CentreX,CentreY); CentreX=reshape(CentreX,1,[]);% X positions of subdomain centres CentreY=reshape(CentreY,1,[]);% Y positions of subdomain centres CentreX=reshape(CentreX,1,[]);% X positions of subdomain centres %% smoothing parameter %% default output SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the positions of subdomains NbCentre=zeros(1,NbSubDomain);%number of interpolated values per subdomain, =0 by default SubRange=zeros(NbCoord,2,NbSubDomain);%initialise the boundaries of subdomains Coord_tps=zeros(1,NbCoord,NbSubDomain);% initialize coordinates of interpolated data U_tps=zeros(1,NbSubDomain);% initialize  interpolated u component V_tps=zeros(1,NbSubDomain);% initialize interpolated v component NbCentre=zeros(1,NbSubDomain);%number of interpolated field values per subdomain, =0 by default W_tps=[];%default (2 component case) U_smooth=zeros(NbVec,1); % smoothed velocity U at the initial positions check_empty=zeros(1,NbSubDomain); %% calculate tps coeff in each subdomain for isub=1:NbSubDomain SubRange(1,:,isub)=[CentreX(isub)-0.55*Siz(1) CentreX(isub)+0.55*Siz(1)]; SubRange(2,:,isub)=[CentreY(isub)-0.55*Siz(2) CentreY(isub)+0.55*Siz(2)]; SubRange(1,:,isub)=[CentreX(isub)-0.55*Siz(1) CentreX(isub)+0.55*Siz(1)];%bounds of subdomain #isub in x coordinate SubRange(2,:,isub)=[CentreY(isub)-0.55*Siz(2) CentreY(isub)+0.55*Siz(2)];%bounds of subdomain #isub in y coordinate ind_sel_previous=[]; ind_sel=0; ind_sel=0;%initialize set of vector indices in the subdomain %increase iteratively the subdomain if it contains less than SubDomainNbVec/4 source vectors while numel(ind_sel)>numel(ind_sel_previous) ind_sel_previous=ind_sel; ind_sel_previous=ind_sel;% record the set of selected vector indices for next iteration ind_sel=find(Coord(:,1)>=SubRange(1,1,isub) & Coord(:,1)<=SubRange(1,2,isub) & Coord(:,2)>=SubRange(2,1,isub) & Coord(:,2)<=SubRange(2,2,isub)); % if no vector in the subdomain, skip the subdomain % if no vector in the subdomain  #isub, skip the subdomain if isempty(ind_sel) check_empty(isub)=1; U_tps(1,isub)=0;%define U_tps and V_tps by default V_tps(1,isub)=0; break % if too few selected vectors, increase the subrange for next iteration elseif numel(ind_sel)
Note: See TracChangeset for help on using the changeset viewer.