How to create a planar STL in PDE Modeler?

21 views (last 30 days)
Coleman Barrie
Coleman Barrie on 15 May 2019
Commented: qi wang on 9 Jul 2023
Is it possible to create a 2D planar STL file as described in PDE Modeler documentation? The general opinion claims a 2D STL is not possible due to the general purpose for 3D printing. If possible, this would allow import of a complex geometry and creation of a 2D finite element model that is far less computationally intensive than the 3D counterpart.
Please see this link or image attached. Mathworks claims this exists.
This is pivotal for my graduate research of creating a finite element groundwater model. Any support is greatly appreciated! If a 2D stl is not possible, is it feasible to import xy coordinates and integrate a 2D geometry to PDE Modeler another way? I have additional experience with and access to ArcGIS, Excel, AutoCAD.
Drawing the domain in the PDE GUI would jeopardize the accuracy of the geometry and aesthetics, but this seems to be the best option for 2D model creation and subdomains for variable parameter input.

Answers (2)

Konstantin Kovalev
Konstantin Kovalev on 16 May 2019
If input data consists of polygons specified as arrays of corner points coordinates, you can use the following approach to create geometry for pde model:
  • Build a geometry description matrix using the polygon data
  • Use decsg function to construct decomposed geometry matrix
  • Use geometryFromEdges function to add geometry to PDE model container
Here is a code example that constructs geometry from 4 simple polygons:
% polygon 1
x1 = [0 1 1 0];
y1 = [0 0 1 1];
% polygon 2
x2 = [1 2 2 1];
y2 = [0 0 1 1];
% polygon 3
x3 = [0.5 1.5 1.5 0.5];
y3 = [0.5 0.5 1.5 1.5];
% polygon 4
x4 = [0.2 0.4 0.3];
y4 = [0.2 0.2 0.4];
% build geometry description matrix (each column describes a shape)
p1 = [2 4 x1 y1];
p2 = [2 4 x2 y2];
p3 = [2 4 x3 y3];
p4 = [2 3 x4 y4 0 0];
gd = [p1' p2' p3' p4'];
figure
hold on
plot(polyshape(x1,y1));
plot(polyshape(x2,y2));
plot(polyshape(x3,y3));
plot(polyshape(x4,y4));
% example 1: combine P1, P2, P3, P4
d = decsg(gd);
pdem = createpde;
geometryFromEdges(pdem,d);
figure
pdegplot(pdem,'EdgeLabels','on','FaceLabels','on');
% example 2: combine P1, P2, P3 and leave void P4
d = decsg(gd,'P1-P4+P2+P3',char('P1','P2','P3','P4')');
pdem = createpde;
geometryFromEdges(pdem,d);
figure
pdegplot(pdem,'EdgeLabels','on','FaceLabels','on');
  2 Comments
Coleman Barrie
Coleman Barrie on 16 May 2019
Perfect! This is exactly what I needed to hear, thank you very much. I figured out how to use descg earlier today and am now working towards building an adaptive mesh.
The next roadblock I forsee is recreating the fairly complex initial conditions of the aquifer I'm attempting to model. I have the data for "Pressure head of the aquifer" and need to figure out how to explain contours with functions in xy or just spatial input. Where there is a will there's a way.
Thank you!
Coleman Barrie
Coleman Barrie on 16 May 2019
for the record I exported the geometry information after the GUI was pulled up. I also did the same for boundary conditions. The method provided by Konstantin seems more streamlined.

Sign in to comment.


Steven Lord
Steven Lord on 15 May 2019
You can look at the PlateHolePlanar.stl file being imported by that example.
edit PlateHolePlanar.stl
It looks to me like the key points that make this "2-D" are that the Z coordinates of each vertex are 0 and the facet normals point directly in the +Z direction.
Can you say a little more about what you mean by “subdomains for variable parameter input”?
  2 Comments
Coleman Barrie
Coleman Barrie on 15 May 2019
Edited: Coleman Barrie on 15 May 2019
I apologize the proper term would be sub regions, areas that will have spatially and temporally modified inputs. I found the pdepoly command can import x,y coordinates and form a 2D polygon and opens the GUI. Attached is the work so far with one wetland area incorporated.
I'm not sure if a planar stl is possible, but this is an acceptable alternative for a 2D model of complex geometry.
[pde_fig,ax]=pdeinit;
set(ax,'XLimMode','auto')
set(ax,'YLimMode','auto')
set(ax,'XTickMode','auto');
set(ax,'YTickMode','auto');
fname1 = 'GeometryInputs';
data = xlsread(fname1,2);
x = data(:,1);
y = data(:,2);
pdepoly(x,y,'Model Domain')
data = xlsread(fname1,3);
x = data(1:20,1);
y = data(1:20,2);
pdepoly(x,y,'Wetland 1')
qi wang
qi wang on 9 Jul 2023
Can you please tell me what is fname1 and how to make it? It seems that fname includes the information of contour.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!