Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

assema

Assemble area integral contributions

assema is not recommended. Use assembleFEMatrices instead.

Syntax

  • [K,M,F] = assema(model,c,a,f)
    example
  • [K,M,F] = assema(p,t,c,a,f)
    example

Description

example

[K,M,F] = assema(model,c,a,f) assembles the stiffness matrix K, the mass matrix M, and the load vector F using the mesh contained in model, and the PDE coefficients c, a, and f.

example

[K,M,F] = assema(p,t,c,a,f) assembles the matrices from the mesh data in p and t.

Examples

collapse all

Assemble finite element matrices for an elliptic problem on complicated geometry.

The PDE is Poisson's equation,

$$ -\nabla\cdot\nabla u = 1.$$

Partial Differential Equation Toolbox™ solves equations of the form

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

So, represent Poisson's equation in toolbox syntax by setting c = 1, a = 0, and f = 1.

c = 1;
a = 0;
f = 1;

Create a PDE model container. Import the ForearmLink.stl file into the model and examine the geometry.

model = createpde;
importGeometry(model,'ForearmLink.stl');
pdegplot(model,'FaceAlpha',0.5)

Create a mesh for the model.

generateMesh(model);

Create the finite element matrics from the mesh and the coefficients.

[K,M,F] = assema(model,c,a,f);

The returned matrix K is quite sparse. M has no nonzero entries.

disp(['Fraction of nonzero entries in K is ',num2str(nnz(K)/numel(K))])
disp(['Number of nonzero entries in M is ',num2str(nnz(M))])
Fraction of nonzero entries in K is 0.0007101
Number of nonzero entries in M is 0

Assemble finite element matrices for the 2-D L-shaped region, using the [p,e,t] mesh representation.

Define the geometry using the lshapeg function included your software.

g = @lshapeg;

Use coefficients c = 1, a = 0, and f = 1.

c = 1;
a = 0;
f = 1;

Create a mesh and assemble the finite element matrices.

[p,e,t] = initmesh(g);
[K,M,F] = assema(p,t,c,a,f);

The returned matrix M has all zeros. The K matrix is quite sparse.

disp(['Fraction of nonzero entries in K is ',num2str(nnz(K)/numel(K))])
disp(['Number of nonzero entries in M is ',num2str(nnz(M))])
Fraction of nonzero entries in K is 0.042844
Number of nonzero entries in M is 0

Input Arguments

collapse all

PDE model, specified as a PDEModel object.

Example: model = createpde(1)

PDE coefficient, specified as a scalar or matrix, as a character array, or as a coefficient function. c represents the c coefficient in the scalar PDE

(cu)+au=f

or in the system of PDEs

(cu)+au=f

You can specifyc in various ways, detailed in c Coefficient for Systems. See also Specify Scalar PDE Coefficients in Character Form, Specify 2-D Scalar Coefficients in Function Form, and Specify 3-D PDE Coefficients in Function Form.

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

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

PDE coefficient, specified as a scalar or matrix, as a character array, or as a coefficient function. a represents the a coefficient in the scalar PDE

(cu)+au=f

or in the system of PDEs

(cu)+au=f

You can specifya in various ways, detailed in a or d Coefficient for Systems. See also Specify Scalar PDE Coefficients in Character Form, Specify 2-D Scalar Coefficients in Function Form, and Specify 3-D PDE Coefficients in Function Form.

Example: 2*eye(3)

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

PDE coefficient, specified as a scalar or matrix, as a character array, or as a coefficient function. f represents the f coefficient in the scalar PDE

(cu)+au=f

or in the system of PDEs

(cu)+au=f

You can specifyf in various ways, detailed in f Coefficient for Systems. See also Specify Scalar PDE Coefficients in Character Form, Specify 2-D Scalar Coefficients in Function Form, and Specify 3-D PDE Coefficients in Function Form.

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

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

Mesh points, specified as a 2-by-Np matrix of points, where Np is the number of points in the mesh. For a description of the (p,e,t) matrices, see Mesh Data.

Typically, you use the p, e, and t data exported from the PDE app, or generated by initmesh or refinemesh.

Example: [p,e,t] = initmesh(gd)

Data Types: double

Mesh triangles, specified as a 4-by-Nt matrix of triangles, where Nt is the number of triangles in the mesh. For a description of the (p,e,t) matrices, see Mesh Data.

Typically, you use the p, e, and t data exported from the PDE app, or generated by initmesh or refinemesh.

Example: [p,e,t] = initmesh(gd)

Data Types: double

Output Arguments

collapse all

Stiffness matrix, returned as a sparse matrix. See Elliptic Equations.

Typically, you use K in a subsequent call to assempde.

Mass matrix. returned as a sparse matrix. See Elliptic Equations.

Typically, you use M in a subsequent call to a solver such as assempde or hyperbolic.

Load vector, returned as a vector. See Elliptic Equations.

Typically, you use F in a subsequent call to assempde.

Introduced before R2006a

Was this topic helpful?