Mercurial > repos > public > sbplib
diff +util/tt2t.m @ 0:48b6fb693025
Initial commit.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 17 Sep 2015 10:12:50 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/+util/tt2t.m Thu Sep 17 10:12:50 2015 +0200 @@ -0,0 +1,28 @@ +% Converts a semidiscretized PDE from second order in time to first order in time. +% v_tt = Dv + S +% becomes +% w_t = Mw + C +% where +% w = [ v ; v_t] +% and +% M = [0 I; +% D 0]; +% C = [0; +% S]; +function [M,C] = tt2t(D,S) + default_arg('S',sparse(size(D))) + time_dependent_bc = isa(S,'function_handle'); + + I = eye(size(D)); + O = zeros(size(D)); + + M = [O I; + D O]; + + if ~time_dependent_bc + C = [zeros(size(S)); S]; + else + o = zeros(size(S(0))); + C = @(t)([o; S(t)]); + end +end