主要内容

geometryFromMesh

从网格创建2-D或3D几何形状

描述

example

几何流行(模型,nodes,元素)在内部创建几何形状模型。For planar and volume triangulated meshes, this function also incorporatesnodes在里面模型。Mesh.Nodes财产和元素在里面模型。Mesh.Elements财产。要用具有不同目标元素大小的网格替换导入的网格,请使用Generatemesh

如果元素代表一个表面三角形网,该网格界定封闭体积,然后geometryFromMesh创建几何形状,但不会将网格结合到模型的相应属性中。要在这种情况下生成网格,请使用Generatemesh

example

几何流行(模型,nodes,元素,ElementIDToRegionID)创建一个多域几何形状。这里,ElementIDToRegionIDspecifies the subdomain IDs for each element of the mesh.

[G,] = geometryFromMesh(模型,nodes,元素)returns a handleGto the geometry in模型。Geometry, 和a handleto the mesh in模型。Mesh

例子

全部收缩

Import a tetrahedral mesh into a PDE model.

将四面体网眼装入工作空间。这tetmeshfile ships with your software. Put the data in the correct shape forgeometryFromMesh

loadtetmeshnodes = X'; elements = tet';

Create a PDE model and import the mesh into the model.

模型= createpde(); geometryFromMesh(model,nodes,elements);

查看几何图形和面部数字。

PDEGPLOT(模型,'FaceLabels','on','FaceAlpha',0.5)

Figure contains an axes object. The axes object contains 3 objects of type quiver, patch, line.

从点网格的凸壳创建一个几何块。

创建一个3-D网格。

[x, y, z] = meshgrid(-2:4:2);

Create the convex hull.

x = x(:);y = y(:);z = z(:);k = convhull(x,y,z);

将数据以正确的形状geometryFromMesh

nodes = [x'; y'; z'];元素= k';

创建PDE模型并导入网格。

模型= createpde(); geometryFromMesh(model,nodes,elements);

查看几何图形和面部数字。

PDEGPLOT(模型,'FaceLabels','on','FaceAlpha',0.5)

Figure contains an axes object. The axes object contains 3 objects of type quiver, patch, line.

使用MATLAB创建3D几何形状Alphashapefunction. First, create anAlphashape带有圆柱孔的块的对象。然后将几何形状导入从Alphashapeboundary.

创建一个2D网格。

[xg,yg] = meshgrid(-3:0.25:3); xg = xg(:); yg = yg(:);

Create a unit disk. Remove all the mesh grid points that fall inside the unit disk, and include the unit disk points.

t = (pi/24:pi/24:2*pi)'; x = cos(t); y = sin(t); circShp = alphaShape(x,y,2); in = inShape(circShp,xg,yg); xg = [xg(~in); cos(t)]; yg = [yg(~in); sin(t)];

创建其余网格点的3-D副本,z- 坐标范围从0到1。将点结合到一个Alphashape目的。

zg = ones(numel(xg),1); xg = repmat(xg,5,1); yg = repmat(yg,5,1); zg = zg*(0:.25:1); zg = zg(:); shp = alphaShape(xg,yg,zg);

获得一个表面网格Alphashape目的。

[元素,节点] = BoundareFacets(SHP);

将数据以正确的形状geometryFromMesh

nodes = nodes'; elements = elements';

创建PDE模型并导入表面网格。

模型= createpde(); geometryFromMesh(model,nodes,elements);

查看几何图形和面部数字。

PDEGPLOT(模型,'FaceLabels','on','FaceAlpha',0.5)

Figure contains an axes object. The axes object contains 3 objects of type quiver, patch, line.

要在分析中使用几何形状,请创建一个音量网。

Generatemesh(model);

Create a 2-D multidomain geometry from a mesh.

Load information about nodes, elements, and element-to-domain correspondence into your workspace. The fileMultidomainMesh2D使用您的软件发货。

loadMultidomainMesh2D

Create a PDE model.

模型= createpde;

Import the mesh into the model.

几何流行(模型,nodes,elements,ElementIdToRegionId);

查看几何图形和面部数字。

PDEGPLOT(模型,'FaceLabels','on')

Figure contains an axes object. The axes object contains an object of type line.

Create a 3-D multidomain geometry from a mesh.

Load information about nodes, elements, and element-to-domain correspondence into your workspace. The fileMultidomainMesh3D使用您的软件发货。

loadMultidomainMesh3D

Create a PDE model.

模型= createpde;

Import the mesh into the model.

几何流行(模型,nodes,elements,ElementIdToRegionId);

查看几何图形和单元格数。

PDEGPLOT(模型,“牢房”,'on')

Figure contains an axes object. The axes object contains 3 objects of type quiver, patch, line.

输入参数

全部收缩

Model object, specified as apdemodel目的,这rmalModel目的,StructuralModel对象或ElectromagneticModel目的。

例子:模型= createpde(3)

例子:ThermalModel = CreatePde('Thermal','Steadystate')

例子:structuralModel = createpde('structural','static-solid')

例子:emagmodel = createpde('electromagnetic','electrostatic')

网状节点, specified as a matrix of real numbers. The matrix size is 2-by-Nnodes对于二维案例和3 by-Nnodesfor a 3-D case.Nnodes是the number of nodes in the mesh.

Nodejhasx,y, 和z列中的坐标jnodes

Data Types:双倍的

Mesh elements, specified as an integer matrix with 3, 4, 6, or 10 rows, andnelements列,哪里nelements是网格中的元素数。

  • Linear planar mesh or linear mesh on the geometry surface has size 3-by-nelements。Each column of元素contains the indices of the triangle corner nodes for a surface element. In this case, the resulting geometry does not contain a full mesh. Create the mesh using theGeneratemeshfunction.

  • 线性元素的大小为4乘nelements。Each column of元素包含一个元素的四面体角节点的索引。

  • 几何表面上的二次平面网格或二次网格的尺寸为6 by-nelements。Each column of元素contains the indices of the triangle corner nodes and edge centers for a surface element. In this case, the resulting geometry does not contain a full mesh. Create the mesh using theGeneratemeshfunction.

  • 二次元素的尺寸为10厘米nelements。Each column of元素包含四面体角节点和四面体边缘中点节点的索引。

有关线性和二次元素的节点编号的详细信息,请参见Mesh Data

Data Types:双倍的

每个网格元素的域信息,指定为正整数的向量。每个元素都是网格元素的几何区域的ID。该矢量的长度等于网格中元素的数量。

Data Types:双倍的

Output Arguments

全部收缩

Geometry, returned as a handle to模型。Geometry。This geometry is of classDiscreteGeometry Properties

有限元网格,作为手柄返回模型。Mesh

  • 如果元素是3乘nelementsmatrix representing a surface mesh, then[]。在这种情况下,使用该几何形状创建网格Generatemeshfunction.

  • 如果元素是a matrix with more than three rows representing a volume mesh, thenhas the same nodes and elements as the inputs. You can get a different mesh for the geometry by using theGeneratemeshfunction.

在R2015B中引入