Main Content

pdecgrad

(Not recommended) Flux of PDE solution

pdecgrad is not recommended. Use evaluateCGradient instead.

Description

example

[cgxu,cgyu] = pdecgrad(p,t,u,c) computes the flux of the solution cu evaluated at the center of each mesh triangle.

The gradient is the same everywhere in the triangle interior because pdecgrad uses only linear basis functions. However, the flux can vary inside a triangle because the coefficient c can vary.

[cgxu,cgyu] = pdecgrad(p,t,u,c,time) uses time for parabolic and hyperbolic problems if c is time-dependent.

[cgxu,cgyu] = pdecgrad(___,FaceID) uses the arguments from the previous syntaxes and 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 flux of the solution and plot the results.

[cgradx,cgrady] = pdecgrad(p,t,c,u);
pdeplot(p,e,t,'XYData',u,'FlowData',[cgradx;cgrady])

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

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

(cu)+au=f

or in the system of PDEs

(cu)+au=f

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

Data Types: double | char | string | function_handle
Complex Number Support: Yes

Time for parabolic and hyperbolic problems with a time-dependent coefficient c, specified as a nonnegative number.

Data Types: double

Face IDs, specified as a vector of integers.

Data Types: double

Output Arguments

collapse all

x-component of the flux 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 j=1Ncij11ujx+cij12ujy.

y-component of the flux 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 j=1Ncij21ujx+cij22ujy.

Version History

Introduced before R2006a

collapse all

R2018a: Not recommended

pdecgrad is not recommended. Use evaluateCGradient instead. There are no plans to remove pdecgrad.