Home > src > matlab > interpolCentersToFacesD1D.m

interpolCentersToFacesD1D

PURPOSE ^

1D interpolation from centers to faces.

SYNOPSIS ^

function I = interpolCentersToFacesD1D(k, m)

DESCRIPTION ^

 1D interpolation from centers to faces.
 logical centers are [1 1.5 2.5 ... m-1.5 m-0.5 m]
 m is the number of cells in the logic x-axis
 ----------------------------------------------------------------------------
 SPDX-License-Identifier: GPL-3.0-or-later
 © 2008-2024 San Diego State University Research Foundation (SDSURF).
 See LICENSE file or https://www.gnu.org/licenses/gpl-3.0.html for details.
 ----------------------------------------------------------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function I = interpolCentersToFacesD1D(k, m)
0002 % 1D interpolation from centers to faces.
0003 % logical centers are [1 1.5 2.5 ... m-1.5 m-0.5 m]
0004 % m is the number of cells in the logic x-axis
0005 % ----------------------------------------------------------------------------
0006 % SPDX-License-Identifier: GPL-3.0-or-later
0007 % © 2008-2024 San Diego State University Research Foundation (SDSURF).
0008 % See LICENSE file or https://www.gnu.org/licenses/gpl-3.0.html for details.
0009 % ----------------------------------------------------------------------------
0010 
0011     I = sparse(m+1, m+2);
0012 
0013     switch k
0014         case 2
0015             I(1, 1) = 2; I(end, end) = 2;
0016             for i = 2:m
0017                I(i, i:i+1) = [1 1];
0018             end
0019             denom = 2;
0020 
0021         case 4
0022             I(1, 1) = 112; I(end, end) = 112;
0023             A = [-16 70 70 -14 2];
0024             I(2, 1:5) = A;
0025             I(m, m-2:end) = fliplr(A);
0026             for i = 3:m-1
0027                I(i, i-1:i+2) = [-7 63 63 -7];
0028             end
0029             denom = 112;
0030 
0031         case 6
0032             I(1, 1) = 8448; I(end, end) = 8448;
0033             A = [-768 4158 6930 -2772  1188 -330  42; ...
0034                   256 -924 4620  5544 -1320  308 -36];
0035             I(2:3, 1:7) = A;
0036             I(m-1:m, m-4:end) = flipud(fliplr(A));%#ok
0037             for i = 4:m-2
0038                 I(i, i-2:i+3) = [99 -825 4950 4950 -825 99];
0039             end
0040             denom = 8448;
0041 
0042         case 8
0043             I(1, 1) = 1; I(end, end) = 1;
0044             A = [-1/15  429/1024 1001/1024 -3003/5120  429/1024 -715/3072  91/1024   -21/1024  11/5120; ...
0045                   1/65  -33/512   231/512   2079/2560 -165/512    77/512  -27/512     77/6656  -3/2560; ...
0046                  -1/143  27/1024 -105/1024   567/1024  675/1024 -175/1024 567/11264 -135/13312  1/1024];
0047             I(2:4, 1:9) = A;
0048             I(m-2:m, m-6:end) = flipud(fliplr(A));%#ok
0049             for i = 5:m-3
0050                 I(i, i-3:i+4) = (1/2048).*[-5 49 -245 1225 1225 -245 49 -5];
0051             end
0052             denom = 1;   
0053 
0054     end
0055     I = (1/denom).*I;
0056 end

Generated on Tue 18-Mar-2025 18:53:27 by m2html © 2003-2022