main content

create triangular or tetrahedral mesh -凯发k8网页登录

create triangular or tetrahedral mesh

description

example

mesh = generatemesh(model) creates a mesh for the geometry stored in the model object. the toolbox stores the mesh in the mesh property of the structural, thermal, electromagnetic model, or pdemodel.

model must contain a geometry. for details about creating a geometry and including it in a model, see geometry and mesh and the geometry functions listed there.

femodel = generatemesh(femodel) creates a mesh for the geometry stored in the femodel object. the toolbox stores the mesh in the geometry.mesh property. assigning the result to the model updates the mesh stored in the geometry property of the model.

example

___ = generatemesh(___,name,value) modifies the mesh generation according to the name,value arguments. this syntax works with the model and femodel arguments.

examples

generate the default 2-d mesh for the l-shaped geometry.

create a pde model and include the l-shaped geometry.

model = createpde(1);
geometryfromedges(model,@lshapeg);

generate the default mesh for the geometry.

generatemesh(model);

view the mesh.

pdeplot(model)

figure contains an axes object. the axes object contains 2 objects of type line.

create a mesh that is finer than the default.

create a pde model and include the brackettwoholes geometry.

model = createpde(1);
importgeometry(model,"brackettwoholes.stl");

generate a default mesh for comparison.

generatemesh(model)
ans = 
  femesh with properties:
             nodes: [3x10003 double]
          elements: [10x5774 double]
    maxelementsize: 9.7980
    minelementsize: 4.8990
     meshgradation: 1.5000
    geometricorder: 'quadratic'

view the mesh.

pdeplot3d(model)

create a mesh with target maximum element size 5 instead of the default 7.3485.

generatemesh(model,"hmax",5)
ans = 
  femesh with properties:
             nodes: [3x66982 double]
          elements: [10x44093 double]
    maxelementsize: 5
    minelementsize: 2.5000
     meshgradation: 1.5000
    geometricorder: 'quadratic'

view the mesh.

pdeplot3d(model)

generate a 2-d mesh with finer spots around the specified edges and vertices.

create a model.

model = createpde;

create and plot a 2-d geometry representing a circle with a diamond-shaped hole in its center.

g = geometryfromedges(model,@scatterg);
pdegplot(g,"vertexlabels","on","edgelabels","on")

figure contains an axes object. the axes object contains 17 objects of type line, text.

generate a mesh for this geometry using the default mesh parameters.

m1 = generatemesh(model)
m1 = 
  femesh with properties:
             nodes: [2x1159 double]
          elements: [6x547 double]
    maxelementsize: 0.0509
    minelementsize: 0.0254
     meshgradation: 1.5000
    geometricorder: 'quadratic'

plot the resulting mesh.

pdeplot(m1)

figure contains an axes object. the axes object contains 2 objects of type line.

generate a mesh with the target size on edge 1, which is smaller than the target minimum element size, minelementsize, of the default mesh.

m2 = generatemesh(model,"hedge",{1,0.001})
m2 = 
  femesh with properties:
             nodes: [2x2635 double]
          elements: [6x1243 double]
    maxelementsize: 0.0509
    minelementsize: 0.0254
     meshgradation: 1.5000
    geometricorder: 'quadratic'

plot the resulting mesh.

pdeplot(m2)

figure contains an axes object. the axes object contains 2 objects of type line.

generate a mesh specifying the target sizes for edge 1 and vertices 6 and 7.

m3 = generatemesh(model,"hedge",{1,0.001},"hvertex",{[6 7],0.002})
m3 = 
  femesh with properties:
             nodes: [2x2887 double]
          elements: [6x1357 double]
    maxelementsize: 0.0509
    minelementsize: 0.0254
     meshgradation: 1.5000
    geometricorder: 'quadratic'

plot the resulting mesh.

pdeplot(m3)

figure contains an axes object. the axes object contains 2 objects of type 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")

finite element model container, specified as a object.

example: model = femodel(analysistype = "structuralstatic")

name-value arguments

specify optional pairs of arguments as name1=value1,...,namen=valuen, where name is the argument name and value is the corresponding value. name-value arguments must appear after other arguments, but the order of the pairs does not matter.

before r2021a, use commas to separate each name and value, and enclose name in quotes.

example: generatemesh(model,"hmax",0.25);

element geometric order, specified as "linear" or "quadratic".

a triangle or tetrahedron representing a linear element has nodes at the corners. a triangle or tetrahedron representing a quadratic element has nodes at its corners and edge centers. the center nodes in quadratic meshes are always added at half-distance between corners. for geometries with curved surfaces and edges, center nodes might not appear on the edge or surface itself.

in general, "quadratic" elements produce more accurate solutions. override the default "quadratic" only to solve a 3-d magnetostatic problem, to save memory, or to solve a 2-d problem using a legacy solver. legacy pde solvers use linear triangular mesh for 2-d geometries.

example: generatemesh(model,"geometricorder","linear");

data types: char | string

mesh growth rate, specified as a number greater than or equal to 1 and less than or equal to 2.

example: generatemesh(model,"hgrad",1.3);

data types: double

target maximum mesh edge length, specified as a positive number.

hmax is an approximate upper bound on the mesh edge lengths. occasionally, generatemesh can create a mesh with some elements that exceed hmax.

generatemesh estimates the default value of hmax from overall dimensions of the geometry.

small hmax values let you create finer meshes, but mesh generation can take a very long time in this case. you can interrupt mesh generation by using ctrl c. note that generatemesh can take additional time to respond to the interrupt.

example: generatemesh(model,"hmax",0.25);

data types: double

target minimum mesh edge length, specified as a nonnegative number.

hmin is an approximate lower bound on the mesh edge lengths. occasionally, generatemesh can create a mesh with some elements that are smaller than hmin.

generatemesh estimates the default value of hmin from overall dimensions of the geometry.

example: generatemesh(model,"hmin",0.05);

data types: double

target size on selected faces, specified as a cell array containing an even number of elements. odd-indexed elements are positive integers or vectors of positive integers specifying face ids. even-indexed elements are positive numbers specifying the target size for the corresponding faces.

example: generatemesh(model,"hmax",0.25,"hface",{[1 2],0.1,[3 4 5],0.05})

data types: double

target size around selected edges, specified as a cell array containing an even number of elements. odd-indexed elements are positive integers or vectors of positive integers specifying edge ids. even-indexed elements are positive numbers specifying the target sizes for the corresponding edges.

example: generatemesh(model,"hmax",0.25,"hedge",{[1 2],0.01,3,0.05})

data types: double

target size around selected vertices, specified as a cell array containing an even number of elements. odd-indexed elements are positive integers or vectors of positive integers specifying vertex ids. even-indexed elements are positive numbers specifying the target sizes for the corresponding vertices.

example: generatemesh(model,"hmax",0.25,"hvertex",{1,0.02})

data types: double

output arguments

mesh description, returned as an object.

more about

element

an element is a basic unit in the finite-element method.

for 2-d problems, an element is a triangle in the model.mesh.element property. if the triangle represents a linear element, it has nodes only at the triangle corners. if the triangle represents a quadratic element, then it has nodes at the triangle corners and edge centers.

for 3-d problems, an element is a tetrahedron with either four or ten points. a four-point (linear) tetrahedron has nodes only at its corners. a ten-point (quadratic) tetrahedron has nodes at its corners and at the center point of each edge.

for details, see .

tips

  • generatemesh can return slightly different meshes in different releases. for example, the number of elements in the mesh can change. avoid writing code that relies on explicitly specified node and element ids or node and element counts.

  • generatemesh uses the following set of rules when you specify local element sizes with hface, hedge, or hvertex. these rules are valid for both the default and custom values of hmin and hmax.

    • if you specify local sizes for regions near each other, generatemesh uses the minimum size. for example, if you specify size 1 on an edge and size 0.5 on one of its vertices, the function gradually reduces the element sizes in the proximity of that vertex.

    • if you specify local sizes smaller than hmin, generatemesh ignores hmin in those localities.

    • if you specify local sizes larger than hmax, generatemesh ignores the specified local sizes. hmax is not exceeded anywhere in the mesh.

version history

introduced in r2015a

see also

functions

objects

  • | | | | |

properties

topics

    网站地图