function [fldu,fldv]=interp_llc_tracer2vectorpts(fldin,nfx,nfy,N)
%---------------------
%function [fldu,fldv]=interp_llc_tracer2vectorpts(fldin,nfx,nfy,N)
% input:
%   fldin: compact size
%   N is the padding, for now, use 1 to get tracer pts to vector pts
% output:
%   fldu: compact size
%   fldv: compact size
%---------------------
%---------------------

if(nfx(3)~=0);
  nx=nfx(3);
elseif(nfx(1)~=0);
  nx=nfx(1);
elseif(nfx(2)~=0);
  nx=nfx(2);
elseif(nfy(4)~=0);
  nx=nfy(4);
elseif(nfy(5)~=0);
  nx=nfy(5);
else;
  error('cannot determine nx');
end;

%assume in compact format
sz=size(fldin);if(length(sz)==2);sz=[sz 1];end;

%first put into faces
ff=get_aste_faces(fldin,nfx,nfy);	

%now pad, for tracer, it's much easier, and always just need pad_dn and pad_left to get tracer to vector
iface=1;
if(nfx(iface)>0);			%/*{{{*/ [f1]
  jface=5;kface=2;%lface=3;
  %if(nfx(kface)>0);pad_right=ff{kface}(1:N,:,:);else;pad_right=nan(N,nfy(1),sz(3));end;
  %if(nfx(lface)>0);clear tmp;tmp=sym_g_mod(ff{lface},5,0);pad_up=tmp(:,1:N,:);else;pad_up=zeros(N,nfx(iface),sz(3));end;
  %pad_up=cat(1,zeros(N,N),pad_up,zeros(N,N));
  if(nfx(jface)>0);clear tmp;tmp=sym_g_mod(ff{jface},7,0);pad_left=tmp(end-N+1:end,:,:);else;pad_left=nan(nfy(iface),N,sz(3));end;
  pad_dn=nan(N+nfx(1),N,sz(3));
  tmp1=cat(1,pad_left,ff{iface});tmp1=cat(2,pad_dn,tmp1);
  
  tmp1u=(tmp1(1:end-1,2:end,:)+tmp1(2:end,2:end,:))./2;
  tmp1v=(tmp1(2:end,1:end-1,:)+tmp1(2:end,2:end,:))./2;
  
  ffu{iface}=tmp1u;
  ffv{iface}=tmp1v;
else;
  ffu{iface}=[];
  ffv{iface}=[];
end;					%/*}}}*/ [f1]

iface=2;
if(nfx(iface)>0);			%/*{{{*/ [f2]
  jface=1;kface=4;
  if(nfx(jface)>0);clear tmp;tmp=ff{jface};pad_left=tmp(end-N+1:end,:,:);else;pad_left=nan(nfy(iface),N,sz(3));end;
  pad_dn=nan(N+nfx(1),N,sz(3));
  tmp1=cat(1,pad_left,ff{iface});tmp1=cat(2,pad_dn,tmp1);
  
  tmp1u=(tmp1(1:end-1,2:end,:)+tmp1(2:end,2:end,:))./2;
  tmp1v=(tmp1(2:end,1:end-1,:)+tmp1(2:end,2:end,:))./2;
  
  ffu{iface}=tmp1u;
  ffv{iface}=tmp1v;
else;
  ffu{iface}=[];
  ffv{iface}=[];
end;					%/*}}}*/ [f2]

iface=3;
if(nfx(iface)>0);			%/*{{{*/ [f3]
  jface=5;kface=2;
  if(nfx(jface)>0);clear tmp;tmp=sym_g_mod(ff{jface},6,0);pad_left=tmp(end-N+1:end,:,:);else;pad_left=nan(nfy(iface),N,sz(3));end;
  if(nfx(kface)>0);pad_dn=ff{kface}(:,end-N+1:N,:);pad_dn=cat(1,zeros(N,N),pad_dn);else;pad_dn=nan(N+nfx(iface),N,sz(3));end;
  tmp1=cat(1,pad_left,ff{iface});tmp1=cat(2,pad_dn,tmp1);
  
  tmp1u=(tmp1(1:end-1,2:end,:)+tmp1(2:end,2:end,:))./2;
  tmp1v=(tmp1(2:end,1:end-1,:)+tmp1(2:end,2:end,:))./2;
  
  ffu{iface}=tmp1u;
  ffv{iface}=tmp1v;
else;
  ffu{iface}=[];
  ffv{iface}=[];
end;					%/*}}}*/ [f3]

iface=4;
if(nfx(iface)>0); 			%/*{{{*/ [f4]
  jface=3;kface=2;
  if(nfx(jface)>0);clear tmp;tmp=ff{jface};pad_left=tmp(end-N+1:end,:,:);else;pad_left=nan(nfy(iface),N,sz(3));end;
  if(nfx(kface)>0);clear tmp;tmp=sym_g_mod(ff{kface},5,0);pad_dn=tmp(:,end-N+1:N,:);pad_dn=cat(1,zeros(N,N),pad_dn);else;pad_dn=nan(N+nfx(iface),N,sz(3));end;
  tmp1=cat(1,pad_left,ff{iface});tmp1=cat(2,pad_dn,tmp1);

  tmp1u=(tmp1(1:end-1,2:end,:)+tmp1(2:end,2:end,:))./2;
  tmp1v=(tmp1(2:end,1:end-1,:)+tmp1(2:end,2:end,:))./2;

  ffu{iface}=tmp1u;
  ffv{iface}=tmp1v;
else;
  ffu{iface}=[];
  ffv{iface}=[];
end;                                    %/*}}}*/ [f4]

iface=5;
if(nfx(iface)>0);                       %/*{{{*/ [f4]
  jface=3;kface=4;
  if(nfx(jface)>0);clear tmp;tmp=sym_g_mod(ff{jface},7,0);pad_left=tmp(end-N+1:end,:,:);else;pad_left=nan(nfy(iface),N,sz(3));end;
  pad_dn=nan(N+nfx(iface),N,sz(3));
  if(nfx(kface)>0);clear tmp;tmp=ff{kface};pad_dn(N+1:N+(min(nfx(iface),nfx(kface))),:,:)=tmp(:,end-N+1:end,:);end;
  tmp1=cat(1,pad_left,ff{iface});tmp1=cat(2,pad_dn,tmp1);

  tmp1u=(tmp1(1:end-1,2:end,:)+tmp1(2:end,2:end,:))./2;
  tmp1v=(tmp1(2:end,1:end-1,:)+tmp1(2:end,2:end,:))./2;

  ffu{iface}=tmp1u;
  ffv{iface}=tmp1v;
else;
  ffu{iface}=[];
  ffv{iface}=[];
end;                                    %/*}}}*/ [f4]

%putting back to compact:
if(nfx(1)>0);
  if(nfx(2)>0);
    if(nfx(3)>0);
      if(nfx(4)>0);
        if(nfx(5)>0);		%/*{{{*/ [1 2 3 4 5]
          fldu=cat(2,ffu{1},ffu{2},ffu{3},reshape(ffu{4},nfy(4),nfx(4),sz(3)),reshape(ffu{5},nfy(5),nfx(5),sz(3)));
          fldv=cat(2,ffv{1},ffv{2},ffv{3},reshape(ffv{4},nfy(4),nfx(4),sz(3)),reshape(ffv{5},nfy(5),nfx(5),sz(3)));
        else;
          fldu=cat(2,ffu{1},ffu{2},ffu{3},reshape(ffu{4},nfy(4),nfx(4),sz(3)));
          fldv=cat(2,ffv{1},ffv{2},ffv{3},reshape(ffv{4},nfy(4),nfx(4),sz(3)));
        end;			%/*}}}*/ [1 2 3 4 5]
      else;
        if(nfx(5)>0);	%/*{{{*/ [1 2 3 5]
          fldu=cat(2,ffu{1},ffu{2},ffu{3},reshape(ffu{5},nfy(5),nfx(5),sz(3)));
          fldv=cat(2,ffv{1},ffv{2},ffv{3},reshape(ffv{5},nfy(5),nfx(5),sz(3)));
        else;
          fldu=cat(2,ffu{1},ffu{2},ffu{3});
          fldv=cat(2,ffv{1},ffv{2},ffv{3});
        end;		%/*}}}*/ [1 2 3 5]
      end;
    else;
      if(nfx(4)>0);
        if(nfx(5)>0);		%/*{{{*/ [1 2 4 5]
          fldu=cat(2,ffu{1},ffu{2},reshape(ffu{4},nfy(4),nfx(4),sz(3)),reshape(ffu{5},nfy(5),nfx(5),sz(3)));
          fldv=cat(2,ffv{1},ffv{2},reshape(ffv{4},nfy(4),nfx(4),sz(3)),reshape(ffv{5},nfy(5),nfx(5),sz(3)));
        else;
          fldu=cat(2,ffu{1},ffu{2},reshape(ffu{4},nfy(4),nfx(4),sz(3)));
          fldv=cat(2,ffv{1},ffv{2},reshape(ffv{4},nfy(4),nfx(4),sz(3)));
        end;			%/*}}}*/ [1 2 4 5]
      end;
    end;
  else;
    if(nfx(3)>0);
      if(nfx(4)>0);
        if(nfx(5)>0);		%/*{{{*/ [1 3 4 5]
          fldu=cat(2,ffu{1},ffu{3},reshape(ffu{4},nfy(4),nfx(4),sz(3)),reshape(ffu{5},nfy(5),nfx(5),sz(3)));
          fldv=cat(2,ffv{1},ffv{3},reshape(ffv{4},nfy(4),nfx(4),sz(3)),reshape(ffv{5},nfy(5),nfx(5),sz(3)));
        else;
          fldu=cat(2,ffu{1},ffu{3},reshape(ffu{4},nfy(4),nfx(4),sz(3)));
          fldv=cat(2,ffv{1},ffv{3},reshape(ffv{4},nfy(4),nfx(4),sz(3)));
        end;			%/*}}}*/ [1 3 4 5]
      else;
        if(nfx(5)>0);		%/*{{{*/ [1 3 5];
          fldu=cat(2,ffu{1},ffu{3},reshape(ffu{5},nfy(5),nfx(5),sz(3)));
          fldv=cat(2,ffv{1},ffv{3},reshape(ffv{5},nfy(5),nfx(5),sz(3)));
        else;
          fldu=cat(2,ffu{1},ffu{3});
          fldv=cat(2,ffv{1},ffv{3});
        end;			%/*}}}*/ [1 3 5]
      end;
    else;
      if(nfx(4)>0);
        if(nfx(5)>0);		%/*{{{*/ [1 4 5]
          fldu=cat(2,ffu{1},reshape(ffu{4},nfy(4),nfx(4),sz(3)),reshape(ffu{5},nfy(5),nfx(5),sz(3)));
          fldv=cat(2,ffv{1},reshape(ffv{4},nfy(4),nfx(4),sz(3)),reshape(ffv{5},nfy(5),nfx(5),sz(3)));
        else;
          fldu=cat(2,ffu{1},reshape(ffu{4},nfy(4),nfx(4),sz(3)));
          fldv=cat(2,ffv{1},reshape(ffv{4},nfy(4),nfx(4),sz(3)));
        end;			%/*}}}*/ [1 4 5]
      else;
        if(nfx(5)>0);	%/*{{{*/ [1 5];
          fldu=cat(2,ffu{1},reshape(ffu{5},nfy(5),nfx(5),sz(3)));
          fldv=cat(2,ffv{1},reshape(ffv{5},nfy(5),nfx(5),sz(3)));
        else;
          fldu=ffu{1};
          fldv=ffv{1};
        end;		%/*}}}*/ [1 5]
      end;
    end;
  end;
else;
  if(nfx(2)>0);
    if(nfx(3)>0);
      if(nfx(4)>0);
        if(nfx(5)>0);		%/*{{{*/ [2 3 4 5]
          fldu=cat(2,ffu{2},ffu{3},reshape(ffu{4},nfy(4),nfx(4),sz(3)),reshape(ffu{5},nfy(5),nfx(5),sz(3)));
          fldv=cat(2,ffv{2},ffv{3},reshape(ffv{4},nfy(4),nfx(4),sz(3)),reshape(ffv{5},nfy(5),nfx(5),sz(3)));
        else;
          fldu=cat(2,ffu{2},ffu{3},reshape(ffu{4},nfy(4),nfx(4),sz(3)));
          fldv=cat(2,ffv{2},ffv{3},reshape(ffv{4},nfy(4),nfx(4),sz(3)));
        end;			%/*}}}*/ [2 3 4 5]
      else;
        if(nfx(5)>0);	%/*{{{*/ [2 3 5]
          fldu=cat(2,ffu{2},ffu{3},reshape(ffu{5},nfy(5),nfx(5),sz(3)));
          fldv=cat(2,ffv{2},ffv{3},reshape(ffv{5},nfy(5),nfx(5),sz(3)));
        else;
          fldu=cat(2,ffu{2},ffu{3});
          fldv=cat(2,ffv{2},ffv{3});
        end;		%/*}}}*/ [2 3 5]
      end;
    else;
      if(nfx(4)>0);
        if(nfx(5)>0);		%/*{{{*/ [2 4 5]
          fldu=cat(2,ffu{2},reshape(ffu{4},nfy(4),nfx(4),sz(3)),reshape(ffu{5},nfy(5),nfx(5),sz(3)));
          fldv=cat(2,ffv{2},reshape(ffv{4},nfy(4),nfx(4),sz(3)),reshape(ffv{5},nfy(5),nfx(5),sz(3)));
        else;
          fldu=cat(2,ffu{2},reshape(ffu{4},nfy(4),nfx(4),sz(3)));
          fldv=cat(2,ffv{2},reshape(ffv{4},nfy(4),nfx(4),sz(3)));
        end;			%/*}}}*/ [2 4 5]
      end;
    end;
  else;
    if(nfx(3)>0);
      if(nfx(4)>0);
        if(nfx(5)>0);		%/*{{{*/ [3 4 5]
          fldu=cat(2,ffu{3},reshape(ffu{4},nfy(4),nfx(4),sz(3)),reshape(ffu{5},nfy(5),nfx(5),sz(3)));
          fldv=cat(2,ffv{3},reshape(ffv{4},nfy(4),nfx(4),sz(3)),reshape(ffv{5},nfy(5),nfx(5),sz(3)));
        else;
          fldu=cat(2,ffu{3},reshape(ffu{4},nfy(4),nfx(4),sz(3)));
          fldv=cat(2,ffv{3},reshape(ffv{4},nfy(4),nfx(4),sz(3)));
        end;			%/*}}}*/ [3 4 5]
      else;
        if(nfx(5)>0);		%/*{{{*/ [3 5];
          fldu=cat(2,ffu{3},reshape(ffu{5},nfy(5),nfx(5),sz(3)));
          fldv=cat(2,ffv{3},reshape(ffv{5},nfy(5),nfx(5),sz(3)));
        else;
          fldu=ffu{3};
          fldv=ffv{3};
        end;			%/*}}}*/ [3 5]
      end;
    else;
      if(nfx(4)>0);
        if(nfx(5)>0);		%/*{{{*/ [4 5]
          fldu=cat(2,reshape(ffu{4},nfy(4),nfx(4),sz(3)),reshape(ffu{5},nfy(5),nfx(5),sz(3)));
          fldv=cat(2,reshape(ffv{4},nfy(4),nfx(4),sz(3)),reshape(ffv{5},nfy(5),nfx(5),sz(3)));
        else;
          fldu=reshape(ffu{4},nfy(4),nfx(4),sz(3));
          fldv=reshape(ffv{4},nfy(4),nfx(4),sz(3));
        end;			%/*}}}*/ [4 5]
      else;
        if(nfx(5)>0);	%/*{{{*/ [5];
          fldu=reshape(ffu{5},nfy(5),nfx(5),sz(3));
          fldv=reshape(ffv{5},nfy(5),nfx(5),sz(3));
        else;
          fldu=nan(sz(1),sz(2),sz(3));
          fldv=nan(sz(1),sz(2),sz(3));
        end;		%/*}}}*/ [5]
      end;
    end;
  end;
end;

%swap out all nans for zeros now:
fldu(find(isnan(fldu(:)==1)))=0;
fldv(find(isnan(fldv(:)==1)))=0;

return
