Mercurial > repos > public > sbplib
comparison +scheme/Laplace1d.m @ 1062:e512714fb890 feature/laplace_curvilinear_test
Merge with feature/getBoundaryOp
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Mon, 14 Jan 2019 18:14:44 -0800 |
parents | 2b1b944deae1 |
children | 8d73fcdb07a5 |
comparison
equal
deleted
inserted
replaced
988:a72038b1f709 | 1062:e512714fb890 |
---|---|
54 % neighbour_boundary is a string specifying which boundary to interface to. | 54 % neighbour_boundary is a string specifying which boundary to interface to. |
55 function [closure, penalty] = boundary_condition(obj,boundary,type,data) | 55 function [closure, penalty] = boundary_condition(obj,boundary,type,data) |
56 default_arg('type','neumann'); | 56 default_arg('type','neumann'); |
57 default_arg('data',0); | 57 default_arg('data',0); |
58 | 58 |
59 [e,d,s] = obj.get_boundary_ops(boundary); | 59 [e, d] = obj.getBoundaryOperator({'e', 'd'}, boundary); |
60 s = obj.getBoundarySign(boundary); | |
60 | 61 |
61 switch type | 62 switch type |
62 % Dirichlet boundary condition | 63 % Dirichlet boundary condition |
63 case {'D','dirichlet'} | 64 case {'D','dirichlet'} |
64 tuning = 1.1; | 65 tuning = 1.1; |
84 end | 85 end |
85 | 86 |
86 function [closure, penalty] = interface(obj, boundary, neighbour_scheme, neighbour_boundary, type) | 87 function [closure, penalty] = interface(obj, boundary, neighbour_scheme, neighbour_boundary, type) |
87 % u denotes the solution in the own domain | 88 % u denotes the solution in the own domain |
88 % v denotes the solution in the neighbour domain | 89 % v denotes the solution in the neighbour domain |
90 [e_u, d_u] = obj.getBoundaryOperator({'e', 'd'}, boundary); | |
91 s_u = obj.getBoundarySign(boundary); | |
89 | 92 |
90 [e_u,d_u,s_u] = obj.get_boundary_ops(boundary); | 93 [e_v, d_v] = neighbour_scheme.getBoundaryOperator({'e', 'd'}, neighbour_boundary); |
91 [e_v,d_v,s_v] = neighbour_scheme.get_boundary_ops(neighbour_boundary); | 94 s_v = neighbour_scheme.getBoundarySign(neighbour_boundary); |
92 | |
93 | 95 |
94 a_u = obj.a; | 96 a_u = obj.a; |
95 a_v = neighbour_scheme.a; | 97 a_v = neighbour_scheme.a; |
96 | 98 |
97 gamm_u = obj.gamm; | 99 gamm_u = obj.gamm; |
109 | 111 |
110 closure = obj.Hi*( tau*e_u' + sig*a_u*d_u'); | 112 closure = obj.Hi*( tau*e_u' + sig*a_u*d_u'); |
111 penalty = obj.Hi*(-tau*e_v' + sig*a_v*d_v'); | 113 penalty = obj.Hi*(-tau*e_v' + sig*a_v*d_v'); |
112 end | 114 end |
113 | 115 |
114 % Ruturns the boundary ops and sign for the boundary specified by the string boundary. | 116 % Returns the boundary operator op for the boundary specified by the string boundary. |
115 % The right boundary is considered the positive boundary | 117 % op -- string or a cell array of strings |
116 function [e,d,s] = get_boundary_ops(obj,boundary) | 118 % boundary -- string |
119 function varargout = getBoundaryOperator(obj, op, boundary) | |
120 | |
121 if ~iscell(op) | |
122 op = {op}; | |
123 end | |
124 | |
125 for i = 1:numel(op) | |
126 switch op{i} | |
127 case 'e' | |
128 switch boundary | |
129 case 'l' | |
130 e = obj.e_l; | |
131 case 'r' | |
132 e = obj.e_r; | |
133 otherwise | |
134 error('No such boundary: boundary = %s',boundary); | |
135 end | |
136 varargout{i} = e; | |
137 | |
138 case 'd' | |
139 switch boundary | |
140 case 'l' | |
141 d = obj.d_l; | |
142 case 'r' | |
143 d = obj.d_r; | |
144 otherwise | |
145 error('No such boundary: boundary = %s',boundary); | |
146 end | |
147 varargout{i} = d; | |
148 end | |
149 end | |
150 end | |
151 | |
152 % Returns the boundary sign. The right boundary is considered the positive boundary | |
153 % boundary -- string | |
154 function s = getBoundarySign(obj, boundary) | |
117 switch boundary | 155 switch boundary |
118 case 'l' | 156 case {'r'} |
119 e = obj.e_l; | 157 s = 1; |
120 d = obj.d_l; | 158 case {'l'} |
121 s = -1; | 159 s = -1; |
122 case 'r' | |
123 e = obj.e_r; | |
124 d = obj.d_r; | |
125 s = 1; | |
126 otherwise | 160 otherwise |
127 error('No such boundary: boundary = %s',boundary); | 161 error('No such boundary: boundary = %s',boundary); |
128 end | 162 end |
129 end | 163 end |
130 | 164 |