Extrude 2D Domain into 3D
14 views (last 30 days)
Show older comments
I am having trouble extruding a 2D domain into a 3D domain for use in the PDE Toolbox. Perhaps I cannot use decsg to create the initial 2D domain, but, if not, how can I?
R1 = [3,4,-1,1,1,-1,-.4,-.4,.4,.4]';
C1 = [1,.5,0,.2]';
C1 = [C1;zeros(length(R1)-length(C1),1)];
C2 = C1;
C2(2,1) = -0.5;
geom = [R1,C1,C2];
ns = (char('R1','C1','C2'))';
% Set formula
sf = 'R1 + C1 + C2';
% Create geometry
gd = decsg(geom,sf,ns);
% View geometry
pdegplot(gd, ...
"FaceLabels","on")
xlim([-1.1 1.1])
axis equal
h = extrude(gd,2,10); % This does not work. How can I extrude this 2D domain into 3D. I want to extrude only face 2...
The error is this:
Undefined function 'extrude' for input arguments of type 'double'.
The first image I uploaded is the original 2D domain. The second image is what I want my final 3D domain to look like. Any suggestions?
Thanks.
This is what I need:
0 Comments
Answers (1)
Aiswarya
on 13 Dec 2023
Hi,
I understand that you want to extrude a 2D domain into a 3D domain. You are trying to extrude only the second face by a height of 10.
Firstly, you can only extrude a particular face of a 3D geometry, not 2D geometry (as mentioned in https://www.mathworks.com/help/pde/ug/pde.discretegeometry.extrude.html#description) . You can first extrude your 2D geometry to 3D by using extrude(g, height) and then extrude 2nd face of the resultant 3D geometry by using (g,2,height).
Also the input of "extrude" can be only of these types: fegeometry, DiscreteGeometry or AnalyticGeometry object (https://www.mathworks.com/help/pde/ug/pde.discretegeometry.extrude.html#mw_eb61fe69-2246-44c8-91d4-b5be3e4cff40). So you may use the function 'geometryFromEdges' to convert it to an Analytical Geometry object( https://www.mathworks.com/help/pde/ug/pde.pdemodel.geometryfromedges.html )
You may refer to the below code and make adjustments in the face number to obtain your desired geometry:
R1 = [3,4,-1,1,1,-1,-.4,-.4,.4,.4]';
C1 = [1,.5,0,.2]';
C1 = [C1;zeros(length(R1)-length(C1),1)];
C2 = C1;
C2(2,1) = -0.5;
geom = [R1,C1,C2];
ns = (char('R1','C1','C2'))';
% Set formula
sf = 'R1 + C1 + C2';
% Create geometry
gd = decsg(geom,sf,ns);
% View geometry
pdegplot(gd,"FaceLabels","on");
xlim([-1.1 1.1]);
axis equal;
model = createpde("thermal","transient");
ge = geometryFromEdges(model,gd);
% 2D -> 3D extrusion
gd1 = extrude(ge,0.5);
figure
pdegplot(gd1,"FaceLabels","on")
% 3D face extrusion
gd2 = extrude(gd1,2,10);
figure
pdegplot(gd2,"FaceLabels","on","FaceAlpha",.5)
Hope this helps!
See Also
Categories
Find more on Geometry and Mesh in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!