How can I set the mesh for this PDE? Is there any way to solve it by iterative methods from this code?

2 views (last 30 days)
Hey guys. I need help solving an elliptical PDE. I used a MATLAB app to solve my problem and saved the solution script. The script says I can't make changes directly and gives me two options. However I'm a newbie and I don't know what to do. I just want to use a square mesh and not a triangular one, if possible I would like to choose the mesh size (distance between each node). To make it clear, all Dirichlet and Neumann conditions are as I want, I just want to change the mesh. Furthermore, can I use the data from this problem to solve it through the SOR iterative method?
% This script is written and read by pdetool and should NOT be edited.
% There are two recommended alternatives:
% 1) Export the required variables from pdetool and create a MATLAB script
% to perform operations on these.
% 2) Define the problem completely using a MATLAB script. See
% http://www.mathworks.com/help/pde/examples/index.html for examples
% of this approach.
function pdemodel
[pde_fig,ax]=pdeinit;
pdetool('appl_cb',1);
set(ax,'DataAspectRatio',[3.5 3.5 1]);
set(ax,'PlotBoxAspectRatio',[1 1 1]);
set(ax,'XLim',[-1 6]);
set(ax,'YLim',[-1 6]);
set(ax,'XTickMode','auto');
set(ax,'YTickMode','auto');
% Geometry description:
pderect([0 5 0 5],'SQ1');
set(findobj(get(pde_fig,'Children'),'Tag','PDEEval'),'String','SQ1')
% Boundary conditions:
pdetool('changemode',0)
pdesetbd(4,...
'dir',...
1,...
'1',...
'75')
pdesetbd(3,...
'dir',...
1,...
'1',...
'0')
pdesetbd(2,...
'neu',...
1,...
'0',...
'0')
pdesetbd(1,...
'dir',...
1,...
'1',...
'50')
% Mesh generation:
setappdata(pde_fig,'Hgrad',1.3);
setappdata(pde_fig,'refinemethod','regular');
setappdata(pde_fig,'jiggle',char('on','mean',''));
setappdata(pde_fig,'MesherVersion','preR2013a');
pdetool('initmesh')
% PDE coefficients:
pdeseteq(1,...
'1.0',...
'0.0',...
'0',...
'1.0',...
'0:10',...
'0.0',...
'0.0',...
'[0 100]')
setappdata(pde_fig,'currparam',...
['1.0';...
'0.0';...
'0 ';...
'1.0'])
% Solve parameters:
setappdata(pde_fig,'solveparam',...
char('0','1000','10','pdeadworst',...
'0.5','longest','0','1E-4','','fixed','Inf'))
% Plotflags and user data strings:
setappdata(pde_fig,'plotflags',[1 1 1 1 1 1 7 1 0 1 0 1 1 0 0 0 0 1]);
setappdata(pde_fig,'colstring','');
setappdata(pde_fig,'arrowstring','');
setappdata(pde_fig,'deformstring','');
setappdata(pde_fig,'heightstring','');
% Solve PDE:
pdetool('solve')
It returns the correctly solution that I'm looking for, but not how I would like to:
Here is the mesh I want:
where f4(y)=75, f1(x)=50, f3(x)=0 and f2(y)=
Please, help me.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!