📄 restrict_dcoef.m
字号:
function [dcoefxh,dcoefyh] = restrict_dcoef(dcoefxh,dcoefyh,nlevels) % [dcoefxH,dcoefyH] = restrict_dcoef(dcoefxh,dcoefyh,nlevels)%% Restrict diffusion coefficient for CCFD discretization of % the differential operator% Lv = -div( dcoef grad u)% = -d/dx(dcoef du/dx) - d/dy(dcoef du/dy)% to coarse grid. [nm1,n] = size(dcoefxh); [tmp1,tmp2] = size(dcoefyh); if n-1 ~= nm1 disp(' *** Error in restrict_dcoef.m. Size of dcoefxh is incorrect ***'); return elseif tmp1-1 ~= tmp2 disp('*** Error in restrict_dcoef.m. Size of dcoefyh is incorrect ***'); return elseif tmp1 ~= n disp('*** Error in restrict_dcoef.m. size(dcoefxh) ~= size(dcoefyh`) ***'); return end if nargin == 2 nlevels = 1; elseif log2(n) < nlevels + 1 disp(' *** Error in restrict_dcoef.m. Too many restriction levels ***'); return end for kk = 1:nlevels tmp = dcoefxh(2:2:nm1,:); dcoefxh = (tmp(:,1:2:nm1) + tmp(:,2:2:n)) / 4; tmp = dcoefyh(:,2:2:nm1); dcoefyh = (tmp(1:2:nm1,:) + tmp(2:2:n,:)) / 4; n = n/2; nm1 = n-1; end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -