# Geometry and Mesh

Define a geometry and discretize it using a triangular or tetrahedral mesh

Reconstruct a geometry from STL or mesh data:

• Import an STL or STEP file into MATLAB® by using `importGeometry`. The STL and STEP file formats are very common and supported by most CAD software. In case of a planar STL geometry, the toolbox converts it to a 2-D geometry by mapping it to the X-Y plane.

• Reconstruct a geometry from a mesh by using `geometryFromMesh`. This function works with triangulated meshes, including planar, volume, and surface triangulation that bounds a closed volume.

Create a geometry:

• Stack or nest cubes, cylinders, or spheres to create a geometry for a 3-D problem.

• Extrude a 2-D geometry into a 3-D geometry.

• Use the constructive solid geometry (CSG) approach, write a geometry function, or use the `polyshape` function to create a geometry for a 2-D problem. The CSG approach uses a set of solid building blocks (square, rectangle, circle, ellipse, and polygon) and combines them to define complex geometries.

• Use the PDE Modeler app to create complex 2-D geometries by drawing, overlapping, and rotating basic shapes, such as circles, polygons and so on.

Mesh a geometry by using the `generateMesh` function. The toolbox uses the finite element method (FEM) to solve PDEs. A PDE model stores the generated mesh as an `FEMesh` object in its `Mesh` property. For details, see Mesh Data.

For details about the components of geometries and meshes and the relationships between them, see Geometry and Mesh Components.

## Functions

expand all

#### Creation and Visualization

 `importGeometry` Import geometry from STL or STEP file `geometryFromMesh` Create 2-D or 3-D geometry from mesh `geometryFromEdges` Create 2-D geometry from decomposed geometry matrix `decsg` Decompose constructive solid 2-D geometry into minimal regions `multicuboid` Create geometry formed by several cubic cells `multicylinder` Create geometry formed by several cylindrical cells `multisphere` Create geometry formed by several spherical cells `pdegplot` Plot PDE geometry

#### Modification

 `addCell` Combine two geometries by adding one inside a cell of another `addFace` Fill void regions in 2-D and split cells in 3-D geometry `addVertex` Add a vertex on a geometry boundary `addVoid` Create void regions inside 3-D geometry `rotate` Rotate geometry `scale` Scale geometry `translate` Translate geometry `extrude` Vertically extrude 2-D geometry or specified faces of 3-D geometry

#### Queries

 `cellEdges` Find edges belonging to boundaries of specified cells `cellFaces` Find faces belonging to specified cells `faceEdges` Find edges belonging to specified faces `facesAttachedToEdges` Find faces attached to specified edges `nearestEdge` Find edges nearest to specified point `nearestFace` Find faces nearest to specified point

#### PDE Modeler App

 `pdecirc` Draw circle in PDE Modeler app `pdeellip` Draw ellipse in PDE Modeler app `pdepoly` Draw polygon in PDE Modeler app `pderect` Draw rectangle in PDE Modeler app
 `generateMesh` Create triangular or tetrahedral mesh `meshQuality` Evaluate shape quality of mesh elements `findElements` Find mesh elements in specified region `findNodes` Find mesh nodes in specified region `area` Area of 2-D mesh elements `volume` Volume of 3-D mesh elements `pdemesh` Plot PDE mesh `pdeplot` Plot solution or mesh for 2-D problem `pdeplot3D` Plot solution or surface mesh for 3-D problem `pdeviz` Create and plot PDE visualization object

#### Geometry

 `csgdel` Delete boundaries between subdomains `pdearcl` Represent arc lengths as parametrized curve `wgeom` Write geometry function to file

#### Mesh

 `adaptmesh` Create adaptive 2-D mesh and solve PDE `initmesh` Create initial 2-D mesh `meshToPet` `[p,e,t]` representation of `FEMesh` data `jigglemesh` (Not recommended) Jiggle internal points of triangular mesh `refinemesh` Refine triangular mesh

## Properties

 AnalyticGeometry Properties Analytic 2-D geometry description DiscreteGeometry Properties Discrete 2-D or 3-D geometry description FEMesh Properties Mesh object PDEVisualization Properties PDE visualization of mesh and nodal results

## Apps

 PDE Modeler Create complex 2-D geometries by drawing, overlapping, and rotating basic shapes