Main Content

assemb

(Not recommended) Assemble boundary condition contributions

assemb is not recommended. Use assembleFEMatrices instead.

Description

[Q,G,H,R] = assemb(model) assembles the matrices Q and H, and the vectors G and R. Q should be added to the system matrix and contains contributions from mixed boundary conditions.

example

[Q,G,H,R] = assemb(b,p,e) assembles the matrices based on the boundary conditions specified in b and the mesh data in p and e.

example

[Q,G,H,R] = assemb(___,[],sdl), for any of the previous input arguments, restricts the finite element matrices to those that include the subdomain specified by the subdomain labels in sdl. The empty argument is required in this syntax for historic and compatibility reasons.

Examples

collapse all

Assemble the boundary condition matrices for an elliptic PDE.

The PDE is Poisson's equation,

-u=1.

Partial Differential Equation Toolbox™ solves equations of the form

-(cu)+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,'Block.stl'); 
h = pdegplot(model,'FaceLabels','on');
h(1).FaceAlpha = 0.5;

Figure contains an axes object. The axes object contains 6 objects of type quiver, text, patch, line.

Set zero Dirichlet boundary conditions on the narrow faces (numbered 1 through 4).

applyBoundaryCondition(model,'Face',1:4,'u',0);

Set a Neumann condition with g = -1 on face 6, and g = 1 on face 5.

applyBoundaryCondition(model,'Face',6,'g',-1);
applyBoundaryCondition(model,'Face',5,'g',1);

Create a mesh for the model.

generateMesh(model);

Create the boundary condition matrices for the model.

[Q,G,H,R] = assemb(model);

The H matrix is quite sparse. The Q matrix has no nonzero entries.

disp(['Fraction of nonzero entries in H is ',num2str(nnz(H)/numel(H))])
Fraction of nonzero entries in H is 7.7991e-05
disp(['Number of nonzero entries in Q is ',num2str(nnz(Q))])
Number of nonzero entries in Q is 0

Assemble boundary condition matrices for the 2-D L-shaped region with Dirichlet boundary conditions, using the [p,e,t] mesh representation.

Define the geometry and boundary conditions using functions included in your software.

g = @lshapeg;
b = @lshapeb;

Create a mesh for the geometry.

[p,e,t] = initmesh(g);

Create the boundary matrices.

[Q,G,H,R] = assemb(b,p,e);

Only one of the resulting matrices is nonzero, namely H. The H matrix is quite sparse.

disp(['Fraction of nonzero entries in H is ',num2str(nnz(H)/numel(H))])
Fraction of nonzero entries in H is 0.0066667

Input Arguments

collapse all

PDE model, specified as a PDEModel object.

Example: model = createpde

Boundary conditions, specified as a boundary matrix or boundary file. Pass a boundary file as a function handle or as a file name. A boundary matrix is generally an export from the PDE Modeler app.

Example: b = 'circleb1', b = "circleb1", or b = @circleb1

Data Types: double | char | string | function_handle

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 as [p,e,t] Triples.

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

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

Data Types: double

Mesh edges, specified as a 7-by-Ne matrix of edges, where Ne is the number of edges in the mesh. For a description of the (p,e,t) matrices, see Mesh Data as [p,e,t] Triples.

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

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

Data Types: double

Subdomain labels, specified as a vector of positive integers. For 2-D geometry only. View the subdomain labels in your geometry using the command

pdegplot(g,'SubdomainLabels','on')

Example: sdl = [1,3:5];

Data Types: double

Output Arguments

collapse all

Neumann boundary condition matrix, returned as a sparse matrix. See Elliptic Equations.

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

Neumann boundary condition vector, returned as a sparse vector. See Elliptic Equations.

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

Dirichlet matrix, returned as a sparse matrix. See Algorithms.

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

Dirichlet vector, returned as a sparse vector. See Algorithms.

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

Algorithms

As explained in Elliptic Equations, the finite element matrices and vectors correspond to the reduced linear system and are the following.

  • Q is the integral of the q boundary condition against the basis functions.

  • G is the integral of the g boundary condition against the basis functions.

  • H is the Dirichlet condition matrix representing hu = r.

  • R is the Dirichlet condition vector for Hu = R.

For more information on the reduced linear system form of the finite element matrices, see the assempde More About section, and the linear algebra approach detailed in Systems of PDEs.

Version History

Introduced before R2006a

collapse all

R2016a: Not recommended

assemb is not recommended. Use assembleFEMatrices instead. There are no plans to remove assemb.