Contents

On this page

triellipt — FEM Solver


Using the FEM Solver

This page guides you through the process of solving PDEs with triellipt.

In what follows, we assume the following import is used:

Pythonimport triellipt as tri

Creating a Mesh

There are a couple of methods to create a mesh:

Refer to Meshing for more details.


Creating a FEM Unit

The next step is to create a FEM computing unit:

Pythonunit = tri.fem.getunit(mesh)

For more details, refer to triellipt.fem.getunit().

Two solver modes are available:

The mesh is preprocessed when creating a unit:

Facts to know:

(a) The permutation is the DataPerm object with the attributes:

For more details, refer to triellipt.fem.FEMUnit.


Creating a Partition

After creating the FEM unit, you must partition the mesh boundary.

Two steps are needed:

Facts to know:

Here is the basic structure of the partition spec:

Pythonpartt_spec = {
    'name': 'new-domain',
    'anchors': [
        (0, 0), (0, 1), ...
    ],
    'dirichlet-sides': [1, 2, ...]
}

The keys are:

Key Description
"name" Name of the partition.
"anchors" Points that define how the mesh boundary is split.
"dirichlet-sides" Section numbers where Dirichlet BCs are applied.

Boundary partition

Section numbering

The numbering convention is as follows:

The core section includes all mesh nodes except those on Dirichlet sides.

Automatic partition

Boundary partitioning can be automated using triellipt.fem.FEMDtN.

This option is only available for simply-connected meshes. The anchor points are still used to split the boundary, but they are kept separately as corners in the partition.

The section numerng is as follows:

See also triellipt.fem.getdtn().

Creating a Matrix

FEM matrices are generated from a partition of the FEM unit — see triellipt.fem.FEMPartt.new_matrix().

Two steps are needed:

(a) Applies only to non-conformal meshes.

The matrix is then generated as follows:

Pythonmatrix = unit.partts['new-domain'].new_matrix(operator, add_constr=True/False)

Set an operator

A general FEM operator is a linear combination of basic FEM operators.

Basic operators

Basic FEM operators are available as properties of triellipt.fem.FEMUnit.

All basic operators are flat arrays representing a special data structure — matrix data stream.

Here is an example of constructing a Laplace operator:

Pythonoperator = unit.diff_2x + unit.diff_2y

Coefficients

Operators can be scaled by coefficients defined on a matrix data stream. To support this, the FEM unit exposes three properties — unit.ij_r, unit.ij_c and unit.ij_t — to specify the row, column, and triangle indices for each matrix value.

Assume we define a triangle-based coefficient as

Pythoncoeff = some_func(*unit.mesh.centrs2d)

where

Then the scaled Laplace operator can be defined as

Pythonoperator = coeff[unit.ij_t] * (unit.diff_2x + unit.diff_2y)

Add constraints

Get sections

For more details, refer to triellipt.fem.MatrixFEM.


Creating a Vector

FEM vectors are generated from a partition of the FEM unit — see triellipt.fem.FEMPartt.new_vector().

For more details, refer to triellipt.fem.VectorFEM.


Copyright © 2023, Igor Semenov.