main content

create 2-凯发k8网页登录

create 2-d or 3-d geometry from mesh

description

example

geometryfrommesh(model,nodes,elements) creates geometry within model. for planar and volume triangulated meshes, this function also incorporates nodes in the model.mesh.nodes property and elements in the model.mesh.elements property. to replace the imported mesh with a mesh having a different target element size, use generatemesh.

if elements represents a surface triangular mesh that bounds a closed volume, then geometryfrommesh creates the geometry, but does not incorporate the mesh into the corresponding properties of the model. to generate a mesh in this case, use generatemesh.

example

geometryfrommesh(model,nodes,elements,elementidtoregionid) creates a multidomain geometry. here, elementidtoregionid specifies the subdomain ids for each element of the mesh.

[g,mesh] = geometryfrommesh(model,nodes,elements) returns a handle g to the geometry in model.geometry, and a handle mesh to the mesh in model.mesh.

examples

import a tetrahedral mesh into a pde model.

load a tetrahedral mesh into your workspace. the tetmesh file ships with your software. put the data in the correct shape for geometryfrommesh.

load tetmesh
nodes = x';
elements = tet';

create a pde model and import the mesh into the model.

model = createpde();
geometryfrommesh(model,nodes,elements);

view the geometry and face numbers.

pdegplot(model,"facelabels","on","facealpha",0.5)

figure contains an axes object. the axes object contains 3 objects of type quiver, patch, line.

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)

figure contains an axes object. the axes object contains 3 objects of type quiver, patch, line.

create a 3-d geometry using the matlab® alphashape function. first, create an object of a block with a cylindrical hole. then import the geometry into a pde model from the alphashape boundary.

create a 2-d mesh grid.

[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)];

create 3-d copies of the remaining mesh grid points, with the z-coordinates ranging from 0 through 1. combine the points into an alphashape object.

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);

obtain a surface mesh of the alphashape object.

[elements,nodes] = boundaryfacets(shp);

put the data in the correct shape for geometryfrommesh.

nodes = nodes';
elements = elements';

create a pde model and import the surface mesh.

model = createpde();
geometryfrommesh(model,nodes,elements);

view the geometry and face numbers.

pdegplot(model,"facelabels","on","facealpha",0.5)

figure contains an axes object. the axes object contains 3 objects of type quiver, patch, line.

to use the geometry in an analysis, create a volume mesh.

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 file multidomainmesh2d ships with your software.

load multidomainmesh2d

create a pde model.

model = createpde;

import the mesh into the model.

geometryfrommesh(model,nodes,elements,elementidtoregionid);

view the geometry and face numbers.

pdegplot(model,"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 file multidomainmesh3d ships with your software.

load multidomainmesh3d

create a pde model.

model = createpde;

import the mesh into the model.

geometryfrommesh(model,nodes,elements,elementidtoregionid);

view the geometry and cell numbers.

pdegplot(model,"celllabels","on")

figure contains an axes object. the axes object contains 3 objects of type quiver, patch, line.

input arguments

model container, specified as a pdemodel object, thermalmodel object, structuralmodel object, or electromagneticmodel object.

example: model = createpde(3)

example: thermalmodel = createpde(thermal="steadystate")

example: structuralmodel = createpde(structural="static-solid")

example: emagmodel = createpde(electromagnetic="electrostatic")

mesh nodes, specified as a matrix of real numbers. the matrix size is 2-by-nnodes for a 2-d case and 3-by-nnodes for a 3-d case. nnodes is the number of nodes in the mesh.

node j has x, y, and z coordinates in column j of nodes.

data types: double

mesh elements, specified as an integer matrix with 3, 4, 6, or 10 rows, and nelements columns, where nelements is the number of elements in the mesh.

  • linear planar mesh or linear mesh on the geometry surface has size 3-by-nelements. each column of elements 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 the generatemesh function.

  • linear elements have size 4-by-nelements. each column of elements contains the indices of the tetrahedral corner nodes for an element.

  • quadratic planar mesh or quadratic mesh on the geometry surface has size 6-by-nelements. each column of elements 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 the generatemesh function.

  • quadratic elements have size 10-by-nelements. each column of elements contains the indices of the tetrahedral corner nodes and the tetrahedral edge midpoint nodes for an element.

for details on node numbering for linear and quadratic elements, see .

data types: double

domain information for each mesh element, specified as a vector of positive integers. each element is an id of a geometric region for an element of the mesh. the length of this vector equals the number of elements in the mesh.

data types: double

output arguments

geometry, returned as a handle to model.geometry. this geometry is of class .

finite element mesh, returned as a handle to model.mesh.

  • if elements is a 3-by-nelements matrix representing a surface mesh, then mesh is []. in this case, create a mesh for the geometry using the generatemesh function.

  • if elements is a matrix with more than three rows representing a volume mesh, then mesh has the same nodes and elements as the inputs. you can get a different mesh for the geometry by using the generatemesh function.

version history

introduced in r2015b

see also

| | |

topics

    网站地图