comparison +scheme/Utux2d.m @ 1022:234c1c02ea39 feature/advectionRV

Add dirichlet bc for north and south boundary and handle cases where the wave speed changes in sign.
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Mon, 07 Jan 2019 12:06:06 +0100
parents cc61dde120cd
children ac80bedc8df7
comparison
equal deleted inserted replaced
1021:cc61dde120cd 1022:234c1c02ea39
103 if (isequal(opSet,@sbp.D1Upwind)) 103 if (isequal(opSet,@sbp.D1Upwind))
104 obj.D = -(a{1}*obj.Dx + a{2}*obj.Dy + fluxSplitting{1}*obj.DissOpx + fluxSplitting{2}*obj.DissOpy); 104 obj.D = -(a{1}*obj.Dx + a{2}*obj.Dy + fluxSplitting{1}*obj.DissOpx + fluxSplitting{2}*obj.DissOpy);
105 else 105 else
106 obj.D = -(a{1}*obj.Dx + a{2}*obj.Dy); 106 obj.D = -(a{1}*obj.Dx + a{2}*obj.Dy);
107 end 107 end
108
109 end 108 end
110 % Closure functions return the opertors applied to the own domain to close the boundary 109 % Closure functions return the opertors applied to the own domain to close the boundary
111 % Penalty functions return the opertors to force the solution. In the case of an interface it returns the operator applied to the other doamin. 110 % Penalty functions return the opertors to force the solution. In the case of an interface it returns the operator applied to the other doamin.
112 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'. 111 % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'.
113 % type is a string specifying the type of boundary condition if there are several. 112 % type is a string specifying the type of boundary condition if there are several. %TBD Remove type here? Only dirichlet applicable?
114 % data is a function returning the data that should be applied at the boundary. 113 % data is a function returning the data that should be applied at the boundary.
115 % neighbour_scheme is an instance of Scheme that should be interfaced to. 114 % neighbour_scheme is an instance of Scheme that should be interfaced to.
116 % neighbour_boundary is a string specifying which boundary to interface to. 115 % neighbour_boundary is a string specifying which boundary to interface to.
117 function [closure, penalty] = boundary_condition(obj,boundary,type) 116 function [closure, penalty] = boundary_condition(obj,boundary,type)
118 default_arg('type','dirichlet'); 117 default_arg('type','dirichlet');
119 118 sigma_left = -1; % Scalar penalty parameter for left boundaries
120 sigma = -1; % Scalar penalty parameter 119 sigma_right = 1; % Scalar penalty parameter for right boundaries
121 switch boundary 120 switch boundary
122 case {'w','W','west','West'} 121 case {'w','W','west','West'}
123 tau = sigma*obj.a{1}*obj.e_w*obj.H_y; 122 % Can only specify boundary condition where there is inflow
123 % Extract positive part of a{1}
124 a_pos = obj.a{1};
125 a_pos(a_pos < 0) = 0;
126 tau = sigma_left*a_pos*obj.e_w*obj.H_y;
124 closure = obj.Hi*tau*obj.e_w'; 127 closure = obj.Hi*tau*obj.e_w';
125
126 case {'s','S','south','South'} 128 case {'s','S','south','South'}
127 tau = sigma*obj.a{2}*obj.e_s*obj.H_x; 129 % Can only specify boundary condition where there is inflow
130 % Extract positive part of a{2}
131 a_pos = obj.a{2};
132 a_pos(a_pos < 0) = 0;
133 tau = sigma_left*a_pos*obj.e_s*obj.H_x;
128 closure = obj.Hi*tau*obj.e_s'; 134 closure = obj.Hi*tau*obj.e_s';
135 case {'e','E','east','East'}
136 % Can only specify boundary condition where there is inflow
137 % Extract negative part of a{1}
138 a_neg = obj.a{1};
139 a_neg(a_neg > 0) = 0;
140 tau = sigma_right*a_neg*obj.e_e*obj.H_y;
141 closure = obj.Hi*tau*obj.e_e';
142 case {'n','N','north','North'}
143 % Can only specify boundary condition where there is inflow
144 % Extract negative part of a{2}
145 a_neg = obj.a{2};
146 a_neg(a_neg > 0) = 0;
147 tau = sigma_right*a_neg*obj.e_n*obj.H_x;
148 closure = obj.Hi*tau*obj.e_n';
129 end 149 end
130 penalty = -obj.Hi*tau; 150 penalty = -obj.Hi*tau;
131
132 end 151 end
133 152
134 % type Struct that specifies the interface coupling. 153 % type Struct that specifies the interface coupling.
135 % Fields: 154 % Fields:
136 % -- couplingType String, type of interface coupling 155 % -- couplingType String, type of interface coupling