⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testcollocpotro.m

📁 本代码为基于matlab的求解偏微分方程的利用径向基函数的无网格方法的源码
💻 M
字号:
% This is the test driver for the potential collocation problem.% Not yet finished, work in progress.
% Before starting this program, please run Collocation.m to define the global% variables%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% generate boundary and interior pointsif RBFdomain==7    domaincreator %m-file    intpoints=[intpoints;bndpoints];                 % use boundary points also as "interior"elsebndpoints=regbndpointsRO(RBFstepsize);   intpoints=[regintpointsRO(RBFstepsize) ; bndpoints]; % use boundary points also as "interior"
end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% plot points, for checkingfigure(2) ; cla
plot(intpoints(:,1),intpoints(:,2),'.')
axis equal
hold on
plot(bndpoints(:,1),bndpoints(:,2),'O');title('Collocation Points');hold off;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%[nint,nintdim]=size(intpoints);intvalues=zeros(nint,1);                                % rhs values in interior
bndvalues=fct2D(bndpoints(:,1),bndpoints(:,2));         % rhs values on boundary%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% solve the linear system
result = rbfLapsolvecond (intpoints, intvalues, bndpoints, bndvalues); 
coeff=result{1};
condition=result{2};handel=findobj('Tag','text3');set(handel,'String',['Condition of matrix: ',num2str(condition)]);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% now evaluate the solution at given boundary points, data must be reproduced  
bndrepvalues = rbfPeval (bndpoints, intpoints, bndpoints, coeff);
bnderrnorm=max(bndrepvalues-bndvalues); % should be small
handel=findobj('Tag','text4');set(handel,'String',['largest error at boundary collocation  points: ',num2str(bnderrnorm)]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(3)   % now test for some more boundary pointsclaif RBFdomain==7    bndtestpoints=onpolygon(RBFstepsize.*0.05,vertex);else
bndtestpoints=regbndpointsRO(RBFstepsize.*0.05);end% now evaluate the solution at the boundary 
bndrepvalues = rbfPeval (bndtestpoints, intpoints, bndpoints, coeff);
plot(bndrepvalues-fct2D(bndtestpoints(:,1),bndtestpoints(:,2))); % plots error on boundary 
title('Error on boundary');hold off;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% now evaluate the Laplacian of the solution at given interior points, data must be reproduced  
intrepvalues = rbfLPeval (intpoints, intpoints, bndpoints, coeff);
interrnorm=max(intrepvalues-intvalues); % should be small
handel=findobj('Tag','text5');set(handel,'String',['largest error of the Laplacian at  interior  collocation points: ',num2str(bnderrnorm)]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% now we create a fine grid 
np=3*ceil(2/RBFstepsize);
[X,Y]=meshgrid(-1:2/(np-1):1,-1:2/(np-1):1);
xr=reshape(X,[(np)*(np) 1]);
yr=reshape(Y,[(np)*(np) 1]);
datapoints=[xr yr];if RBFdomain==7   in=inpolygon(X,Y,vertex(:,1),vertex(:,2));mask=in==1;else    in=domainfct(X,Y);    mask=in<=0;
end;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% now we evaluate the approximation on a fine grid 
figure(4) cla
datarepvalues = rbfPeval (datapoints, intpoints, bndpoints, coeff);
surfc(X,Y,mask.*reshape(datarepvalues,[np np]));
shading interp;hold ontitle('the plot shows the approximation inside the domain');
hold off%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% now we evaluate the Laplacian of the approximation on a fine grid 
figure(5) cla
datarepvalues = rbfLPeval (datapoints, intpoints, bndpoints, coeff);
surfc(X,Y,mask.*reshape(datarepvalues,[np np]));
shading interp;hold ontitle('the plot shows: Laplace[approximation] inside the domain');
handel=findobj('Tag','text6');error=max(max(abs(mask.*reshape(datarepvalues,[np np]))));set(handel,'String',['largest value  of Laplacian  inside the domain    : ',num2str(error)]);
hold off;handel=findobj('Tag','text7');set(handel,'String','');
figure(6)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -