# jigglemesh

(Not recommended) Jiggle internal points of 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.**

## Description

## Examples

### Jiggle Mesh

Create a triangular mesh of the square geometry by using `initmesh`

. To avoid jiggling, call `initimesh`

with the `Jiggle`

value set to `off`

.

[p,e,t] = initmesh("lshapeg","Jiggle","off");

Evaluate quality of the mesh elements using the `pdetriq`

function.

q = pdetriq(p,t);

Plot the mesh.

pdeplot(p,e,t,"XYData",q,"ColorBar","on","XYStyle","flat")

Jiggle the mesh using the default parameter values. Plot the result.

p1 = jigglemesh(p,e,t); q = pdetriq(p1,t); pdeplot(p1,e,t,"XYData",q,"ColorBar","on","XYStyle","flat")

Now jiggle the original mesh again, this time using 50000 iterations.

p2 = jigglemesh(p,e,t,"Opt","off","Iter",5e4); q = pdetriq(p2,t); pdeplot(p2,e,t,"XYData",q,"ColorBar","on","XYStyle","flat")

## Input Arguments

`p`

— Mesh points

2-by-`Np`

matrix

Mesh points, specified as a 2-by-`Np`

matrix. `Np`

is the number of points (nodes) in the mesh. Column `k`

of
`p`

consists of the *x*-coordinate of point
`k`

in `p(1,k)`

and the
*y*-coordinate of point `k`

in
`p(2,k)`

. For details, see Mesh Data as [p,e,t] Triples.

`e`

— Mesh edges

7-by-`Ne`

matrix

Mesh edges, specified as a 7-by-`Ne`

matrix, where
`Ne`

is the number of edges in the mesh. An edge is a pair of points
in `p`

containing a boundary between subdomains, or containing an outer
boundary. For details, see Mesh Data as [p,e,t] Triples.

`t`

— Mesh elements

4-by-`Nt`

matrix

Mesh elements, specified as a 4-by-`Nt`

matrix.
`Nt`

is the number of triangles in the mesh.

The `t(i,k)`

, with `i`

ranging from 1 through
`end - 1`

, contain indices to the corner points of element
`k`

. For details, see Mesh Data as [p,e,t] Triples. The last row,
`t(end,k)`

, contains the subdomain number of the element.

### 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: **`p1 = jigglemesh(p,e,t,"Iter",Inf)`

`Opt`

— Optimization method

`"mean"`

(default) | `"minimum"`

| `"off"`

Optimization method, specified as the comma-separated pair consisting of
`"Opt"`

and `"mean"`

,
`"minimum"`

, or `"off"`

.

Jiggling a mesh moves each mesh point not located on an edge segment towards the
center of mass of the polygon formed by the adjacent triangles. The optimization
method controls how many times `jigglemesh`

repeats this
process:

If

`Opt`

is`"off"`

,`jigglemesh`

repeats this process`Iter`

times. The default value of`Iter`

in this case is 1.If

`Opt`

is`"mean"`

,`jigglemesh`

repeats this process until the mean triangle quality stops increasing significantly or until the maximum number of iterations is reached. The default value of`Iter`

in this case is 20.If

`Opt`

is`"minimum"`

,`jigglemesh`

repeats this process until the minimum triangle quality stops increasing significantly or until the maximum number of iterations is reached. The default value of`Iter`

in this case is 20.

**Example: **```
p1 = jigglemesh(p,e,t,"Opt","off","Iter",1000);
```

**Data Types: **`char`

| `string`

`Iter`

— Maximum number of iterations

1 or 20 (default) | positive integer

Maximum number of iterations, specified as the comma-separated pair consisting of
`"Iter"`

and a positive number. The default value depends on the
`Opt`

argument value. If `Opt`

is set to
`"mean"`

(default) or `"minimum"`

, the default
maximum number of iterations is 20. If `Opt`

is set to
`"off"`

, the default maximum number of iterations is 1.

**Example: **```
p1 =
jigglemesh(p,e,t,"Opt","off","Iter",1000);
```

**Data Types: **`double`

## Output Arguments

`p1`

— Modified mesh points

2-by-`Np`

matrix

Modified mesh points, returned as a 2-by-`Np`

matrix.
`Np`

is the number of points (nodes) in the mesh. Column
`k`

of `p`

consists of the
*x*-coordinate of point `k`

in
`p(1,k)`

and the *y*-coordinate of point
`k`

in `p(2,k)`

. For details, see Mesh Data as [p,e,t] Triples.

## Version History

**Introduced before R2006a**

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

# Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)