Contents

On this page


triellipt.fem

FEM (P1) solver.

getunit()

triellipt.fem.getunit(mesh, anchors=None, mode=None)

Creates a FEM computing unit.

Parameters

mesh : TriMesh

Input triangle mesh.

anchors : Iterable = None

Provides (float, float) points to synchronize the mesh boundary.

mode : str = None

Solver mode — "fvm" or "fem" (default).

Returns

FEMUnit

FEM computing unit.

getdtn()

triellipt.fem.getdtn(mesh, anchors, mode=None)

Creates a FEM-DtN unit.

Parameters

mesh : TriMesh

Input triangle mesh.

anchors : Iterable

Provides (float, float) points to partition the mesh boundary.

mode : str = None

Solver mode — "fvm" or "fem" (default).

Returns

FEMDtN

FEM-DtN computing unit.

Notes

FEM-DtN units are only supported for simply-connected meshes.

FEMUnit

class triellipt.fem.FEMUnit(mesh=None, meta=None)

FEM computing unit.

Properties

Basic FEM operators as data-streams:

Name Description
massmat Mass-matrix
massdig Mass-matrix lumped
diff_1y 1st y-derivative (weak)
diff_1x 1st x-derivative (weak)
grad_1y 1st y-derivative (strong)
grad_1x 1st x-derivative (strong)
diff_2y 2nd y-derivative (weak)
diff_2x 2nd x-derivative (weak)
diff_yx 2nd yx-derivative (weak)
diff_xy 2nd xy-derivative (weak)

General properties:

Name Description
grad Gradient operator (a).
geom Geometric properties (b).
perm Mesh-to-unit permutation (c).
base Basic edge-core partition.
loops List of the mesh loops.
partts Map of the unit partitions.

Notes

add_partition()

FEMUnit.add_partition(self, partt_spec)

Adds new partition to the unit.

Parameters

partt_spec : dict

Partition specification.

Returns

self

Unit with the partition added.

get_partition()

FEMUnit.get_partition(self, partt_name)

Fetches the unit partition.

Parameters

partt_name : str

Partition name.

Returns

FEMPartt

Desired unit partition.

del_partition()

FEMUnit.del_partition(self, name) → None

Deletes the specified partition from the unit.

getinterp()

FEMUnit.getinterp(self, xnodes, ynodes)

Creates an interpolator on a mesh.

Parameters

xnodes : flat-float-array

x-coordinates of the interpolation nodes.

ynodes : flat-float-array

y-coordinates of the interpolation nodes.

Returns

TriInterp

Callable interpolator.

Notes

TriInterp object has the following attributes:

TriInterp() takes nodes-data and returns interpolated one.

massopr()

FEMUnit.massopr(self, is_lumped, add_constr)

Creates the mass operator from the base partition.

Parameters

is_lumped : bool

Creates a lumped mass operator, if True.

add_constr : bool

Adds constraints, if True.

Returns

MatrixFEM

Mass operator as a matrix.

average()

FEMUnit.average(self, data)

Converts node-based data to triangle-averaged values.

Parameters

data : float-flat-array

Node-based data.

Returns

float-flat-array

Triangle-averaged values.

FEMDtN

class triellipt.fem.FEMDtN(unit=None)

FEM-DtN computing unit.

Properties

Name Description
fem Parent FEM unit.
dtn DtN partition.

dirich_sides()

FEMDtN.dirich_sides(self) → list

Returns a list of Dirichlet sides.

switch_side()

FEMDtN.switch_side(self, key)

Switches the DtN state of the boundary part.

Parameters

key : int

Index of the boundary part.

Returns

self

Unit itself.

FEMPartt

class triellipt.fem.FEMPartt(unit, meta, edge)

FEM unit partition.

Properties

Name Description
core Core section.
edge Map of edge sections.
meta Partition metadata.

new_vector()

FEMPartt.new_vector(self)

Creates a new FEM vector.

Returns

VectorFEM

New empty FEM vector.

new_matrix()

FEMPartt.new_matrix(self, operator, add_constr=False)

Creates a new FEM matrix.

Parameters

operator : flat-float-array

Linear combination of the basic FEM operators.

add_constr : bool = False

Constraints are included in the matrix, if True.

Returns

MatrixFEM

Resulting FEM matrix.

get_nodes()

FEMPartt.get_nodes(self, key)

Retrieves the points of the partition section.

Parameters

key : int

Number of the partition section.

Returns

two-row-float-array

Points of the partition section stacked horizontally.

Notes

This method is also available as nodes2d(key).

MatrixFEM

class triellipt.fem.MatrixFEM(partt=None, body=None, meta=None)

Global FEM matrix.

getblock()

MatrixFEM.getblock(self, row_id, col_id)

Extracts a block of a matrix.

Parameters

row_id : int

ID of the vertical section.

col_id : int

ID of the horizontal section.

Returns

csc-matrix

Matrix bock in CSC format.

VectorFEM

class triellipt.fem.VectorFEM(partt=None, body=None)

FEM vector.

with_body()

VectorFEM.with_body(self, value)

Defines the vector body.

Parameters

value : scalar | flat-float-array

Data that defines the vector body.

Returns

VectorFEM

Copy of the vector with the body updated.

from_func()

VectorFEM.from_func(self, func)

Defines the vector via a function on the mesh nodes.

Parameters

func : Callable

Function (x, y) that returns the vector body.

Returns

VectorFEM

Copy of the vector with the body updated.

constrained()

VectorFEM.constrained(self)

Constrains the vector on the parent mesh.

Returns

VectorFEM

Copy of the vector with the body constrained.

getsection()

VectorFEM.getsection(self, sec_id)

Returns a copy of the vector section.

Parameters

sec_id : int

ID of the vector section.

Returns

flat-float-array

Copy of the vector section.

setsection()

VectorFEM.setsection(self, sec_id, data) → None

Defines the vector section.

Parameters

sec_id : int

ID of the vector section.

data : scalar | flat-float-array

Data that defines the vector section.

mesh_grad()

triellipt.fem.mesh_grad(mesh)

Returns the mesh gradient operator.

Parameters

mesh : TriMesh

Triangular mesh.

Returns

TriGrad

Gradient operator on the mesh.

Notes

mesh_geom()

triellipt.fem.mesh_geom(mesh)

Returns the mesh geometric properties.

Parameters

mesh : TriMesh

Triangular mesh.

Returns

MeshGeom

Object with the geometric properties of triangles.

Notes

MeshGeom object has the following attributes:

mesh_metric()

triellipt.fem.mesh_metric(mesh)

Returns the mesh metric properties.

Parameters

mesh : TriMesh

Triangular mesh.

Returns

MeshMetric

Object with the metric properties of triangles.

Notes

MeshMetric object has the following attributes:


Copyright © 2023, Igor Semenov.