Assemble stiffness matrix and right side of PDE problem

u = assempde(model,c,a,f) u = assempde(model,c,a,f,u0) u = assempde(model,c,a,f,u0,time) u = assempde(model,c,a,f,time) u = assempde(b,p,e,t,c,a,f) u = assempde(b,p,e,t,c,a,f,u0) u = assempde(b,p,e,t,c,a,f,u0,time) u = assempde(b,p,e,t,c,a,f,time) [K,F] = assempde(model,c,a,f) [K,F] = assempde(model,c,a,f,u0) [K,F] = assempde(model,c,a,f,u0,time) [K,F] = assempde(model,c,a,f,time) [K,F] = assempde(b,p,e,t,c,a,f) [K,F] = assempde(b,p,e,t,c,a,f,u0) [K,F] = assempde(b,p,e,t,c,a,f,u0,time) [K,F] = assempde(b,p,e,t,c,a,f,u0,time,sdl) [K,F] = assempde(b,p,e,t,c,a,f,time) [K,F] = assempde(b,p,e,t,c,a,f,time,sdl) [K,F,B,ud] = assempde(model,c,a,f) [K,F,B,ud] = assempde(model,c,a,f,u0) [K,F,B,ud] = assempde(model,c,a,f,u0,time) [K,F,B,ud] = assempde(model,c,a,f,time) [K,F,B,ud] = assempde(b,p,e,t,c,a,f) [K,F,B,ud] = assempde(b,p,e,t,c,a,f,u0) [K,F,B,ud] = assempde(b,p,e,t,c,a,f,u0,time) [K,F,B,ud] = assempde(b,p,e,t,c,a,f,time) [K,M,F,Q,G,H,R] = assempde(model,c,a,f) [K,M,F,Q,G,H,R] = assempde(model,c,a,f,u0) [K,M,F,Q,G,H,R] = assempde(model,c,a,f,u0,time) [K,M,F,Q,G,H,R] = assempde(model,c,a,f,u0,time,sdl) [K,M,F,Q,G,H,R] = assempde(model,c,a,f,time) [K,M,F,Q,G,H,R] = assempde(model,c,a,f,time,sdl) [K,M,F,Q,G,H,R] = assempde(b,p,e,t,c,a,f) [K,M,F,Q,G,H,R] = assempde(b,p,e,t,c,a,f,u0) [K,M,F,Q,G,H,R] = assempde(b,p,e,t,c,a,f,u0,time) [K,M,F,Q,G,H,R] = assempde(b,p,e,t,c,a,f,u0,time,sdl) [K,M,F,Q,G,H,R] = assempde(b,p,e,t,c,a,f,time) [K,M,F,Q,G,H,R] = assempde(b,p,e,t,c,a,f,time,sdl) u = assempde(K,M,F,Q,G,H,R) [K1,F1] = assempde(K,M,F,Q,G,H,R) [K1,F1,B,ud] = assempde(K,M,F,Q,G,H,R)

`assempde`

is the basic Partial Differential Equation Toolbox™ function.
It assembles a PDE problem by using the FEM formulation described
in Elliptic Equations.
The command `assempde`

assembles the scalar PDE
problem

$$-\nabla \cdot \left(c\nabla u\right)+au=f,$$

for (*x*,*y*) ∊ Ω, or the system PDE problem

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

The command can optionally produce a solution to the PDE problem.

For the scalar case the *solution vector* *u* is
represented as a column vector of solution values at the corresponding
node points from `p`

. For a system of dimension *N* with *n _{p}* node
points, the first

`u`

describe the first component of `u`

describe the second component of `u`

as `model`

is a `PDEModel`

object
that incorporates the number of equations, geometry, mesh, and boundary
conditions.

`u = assempde(b,p,e,t,c,a,f)`

assembles
and solves the PDE problem using the finite element method. The `[p,e,t]`

arguments
are the 2-D mesh data (see Mesh Data for [p,e,t] Triples: 2-D).

`b`

describes the boundary conditions of the
PDE problem. For the recommended way of specifying boundary conditions,
see Specify Boundary Conditions Objects. For all methods
of specifying boundary conditions, see Forms of Boundary Condition Specification.

`[K,F] = assempde(b,p,e,t,c,a,f)`

assembles
the PDE problem by approximating the Dirichlet boundary condition
with stiff springs (see Systems of PDEs for
details). `K`

and `F`

are the stiffness
matrix and right-hand side, respectively. The solution to the FEM
formulation of the PDE problem is `u = K\F`

.

`[K,F,B,ud] = assempde(b,p,e,t,c,a,f)`

assembles
the PDE problem by eliminating the Dirichlet boundary conditions from
the system of linear equations. `u1 = K\F`

returns
the solution on the non-Dirichlet points. The solution to the full
PDE problem can be obtained as the MATLAB^{®} expression ```
u
= B*u1+ud
```

.

`[K,M,F,Q,G,H,R] = assempde(b,p,e,t,c,a,f)`

gives
a split representation of the PDE problem.

`u = assempde(K,M,F,Q,G,H,R)`

collapses
the split representation into the single matrix/vector form, and then
solves the PDE problem by eliminating the Dirichlet boundary conditions
from the system of linear equations.

`[K1,F1] = assempde(K,M,F,Q,G,H,R)`

collapses
the split representation into the single matrix/vector form, by fixing
the Dirichlet boundary condition with large spring constants.

`[K1,F1,B,ud] = assempde(K,M,F,Q,G,H,R)`

collapses
the split representation into the single matrix/vector form by eliminating
the Dirichlet boundary conditions from the system of linear equations.

The optional list of subdomain labels, `sdl`

,
restricts the assembly process to the subdomains denoted by the labels
in the list. You cannot include a `sdl`

argument
in a model with 3-D geometry. The optional input arguments `u0`

and `time`

are
used for the nonlinear solver and time stepping algorithms, respectively.
The tentative input solution vector `u0`

has the
same format as `u`

.

Solve a 3-D elliptic PDE using a PDE model.

Create a PDE model container, import a 3-D geometry description, and view the geometry.

model = createpde; importGeometry(model,'Block.stl'); h = pdegplot(model,'FaceLabels','on'); h(1).FaceAlpha = 0.5;

Set zero Dirichlet conditions on faces 1 through 4 (the
edges). Set Neumann conditions with *g* =
–1 on face 6 and *g* =
1 on face 5.

applyBoundaryCondition(model,'Face',1:4,'u',0); applyBoundaryCondition(model,'Face',6,'g',-1); applyBoundaryCondition(model,'Face',5,'g',1);

Set coefficients *c* =
1, *a* =
0, and *f* =
0.1.

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

Create a mesh and solve the problem.

generateMesh(model); u = assempde(model,c,a,f);

Plot the solution on the surface.

`pdeplot3D(model,'colormapdata',u);`

Solve the equation Δ*u* = 1 on the geometry
defined by the L-shaped membrane. Use Dirichlet boundary conditions *u* =
0 on ∂Ω. Finally plot the solution.

[p,e,t] = initmesh('lshapeg','Hmax',0.2); [p,e,t] = refinemesh('lshapeg',p,e,t); u = assempde('lshapeb',p,e,t,1,0,1); pdesurf(p,t,u)

Consider Poisson's equation on the unit circle with unit point source at the origin. The exact solution

$$u=-\frac{1}{2\pi}\mathrm{log}(r)$$

is known for this problem. We define the function ```
f
= circlef(p,t,u,time)
```

for computing the right-hand side. `circlef`

returns
zero for all triangles except for the one located at the origin; for
that triangle it returns 1/*a*, where *a* is
the triangle area. `pdedemo7`

executes
an adaptive solution for this problem.

`assema`

| `assemb`

| `initmesh`

| `refinemesh`

Was this topic helpful?