You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
High Level API Finite Element Methods based on [ExtendableGrids.jl](https://github.com/WIAS-PDELib/ExtendableGrids.jl) (for grid management)
9
-
and [ExtendableFEMBase.jl](https://github.com/WIAS-PDELib/ExtendableFEMBase.jl) (for finite element basis functions and dof management).
10
-
It offers a ProblemDescription interface, that basically involves assigning Unknowns and Operators. Such operators usually stem from a weak formulation of the problem and mainly consist of three types that can be customized via kernel functions:
7
+
**ExtendableFEM.jl** is a high-level, extensible finite element method (FEM) library for Julia, supporting flexible problem descriptions, custom operators, and advanced grid management.
11
8
12
-
- BilinearOperator,
13
-
- LinearOperator,
14
-
- NonlinearOperator (that automatically assemble Newton's method by automatic differentiation)
9
+
## Features
15
10
16
-
### Quick Example
11
+
- High-level, extensible API for solving PDE problems by finite element methods
12
+
- Flexible `ProblemDescription` interface for assigning unknowns and operators
13
+
- Supports custom kernel functions for bilinear, linear, and nonlinear forms
14
+
- Automatic assembly and Newton's method for NonlinearOperators
15
+
- Builds upon [ExtendableGrids.jl](https://github.com/WIAS-PDELib/ExtendableGrids.jl) and low level structures from [ExtendableFEMBase.jl](https://github.com/WIAS-PDELib/ExtendableFEMBase.jl)
17
16
18
-
The following minimal example demonstrates how to setup a Poisson problem.
17
+
## Quick Example
18
+
19
+
The following minimal example demonstrates how to set up and solve a Poisson problem:
19
20
20
21
```julia
21
22
using ExtendableFEM
22
23
using ExtendableGrids
23
24
24
-
#build/load any grid (here: a uniform-refined 2D unit square into triangles)
25
+
#Build a uniform-refined 2D unit square grid with triangles
Copy file name to clipboardExpand all lines: docs/src/bilinearoperator.md
+20-25Lines changed: 20 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,12 @@
1
-
2
1
# BilinearOperator
3
2
4
-
A bilinear operator allows to add matrices to the system matrix that usually refer to
5
-
linearisations of the PDE operators or stabilisations. If the bilinear operator
6
-
lives on face entities, also jumps of operators can be involved, if they are naturally
7
-
continuous for the finite element space in operation (also jumps for broken spaces)
8
-
and only involve degrees of freedom on the face, e.g.
9
-
normal jumps for Hdiv spaces or jumps for H1-conforming spaces or tangential jumps
10
-
of Hcurl spaces. For all other discontinuous operator evaluations
11
-
(that needs to evaluat more than the degrees of freedom on the face)
12
-
there is the possibility to use BilinearOperatorDG.
13
-
It is also possible to assign a matrix assembled by the user as a BilinearOperator.
3
+
`BilinearOperator` provides a flexible interface for defining bilinear forms (matrices) in finite element problems. These operators typically represent (linearizations of) PDE operators, stabilization terms, or custom user-defined couplings. The interface supports both standard and discontinuous Galerkin (DG) forms, and allows for custom assembly on cells, faces, or other grid entities.
4
+
5
+
## Overview
6
+
7
+
-**Standard Bilinear Operators:** Assemble contributions to the system matrix, including diffusion, mass, and convection terms, as well as custom couplings. Supports both cell- and face-based assembly, including jump terms for conforming and piecewise spaces that only require the dofs on that entity.
8
+
-**Discontinuous Galerkin (DG) Operators:** Use `BilinearOperatorDG` for forms that require evaluation of jumps or averages involving all degrees of freedom on neighboring cells (e.g., interior penalty stabilization, gradient jumps for H1 elements).
9
+
-**Custom Matrices:** You can also assign a user-assembled matrix as a `BilinearOperator`.
14
10
15
11
## Constructors
16
12
@@ -22,10 +18,7 @@ Order = [:type, :function]
22
18
23
19
## BilinearOperatorDG
24
20
25
-
BilinearOperatorDG is intended for bilinear forms that involves jumps of discontinuous quantities
26
-
on faces whose assembly requires evaluation of all degrees of freedom on the neighbouring cells,
27
-
e.g. gradient jumps for H1 conforming functions. In this case the assembly loop triggers
28
-
integration along the boundary of the cells.
21
+
`BilinearOperatorDG` is intended for bilinear forms that involve jumps or averages of discontinuous quantities on faces, requiring access to all degrees of freedom on neighboring cells. This is essential for DG methods and certain stabilization techniques.
29
22
30
23
```@autodocs
31
24
Modules = [ExtendableFEM]
@@ -35,11 +28,10 @@ Order = [:type, :function]
35
28
36
29
## Examples
37
30
38
-
Below two examples illustrate some use cases.
31
+
### Example: Stokes Operator
39
32
40
-
### Example - Stokes operator
33
+
For the linear operator of a Stokes problem, a kernel could look like:
41
34
42
-
For the linear operator of a Stokes problem a kernel could look like
43
35
```julia
44
36
μ =0.1# viscosity parameter
45
37
functionkernel!(result, input, qpinfo)
@@ -52,26 +44,29 @@ function kernel!(result, input, qpinfo)
52
44
returnnothing
53
45
end
54
46
```
55
-
and the coressponding BilinearOperator constructor call reads
47
+
48
+
The corresponding `BilinearOperator` constructor call reads:
The additional argument causes that the zero pressure-pressure block of the matrix is not (even tried to be) assembled,
62
-
since ```input[5]``` does not couple with ```result[5]```.
63
55
56
+
The `use_sparsity_pattern` argument ensures that the zero pressure-pressure block of the matrix is not assembled, since `input[5]` does not couple with `result[5]`.
57
+
58
+
### Example: Interior Penalty Stabilization
64
59
65
-
### Example - interior penalty stabilization
60
+
A popular stabilization for convection-dominated problems is based on jumps of the gradient, which can be realized with the following kernel:
66
61
67
-
A popular convection stabilization is based on the jumps of the gradient, which can be realised with
A callback operator passes the matrix and rhs to a user-defined function where they can be modified as desired.
5
-
An example where this is used is Example265.
3
+
`CallbackOperator` provides a flexible interface for injecting custom assembly logic into the finite element workflow. It delegates the assembly of the system matrix and right-hand side to a user-supplied callback function, allowing for advanced or nonstandard modifications that are difficult to express with standard operators.
`CombineDofs` provides a mechanism to couple degrees of freedom (DOFs) in a finite element system. This is especially useful for enforcing periodic boundary conditions, multi-point constraints, or other situations where DOFs from different locations or unknowns should be treated as identical in the assembled system.
4
+
4
5
```@autodocs
5
6
Modules = [ExtendableFEM]
6
7
Pages = ["common_operators/combinedofs.jl"]
7
8
Order = [:type, :function]
8
9
```
9
10
10
-
The following function might be useful to find out the dofs
11
-
the need to be coupled for periodic
12
-
boundary conditions:
11
+
## Periodic Boundary Conditions
13
12
13
+
To set up periodic boundary conditions, you often need to determine which DOFs should be coupled. The following utility functions can help:
14
14
15
15
```@docs
16
16
get_periodic_coupling_info
17
+
get_periodic_coupling_matrix
17
18
```
19
+
20
+
## Example: Periodic Boundary Coupling (extract from Example212)
21
+
22
+
Suppose you want to enforce periodicity between the left and right boundaries of a 2D domain. You can use `get_periodic_coupling_matrix` to find the corresponding DOFs, and then use `CombineDofs` to couple them in the system. The following code is adapted from [Example212_PeriodicBoundary2D.jl](https://github.com/WIAS-PDELib/ExtendableFEM.jl/blob/main/examples/Example212_PeriodicBoundary2D.jl):
23
+
24
+
```julia
25
+
# Define a function to map points on the left to the right boundary
# Assign the CombineDofs operator to the problem description
36
+
assign_operator!(PD, CombineDofs(u, u, coupling_matrix))
37
+
```
38
+
39
+
See also [Example212](https://wias-pdelib.github.io/ExtendableFEM.jl/stable/examples/) and [Example312](https://wias-pdelib.github.io/ExtendableFEM.jl/stable/examples/) for more advanced use cases and details on periodic boundary conditions.
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,
13
-
the printouts in the documentation are taken from a second run after compilations are done
14
-
15
-
16
-
## Running the examples
17
-
18
-
In order to run `ExampleXXX`, perform the following steps:
19
-
20
-
- Download the example file (e.g. via the source code link at the top)
21
-
- Make sure all used packages are installed in your Julia environment
22
-
- In the REPL:
23
-
```
24
-
julia> include("ExampleXXX.jl")`
25
-
26
-
julia> ExampleXXX.main()
27
-
```
28
-
- Some examples offer visual output via the optional argument Plotter = PyPlot or Plotter = GLMakie
29
-
(provided the package PyPlot/GLMakie is installed and loaded)
1
+
# About the Examples
2
+
3
+
The examples in this package are designed to be practical, reproducible, and educational. They demonstrate a wide range of finite element applications and PDE model problems.
4
+
5
+
## Design Principles
6
+
7
+
-All examples can be run directly from the Julia REPL.
8
+
-Each example is a Julia module named after the file.
9
+
- Examples can serve as templates for your own projects.
10
+
-Many examples include test cases for automated verification.
11
+
12
+
## Running the Examples
13
+
14
+
To run an example (e.g., `Example212_PeriodicBoundary2D`):
15
+
16
+
1. Download the example file (see the source code link at the top of the example page).
17
+
2. Ensure all required packages are installed in your Julia environment.
18
+
3.In the Julia REPL:
19
+
20
+
```julia
21
+
julia>include("Example212_PeriodicBoundary2D.jl")
22
+
julia> Example212_PeriodicBoundary2D.main()
23
+
```
24
+
25
+
4. Some examples offer visual output via the optional argument `Plotter = PyPlot` or `Plotter = GLMakie` (provided the package is installed and loaded):
The face interpolator provides tools for evaluating and interpolating finite element functions on mesh faces. This is particularly useful for postprocessing tasks that require access to traces or jumps of functions across element boundaries.
`HomogeneousData` provides a convenient way to enforce homogeneous (zero) Dirichlet boundary conditions or constraints in a finite element problem. It automatically sets the solution to zero on specified regions or entities.
0 commit comments