annotate +scheme/hypsyst2d.m @ 292:3d275c5e45b3 feature/hypsyst

Changed how the matrices are built
author Ylva Rydin <ylva.rydin@telia.com>
date Fri, 23 Sep 2016 14:48:54 +0200
parents 807dfe8be3ec
children 2d604d16842c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
1 classdef hypsyst2d < scheme.Scheme
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
2 properties
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
3 m % Number of points in each direction, possibly a vector
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
4 h % Grid spacing
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
5 x,y % Grid
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
6 X,Y % Values of x and y for each grid point
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
7 order % Order accuracy for the approximation
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
8
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
9 D % non-stabalized scheme operator
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
10 A, B, E
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
11
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
12 H % Discrete norm
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
13 % Norms in the x and y directions
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
14 Hxi,Hyi % Kroneckerd norms. 1'*Hx*v corresponds to integration in the x dir.
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
15 I_x,I_y, I_N
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
16 e_w, e_e, e_s, e_n
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
17 params %parameters for the coeficient matrices
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
18 matrices
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
19 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
20
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
21
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
22 methods
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
23 function obj = hypsyst2d(m,lim,order,matrices,params)
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
24
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
25 xlim = lim{1};
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
26 ylim = lim{2};
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
27
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
28 if length(m) == 1
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
29 m = [m m];
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
30 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
31
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
32 m_x = m(1);
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
33 m_y = m(2);
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
34
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
35 obj.matrices=matrices;
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
36
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
37 ops_x = sbp.D2Standard(m_x,xlim,order);
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
38 ops_y = sbp.D2Standard(m_y,ylim,order);
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
39
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
40 obj.x=ops_x.x;
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
41 obj.y=ops_y.x;
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
42
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
43 obj.X = kr(obj.x,ones(m_y,1));
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
44 obj.Y = kr(ones(m_x,1),obj.y);
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
45
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
46 I_x = speye(m_x); obj.I_x=I_x;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
47 I_y = speye(m_y); obj.I_y=I_y;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
48
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
49 I_n= eye(4);
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
50
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
51
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
52 D1_x = kr(kr(I_n,ops_x.D1),I_y);
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
53 obj.Hxi= kr(kr(I_n,ops_x.HI),I_y);
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
54 D1_y=kr(I_n,kr(I_x,ops_y.D1));
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
55 obj.Hyi=kr(I_n,kr(I_x,ops_y.HI));
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
56
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
57 obj.e_w=kr(I_n,kr(ops_x.e_l,I_y));
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
58 obj.e_e=kr(I_n,kr(ops_x.e_r,I_y));
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
59 obj.e_s=kr(I_n,kr(I_x,ops_y.e_l));
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
60 obj.e_n=kr(I_n,kr(I_x,ops_y.e_r));
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
61
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
62 obj.m=m;
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
63 obj.h=[ops_x.h ops_y.h];
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
64 obj.order=order;
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
65 obj.params=params;
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
66
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
67 obj.A=obj.matrixBuild(matrices.A);
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
68 obj.B=obj.matrixBuild(matrices.B);
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
69 obj.E=obj.matrixBuild(matrices.E);
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
70
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
71
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
72 obj.D=-obj.A*D1_x-obj.B*D1_y-obj.E;
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
73
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
74 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
75 % Closure functions return the opertors applied to the own doamin to close the boundary
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
76 % Penalty functions return the opertors to force the solution. In the case of an interface it returns the operator applied to the other doamin.
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
77 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'.
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
78 % type is a string specifying the type of boundary condition if there are several.
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
79 % data is a function returning the data that should be applied at the boundary.
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
80 % neighbour_scheme is an instance of Scheme that should be interfaced to.
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
81 % neighbour_boundary is a string specifying which boundary to interface to.
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
82 function [closure, penalty] = boundary_condition(obj,boundary,type)
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
83 default_arg('type','neumann');
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
84 default_arg('data',0);
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
85
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
86 switch type
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
87 case{'c','char'}
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
88 [closure,penalty]=GetBoundarydata_char(obj,boundary);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
89 case{'wall'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
90 [closure,penalty]=GetBoundarydata_wall(obj,boundary);
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
91 otherwise
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
92 error('No such boundary condition')
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
93 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
94 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
95
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
96 function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary)
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
97 error('An interface function does not exist yet');
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
98 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
99
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
100 function N = size(obj)
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
101 N = obj.m;
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
102 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
103
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
104 function [ret]=matrixBuild(obj,mat,x,y)
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
105 %extra info for coordinate transfomration mult my y_ny and
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
106 %x,ny osv...
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
107 params=obj.params;
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
108 X=obj.X;
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
109 Y=obj.Y;
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
110
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
111 if isa(mat,'function_handle')
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
112 [rows,cols]=size(mat(params,0,0));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
113 matVec=mat(params,X',Y');
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
114 matVec=sparse(matVec);
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
115 side=max(length(X),length(Y));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
116 else
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
117 matVec=mat;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
118 [rows,cols]=size(matVec);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
119 side=max(length(x),length(y));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
120 cols=cols/side;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
121 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
122
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
123
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
124 ret=kron(ones(rows,cols),speye(side));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
125
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
126 for ii=1:rows
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
127 for jj=1:cols
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
128 ret((ii-1)*side+1:ii*side,(jj-1)*side+1:jj*side)=diag(matVec(ii,(jj-1)*side+1:jj*side));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
129 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
130 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
131
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
132 end
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
133
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
134
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
135 function [closure, penalty]=GetBoundarydata_char(obj,boundary)
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
136 params=obj.params;
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
137 x=obj.x;
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
138 y=obj.y;
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
139
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
140 side=max(length(x),length(y));
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
141
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
142 switch boundary
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
143 case {'w','W','west'}
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
144 e_=obj.e_w;
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
145 mat=obj.matrices.A;
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
146 boundPos='l';
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
147 Hi=obj.Hxi;
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
148 [V,Vi,D,signVec]=obj.matrixDiag(mat,x(1),y);
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
149 case {'e','E','east'}
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
150 e_=obj.e_e;
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
151 mat=obj.matrices.A;
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
152 boundPos='r';
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
153 Hi=obj.Hxi;
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
154 [V,Vi,D,signVec]=obj.matrixDiag(mat,x(end),y);
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
155 case {'s','S','south'}
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
156 e_=obj.e_s;
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
157 mat=obj.matrices.B;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
158 boundPos='l';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
159 Hi=obj.Hxi;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
160 [V,Vi,D,signVec]=obj.matrixDiag(mat,x,y(1));
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
161 case {'n','N','north'}
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
162 e_=obj.e_n;
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
163 mat=obj.matrices.B;
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
164 boundPos='r';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
165 Hi=obj.Hxi;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
166 [V,Vi,D,signVec]=obj.matrixDiag(mat,x,y(end));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
167 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
168
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
169 pos=signVec(1); zeroval=signVec(2); neg=signVec(3);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
170
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
171 switch boundPos
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
172 case {'l'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
173 tau=sparse(4*side,pos*side);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
174 Vi_plus=Vi(1:pos*side,:);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
175 tau(1:pos*side,:)=-abs(D(1:pos*side,1:pos*side));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
176 closure=Hi*e_*V*tau*Vi_plus*e_';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
177 penalty=-Hi*e_*V*tau*Vi_plus;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
178
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
179 case {'r'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
180 tau=sparse(4*side,neg*side);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
181 tau((pos+zeroval)*side+1:4*side,:)=-abs(D((pos+zeroval)*side+1:4*side,(pos+zeroval)*side+1:4*side));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
182 Vi_minus=Vi((pos+zeroval)*side+1:4*side,:);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
183 closure=Hi*e_*V*tau*Vi_minus*e_';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
184 penalty=-Hi*e_*V*tau*Vi_minus;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
185
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
186 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
187 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
188
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
189 function [closure, penalty]=GetBoundarydata_wall(obj,boundary)
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
190 switch boundary
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
191 case {'e','w'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
192 L=[0 1 0 0]';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
193 L=kr(L,obj.I_y);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
194 L=L';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
195 case {'s','n'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
196 L=[0 0 1 0]';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
197 L=kr(L,obj.I_x);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
198 L=L';
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
199
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
200 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
201 [closure,penalty]=GeneralBoundaryCond(obj,boundary,L);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
202 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
203
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
204
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
205 function [closure,penalty]=GeneralBoundaryCond(obj,boundary,L)
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
206 params=obj.params;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
207 x=obj.x;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
208 y=obj.y;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
209
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
210 side=max(length(x),length(y));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
211
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
212
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
213 switch boundary
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
214 case {'w','W','west'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
215 e_=obj.e_w;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
216 mat=obj.matrices.A;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
217 boundPos='l';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
218 Hi=obj.Hxi;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
219 [V,Vi,D,signVec]=obj.matrixDiag(mat,x(1),y);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
220 case {'e','E','east'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
221 e_=obj.e_e;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
222 mat=obj.matrices.A;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
223 boundPos='r';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
224 Hi=obj.Hxi;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
225 [V,Vi,D,signVec]=obj.matrixDiag(mat,x(end),y);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
226 case {'s','S','south'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
227 e_=obj.e_s;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
228 mat=obj.matrices.B;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
229 boundPos='l';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
230 Hi=obj.Hxi;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
231 [V,Vi,D,signVec]=obj.matrixDiag(mat,x,y(1));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
232 case {'n','N','north'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
233 e_=obj.e_n;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
234 mat=obj.matrices.B;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
235 boundPos='r';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
236 Hi=obj.Hxi;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
237 [V,Vi,D,signVec]=obj.matrixDiag(mat,x,y(end));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
238 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
239
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
240 pos=signVec(1); zeroval=signVec(2); neg=signVec(3);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
241
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
242
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
243
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
244 switch boundPos
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
245 case {'l'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
246 tau=sparse(4*side,pos*side);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
247 Vi_plus=Vi(1:pos*side,:);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
248 Vi_minus=Vi(pos*side+1:4*side,:);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
249
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
250 V_plus=Vi(:,1:pos*side);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
251 V_minus=Vi(:,(pos+zeroval)*side+1:4*side);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
252
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
253 tau(1:pos*side,:)=-abs(D(1:pos*side,1:pos*side));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
254 R=-inv(L*V_plus)*(L*V_minus);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
255 closure=Hi*e_*V*tau*(Vi_plus-R*Vi_minus)*e_';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
256 penalty=-Hi*e_*V*tau*inv(L*V_plus)*L;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
257
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
258
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
259 case {'r'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
260 tau=sparse(4*side,neg*side);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
261 tau((pos+zeroval)*side+1:4*side,:)=-abs(D((pos+zeroval)*side+1:4*side,(pos+zeroval)*side+1:4*side));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
262 Vi_plus=Vi(1:pos*side,:);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
263 Vi_minus=Vi((pos+zeroval)*side+1:4*side,:);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
264
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
265 V_plus=Vi(:,1:pos*side);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
266 V_minus=Vi(:,(pos+zeroval)*side+1:4*side);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
267 R=-inv(L*V_minus)*(L*V_plus);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
268 closure=Hi*e_*V*tau*(Vi_minus-R*Vi_plus)*e_';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
269 penalty=-Hi*e_*V*tau*inv(L*V_minus)*L;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
270
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
271
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
272 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
273 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
274
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
275
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
276 function [V,Vi, D,signVec]=matrixDiag(obj,mat,x,y)
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
277 params=obj.params;
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
278 syms xs ys;
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
279 [V, D]=eig(mat(params,xs,ys));
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
280 xs=1;ys=1;
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
281 DD=eval(diag(D));
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
282
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
283 poseig=find(DD>0);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
284 zeroeig=find(DD==0);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
285 negeig=find(DD<0);
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
286 syms xs ys
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
287 DD=diag(D);
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
288
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
289 D=diag([DD(poseig);DD(zeroeig); DD(negeig)]);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
290 V=[V(:,poseig) V(:,zeroeig) V(:,negeig)];
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
292 xs=x; ys=y;
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
293
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
294
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
295 side=max(length(x),length(y));
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
296 Dret=zeros(4,side*4);
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
297 Vret=zeros(4,side*4);
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
298 for ii=1:4
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
299 for jj=1:4
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
300 Dret(jj,(ii-1)*side+1:side*ii)=eval(D(jj,ii));
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
301 Vret(jj,(ii-1)*side+1:side*ii)=eval(V(jj,ii));
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
302 end
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
303 end
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
304
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
305 D=sparse(Dret);
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
306 V=sparse(normc(Vret));
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
307 V=obj.matrixBuild(V,x,y);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
308 D=obj.matrixBuild(D,x,y);
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
309 Vi=inv(V);
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
310 signVec=[length(poseig),length(zeroeig),length(negeig)];
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
311 end
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
312
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
313 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
314
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
315 methods(Static)
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
316 % Calculates the matrcis need for the inteface coupling between boundary bound_u of scheme schm_u
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
317 % and bound_v of scheme schm_v.
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
318 % [uu, uv, vv, vu] = inteface_couplong(A,'r',B,'l')
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
319 function [uu, uv, vv, vu] = interface_coupling(schm_u,bound_u,schm_v,bound_v)
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
320 [uu,uv] = schm_u.interface(bound_u,schm_v,bound_v);
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
321 [vv,vu] = schm_v.interface(bound_v,schm_u,bound_u);
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
322 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
323
291
807dfe8be3ec Have made a lot of stupid changes in hypsyst in order to find a stupid bug
Ylva Rydin <ylva.rydin@telia.com>
parents: 290
diff changeset
324
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
325 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
326 end