# pdejmps

(Not recommended) Error estimates for adaptation

`pdejmps`

is not recommended. Use meshes represented as
`FEMesh`

objects instead of `[p,e,t]`

meshes. For more
information, see Compatibility Considerations.

## Description

calculates the error indication function used for mesh adaptation. The columns of
`errf`

= pdejmps(`p`

,`t`

,`c`

,`a`

,`f`

,`u`

,`alpha`

,`beta`

,`m`

)`errf`

correspond to triangles, and the rows correspond to the
equations in the PDE system.

The function computes the error indicator *E*(*K*) for
each triangle *K* as

$$E\left(K\right)=\alpha {\Vert {h}^{m}\left(f-au\right)\Vert}_{K}+\beta {\left(\frac{1}{2}{\displaystyle \sum _{\tau \in \partial K}{h}_{\tau}^{2m}{[{n}_{\tau}\cdot \text{\hspace{0.17em}}(c\nabla {u}_{h})]}^{2}}\right)}^{1/2}$$

where $${n}_{\tau}$$ is the unit normal of edge $$\tau $$ and the braced term is the jump in flux across the element edge. Here,
*α* and *β* are weight indices, and *m*
is an order parameter. The norm is an *L*_{2} norm
computed over the element *K*.

## Examples

### Error Indication Function

Solve the Laplace equation over a circle sector, with Dirichlet boundary conditions *u* = cos(2/3atan2(*y*,*x*)) along the arc and *u* = 0 along the straight lines. Use the original coarser mesh and the refined mesh, and calculate the error indication function in both cases.

Generate and plot a mesh for the circle sector geometry.

```
[p,e,t] = initmesh('cirsg');
pdemesh(p,e,t)
```

Solve the Laplace equation.

`u = assempde('cirsb',p,e,t,1,0,0);`

Calculate the error indication function for each mesh triangle. Use the weight indices $$\alpha =0.15$$, $$\beta =0.15$$, and the order parameter *m* = 1.

alpha = 0.15; beta = 0.15; m = 1; errf = pdejmps(p,t,1,0,0,u,alpha,beta,m);

Find the maximum value of the error indication function.

max(abs(errf))

ans = 0.0306

Refine the original mesh and plot the result.

```
[p,e,t] = refinemesh('cirsg',p,e,t);
pdemesh(p,e,t)
```

Solve the same equation on the refined mesh, and calculate the error indication function for each mesh triangle. Use the same values for the weight indices and the order parameter.

```
u = assempde('cirsb',p,e,t,1,0,0);
errf = pdejmps(p,t,1,0,0,u,alpha,beta,m);
```

Find the maximum value of the error indication function.

max(abs(errf))

ans = 0.0194

Solve the same equation using the `adaptmesh`

function.

[u,p,e,t] = adaptmesh('cirsg','cirsb',1,0,0);

Number of triangles: 197 Number of triangles: 201 Number of triangles: 216 Number of triangles: 233 Number of triangles: 254 Number of triangles: 265 Number of triangles: 313 Number of triangles: 344 Number of triangles: 417 Number of triangles: 475 Number of triangles: 629 Maximum number of refinement passes obtained.

Plot the mesh.

pdemesh(p,e,t)

Calculate the error indication function for each mesh triangle.

errf = pdejmps(p,t,1,0,0,u,alpha,beta,m);

Find the maximum value of the error indication function.

max(abs(errf))

ans = 0.0024

## Input Arguments

`p`

— Mesh node points

matrix

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

matrix of points
(nodes), where `Np`

is the number of nodes in the mesh. For details on
mesh data representation, see `initmesh`

.

**Data Types: **`double`

`t`

— Mesh elements

`4`

-by-`Nt`

matrix

Mesh elements, specified as a `4`

-by-`Nt`

matrix
of triangles, where `Nt`

is the number of triangles in the mesh. For
details on mesh data representation, see `initmesh`

.

**Data Types: **`double`

`c`

— PDE coefficient

scalar | matrix | character vector | character array | string scalar | string vector | coefficient function

PDE coefficient, specified as a scalar, matrix, character vector, character array,
string scalar, string vector, or coefficient function. `c`

represents
the *c* coefficient in the scalar PDE

$$-\nabla \cdot \left(c\nabla u\right)+au=f$$

or in the system of PDEs

$$-\nabla \cdot \left(c\otimes \nabla u\right)+au=f$$

The coefficients `c`

, `a`

, and
`f`

can depend on the solution `u`

if you use the
nonlinear solver by setting the value of `'Nonlin'`

to
`'on'`

. The coefficients cannot be functions of the time
`t`

.

**Example: **`'cosh(x+y.^2)'`

**Data Types: **`double`

| `char`

| `string`

| `function_handle`

`a`

— PDE coefficient

scalar | matrix | character vector | character array | string scalar | string vector | coefficient function

PDE coefficient, specified as a scalar, matrix, character vector, character array,
string scalar, string vector, or coefficient function. `a`

represents
the *a* coefficient in the scalar PDE

$$-\nabla \cdot \left(c\nabla u\right)+au=f$$

or in the system of PDEs

$$-\nabla \cdot \left(c\otimes \nabla u\right)+au=f$$

The coefficients `c`

, `a`

, and
`f`

can depend on the solution `u`

if you use the
nonlinear solver by setting the value of `'Nonlin'`

to
`'on'`

. The coefficients cannot be functions of the time
`t`

.

**Example: **`2*eye(3)`

**Data Types: **`double`

| `char`

| `string`

| `function_handle`

`f`

— PDE coefficient

scalar | matrix | character vector | character array | string scalar | string vector | coefficient function

PDE coefficient, specified as a scalar, matrix, character vector, character array,
string scalar, string vector, or coefficient function. `f`

represents
the *f* coefficient in the scalar PDE

$$-\nabla \cdot \left(c\nabla u\right)+au=f$$

or in the system of PDEs

$$-\nabla \cdot \left(c\otimes \nabla u\right)+au=f$$

The coefficients `c`

, `a`

, and
`f`

can depend on the solution `u`

if you use the
nonlinear solver by setting the value of `'Nonlin'`

to
`'on'`

. The coefficients cannot be functions of the time
`t`

.

**Example: **`char('sin(x)';'cos(y)';'tan(z)')`

**Data Types: **`double`

| `char`

| `string`

| `function_handle`

`u`

— PDE solution

vector

PDE solution, specified as a vector.

If the PDE is scalar, meaning that it has only one equation, then

`u`

is a column vector representing the solution*u*at each node in the mesh.If the PDE is a system of

*N*> 1 equations, then`u`

is a column vector with`N*Np`

elements, where`Np`

is the number of nodes in the mesh. The first`Np`

elements of`u`

represent the solution of equation 1, the next`Np`

elements represent the solution of equation 2, and so on.

`alpha`

— Weight index

number

Weight index, specified as number.

**Data Types: **`double`

`beta`

— Weight index

number

Weight index, specified as a number.

**Data Types: **`double`

`m`

— Order parameter

number

Order parameter, specified as number.

**Data Types: **`double`

## Output Arguments

`errf`

— Error indicator

matrix

Error indicator, returned as a matrix with the number of columns equal to the number
of triangles `t`

and the number of rows equal to the number of PDEs
in the system.

Each matrix row corresponds to an equation in the PDE system.

Each column corresponds to a triangle.

## Version History

**Introduced before R2006a**

### R2016b: `pdejmps`

is not recommended

*Not recommended starting in R2016b*

`pdejmps`

and `[p,e,t]`

meshes are not recommended.
Use meshes represented as `FEMesh`

objects instead. There are no plans to
remove `pdejmps`

and `[p,e,t]`

meshes.

Starting in R2016a, use the `generateMesh`

function to create meshes as
`FEMesh`

objects. For details about these meshes, see Mesh Data.

## See Also

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