annotate +scheme/hypsyst2d.m @ 293:2d604d16842c feature/hypsyst

Works with varying coefficients and char boundary condition
author Ylva Rydin <ylva.rydin@telia.com>
date Fri, 23 Sep 2016 16:30:51 +0200
parents 3d275c5e45b3
children 8ff6ec6249e8
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
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
4 n %size of system
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
5 h % Grid spacing
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
6 x,y % Grid
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
7 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
8 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
9
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
10 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
11 A, B, E
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
12
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
13 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
14 % 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
15 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
16 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
17 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
18 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
19 matrices
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
20 end
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
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
23 methods
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
24 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
25
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
26 xlim = lim{1};
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
27 ylim = lim{2};
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
28
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
29 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
30 m = [m m];
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
31 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
32
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
33 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
34 m_y = m(2);
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
35 obj.params=params;
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
36
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
37 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
38
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
39 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
40 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
41
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
42 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
43 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
44
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
45 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
46 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
47
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
48 obj.A=obj.matrixBuild(matrices.A);
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
49 obj.B=obj.matrixBuild(matrices.B);
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
50 obj.E=obj.matrixBuild(matrices.E);
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
51
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
52 obj.n=length(matrices.A(obj.params,0,0));
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
53
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
54 I_n= eye(obj.n);
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
55 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
56 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
57
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
58
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
59 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
60 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
61 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
62 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
63
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
64 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
65 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
66 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
67 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
68
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
69 obj.m=m;
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
70 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
71 obj.order=order;
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
72
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
73 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
74
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
75 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
76 % 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
77 % 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
78 % 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
79 % 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
80 % 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
81 % 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
82 % neighbour_boundary is a string specifying which boundary to interface to.
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
83 function [closure, penalty] = boundary_condition(obj,boundary,type,L)
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
84 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
85 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
86
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
87 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
88 case{'c','char'}
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
89 [closure,penalty]=GetBoundarydata_char(obj,boundary);
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
90 case{'general'}
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
91 [closure,penalty]=GeneralBoundaryCond(obj,boundary,L);
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
92 otherwise
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
93 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
94 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
95 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
96
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
97 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
98 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
99 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
100
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
101 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
102 N = obj.m;
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
103 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
104
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
105 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
106 %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
107 %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
108 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
109 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
110 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
111
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
112 if isa(mat,'function_handle')
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
113 [rows,cols]=size(mat(params,0,0));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
114 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
115 matVec=sparse(matVec);
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
116 side=max(length(X),length(Y));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
117 else
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
118 matVec=mat;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
119 [rows,cols]=size(matVec);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
120 side=max(length(x),length(y));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
121 cols=cols/side;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
122 end
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
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
125 ret=kron(ones(rows,cols),speye(side));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
126
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
127 for ii=1:rows
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
128 for jj=1:cols
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
129 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
130 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
131 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
132
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
133 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
134
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
135
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
136 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
137 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
138 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
139 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
140
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 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
142
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 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
144 case {'w','W','west'}
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
145 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
146 mat=obj.matrices.A;
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
147 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
148 Hi=obj.Hxi;
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
149 [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
150 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
151 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
152 mat=obj.matrices.A;
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
153 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
154 Hi=obj.Hxi;
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
155 [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
156 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
157 e_=obj.e_s;
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
158 mat=obj.matrices.B;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
159 boundPos='l';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
160 Hi=obj.Hxi;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
161 [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
162 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
163 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
164 mat=obj.matrices.B;
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
165 boundPos='r';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
166 Hi=obj.Hxi;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
167 [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
168 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
169
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
170 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
171
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
172 switch boundPos
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
173 case {'l'}
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
174 tau=sparse(obj.n*side,pos*side);
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
175 Vi_plus=Vi(1:pos*side,:);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
176 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
177 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
178 penalty=-Hi*e_*V*tau*Vi_plus;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
179
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
180 case {'r'}
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
181 tau=sparse(obj.n*side,neg*side);
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
182 tau((pos+zeroval)*side+1:obj.n*side,:)=-abs(D((pos+zeroval)*side+1:obj.n*side,(pos+zeroval)*side+1:obj.n*side));
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
183 Vi_minus=Vi((pos+zeroval)*side+1:obj.n*side,:);
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
184 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
185 penalty=-Hi*e_*V*tau*Vi_minus;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
186
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 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
189
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
190
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
191 function [closure,penalty]=GeneralBoundaryCond(obj,boundary,L)
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
192 params=obj.params;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
193 x=obj.x;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
194 y=obj.y;
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
195 L=obj.matrixBuild(L,x,y);
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
196 side=max(length(x),length(y));
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
197
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
198
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
199 switch boundary
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
200 case {'w','W','west'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
201 e_=obj.e_w;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
202 mat=obj.matrices.A;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
203 boundPos='l';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
204 Hi=obj.Hxi;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
205 [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
206 case {'e','E','east'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
207 e_=obj.e_e;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
208 mat=obj.matrices.A;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
209 boundPos='r';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
210 Hi=obj.Hxi;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
211 [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
212 case {'s','S','south'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
213 e_=obj.e_s;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
214 mat=obj.matrices.B;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
215 boundPos='l';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
216 Hi=obj.Hxi;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
217 [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
218 case {'n','N','north'}
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
219 e_=obj.e_n;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
220 mat=obj.matrices.B;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
221 boundPos='r';
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
222 Hi=obj.Hxi;
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
223 [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
224 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
225
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
226 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
227
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
228
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
229
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
230 switch boundPos
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
231 case {'l'}
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
232 tau=sparse(obj.n*side,pos*side);
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
233 Vi_plus=Vi(1:pos*side,:);
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
234 Vi_minus=Vi(pos*side+1:obj.n*side,:);
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
235
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
236 V_plus=Vi(:,1:pos*side);
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
237 V_minus=Vi(:,(pos+zeroval)*side+1:obj.n*side);
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
238
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
239 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
240 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
241 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
242 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
243
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
244
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
245 case {'r'}
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
246 tau=sparse(obj.n*side,neg*side);
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
247 tau((pos+zeroval)*side+1:obj.n*side,:)=-abs(D((pos+zeroval)*side+1:obj.n*side,(pos+zeroval)*side+1:obj.n*side));
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
248 Vi_plus=Vi(1:pos*side,:);
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
249 Vi_minus=Vi((pos+zeroval)*side+1:obj.n*side,:);
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
250
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
251 V_plus=Vi(:,1:pos*side);
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
252 V_minus=Vi(:,(pos+zeroval)*side+1:obj.n*side);
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
253 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
254 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
255 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
256
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 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
259 end
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
260
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
261
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
262 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
263 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
264 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
265 [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
266 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
267 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
268
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
269 poseig=find(DD>0);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
270 zeroeig=find(DD==0);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
271 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
272 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
273 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
274
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
275 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
276 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
277
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 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
279
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
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 side=max(length(x),length(y));
293
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
282 Dret=zeros(obj.n,side*obj.n);
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
283 Vret=zeros(obj.n,side*obj.n);
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
284 for ii=1:obj.n
2d604d16842c Works with varying coefficients and char boundary condition
Ylva Rydin <ylva.rydin@telia.com>
parents: 292
diff changeset
285 for jj=1:obj.n
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 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
287 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
288 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
289 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
290
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 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
292 V=sparse(normc(Vret));
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
293 V=obj.matrixBuild(V,x,y);
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
294 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
295 Vi=inv(V);
292
3d275c5e45b3 Changed how the matrices are built
Ylva Rydin <ylva.rydin@telia.com>
parents: 291
diff changeset
296 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
297 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
298
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
299 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
300
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
301 methods(Static)
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
302 % 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
303 % 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
304 % [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
305 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
306 [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
307 [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
308 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
309
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
310
290
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
311 end
d32f674bcbe5 A first attempt to make a general scheme fo hyperbolic systems
Ylva Rydin <ylva.rydin@telia.com>
parents:
diff changeset
312 end