Documentation

assemb

Assemble boundary condition contributions

assemb IS NOT RECOMMENDED. Use assembleFEMatrices instead.

Syntax

  • [Q,G,H,R] = assemb(model)
    example
  • [Q,G,H,R] = assemb(b,p,e)
    example
  • [Q,G,H,R] = assemb(___,[],sdl)

Description

example

[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.

[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 Boundary Condition Matrices

Assemble the boundary condition matrices for an elliptic PDE.

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

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))])
disp(['Number of nonzero entries in Q is ',num2str(nnz(Q))])
Fraction of nonzero entries in H is 3.4709e-05
Number of nonzero entries in Q is 0

Assemble Boundary Matrices Using [p,e,t] Mesh

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

model — PDE modelPDEModel object

PDE model, specified as a PDEModel object.

Example: model = createpde(1)

b — Boundary conditionsboundary matrix | boundary file

Boundary conditions, specified as a boundary matrix or boundary file. Pass a boundary file as a function handle or as a string naming the file.

For more information on boundary conditions, see Forms of Boundary Condition Specification.

Example: b = 'circleb1' or equivalently b = @circleb1

Data Types: double | char | function_handle

p — Mesh nodesoutput of initmesh | output of meshToPet

Mesh nodes, specified as the output of initmesh or meshToPet. For the structure of a p matrix, see Mesh Data for [p,e,t] Triples: 2-D and Mesh Data for [p,e,t] Triples: 3-D.

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

Data Types: double

e — Mesh edgesoutput of initmesh | output of meshToPet

Mesh edges, specified as the output of initmesh or meshToPet. For the structure of e, see Mesh Data for [p,e,t] Triples: 2-D and Mesh Data for [p,e,t] Triples: 3-D.

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

Data Types: double

sdl — Subdomain labelsvector of positive integers

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

Q — Neumann boundary condition matrixsparse matrix

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.

G — Neumann boundary condition vectorsparse vector

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.

H — Dirichlet matrixsparse matrix

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

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

R — Dirichlet vectorsparse vector

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

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

More About

collapse all

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 Definitions section, and the linear algebra approach detailed in Systems of PDEs.

Introduced before R2006a

Was this topic helpful?