Skip to content

Commit 2c88ed8

Browse files
authored
documentation/docstrings overhaul and several improvements in show functions and FEVector handling
supported by github copilot
1 parent 5afe347 commit 2c88ed8

31 files changed

+971
-466
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGES
22

3+
## v1.2.0 June 25, 2025
4+
- major documentation and docstring overhaul
5+
- improved show functions and constructors for FEMatrix, FEVector
6+
- added range check in getindex functions for FEVector
7+
- added slice views for FEVectorBlocks
8+
- added Array conversions for FEVector and FEVectorBlock
9+
310
## v1.1.1 June 16, 2025
411
- docstring improvements
512

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ExtendableFEMBase"
22
uuid = "12fb9182-3d4c-4424-8fd1-727a0899810c"
33
authors = ["Christian Merdon <merdon@wias-berlin.de>", "Patrick Jaap <patrick.jaap@wias-berlin.de>"]
4-
version = "1.1.1"
4+
version = "1.2.0"
55

66
[deps]
77
DiffResults = "163ba53b-c6d8-5494-b064-1a9d43ac40c5"

README.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,13 @@
66

77
# ExtendableFEMBase
88

9-
This package provides basic finite element structures to setup finite element schemes on ExtendableGrids. For a full high-level API
10-
see [ExtendableFEM.jl](https://github.com/WIAS-PDELib/ExtendableFEM.jl).
9+
ExtendableFEMBase.jl provides foundational data structures and tools for assembling custom finite element solvers in Julia. It is designed for flexibility, efficiency, and extensibility, and serves as the low-level backend for [ExtendableFEM.jl](https://github.com/WIAS-PDELib/ExtendableFEM.jl). All functionality is built on top of [ExtendableGrids.jl](https://github.com/WIAS-PDELib/ExtendableGrids.jl).
1110

12-
This low level structures in the package incorporate:
11+
## Features
1312

14-
- Finite element types (Basis functions on reference geometries and dof management for several H1, Hdiv and Hcurl elements)
15-
- FESpace (Discrete finite element space with respect to a mesh from ExtendableGrids, knows the Dofmaps)
16-
- FEMatrix (block overlay for an ExtendableSparse matrix, where each block corresponds to a coupling between two FESpaces in a system)
17-
- FEVector (block overlay for an array, where each block corresponds to a FESpace)
18-
- FunctionOperators (primitive linear operators like Identity, Gradient, Divergence) and rules how to evaluate them for for different finite element types
19-
- FEEvaluator (finite element basis evaluators for different FunctionOperators and entities of the grid)
20-
- QuadratureRule (basic quadrature rules for different ElementGeometries from ExtendableGrids)
21-
- interpolations (standard interpolations into the provided finite element spaces, averaging routines and interpolations between meshes/FESpaces)
22-
- reconstruction operators (special FunctionOperators that involve an interpolation into a different finite element type)
23-
24-
13+
- Wide range of finite element types (H1, Hdiv, Hcurl, etc.)
14+
- Flexible finite element spaces (`FESpace`)
15+
- Block-structured matrices and vectors (`FEMatrix`, `FEVector`)
16+
- Primitive and composite function operators (e.g., gradient, divergence)
17+
- Efficient basis evaluation and quadrature routines
18+
- Interpolation and reconstruction operators

docs/src/examples_intro.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
1-
# About the examples
1+
# About the Examples
22

3-
The examples have been designed with the following issues in mind:
4-
- they run from the Julia REPL
5-
- each example is a Julia module named similar to the basename of the example file.
6-
- an example can be used as the starting point for a project
7-
- some examples define test cases for the test suite
8-
- ExampleXYZ with X = A can be considered advanced and uses low-level structures
9-
and/or demonstrates customisation features or experimental features
10-
- the default output of the main function is printed on the website and can be
11-
used to check if the code runs as expected (unfortunately REPL messages are not recorded)
12-
- printed assembly and solving times (especially in a first iteration) can be much larger due to first-run compilation times
3+
The provided examples are designed with the following goals in mind:
4+
- They can be run directly from the Julia REPL.
5+
- Each example is implemented as a Julia module, named similarly to the file's basename.
6+
- Examples can serve as starting points for your own projects.
7+
- Some examples include test cases that are integrated into the test suite.
8+
- Assembly and solve times (especially for the first run) may be significantly higher due to Julia's just-in-time compilation.
139

1410

1511
## Running the examples
1612

1713
In order to run `ExampleXXX`, perform the following steps:
1814

19-
- Download the example file (e.g. via the source code link at the top)
20-
- Make sure all used packages are installed in your Julia environment
21-
- In the REPL:
22-
```
23-
julia> include("ExampleXXX.jl")`
15+
- Download the example file (e.g., using the source code link at the top of the page).
16+
- Ensure all required packages are installed in your Julia environment.
17+
- In the Julia REPL, run:
2418

19+
```julia
20+
julia> include("ExampleXXX.jl")
2521
julia> ExampleXXX.main()
2622
```
27-
- Some examples offer visual output via the optional argument Plotter = PyPlot or Plotter = GLMakie
28-
(provided the package PyPlot/GLMakie is installed and loaded)
23+
24+
- Some examples provide visual output via the optional argument `Plotter = PyPlot` or `Plotter = GLMakie` (these require the corresponding plotting package to be installed and loaded).

docs/src/feevaluator.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

22
# FEEvaluator
33

4-
FEEvaluators provide a structure that handles the evaluation of finite element basis functions for a given function operator, quadrature rule and item geometry. It stores the evaluations on the reference geometry (where derivatives are computed by automatic differentiation) and on the current mesh item. The current mesh item can be changed via the update! call.
4+
The `FEEvaluator` provides a unified interface for evaluating finite element basis functions, their derivatives, and related quantities for a given function operator, quadrature rule, and mesh entity. It manages the storage and reuse of basis evaluations both on the reference element (where derivatives are computed via automatic differentiation) and on the current mesh item. The mesh item context can be updated dynamically using the `update!` function.
5+
56

67
```@autodocs
78
Modules = [ExtendableFEMBase]

docs/src/fematrix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FEMatrix
22

3-
A FEMatrix consists of FEMatrixBlocks that share a common ExtendableSparseMatrix. Each block is associated to two FESpaces and can only write into a submatrix of the common sparse matrix specified by offsets.
3+
A `FEMatrix` represents a block-structured finite element matrix, where each block (a `FEMatrixBlock`) corresponds to a pair of finite element spaces and operates on a submatrix of a shared `ExtendableSparseMatrix`.
44

55
```@autodocs
66
Modules = [ExtendableFEMBase]

docs/src/fems.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
21
# Implemented Finite Elements
32

4-
This page describes the finite element type-tree and lists all implemented finite elements.
5-
6-
3+
This page provides an overview of the finite element type hierarchy and lists all finite elements currently implemented in ExtendableFEMBase.
74

8-
## The Finite Element Type-Tree
5+
## The Finite Element Type Hierarchy
96

10-
Finite elements are abstract type leaves in a type-tree. The complete tree looks like this:
7+
Finite elements in ExtendableFEMBase are organized as leaves in an abstract type hierarchy. The complete type tree is as follows:
118

129
```
1310
AbstractFiniteElement
@@ -40,21 +37,20 @@ AbstractFiniteElement
4037

4138

4239
#### Remarks
43-
- each type depends on one/two or three parameters, the first one is always the number of components (ncomponents) that determines if the
44-
finite element is scalar- or veector-valued; some elements additionally require the parameter edim <: Int if they are structurally different in different space dimensions; arbitrary order elements require a third parameter that determines the order
45-
- each finite elements mainly comes with a set of basis functions in reference coordinates for each applicable AbstractElementGeometry and degrees of freedom maps for each mesh entity
46-
- broken finite elements are possible via the broken switch in the [FESpace](@ref) constructor
47-
- the type steers how the basis functions are transformed from local to global coordinates and how FunctionOperators are evaluated
48-
- depending on additional continuity properties of the element types more basis function sets are defined:
49-
- AbstractH1FiniteElements additionally have evaluations of nonzero basisfunctions on faces/bfaces
50-
- AbstractHdivFiniteElements additionally have evaluations of nonzero normalfluxes of basisfunctions on faces/bfaces
51-
- AbstractHcurlFiniteElements additionally have evaluations of nonzero tangentfluxes of basisfunctions on edges/bedges
52-
- each finite element has its own implemented standard interpolation interpolate! (see [Finite Element Interpolations](@ref)) that can be applied to a function with header function(result, qpinfo), below it is shortly described what this means for each finite element
40+
- Each finite element type depends on one, two, or three parameters. The first parameter is always the number of components (`ncomponents`), which determines whether the element is scalar- or vector-valued. Some elements also require the parameter `edim <: Int` if their structure differs by spatial dimension. Arbitrary order elements require a third parameter specifying the polynomial order.
41+
- Each finite element provides a set of basis functions in reference coordinates for each applicable `AbstractElementGeometry`, as well as degree-of-freedom (dof) maps for each mesh entity.
42+
- Discontinuous (broken) finite elements can be created using the `broken` switch in the [`FESpace`](@ref) constructor.
43+
- The element type determines how basis functions are transformed from local to global coordinates and how `FunctionOperators` are evaluated.
44+
- Additional continuity properties of element types lead to more specialized basis function sets:
45+
- `AbstractH1FiniteElement` types provide evaluations of nonzero basis functions on faces/boundary faces.
46+
- `AbstractHdivFiniteElement` types provide evaluations of nonzero normal fluxes of basis functions on faces/boundary faces.
47+
- `AbstractHcurlFiniteElement` types provide evaluations of nonzero tangential fluxes of basis functions on edges/boundary edges.
48+
- Each finite element has its own standard interpolation routine `interpolate!` (see [Finite Element Interpolations](@ref)), which can be applied to a function with the signature `function(result, qpinfo)`. The specific interpolation behavior is described for each element below.
5349

5450

55-
## List of implemented Finite Elements
51+
## List of Implemented Finite Elements
5652

57-
The following table lists all currently implemented finite elements and on which geometries they are available (in brackets a dofmap pattern for CellDofs is shown and the number of local degrees of freedom for a vector-valued realisation). Click on the FEType to find out more details.
53+
The following table summarizes all finite elements currently implemented in ExtendableFEMBase and indicates the reference geometries on which they are available. For each entry, the dofmap pattern for cell degrees of freedom is shown in brackets, along with the number of local degrees of freedom for a vector-valued realization. Click on an FEType to view more details.
5854

5955
| FEType | Triangle2D | Parallelogram2D | Tetrahedron3D | Parallelepiped3D |
6056
| :----------------: | :----------------: | :----------------: | :----------------: | :----------------: |
@@ -86,7 +82,7 @@ The following table lists all currently implemented finite elements and on which
8682
| [`HDIVRTkENRICH`](@ref) | ✓ (order-dep) | | ✓ (order-dep) | |
8783

8884

89-
Note: the dofmap pattern describes the connection of the local degrees of freedom to entities of the grid and also hints to the continuity. Here, "N" or "n" means nodes, "F" or "f" means faces, "E" or "e" means edges and "I" means interior (dofs without any continuity across elements). Capital letters cause that every component has its own degree of freedom, while small letters signalize that only one dof is associated to the entity. As an example "N1f1" (for the Bernardi-Raugel element) means that at each node sits one dof per component and at each face sits a single dof. Usually finite elements that involve small letters are only defined vector-valued (i.e. the number of components has to match the element dimension), while finite elements that only involve capital letters are available for any number of components.
85+
Note: The dofmap pattern describes how local degrees of freedom are associated with grid entities and provides insight into the continuity properties of the element. Here, "N" or "n" denotes nodes, "F" or "f" denotes faces, "E" or "e" denotes edges, and "I" denotes interior degrees of freedom (i.e., those without continuity across elements). Capital letters indicate that each component has its own degree of freedom, while lowercase letters mean only one degree of freedom is associated with the entity. For example, "N1f1" (as in the Bernardi-Raugel element) means that each node has one dof per component and each face has a single dof. Typically, finite elements involving lowercase letters are only defined for vector-valued cases (i.e., the number of components must match the element dimension), while those with only capital letters are available for any number of components.
9086

9187

9288
## H1-conforming finite elements

docs/src/fespace.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# FESpace
33

4-
To generate a finite element space only a finite element type and a grid is needed, dofmaps are generated automatically on their first demand.
4+
A **finite element space** (FESpace) represents the set of all functions that can be expressed using a particular finite element type on a given computational grid. In ExtendableFEMBase, constructing a finite element space requires only specifying the finite element type and the grid; all necessary degree-of-freedom (dof) mappings are generated automatically on first access.
55

66
```@autodocs
77
Modules = [ExtendableFEMBase]

docs/src/fevector.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# FEVector
22

3-
A FEVector consists of FEVectorBlocks that share a common one-dimensional array. Each block is associated to a FESpace and can only write into a region of the common array specified by offsets that stores the degrees of freedom of that FEspace.
3+
A `FEVector` represents a block-structured vector used in finite element computations. It consists of one or more `FEVectorBlock`s, each associated with a specific `FESpace`. All blocks share a common one-dimensional array that stores the global degrees of freedom (DoFs). Each block can only write to a region of the array specified by offsets, ensuring that each `FESpace` manages its own DoFs within the global vector.
44

55

66
```@autodocs

docs/src/functionoperators.md

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
21
# Function Operators
32

43
## StandardFunctionOperators
54

6-
StandardFunctionOperators are abstract types that encode primitive (linear) operators (like Identity, Gradient etc.)
7-
used to dispatch different evaluations of finite element basis functions.
5+
`StandardFunctionOperators` are abstract types that represent fundamental (linear) operators, such as the identity, gradient, divergence, and others. These operators provide a unified interface for evaluating finite element basis functions in various ways.
86

9-
### List of primitive operators
7+
### List of Primitive Operators
108

119
| StandardFunctionOperator | Description | Mathematically |
1210
| :--------------------------------------------------- | :------------------------------------------------------- | :------------------------------------------------------------------------ |
@@ -28,12 +26,9 @@ used to dispatch different evaluations of finite element basis functions.
2826

2927
!!! note
3028

31-
As each finite element type is transformed differently from the reference domain to the general domain,
32-
the evaluation of each function operator has to be implemented for each finite element class.
33-
Currently, not every function operator works in any dimension and for any finite element. More evaluations
34-
are added as soon as they are needed (and possibly upon request).
35-
Also, the function operators can be combined with user-defined actions to evaluate other operators that
36-
can be build from the ones available (e.g. the deviator).
29+
The transformation from the reference domain to the physical domain differs for each finite element class. As a result, the evaluation of each function operator must be implemented specifically for every finite element class. Not all function operators are currently available for every dimension or element type, but new implementations are added as needed or upon request.
30+
31+
Additionally, function operators can be combined with user-defined kernels to postprocess/construct more advanced operators from the available primitives (for example, the deviatoric part of a tensor).
3732

3833

3934
```@autodocs
@@ -45,25 +40,22 @@ Order = [:type, :function]
4540

4641
## ReconstructionOperators
4742

48-
There are special operators that allow to evaluate a primitive operator of some discrete
49-
reconstructed version of a testfunction.
43+
Special operators are provided to evaluate a primitive operator on a reconstructed version of a test function. These are useful for advanced discretizations and post-processing.
5044

5145
```@autodocs
5246
Modules = [ExtendableFEMBase]
5347
Pages = ["reconstructionoperators.jl"]
5448
Order = [:type, :function]
5549
```
5650

57-
### Divergence-free reconstruction operators
58-
For gradient-robust discretisations of certain classical non divergence-conforming ansatz spaces,
59-
reconstruction operators are available that map a discretely divergence-free H1 function to a pointwise divergence-free
60-
Hdiv function. So far such operators are available for the vector-valued Crouzeix-Raviart (H1CR) and Bernardi--Raugel (H1BR) finite element types,
61-
as well as for the P2-bubble (H1P2B) finite element type in two dimensions.
51+
### Divergence-Free Reconstruction Operators
52+
53+
For gradient-robust discretizations of certain classical non-divergence-conforming ansatz spaces, reconstruction operators are available that map a discretely divergence-free H1 function to a pointwise divergence-free H(div) function. Currently, such operators are implemented for the vector-valued Crouzeix-Raviart (H1CR) and Bernardi–Raugel (H1BR) finite element types, as well as for the P2-bubble (H1P2B) element in two dimensions.
6254

63-
**Example:** Reconst{HDIVRT0{d}, Identity} gives the reconstruction of the Identity operator into HDIVRT0 (and is available for H1BR{d} and H1CR{d} for d = 1,2)
55+
**Example:** `Reconst{HDIVRT0{d}, Identity}` reconstructs the identity operator into HDIVRT0, and is available for `H1BR{d}` and `H1CR{d}` for `d = 1, 2`.
6456

6557

6658

67-
## Operator Pairs (experimental)
59+
## Operator Pairs (Experimental)
6860

69-
Two function operators can be put into an OperatorPair so that one can provide effectively two operators in each argument of an assembly pattern. However, the user should make sure that both operators can be evaluated together reasonably (meaning both should be well-defined on the element geometries and the finite element space where the argument will be evaluated, and the action of the operator has to operate with coressponding input and result fields). This feature is still experimental and might have issues in some cases. OperatorTriple for a combination of three operators is also available.
61+
Two function operators can be combined into an `OperatorPair`, allowing you to provide two operators in each argument of an assembly pattern. Both operators must be well-defined on the relevant element geometries and finite element spaces, and their actions must be compatible with the input and result fields. This feature is experimental and may have limitations in some cases. An `OperatorTriple` is also available for combining three operators.

0 commit comments

Comments
 (0)