Assemble area integral contributions

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

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

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.

K

M

F

model

c

a

f

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

p

t

collapse all

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

The PDE is Poisson's equation,

Partial Differential Equation Toolbox™ solves equations of the form

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.

ForearmLink.stl

model = createpde; importGeometry(model,'ForearmLink.stl'); h = pdegplot(model); h(1).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 legacy syntax.

Define the geometry using the lshapeg function included your software.

lshapeg

g = @lshapeg;

Use coefficients c = 1, a = 0, and 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.

Fraction of nonzero entries in K is 0.042844 Number of nonzero entries in M is 0

PDEModel

PDE model, specified as a PDEModel object.

Example: model = createpde(1)

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

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

or in the system of PDEs

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

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

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

'cosh(x+y.^2)'

Data Types: double | char | function_handleComplex Number Support: Yes

double

char

function_handle

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

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

Example: 2*eye(3)

2*eye(3)

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

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

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

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

initmesh

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)

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

Data Types: double

Mesh elements, specified as the output of initmesh or meshToPet. Mesh elements are the triangles or tetrahedra that form the finite element mesh. For the structure of a t matrix, see Mesh Data for [p,e,t] Triples: 2-D and Mesh Data for [p,e,t] Triples: 3-D.

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

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

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.

hyperbolic

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

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

assemb | assempde

assemb

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.