1 |
|
---|
2 | %'calc_field': defines fields (velocity, vort, div...) from civx data and calculate them
|
---|
3 | %---------------------------------------------------------------------
|
---|
4 | % [DataOut,VarAttribute,errormsg]=calc_field_interp(Coord_tps,NbSites,SubRange,FieldVar,Operation,Coord_interp)
|
---|
5 | %
|
---|
6 | % OUTPUT:
|
---|
7 | % DataOut: structure representing the output fields
|
---|
8 | %
|
---|
9 | % INPUT:
|
---|
10 | % Coord_tps:
|
---|
11 | % NbSites
|
---|
12 | % SubRange
|
---|
13 | % FieldVar
|
---|
14 | % Operation: cell array representing the list of operations (eg div, rot..)
|
---|
15 | % Coord_interp: coordiantes of sites on which the fields need to be calculated
|
---|
16 |
|
---|
17 | function [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,FieldVar,Operation,XI,YI)
|
---|
18 |
|
---|
19 | %% nbre of subdomains
|
---|
20 | % if ndims(Coord_interp)==3
|
---|
21 | % nb_coord=size(Coord_interp,3);
|
---|
22 | % npx=size(Coord_interp,2);
|
---|
23 | % npy=size(Coord_interp,1);
|
---|
24 | % nb_sites=npx*npy;
|
---|
25 | % Coord_interp=reshape(Coord_interp,nb_sites,nb_coord);
|
---|
26 | % else
|
---|
27 | % nb_coord=size(Coord_interp,2);
|
---|
28 | % nb_sites=size(Coord_interp,1);
|
---|
29 | % end
|
---|
30 | VarVal=[];
|
---|
31 | ListVarName={};
|
---|
32 | VarAttribute={};
|
---|
33 | errormsg='';
|
---|
34 | check_u=0;
|
---|
35 | check_v=0;
|
---|
36 | for ilist=1:length(Operation)
|
---|
37 | switch Operation{ilist}
|
---|
38 | case {'U'}
|
---|
39 | check_u=1;
|
---|
40 | case {'V'}
|
---|
41 | check_v=1;
|
---|
42 | case {'vec(U,V)','norm(U,V)'}
|
---|
43 | check_u=1;
|
---|
44 | check_v=1;
|
---|
45 | end
|
---|
46 | end
|
---|
47 | if check_u
|
---|
48 | F_u = TriScatteredInterp(Coord,FieldVar(:,1),'linear');
|
---|
49 | end
|
---|
50 | if check_v
|
---|
51 | F_v = TriScatteredInterp(Coord,FieldVar(:,2),'linear');
|
---|
52 | end
|
---|
53 | for ilist=1:length(Operation)
|
---|
54 | nbvar=numel(ListVarName);
|
---|
55 | switch Operation{ilist}
|
---|
56 | case 'vec(U,V)'
|
---|
57 | VarVal{nbvar+1}=F_u(XI,YI);
|
---|
58 | VarVal{nbvar+2}=F_v(XI,YI);
|
---|
59 | ListVarName{nbvar+1}='U';
|
---|
60 | ListVarName{nbvar+2}='V';
|
---|
61 | VarAttribute{nbvar+1}.Role='vector_x';
|
---|
62 | VarAttribute{nbvar+2}.Role='vector_y';
|
---|
63 | case 'U'
|
---|
64 | VarVal{nbvar+1}=F_u(XI,YI);
|
---|
65 | ListVarName{nbvar+1}='U';
|
---|
66 | VarAttribute{nbvar+1}.Role='scalar';
|
---|
67 | case 'V'
|
---|
68 | VarVal{nbvar+1}=F_v(XI,YI);
|
---|
69 | ListVarName{nbvar+1}='V';
|
---|
70 | VarAttribute{nbvar+1}.Role='scalar';
|
---|
71 | case 'norm(U,V)'
|
---|
72 | VarVal{nbvar+1}=sqrt(F_u(XI,YI).*F_u(XI,YI)+F_v(XI,YI).*F_v(XI,YI));
|
---|
73 | ListVarName{nbvar+1}='norm(U,V)';
|
---|
74 | VarAttribute{nbvar+1}.Role='scalar';
|
---|
75 | end
|
---|
76 | end
|
---|
77 | nbvar=numel(ListVarName);
|
---|
78 | ListVarName{nbvar+1}='FF';
|
---|
79 | VarVal{nbvar+1}=isnan(VarVal{nbvar});
|
---|
80 | VarAttribute{nbvar+1}.Role='errorflag';
|
---|
81 |
|
---|
82 | % Attr_FF.Role='errorflag';
|
---|
83 | % VarAttribute=[VarAttribute {Attr_FF}];
|
---|
84 |
|
---|
85 |
|
---|
86 |
|
---|
87 |
|
---|
88 |
|
---|