-
Notifications
You must be signed in to change notification settings - Fork 1
/
openMA_modes_group_same_grid.m
106 lines (93 loc) · 2.69 KB
/
openMA_modes_group_same_grid.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
function [ux,uy] = openMA_modes_group_same_grid( nm, dm, bm )
% OPENMA_MODES_GROUP_SAME_GRID - Simple function to group modes
% together that were created on a single triangular grid.
%
% Usage: [uu] = openMA_modes_group_same_grid( vfm, dfm, bm )
% [ux,uy] = openMA_modes_group_same_grid( vfm, dfm, bm )
%
% You would use this function if you created a bunch of modes using, for
% example, openMA_pdetool_neumann_modes_solve, etc., but did so on a single
% triangular mesh (i.e. you turned off adaptive mesh). This function just
% runs through modes and puts them in matrices. It works similar to
% openMA_modes_interp, but no interpolation is done and it is assumed all
% modes are on the same grid as the first vfm mode.
%
% If the function is given one output arguments, then the modes
% themselves are returned. If the function is given two output
% arguments then the current fields of each mode, evaluated at the
% triangle center, is returned.
%
% The different modes groups can be left off or empty and the function will
% work as expected.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% $Id: openMA_modes_group_same_grid.m 79 2007-03-05 21:51:20Z dmk $
%
% Copyright (C) 2005 David M. Kaplan
% Licence: GPL (Gnu Public License)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~exist('dm','var')
dm = [];
end
if ~exist('bm','var')
bm = [];
end
nnn = length(nm) + length(dm) + length(bm);
if nnn == 0
warning( 'No data given' )
ux = [];
if nargout > 1, uy = []; end
return
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Put modes together.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargout <= 1
% Need to do this to deal with missing mode structures.
ux = [];
try
ux = [ ux, nm.u ];
end
try
ux = [ ux, dm.u ];
end
try
ux = [ ux, bm.u ];
end
return
else
% Need to do this for missing mode structures.
try
p = nm(1).p;
t = nm(1).t;
catch
try
p = dm(1).p;
t = dm(1).t;
catch
p = bm(1).p;
t = bm(1).t;
end
end
% Want vector velocities from pdegrad.
[ux,uy] = deal( zeros(size(t,2),nnn) );
nn = 0; % Counter.
% Neumann
if ~isempty( nm )
nn = nn(end) + (1:length(nm));
[ ux(:,nn), uy(:,nn) ] = pdegrad_multi_col( p, t, [ nm.u ] );
end
% Dirichlet
if ~isempty( dm )
nn = nn(end) + (1:length(dm));
[ a, b ] = pdegrad_multi_col( p, t, [ dm.u ] );
[ ux(:,nn), uy(:,nn) ] = deal( -b, a ); % -b fixes sign
end
% Boundary
if ~isempty( bm )
nn = nn(end) + (1:length(bm));
[ ux(:,nn), uy(:,nn) ] = pdegrad_multi_col( p, t, [ bm.u ] );
end
end