1 |
function [vo,z,d,xl,yl]=vslice(Q,Z,x,y,np,mesh) |
---|
2 |
|
---|
3 |
% [V,Z,D,X,Y]=vslice(Q,Z,X,Y,NP,MESH) |
---|
4 |
% [V,Z,D,X,Y]=vslice(Q,Z,X,Y,MESH) |
---|
5 |
% |
---|
6 |
% Q and Z are expected to be [nn x nnv] |
---|
7 |
|
---|
8 |
% OPNML COMPLIANT 3-19-99 CVL |
---|
9 |
|
---|
10 |
if exist('mesh')~=1&isstruct(np) |
---|
11 |
mesh=np; |
---|
12 |
np=25; |
---|
13 |
end |
---|
14 |
|
---|
15 |
% GET [1 X 2] LINE DESIGNATORS |
---|
16 |
|
---|
17 |
if isempty(x)|isnan(x) |
---|
18 |
x=[min(mesh.x) max(mesh.x)]; |
---|
19 |
elseif length(x)==1 |
---|
20 |
x=[x x]; |
---|
21 |
end |
---|
22 |
|
---|
23 |
if isempty(y)|isnan(y) |
---|
24 |
y=[min(mesh.y) max(mesh.y)]; |
---|
25 |
elseif length(y)==1 |
---|
26 |
y=[y y]; |
---|
27 |
end |
---|
28 |
|
---|
29 |
% REMAP OUTSIDE POINTS TO BOUNDARY |
---|
30 |
|
---|
31 |
mesh=belint(mesh); |
---|
32 |
mesh=el_areas(mesh); |
---|
33 |
ll=findelem(mesh,[x;y]'); |
---|
34 |
if any(isnan(ll)) |
---|
35 |
[xb,yb]=boundcross(x,y,mesh); |
---|
36 |
cpti=find(min(abs(x+i*y))); |
---|
37 |
cptb=find(min(abs(xb+i*yb))); |
---|
38 |
if isnan(ll(cpti)) |
---|
39 |
x(cpti)=xb(cptb); |
---|
40 |
y(cpti)=yb(cptb); |
---|
41 |
end |
---|
42 |
if isnan(ll(3-cpti)) |
---|
43 |
x(3-cpti)=xb(3-cptb); |
---|
44 |
y(3-cpti)=yb(3-cptb); |
---|
45 |
end |
---|
46 |
x=x+[1 -1]*diff(x)*1e-9; |
---|
47 |
y=y+[1 -1]*diff(y)*1e-9; |
---|
48 |
ll=findelem(mesh,[x;y]'); |
---|
49 |
end |
---|
50 |
|
---|
51 |
|
---|
52 |
% CALCULATE POINTS ON LINE |
---|
53 |
|
---|
54 |
NNV=size(Z,2); |
---|
55 |
in=[0:np]/np; |
---|
56 |
xl=x(1)+diff(x)*in; |
---|
57 |
yl=y(1)+diff(y)*in; |
---|
58 |
|
---|
59 |
ll=findelem(mesh,[xl;yl]'); |
---|
60 |
ind=find(~isnan(ll)); |
---|
61 |
if isempty(ind) |
---|
62 |
error('section off grid!') |
---|
63 |
end |
---|
64 |
|
---|
65 |
xl=xl(ind); |
---|
66 |
yl=yl(ind); |
---|
67 |
ll=ll(ind); |
---|
68 |
d=((xl-xl(1)).^2+(yl-yl(1)).^2).^0.5; |
---|
69 |
p=basis2d(mesh,[xl;yl]',ll); |
---|
70 |
n=mesh.e(ll,:); |
---|
71 |
|
---|
72 |
for iv=1:NNV |
---|
73 |
t=Z(:,iv)'; |
---|
74 |
sum((p.*t(n))'); |
---|
75 |
z(iv,1:length(xl))=sum((p.*t(n))'); |
---|
76 |
t=Q(:,iv); |
---|
77 |
v(iv,1:length(xl))=sum((p.*t(n))'); |
---|
78 |
end |
---|
79 |
|
---|
80 |
if nargout |
---|
81 |
vo=v; |
---|
82 |
[d,tm]=meshgrid(d,z(:,1)); |
---|
83 |
yl=meshgrid(yl,1:NNV); |
---|
84 |
xl=meshgrid(xl,1:NNV); |
---|
85 |
else |
---|
86 |
subplot(211) |
---|
87 |
pcolor(d,z,v) |
---|
88 |
shading('interp') |
---|
89 |
subplot(212) |
---|
90 |
plotbnd(mesh) |
---|
91 |
hold on |
---|
92 |
plot(xl,yl,'rx') |
---|
93 |
end |
---|