annotate +sbp/+implementations/intOpMC_orders_2to2_ratio2to1.m @ 1198:2924b3a9b921 feature/d2_compatible

Add OpSet for fully compatible D2Variable, created from regular D2Variable by replacing d1 by first row of D1. Formal reduction by one order of accuracy at the boundary point.
author Martin Almquist <malmquist@stanford.edu>
date Fri, 16 Aug 2019 14:30:28 -0700
parents c923fe6197ff
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
608
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
1 function [IC2F,IF2C] = intOpMC_orders_2to2_ratio2to1(mc)
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
2
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
3 mf = 2*(mc-1) + 1;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
4
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
5 stencil_F2C = [1.0./4.0,1.0./2.0,1.0./4.0];
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
6 stencil_width = length(stencil_F2C);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
7 stencil_halfwidth = (stencil_width-1)/2;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
8
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
9 BC_F2C = [1.0./2.0,1.0./2.0];
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
10
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
11 Hc = speye(mc,mc);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
12 Hc(1,1) = 1/2;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
13 Hc(end,end) = 1/2;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
14
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
15 Hf = 1/2*speye(mf,mf);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
16 Hf(1,1) = 1/4;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
17 Hf(end,end) = 1/4;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
18
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
19 IF2C = sparse(mc,mf);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
20 [BCrows, BCcols] = size(BC_F2C);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
21 IF2C(1:BCrows, 1:BCcols) = BC_F2C;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
22 IF2C(mc-BCrows+1:mc, mf-BCcols+1:mf) = rot90(BC_F2C,2);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
23
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
24 for i = BCrows+1 : mc-BCrows
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
25 IF2C(i,(2*i-stencil_halfwidth-1) :(2*i+stencil_halfwidth-1))...
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
26 = stencil_F2C;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
27 end
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
28
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
29 IC2F = Hf\(IF2C'*Hc);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
30
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
31
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
32
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
33
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
34
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
35