Changing Faces of DiscreteGeometry (PDE Toolbox)
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nick
am 27 Nov. 2016
Kommentiert: Nick
am 19 Dez. 2016
I am trying to add a geometry to my PDE model from my given mesh (Nodes and Tetrahedron elements).
model = createpde(1);
Nodes = [-1 -1 -1; 1 -1 -1; -1 1 -1; 1 1 -1; -1 -1 1; 1 -1 1; -1 1 1; 1 1 1]';
Elements = [1 2 3 6; 2 3 4 6; 1 3 5 6; 3 4 6 8; 3 5 6 7; 3 6 7 8]';
[G, Mesh] = geometryFromMesh(model,Nodes,Elements);
h = pdegplot(model, 'FaceLabels', 'on');
set(h(1), 'FaceAlpha', 0.5);
I am expecting the geometry G to have 6 Faces (obviously, because I have a cube), but the Geometry does not work like expected on the top and bottom Face, which are divided into several Faces, depending on the Tetrahedrons. On the "side" Faces it looks good.4
My question now is: Is there a way to change the Faces of the geometry, so for example that I say Face 1 should be the area between the Nodes 1-4 or something like that. Or alternatively: Does someone know, why the faces on top and bottom are divided like that and what I can change in my code to stop that from happen.
Best regards Nick
0 Kommentare
Akzeptierte Antwort
Damian Sheehy
am 13 Dez. 2016
Elements 2,4,6 have reversed orientations. The input tetrahedral elements should honor the following numbering convention https://www.mathworks.com/help/pde/ug/mesh-data.html#buqc57w-1
Weitere Antworten (1)
Gautham Sholingar
am 30 Nov. 2016
Hello Nick,
MATLAB documentation provides a few good examples showing how to use the 'geometryFromMesh' function to create the geometry of a cube. The following link has a section pertaining to using a convex hull to generate the 3-D geometry of a cube:
%%Geometry from Convex Hull
% Create a geometric block from the convex hull of a mesh grid of points.
Create a 3-D mesh grid.
[x,y,z] = meshgrid(-2:4:2);
Create the convex hull.
x = x(:);
y = y(:);
z = z(:);
K = convhull(x,y,z);
Put the data in the correct shape for geometryFromMesh.
nodes = [x';y';z'];
elements = K';
Create a PDE model and import the mesh.
model = createpde();
geometryFromMesh(model,nodes,elements);
View the geometry and face numbers.
pdegplot(model,'FaceLabels','on','FaceAlpha',0.5)
The reason you had triangular faces on top is that the 'elements' variable needs to represent the triangular facets in this geometry and needs to be of size 3-by-m where m represents the number of triangular facets. Your current implementation uses 'elements' of size 4-by-6 which is correct for square faces but does not work for a triangular representation. You will need a 3-by-12 'elements' variable to represent the 12 triangular faces on a cube: 2 on each face. The elements variable in the example above is as follows:
1 1 1 2 2 2 3 3 4 4 5 6
2 3 5 4 5 6 4 7 6 8 7 7
3 5 2 3 6 4 7 5 8 7 6 8
This should give you the desired result as follows (Note: you might need to adjust the meshgrid for your case)
I hope that resolves your issue. The above code was tested in MATLAB R2016b.
Regards,
Gautham Sholingar
Siehe auch
Kategorien
Mehr zu Geometry and Mesh finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!