annotate +sbp/+implementations/intOpAWW_orders_6to6_ratio2to1.m @ 608:c923fe6197ff feature/interpolation

Add inerpolation operator classes and implementations for MC and AWW.
author Martin Almquist <malmquist@stanford.edu>
date Sat, 14 Oct 2017 22:32:25 -0700
parents
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,Hc,Hf] = IntOp_orders_6to6_ratio2to1(mc,hc,ACC)
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 % ACC is a string.
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
4 % ACC = 'C2F' creates IC2F with one order of accuracy higher than IF2C.
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
5 % ACC = 'F2C' creates IF2C with one order of accuracy higher than IC2F.
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
6 ratio = 2;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
7 mf = ratio*mc-1;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
8 hf = hc/ratio;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
9
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
10 switch ACC
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
11 case 'F2C'
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
12 [stencil_F2C,BC_F2C,HcU,HfU] = ...
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
13 sbp.implementations.intOpAWW_orders_6to6_ratio_2to1_accC2F3_accF2C4;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
14 case 'C2F'
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
15 [stencil_F2C,BC_F2C,HcU,HfU] = ...
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
16 sbp.implementations.intOpAWW_orders_6to6_ratio_2to1_accC2F4_accF2C3;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
17 end
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 stencil_width = length(stencil_F2C);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
20 stencil_hw = (stencil_width-1)/2;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
21 [BC_rows,BC_cols] = size(BC_F2C);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
22
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
23 %%% Norm matrices %%%
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
24 Hc = speye(mc,mc);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
25 HcUm = length(HcU);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
26 Hc(1:HcUm,1:HcUm) = spdiags(HcU',0,HcUm,HcUm);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
27 Hc(mc-HcUm+1:mc,mc-HcUm+1:mc) = spdiags(rot90(HcU',2),0,HcUm,HcUm);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
28 Hc = Hc*hc;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
29
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
30 Hf = speye(mf,mf);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
31 HfUm = length(HfU);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
32 Hf(1:HfUm,1:HfUm) = spdiags(HfU',0,HfUm,HfUm);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
33 Hf(mf-length(HfU)+1:mf,mf-length(HfU)+1:mf) = spdiags(rot90(HfU',2),0,HfUm,HfUm);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
34 Hf = Hf*hf;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
35 %%%%%%%%%%%%%%%%%%%%%%
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
36
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
37 %%% Create IF2C from stencil and BC
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
38 IF2C = sparse(mc,mf);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
39 for i = BC_rows+1 : mc-BC_rows
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
40 IF2C(i,ratio*i-1+(-stencil_hw:stencil_hw)) = stencil_F2C; %#ok<SPRIX>
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
41 end
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
42 IF2C(1:BC_rows,1:BC_cols) = BC_F2C;
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
43 IF2C(end-BC_rows+1:end,end-BC_cols+1:end) = rot90(BC_F2C,2);
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
45
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
46 %%% Create IC2F using symmetry condition %%%%
c923fe6197ff Add inerpolation operator classes and implementations for MC and AWW.
Martin Almquist <malmquist@stanford.edu>
parents:
diff changeset
47 IC2F = Hf\IF2C.'*Hc;