How do I export geometry, boundary conditionss & mesh data to the workspace in the pdetoolbox using the command line?

7 views (last 30 days)
I have been given an .m file that is trying to do a thermal analysis on an electric board. There is an error with the way that the geometric boundary and mesh data is being exported such that when I try to plot the mesh using pdemesh(p,e,t) it flags up an error that p does not exist.
The code up to this point in the file is as follows:
% ---- setup fe window
[pde_fig,ax] = pdeinit;
pdetool('appl_cb',1); set(ax,'DataAspectRatio',[1 1 1]);
set(ax,'PlotBoxAspectRatio',[1.5 1 1]);
set(ax,'XLim',[-10,110+10]*1e-3); set(ax,'YLim',[-10, 110+10]*1e-3);
set(ax,'XTickMode','auto'); set(ax,'YTickMode','auto');
% ---- Geometry description:
pderect([0,104,0,72]*1e-3,'base'); % base
pderect([1,104-1,1,72-1]*1e-3,'wallo'); % outer wall
pderect([4,104-4,4,72-4]*1e-3,'walli'); % inner wall
x = 5; y = 21; pderect([x,x+30,y,y+31]*1e-3,'sub1'); % substrate 1
pderect([x+2,x+2+9,y+2,y+2+5]*1e-3,'C11'); % device
pderect([x+2+9+8,x+2+9+8+9,y+2,y+2+9]*1e-3,'C12'); % device
pderect([x+2,x+2+9,y+2+5+2,y+2+5+2+9]*1e-3,'C21'); % device
pderect([x+2+9+8,x+2+9+8+9,y+2+9+2,y+2+9+2+9]*1e-3,'C22'); % device
pderect([x+2,x+2+9,y+2+5+2+9+2,y+2+5+2+9+2+9]*1e-3,'C31'); % device
pderect([x+2+9+8,x+2+9+8+9,y+2+9+2+9+2,y+2+9+2+9+2+5]*1e-3,'C32'); % device
x = 37; y = 16; pderect([x,x+30,y,y+31]*1e-3,'sub2'); % substrate 2
pderect([x+2+9+8,x+2+9+9+8,y+2,y+2+5]*1e-3,'C13'); % device
pderect([x+2,x+2+9,y+2,y+2+9]*1e-3,'C14'); % device
pderect([x+2+9+8,x+2+9+9+8,y+2+5+2,y+2+5+2+9]*1e-3,'C23'); % device
pderect([x+2,x+2+9,y+2+9+2,y+2+9+2+9]*1e-3,'C24'); % device
pderect([x+2+9+8,x+2+9+9+8,y+2+5+2+9+2,y+2+5+2+9+2+9]*1e-3,'C33'); % device
pderect([x+2,x+2+9,y+2+9+2+9+2,y+2+9+2+9+2+5]*1e-3,'C34'); % device
x = 69; y = 21; pderect([x,x+30,y,y+31]*1e-3,'sub3'); % substrate 2
pderect([x+2+9+8,x+2+9+9+8,y+2,y+2+5]*1e-3,'C15'); % device
pderect([x+2,x+2+9,y+2,y+2+9]*1e-3,'C16'); % device
pderect([x+2+9+8,x+2+9+9+8,y+2+5+2,y+2+5+2+9]*1e-3,'C25'); % device
pderect([x+2,x+2+9,y+2+9+2,y+2+9+2+9]*1e-3,'C26'); % device
pderect([x+2+9+8,x+2+9+9+8,y+2+5+2+9+2,y+2+5+2+9+2+9]*1e-3,'C35'); % device
pderect([x+2,x+2+9,y+2+9+2+9+2,y+2+9+2+9+2+5]*1e-3,'C36'); % device
set(findobj(get(pde_fig,'Children'),'Tag','PDEEval'),'String',...
'base + wallo + walli + sub1 + C11 + C12 + C21 + C22 + C31 + C32 + sub2 + C13 + C14 + C23 + C24 + C33 + C34 + sub3 + C15 + C16 + C25 + C26 + C35 + C36')
% ---- Boundary conditions:
pdetool('changemode',0)
pdesetbd(1,'neu',1,'0','0'); pdesetbd(2,'neu',1,'0','0');
pdesetbd(23,'neu',1,'0','0'); pdesetbd(24,'neu',1,'0','0');
% ---- Mesh generation:
setappdata(pde_fig,'Hgrad',1.3);
setappdata(pde_fig,'refinemethod','regular');
pdetool('initmesh'); pdetool('refine'); % pdetool('jiggle'); pdetool('refine');
pdetool('exportx',1);% get geo data (gd, ns, sf)
pdetool('exportx',2);% get decomp geo and bound data (g,b)
pdetool('exportx',3);% get node, edge and triangle data (p,e,t)
% ---- plot mesh
figure; pdemesh(p,e,t); grid; axis equal;
Matlab does not seem to recognise the pdetool('exportx',1) command as nothing is being exported to the workspace. Any advice on how to simply export the gd,ns,sf,g,b,p,e,t variables would be great.

Answers (2)

Sean de Wolski
Sean de Wolski on 24 Oct 2012
Menubar -> Mesh -> Export Mesh
This looks like what you want.

Elfaham
Elfaham on 4 Oct 2013
% export geometry data:
gd=get(findobj(get(pde_fig,'Children'),'flat',...
'Tag','PDEMeshMenu'),'UserData');
ns=getuprop(pde_fig,'objnames');
evalhndl=findobj(get(pde_fig,'Children'),'flat','Tag','PDEEval');
sf=get(evalhndl,'String');
matqueue('put',gd,sf,ns)
pstr='Variable names for geometry data, set formula, labels:';
estr='gd sf ns';
% export decomposed list, boundary conditions:
dl1=getuprop(pde_fig,'dl1');
h=findobj(get(pde_fig,'Children'),'flat','Tag','PDEBoundMenu');
bl=get(findobj(get(h,'Children'),'flat',...
'Tag','PDEBoundMode'),'UserData');
matqueue('put',dl1,bl)
pstr='Variable names for decomposed geometry, boundary cond''s:';
estr='g b';
% export mesh:
h=findobj(get(pde_fig,'Children'),'flat','Tag','PDEMeshMenu');
p=get(findobj(get(h,'Children'),'flat','Tag','PDEInitMesh'),...
'UserData');
e=get(findobj(get(h,'Children'),'flat','Tag','PDERefine'),...
'UserData');
t=get(findobj(get(h,'Children'),'flat','Tag','PDEMeshParam'),...
'UserData');
matqueue('put',p,e,t)
pstr='Variable names for mesh data (points, edges, triangles):';
estr='p e t';

Tags

Community Treasure Hunt

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

Start Hunting!