Mercurial > repos > public > sbplib
changeset 284:dae8c3a56f5e
Merged in operator_remake (pull request #2)
Operator remake
author | Jonatan Werpers <jonatan.werpers@it.uu.se> |
---|---|
date | Mon, 12 Sep 2016 12:53:02 +0200 |
parents | 18c023aaf3f7 (diff) 728fdc431212 (current diff) |
children | 70184f6c6cb5 |
files | +sbp/BlockNorm.m +sbp/Higher.m +sbp/HigherCompatible.m +sbp/HigherCompatibleVariable.m +sbp/HigherPeriodic.m +sbp/Ordinary.m +sbp/Upwind.m +sbp/Variable.m +sbp/blocknorm10.m +sbp/blocknorm4.m +sbp/blocknorm6.m +sbp/blocknorm8.m +sbp/higher2_compatible_halfvariable.m +sbp/higher4.m +sbp/higher4_compatible_halfvariable.m +sbp/higher6.m +sbp/higher6_compatible_halfvariable.m +sbp/higher_compatible2.m +sbp/higher_compatible4.m +sbp/higher_compatible6.m +sbp/ordinary10.m +sbp/ordinary2.m +sbp/ordinary4.m +sbp/ordinary6.m +sbp/ordinary8.m +sbp/upwind2.m +sbp/upwind3.m +sbp/upwind4.m +sbp/upwind5.m +sbp/upwind6.m +sbp/upwind7.m +sbp/upwind8.m +sbp/upwind9.m +sbp/variable4.m |
diffstat | 2 files changed, 92 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/+scheme/Utux.m Mon Sep 12 12:53:02 2016 +0200 @@ -0,0 +1,75 @@ +classdef Utux < scheme.Scheme + properties + m % Number of points in each direction, possibly a vector + h % Grid spacing + x % Grid + order % Order accuracy for the approximation + + H % Discrete norm + M % Derivative norm + D + + D1 + Hi + e_l + e_r + v0 + end + + + methods + function obj = Utux(m,xlim,order) + default_arg('a',1); + [x, h] = util.get_grid(xlim{:},m); + ops = sbp.Ordinary(m,h,order); + + obj.D1 = sparse(ops.derivatives.D1); + obj.H = sparse(ops.norms.H); + obj.Hi = sparse(ops.norms.HI); + obj.M = sparse(ops.norms.M); + obj.e_l = sparse(ops.boundary.e_1); + obj.e_r = sparse(ops.boundary.e_m); + obj.D=obj.D1; + + obj.m = m; + obj.h = h; + obj.order = order; + obj.x = x; + + end + % Closure functions return the opertors applied to the own doamin to close the boundary + % Penalty functions return the opertors to force the solution. In the case of an interface it returns the operator applied to the other doamin. + % boundary is a string specifying the boundary e.g. 'l','r' or 'e','w','n','s'. + % type is a string specifying the type of boundary condition if there are several. + % 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,data) + default_arg('type','neumann'); + default_arg('data',0); + tau = -1*obj.e_l; + closure = obj.Hi*tau*obj.e_l'; + penalty = 0*obj.e_l; + + end + + function [closure, penalty] = interface(obj,boundary,neighbour_scheme,neighbour_boundary) + error('An interface function does not exist yet'); + end + + function N = size(obj) + N = obj.m; + end + + end + + methods(Static) + % Calculates the matrcis need for the inteface coupling between boundary bound_u of scheme schm_u + % and bound_v of scheme schm_v. + % [uu, uv, vv, vu] = inteface_couplong(A,'r',B,'l') + function [uu, uv, vv, vu] = interface_coupling(schm_u,bound_u,schm_v,bound_v) + [uu,uv] = schm_u.interface(bound_u,schm_v,bound_v); + [vv,vu] = schm_v.interface(bound_v,schm_u,bound_u); + end + end +end \ No newline at end of file
--- a/savepng.m Mon Sep 12 12:53:02 2016 +0200 +++ b/savepng.m Mon Sep 12 12:53:02 2016 +0200 @@ -1,6 +1,21 @@ +% TODO +% Let print size in inches as input parameter +% Smaller boundingbox function savepng(h, filename, dpi) default_arg('dpi', 300) + + handle_units = h.Units; % Save the current units to be able to restore + + % Copy size of figure in centimeters to a place where saveas will honor it + h.Units = 'centimeters'; + h.PaperUnits = 'centimeters'; + h.PaperPosition(3:4) = h.Position(3:4); + + % Save as a bugged eps file. print(h,filename,'-dpng',sprintf('-r%d',dpi)); - % Let print size in inches as input parameter - % Smaller boundingbox + + h.Units = handle_units; % Restore the old units + + + end