Mercurial > repos > public > sbplib
annotate +util/tt2t.m @ 815:fae41958af4f feature/burgers1d
Add support for artificial viscosity to the 1d burgers scheme.
- Add support for artificial viscosity by parametrizing the discretization operator and boundary closure on the viscosity.
- Add a time stepper which evaluates and updates the residual viscosity of the solution.
author | Vidar Stiernstrom <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 06 Sep 2018 12:43:51 +0200 |
parents | 48b6fb693025 |
children |
rev | line source |
---|---|
0 | 1 % Converts a semidiscretized PDE from second order in time to first order in time. |
2 % v_tt = Dv + S | |
3 % becomes | |
4 % w_t = Mw + C | |
5 % where | |
6 % w = [ v ; v_t] | |
7 % and | |
8 % M = [0 I; | |
9 % D 0]; | |
10 % C = [0; | |
11 % S]; | |
12 function [M,C] = tt2t(D,S) | |
13 default_arg('S',sparse(size(D))) | |
14 time_dependent_bc = isa(S,'function_handle'); | |
15 | |
16 I = eye(size(D)); | |
17 O = zeros(size(D)); | |
18 | |
19 M = [O I; | |
20 D O]; | |
21 | |
22 if ~time_dependent_bc | |
23 C = [zeros(size(S)); S]; | |
24 else | |
25 o = zeros(size(S(0))); | |
26 C = @(t)([o; S(t)]); | |
27 end | |
28 end |