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 | VarVal=[];
|
---|
20 | ListVarName={};
|
---|
21 | VarAttribute={};
|
---|
22 | errormsg='';
|
---|
23 | check_u=0;
|
---|
24 | check_v=0;
|
---|
25 | for ilist=1:length(Operation)
|
---|
26 | switch Operation{ilist}
|
---|
27 | case {'U'}
|
---|
28 | check_u=1;
|
---|
29 | case {'V'}
|
---|
30 | check_v=1;
|
---|
31 | case {'vec(U,V)','norm(U,V)'}
|
---|
32 | check_u=1;
|
---|
33 | check_v=1;
|
---|
34 | end
|
---|
35 | end
|
---|
36 | if check_u
|
---|
37 | F_u = TriScatteredInterp(Coord,FieldVar(:,1),'linear');
|
---|
38 | end
|
---|
39 | if check_v
|
---|
40 | F_v = TriScatteredInterp(Coord,FieldVar(:,2),'linear');
|
---|
41 | end
|
---|
42 | for ilist=1:length(Operation)
|
---|
43 | nbvar=numel(ListVarName);
|
---|
44 | switch Operation{ilist}
|
---|
45 | case 'vec(U,V)'
|
---|
46 | VarVal{nbvar+1}=F_u(XI,YI);
|
---|
47 | VarVal{nbvar+2}=F_v(XI,YI);
|
---|
48 | ListVarName{nbvar+1}='U';
|
---|
49 | ListVarName{nbvar+2}='V';
|
---|
50 | VarAttribute{nbvar+1}.Role='vector_x';
|
---|
51 | VarAttribute{nbvar+2}.Role='vector_y';
|
---|
52 | case 'U'
|
---|
53 | VarVal{nbvar+1}=F_u(XI,YI);
|
---|
54 | ListVarName{nbvar+1}='U';
|
---|
55 | VarAttribute{nbvar+1}.Role='scalar';
|
---|
56 | case 'V'
|
---|
57 | VarVal{nbvar+1}=F_v(XI,YI);
|
---|
58 | ListVarName{nbvar+1}='V';
|
---|
59 | VarAttribute{nbvar+1}.Role='scalar';
|
---|
60 | case 'norm(U,V)'
|
---|
61 | VarVal{nbvar+1}=sqrt(F_u(XI,YI).*F_u(XI,YI)+F_v(XI,YI).*F_v(XI,YI));
|
---|
62 | ListVarName{nbvar+1}='norm(U,V)';
|
---|
63 | VarAttribute{nbvar+1}.Role='scalar';
|
---|
64 | end
|
---|
65 | end
|
---|
66 | nbvar=numel(ListVarName);
|
---|
67 | ListVarName{nbvar+1}='FF';
|
---|
68 | VarVal{nbvar+1}=isnan(VarVal{nbvar});
|
---|
69 | VarAttribute{nbvar+1}.Role='errorflag';
|
---|
70 |
|
---|
71 | % Attr_FF.Role='errorflag';
|
---|
72 | % VarAttribute=[VarAttribute {Attr_FF}];
|
---|
73 |
|
---|
74 |
|
---|
75 |
|
---|
76 |
|
---|
77 |
|
---|