Mercurial > repos > public > sbplib
diff +scheme/Heat2dVariable.m @ 943:21394c78c72e feature/utux2D
Merge with default
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Tue, 04 Dec 2018 15:24:36 -0800 |
parents | b9c98661ff5d e9e15d64f9f9 |
children | 78db023a7fe3 |
line wrap: on
line diff
--- a/+scheme/Heat2dVariable.m Tue Dec 04 14:54:28 2018 -0800 +++ b/+scheme/Heat2dVariable.m Tue Dec 04 15:24:36 2018 -0800 @@ -1,9 +1,9 @@ classdef Heat2dVariable < scheme.Scheme % Discretizes the Laplacian with variable coefficent, -% In the Heat equation way (i.e., the discretization matrix is not necessarily +% In the Heat equation way (i.e., the discretization matrix is not necessarily % symmetric) -% u_t = div * (kappa * grad u ) +% u_t = div * (kappa * grad u ) % opSet should be cell array of opSets, one per dimension. This % is useful if we have periodic BC in one direction. @@ -28,7 +28,8 @@ H, Hi % Inner products e_l, e_r d1_l, d1_r % Normal derivatives at the boundary - + alpha % Vector of borrowing constants + H_boundary % Boundary inner products end @@ -144,6 +145,7 @@ obj.order = order; obj.grid = g; obj.dim = dim; + obj.alpha = [ops{1}.borrowing.M.d1, ops{2}.borrowing.M.d1]; end @@ -155,12 +157,13 @@ % data is a function returning the data that should be applied at the boundary. % neighbour_scheme is an instance of Scheme that should be interfaced to. % neighbour_boundary is a string specifying which boundary to interface to. - function [closure, penalty] = boundary_condition(obj, boundary, type, parameter) + function [closure, penalty] = boundary_condition(obj, boundary, type, symmetric, tuning) default_arg('type','Neumann'); - default_arg('parameter', []); + default_arg('symmetric', false); + default_arg('tuning',1.2); % j is the coordinate direction of the boundary - % nj: outward unit normal component. + % nj: outward unit normal component. % nj = -1 for west, south, bottom boundaries % nj = 1 for east, north, top boundaries [j, nj] = obj.get_boundary_number(boundary); @@ -176,19 +179,30 @@ Hi = obj.Hi; H_gamma = obj.H_boundary{j}; KAPPA = obj.KAPPA; - kappa_gamma = e{j}'*KAPPA*e{j}; + kappa_gamma = e{j}'*KAPPA*e{j}; + h = obj.h(j); + alpha = h*obj.alpha(j); switch type % Dirichlet boundary condition case {'D','d','dirichlet','Dirichlet'} - closure = -nj*Hi*d{j}*kappa_gamma*H_gamma*(e{j}' ); + + if ~symmetric + closure = -nj*Hi*d{j}*kappa_gamma*H_gamma*(e{j}' ); penalty = nj*Hi*d{j}*kappa_gamma*H_gamma; + else + closure = nj*Hi*d{j}*kappa_gamma*H_gamma*(e{j}' )... + -tuning*2/alpha*Hi*e{j}*kappa_gamma*H_gamma*(e{j}' ) ; + penalty = -nj*Hi*d{j}*kappa_gamma*H_gamma ... + +tuning*2/alpha*Hi*e{j}*kappa_gamma*H_gamma; + end % Free boundary condition case {'N','n','neumann','Neumann'} - closure = -nj*Hi*e{j}*kappa_gamma*H_gamma*(d{j}' ); - penalty = nj*Hi*e{j}*kappa_gamma*H_gamma; + closure = -nj*Hi*e{j}*kappa_gamma*H_gamma*(d{j}' ); + penalty = Hi*e{j}*kappa_gamma*H_gamma; + % penalty is for normal derivative and not for derivative, hence the sign. % Unknown boundary condition otherwise @@ -196,7 +210,7 @@ end end - function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary,opts) + function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) % u denotes the solution in the own domain % v denotes the solution in the neighbour domain error('Interface not implemented');