# Geometry and Mesh

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

Unified finite element analysis workflow uses an `fegeometry` object to define a geometry. You can simply assign a geometry to the `Geometry` property of `femodel`.

Define a geometry using one of these sources:

The general PDE workflow, as well as the domain-specific workflows, use a `DiscreteGeometry` and `AnalyticGeometry` objects. Typically, you can define these objects using the same sources as for `fegeometry`.

Mesh a geometry using the `generateMesh` function. The toolbox uses the finite element method (FEM) to solve PDEs. For details about meshing, 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 `triangulation` Create `triangulation` object from `fegeometry` (Since R2023b) `pdegplot` Plot PDE geometry

#### Modification

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

#### Queries

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

#### 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 (Since R2021a)

#### 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

## Objects

 `fegeometry` Geometry object for finite element analysis (Since R2023a) `DiscreteGeometry` Discrete 2-D or 3-D geometry description `AnalyticGeometry` Analytic 2-D geometry description `FEMesh` Mesh object

## Properties

 PDEVisualization Properties PDE visualization of mesh and nodal results (Since R2021a)

## Apps

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