Can the following domain be created for use in the PDE Toolbox? It does not seem that ordinary operations with the multicuboid function can stack cuboids with different width and heights, but is there another way?
Thanks!

 채택된 답변

Ravi Kumar
Ravi Kumar 2024년 2월 9일
편집: Ravi Kumar 2024년 2월 10일

0 개 추천

Here is an example, use this code and modify the dimensions.
% Define the first square of size 1
x1 = [0; 1; 1; 0]; % x-coordinates
y1 = [0; 0; 1; 1]; % y-coordinates
% Define the second square of size 0.5
x2 = [0.25; 0.75; 0.75; 0.25]; % x-coordinates
y2 = [0.25; 0.25; 0.75; 0.75]; % y-coordinates
% Concatenate coordinates for decsg input
rect1 = [3; 4; x1; y1]; % First square definition
rect2 = [3; 4; x2; y2]; % Second square definition
% Create geometry matrix for decsg
gdm = [rect1, rect2]; % Geometry description matrix
ns = char('R1', 'R2'); % Name space matrix
sf = 'R1+R2'; % Set formula
ns = ns';
% Create the 2-D geometry using decsg
gd = decsg(gdm, sf, ns);
% Create a fegeometry
gm = fegeometry(gd);
% Now, extrude the 2-D geometry to a 3-D geometry with a length of 1
gm = extrude(gm, 1);
% Merge the cells in the 3-D geometry
cellIDsToMerge = [1, 2];
gm = mergeCells(gm, cellIDsToMerge);
% Find the smaller of the two faces at the top
% We use a point above the center of the smaller square along the z-axis
topSmallerSquareCenterPoint = [0.5, 0.5, 1]; % Row vector for coordinates
topSmallerFaceID = nearestFace(gm, topSmallerSquareCenterPoint);
% Extrude the smaller top face by a length of 1
gm = extrude(gm, topSmallerFaceID, 1);
% Rotate the complete geometry by 180 degrees around the x-axis
% to place the new smaller cube at the bottom
axisOfRotation = [1, 0, 0]; % Rotation axis (x-axis)
pointOnAxis = [0, 0, 0]; % A point on the axis of rotation (origin)
angleOfRotation = 180; % Rotation angle in radians (180 degrees)
gm = rotate(gm, angleOfRotation, axisOfRotation, pointOnAxis);
% Now the complete geometry is rotated, and the smaller cube is at the bottom
pdegplot(gm)

댓글 수: 5

Torsten
Torsten 2024년 2월 9일
That's great, but what an unbelievable effort for such a relatively simple geometry !
Ravi Kumar
Ravi Kumar 2024년 2월 10일
Thanks for the feedback, Torsten. Agreed, it does require a lot of code with the currently capabilities. Out of curiosity, what would be your ideal approach for such geometry creation? You don't have to think about feasibility, I am looking for what would be your natural steps to create such geometry.
Paul Safier
Paul Safier 2024년 2월 10일
@Ravi Kumar, thanks so much, that works great!
@Torsten, agreed, it is quite a bit of code to create such a simple geometry. I'm grateful to have the guidance from Ravi because that definitely was a circuitous route to the solution.
Imagine trying to create this though, haha! :) Gulp.
Torsten
Torsten 2024년 2월 10일
In old FLUENT/Gambit, you can just define the two volumes by the 8 corner points. Then there is a command "split" that splits the big face by the small face where the two volumes meet. That's all. After this, you can mesh both volumes separately.
Ravi Kumar
Ravi Kumar 2024년 2월 13일
Thanks for sharing that approach!

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Torsten
Torsten 2024년 2월 8일
편집: Torsten 2024년 2월 8일

0 개 추천

Usually in such cases the domain is divided into subcubes that share common faces.
E.g. the upper cube could be divided into 9 obvious subcubes: 3 in the left part, 3 in the middle and 3 in the right part.

댓글 수: 2

Paul Safier
Paul Safier 2024년 2월 8일
편집: Paul Safier 2024년 2월 8일
Hi @Torsten. Thanks for the idea. I have not found any info or example of how to subdivide a cube. I did attempt to add vertices in hopes that I could ultimately use the addFace function, but that needs edges to be defined and there is no addEdges function.
I also attempted to define the domain in 2D and then extrude to 3D, but that is failing because I need some separation to define the bottom cube.
Do you have an example of what you suggest? Thanks.
Torsten
Torsten 2024년 2월 8일
편집: Torsten 2024년 2월 8일
I don't know about the capabilities of the geometry builder of the PDE Toolbox.
Is it not possible to create two cuboids that share a common face and unite them ?
But looking at the examples, it seems best to create the geometry in an external CAD program and then import it in MATLAB.

댓글을 달려면 로그인하십시오.

Ravi Kumar
Ravi Kumar 2024년 2월 13일

0 개 추천

Our geometry expert provided a much compact version to create this geometry:
g=fegeometry(multicuboid([1 2],[1 2],2))
g2=extrude(g,2,1)
g3=mergeCells(g2,[1 2])
pdegplot(g3,FaceAlpha=0.8,CellLabels="on")

카테고리

제품

릴리스

R2023b

질문:

2024년 2월 7일

댓글:

2024년 2월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by