Main Content

pdegrad

(Not recommended) Gradient of PDE solution

pdegrad is not recommended. Use evaluateGradient instead.

Description

example

[ux,uy] = pdegrad(p,t,u) returns the gradient of u evaluated at the center of each mesh triangle.

The gradient is the same everywhere in the triangle interior because pdegrad uses only linear basis functions. The derivatives at the boundaries of the triangles can be discontinuous.

[ux,uy] = pdegrad(p,t,u,FaceID) restricts the computation to the faces listed in FaceID.

Examples

collapse all

Create a [p,e,t] mesh on the L-shaped membrane.

[p,e,t] = initmesh('lshapeg');

Solve the equation using the Dirichlet boundary condition u=0 on Ω.

c = 1;
a = 0;
f = 1;
u = assempde('lshapeb',p,e,t,c,a,f);

Compute the gradient of the solution and plot the results.

[gradx,grady] = pdegrad(p,t,u);
pdeplot(p,e,t,'XYData',u,'FlowData',[gradx;grady])

Input Arguments

collapse all

Mesh nodes, specified as a 2-by-Np matrix of nodes (points), where Np is the number of nodes in the mesh. For details on the mesh data representation, see initmesh.

Data Types: double

Mesh elements, specified as a 4-by-Nt matrix of triangles, where Nt is the number of triangles in the mesh. For details on the mesh data representation, see initmesh.

Data Types: double

Data at nodes, specified as a column vector.

For a PDE system of N equations and a mesh with Np node points, the first Np values of u describe the first component, the following Np values of u describe the second component, and so on.

Data Types: double

Face IDs, specified as a vector of integers.

Data Types: double

Output Arguments

collapse all

x-component of the gradient of u evaluated at the center of each triangle, returned as a row vector for a scalar PDE or a matrix for a system of PDEs. The number of elements in a row vector or columns in a matrix corresponds to the number Nt of mesh triangles. For a PDE system of N equations, each row i from 1 to N contains uix.

y-component of the gradient of u evaluated at the center of each triangle, returned as a row vector for a scalar PDE or a matrix for a system of PDEs. The number of elements in a row vector or columns in a matrix corresponds to the number Nt of mesh triangles. For a PDE system of N equations, each row i from 1 to N contains uiy.

Version History

Introduced before R2006a

collapse all

R2018a: Not recommended

pdegrad is not recommended. Use evaluateGradient instead. There are no plans to remove pdegrad.