# refinemesh

Refine triangular mesh

**This page describes the legacy workflow. New features might not be compatible with the
legacy workflow. For the corresponding step in the recommended workflow, see generateMesh.**

## Syntax

## Description

`[`

refines the mesh and extends the solution `p1`

,`e1`

,`t1`

,`u1`

] = refinemesh(`g`

,`p`

,`e`

,`t`

,`u`

)`u`

to the new mesh nodes by
linear interpolation. The number of rows in `u`

must correspond to the
number of columns in `p`

, and `u1`

has as many rows as
there are points in `p1`

.

`refinemesh`

interpolates each column of `u`

separately.

`[___] = refinemesh(___,`

uses the input and output arguments from the previous syntaxes and specifies the list
`it`

)`it`

of geometric faces or triangles to refine. A scalar or a row
vector specifies faces. A column vector specifies triangles.

`[___] = refinemesh(___,'longest')`

uses the
longest edge refinement, where the longest edge of each triangle is bisected. By default,
`refinemesh`

uses the regular refinement, where all triangles are divided
into four triangles of the same shape. You also can explicitly specify
`'regular'`

instead of `'longest'`

. If you use a column
vector `it`

to specify the triangles to refine, then
`refinemesh`

can refine some triangles outside of the specified set to
preserve the triangulation and its quality.

## Examples

## Input Arguments

## Output Arguments

## Algorithms

The refinement algorithm follows these steps:

Pick the initial set of triangles to refine.

Divide all edges of the selected triangles in half (regular refinement) or divide the longest edge in half (longest edge refinement).

Divide the longest edge of any triangle that has a divided edge.

Repeat step 3 until no more edges are divided.

Introduce new points of all divided edges, and replace all divided entries in

`e`

by two new entries.Form the new triangles. If all three sides are divided, new triangles are formed by joining the side midpoints. If two sides are divided, the midpoint of the longest edge is joined with the opposing corner and with the other midpoint. If only the longest edge is divided, its midpoint is joined with the opposing corner.

## Version History

**Introduced before R2006a**