Create loop for mesh refinement and store the nodal coordinates (p) and elements (t) for each iteration

6 views (last 30 days)
I created this geometry and mesh using pde toolbox in Matlab. Find the code below. 1) I want to create a loop for the mesh refinement, refine the mesh 100 times, each at the increment of 0.5 (or whatever increment specified). 2) I want to store the nodal coordinates and elements at each iteration. 3) I want to store the node set of the fixed boundary condition for each iteration. 4) I want to store the node of the force boundary condition for each iteration. Please, how can I apply force just on a node (See the attached picture)).
Please, kindly help me adjust my code to be able to achieve these. I will also appreciate it if you have a simpler way of achieving this. Thank you.
Code:
function [p,e,t]= pdemodel
[pde_fig,ax]=pdeinit;
pdetool('appl_cb',3);
set(ax,'DataAspectRatio',[1 1 1]);
set(ax,'PlotBoxAspectRatio',[1.5 1 1]);
set(ax,'XLim',[-3.5 3.5]);
set(ax,'YLim',[-3 3]);
set(ax,'XTickMode','auto');
set(ax,'YTickMode','auto');
% Geometry description:
pdepoly(2.5*[ -1.1501501501501503,...
-0.072072072072072002,...
-0.075075075075075048,...
0.33933933933933935,...
0.32732732732732739,...
-0.8798798798798797,...
-0.88288288288288275,...
-1.246246246246246,...
],...
2.5*[ 0.48648648648648685,...
0.48048048048048053,...
0.081081081081081141,...
0.081081081081081141,...
-0.36036036036036023,...
-0.33933933933933913,...
-0.12012012012011986,...
-0.12012012012011986,...
],...
'P1');
set(findobj(get(pde_fig,'Children'),'Tag','PDEEval'),'String','P1')
% Boundary conditions:
pdetool('changemode',0)
pdesetbd(8,...
'neu',...
2,...
char('0','0','0','0'),...
char('0','0'))
pdesetbd(7,...
'dir',...
2,...
char('1','0','0','1'),...
char('0','0'))
pdesetbd(6,...
'dir',...
2,...
char('1','0','0','1'),...
char('0','0'))
pdesetbd(5,...
'dir',...
2,...
char('1','0','0','1'),...
char('0','0'))
pdesetbd(4,...
'dir',...
2,...
char('1','0','0','1'),...
char('0','0'))
pdesetbd(3,...
'dir',...
2,...
char('1','0','0','1'),...
char('0','0'))
pdesetbd(2,...
'dir',...
2,...
char('1','0','0','1'),...
char('0','0'))
pdesetbd(1,...
'dir',...
2,...
char('1','0','0','1'),...
char('0','0'))
% 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')
pdetool('refine')
% PDE coefficients:
pdeseteq(1,...
char('2*((1E3)./(2*(1+(0.3))))+(2*((1E3)./(2*(1+(0.3)))).*(0.3)./(1-(0.3)))','0','(1E3)./(2*(1+(0.3)))','0','(1E3)./(2*(1+(0.3)))','2*((1E3)./(2*(1+(0.3)))).*(0.3)./(1-(0.3))','0','(1E3)./(2*(1+(0.3)))','0','2*((1E3)./(2*(1+(0.3))))+(2*((1E3)./(2*(1+(0.3)))).*(0.3)./(1-(0.3)))'),...
char('0.0','0.0','0.0','0.0'),...
char('0.0','0.0'),...
char('1.0','0','0','1.0'),...
'0:10',...
'0.0',...
'0.0',...
'[0 100]')
setappdata(pde_fig,'currparam',...
['1E3';...
'0.3';...
'0.0';...
'0.0';...
'1.0'])
% Solve parameters:
setappdata(pde_fig,'solveparam',...
char('0','13824','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 1 1 0 0 0 1 1 0 0 0 0 1]);
setappdata(pde_fig,'colstring','');
setappdata(pde_fig,'arrowstring','');
setappdata(pde_fig,'deformstring','');
setappdata(pde_fig,'heightstring','');
%Get mesh data p,e,t and solution u from the pde toolbox:
pde_fig=findobj(allchild(0),'flat','Tag','PDETool');
if isempty(pde_fig)
error('PDE Toolbox GUI not active.')
end
h=findobj(get(pde_fig,'Children'),'flat','Tag','PDEMeshMenu');
hp=findobj(get(h,'Children'),'flat','Tag','PDEInitMesh');
he=findobj(get(h,'Children'),'flat','Tag','PDERefine');
ht=findobj(get(h,'Children'),'flat','Tag','PDEMeshParam');
p=get(hp,'UserData');
e=get(he,'UserData');
t=get(ht,'UserData');

Answers (1)

Alan Weiss
Alan Weiss on 16 May 2017
I believe that there is no affordance for specifying load at a single point. However, this model has somewhat similar geometry. You can specify a load on the rightmost vertical edge instead of just at the point.
As for some of your other comments, you want to "refine the mesh 100 times"? Why? How many edges and points do you think that you will have after that many refinements? The answer: way too many to hold in memory. Remember, 2^100 ~ 10^30, and your computer doesn't have that much memory.
Alan Weiss
MATLAB mathematical toolbox documentation
  2 Comments
SAMUEL AYINDE
SAMUEL AYINDE on 16 May 2017
Edited: SAMUEL AYINDE on 16 May 2017
Thank you so much, Alan. Basically, the big picture is to use each mesh refinement for an optimization iteration. And the optimization may not reach 100 iterations before it converges. Perhaps, it reaches 100 times or more, I may consider the option of using a supercomputer that has sufficient memory to accommodate such large size. Kindly help me with how to implement the mesh refinements 100 times (or better still, n times). What codes do I need to add to my current code to make it possible Thank you.
Alan Weiss
Alan Weiss on 16 May 2017
To me, you have not described the purpose of the optimization and mesh refinements.
And you have certainly not understood the limitations of the algorithm you described with successive halving of the mesh size, which I believe in 2-D leads to at least a fourfold increase in memory usage at each refinement. How big is 4^100? Do you seriously believe that there is a supercomputer on earth with this much memory?
If you want more help, please state the purpose, meaning the problem that you want to address, not how you propose to address it.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!