Skip to content
This repository was archived by the owner on Dec 2, 2025. It is now read-only.

Commit 36fe3ab

Browse files
authored
Various documentation improvements (#104)
* most users, not necessarily all * not just a factory * indentation * remove double space * tweak docs * delete commented code * details about natural polynomial spaces (ie make it correct for pyramids) * degree, rather than overloading "order" * move ciarlet definition to ciarlet.rs: finite element trait is not necessarily going use the Ciarlet definition Also guardian style guide change e.g. -> eg * define reference cells * various docstring tweaks * tweak docs * shapes in push forward * slightly more than just a factory * link * make katex work in docs * fmt * full stops * clippy
1 parent 1622fce commit 36fe3ab

17 files changed

Lines changed: 120 additions & 114 deletions

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
mpi: "mpich"
2828
- uses: actions/checkout@v4
2929
- name: Build Rust docs
30-
run: cargo +nightly doc --no-deps -Zunstable-options -Zrustdoc-scrape-examples --all-features
30+
run: RUSTDOCFLAGS="--html-in-header katex-header.html" cargo +nightly doc --no-deps -Zunstable-options -Zrustdoc-scrape-examples --all-features
3131
- name: Make index page
3232
run: echo "<html><head><meta http-equiv='refresh' content='0; URL=ndelement'></head></html>" > target/doc/index.html
3333
- name: Set file permissions

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ blas-src = { version = "0.14", features = ["blis"]}
4444
paste = "1.*"
4545
approx = "0.5"
4646

47-
[build]
48-
rustdocflags = [ "--html-in-header", "katex-header.html" ]
49-
50-
5147
[build-dependencies]
5248
cbindgen = "0.29.*"
5349

src/bindings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Binding for C
1+
//! Bindings for C.
22
#![allow(missing_docs)]
33
#![allow(clippy::missing_safety_doc)]
44

src/ciarlet.rs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
1-
//! Finite element definitions
1+
//! Ciarlet finite elements.
2+
//!
3+
//! In the Ciarlet definition, a finite element is defined to be a triple
4+
//! $(\mathcal{R}, \mathcal{V}, \mathcal{L})$, where:
5+
//!
6+
//! - $\mathcal{R}\subset\mathbb{R}^d$ is the reference cell,
7+
//! - $\mathcal{V}$ is a finite dimensional function space on $\mathcal{R}$ of dimension $n$, usually polynomials,
8+
//! - $\mathcal{L} = \{\ell_0,\dots, \ell_{n-1}\}$ is a basis of the dual space $\mathcal{V}^* = \set{f:\mathcal{V} -> \mathbb{R}: f\text{ is linear}}$, with
9+
// each functional associated with a subentity of the reference cell $\mathcal{R}$.
10+
//!
11+
//! The basis functions $\phi_0,\dots, \phi_{n-1}$ of the finite element space are defined by
12+
//! $$\ell_i(\phi_j) = \begin{cases}1 &\text{if }~i = j \newline
13+
//! 0 &\text{otherwise}\end{cases}.
14+
//! $$
15+
//!
16+
//! ## Example
17+
//! The order 1 [Lagrange space](https://defelement.org/elements/lagrange.html) on a triangle is
18+
//! defined by:
19+
//!
20+
//! - $\mathcal{R}$ is a triangle with vertices $(0, 0)$, $(1, 0)$, $(0, 1)$.
21+
//! - $\mathcal{V} = \text{span}\set{1, x, y}$.
22+
//! - $\mathcal{L} = \set{\ell_0, \ell_0, \ell_1}$ with $\ell_j$ the pointwise evaluation at vertex $v_j$, and each functional associated with the relevant vertex.
23+
//!
24+
//! This gives the basis functions $\phi_0(x, y) = 1 - x - y$, $\phi_1(x, y) = x$, $\phi_2(x, y) = y$.
25+
//!
26+
//! ## References
27+
//! - [https://defelement.org/ciarlet.html](https://defelement.org/ciarlet.html)
228
329
extern crate blas_src;
430
extern crate lapack_src;
@@ -74,8 +100,8 @@ where
74100
{
75101
/// Create a Ciarlet element.
76102
///
77-
/// This should not be used directly. Instead users should call the `create`
78-
/// function for one of the following special cases of a general Ciarlet element.
103+
/// The majority of users will not wish to use this directly, and should insteal call
104+
/// the `create`function for one of the following special cases of a general Ciarlet element:
79105
/// - [crate::ciarlet::lagrange::create]: Create a new Lagrange element.
80106
/// - [crate::ciarlet::nedelec::create]: Create a new Nedelec element.
81107
/// - [crate::ciarlet::raviart_thomas::create]: Create a Raviart-Thomas element.

src/ciarlet/lagrange.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Lagrange elements
1+
//! Lagrange elements.
22
33
use super::CiarletElement;
44
use crate::map::IdentityMap;
@@ -270,7 +270,8 @@ pub fn create<T: RlstScalar + Getrf + Getri>(
270270

271271
/// Lagrange element family.
272272
///
273-
/// A factory structure to create new Lagrange elements.
273+
/// A family of Lagrange elements on multiple cell types with appropriate
274+
/// continuity across different cell types.
274275
pub struct LagrangeElementFamily<T: RlstScalar + Getrf + Getri> {
275276
degree: usize,
276277
continuity: Continuity,

src/ciarlet/nedelec.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Nedelec elements
1+
//! Nedelec elements.
22
33
use super::CiarletElement;
44
use crate::map::CovariantPiolaMap;
@@ -641,7 +641,8 @@ pub fn create<T: RlstScalar + Getrf + Getri>(
641641

642642
/// Nedelec (first kind) element family
643643
///
644-
/// A factory structure to create new Nedelec elements.
644+
/// A family of Nedelec elements on multiple cell types with appropriate
645+
/// continuity across different cell types.
645646
pub struct NedelecFirstKindElementFamily<T: RlstScalar + Getrf + Getri> {
646647
degree: usize,
647648
continuity: Continuity,

src/ciarlet/raviart_thomas.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Raviart-Thomas elements
1+
//! Raviart-Thomas elements.
22
33
use super::CiarletElement;
44
use crate::map::ContravariantPiolaMap;
@@ -484,7 +484,8 @@ pub fn create<T: RlstScalar + Getrf + Getri>(
484484

485485
/// Raviart-Thomas element family
486486
///
487-
/// A factory structure to create new Raviart-Thomas elements.
487+
/// A family of Raviart-Thomas elements on multiple cell types with appropriate
488+
/// continuity across different cell types.
488489
pub struct RaviartThomasElementFamily<T: RlstScalar + Getrf + Getri> {
489490
degree: usize,
490491
continuity: Continuity,

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
//! element.tabulate(&points, 0, &mut basis_values);
3434
//! println!(
3535
//! "The values of the basis functions at the point (1/2, 1/2) are: {:?}",
36-
//! basis_values.data()
36+
//! basis_values.data()
3737
//! );
3838
//! ```
3939
#![cfg_attr(feature = "strict", deny(warnings), deny(unused_crate_dependencies))]

src/map.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//! Maps from the reference cell to/from physical cells
1+
//! Maps from the reference cell to/from physical cells.
22
use crate::traits::Map;
33
use rlst::{Array, MutableArrayImpl, RlstScalar, ValueArrayImpl};
44

55
/// Identity map
66
///
7-
/// An identity map pushes values from the reference to the physical
7+
/// An identity map pushes values from the reference to the physical
88
/// cell without modifying them.
99
pub struct IdentityMap {}
1010

@@ -62,7 +62,7 @@ impl Map for IdentityMap {
6262
/// $$
6363
/// J^{-T}\Phi\circ F^{-1}
6464
/// $$
65-
/// The coviariant Piola map preserves tangential continuity. If $J$
65+
/// The covariant Piola map preserves tangential continuity. If $J$
6666
/// is a rectangular matrix then the pseudo-inverse is used instead of
6767
/// the inverse.
6868
pub struct CovariantPiolaMap {}
@@ -157,9 +157,11 @@ impl Map for CovariantPiolaMap {
157157
/// and let $J$ be its Jacobian. Let $\Phi$ be the function values
158158
/// on the reference cell. The contravariant Piola map is defined by
159159
/// $$
160-
/// \frac{1}{\sqrt{\det{J^TJ}}}J\Phi\circ F^{-1}
160+
/// \frac{1}{\det{J}}J\Phi\circ F^{-1}
161161
/// $$
162-
/// The contravariant Piola map preserves normal continuity.
162+
/// The contravariant Piola map preserves normal continuity. If $J$
163+
/// is a rectangular matrix then $\sqrt{\det{J^TJ}}$ is used instead
164+
/// of $\det{J}$.
163165
pub struct ContravariantPiolaMap {}
164166

165167
impl Map for ContravariantPiolaMap {

src/math.rs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Mathematical functions
1+
//! Mathematical functions.
22
use rlst::{Array, MutableArrayImpl, RlstScalar, ValueArrayImpl};
33

44
/// Orthogonalise the rows of a matrix, starting with the row numbered `start`
@@ -161,31 +161,6 @@ pub fn apply_matrix<T: RlstScalar, Array2Impl: ValueArrayImpl<T, 2>>(
161161
}
162162
}
163163

164-
// /// Orthogonalise the rows of a matrix, starting with the row numbered `start`
165-
// pub(crate) fn orthogonalise<T: RlstScalar, Array2MutImpl: MutableArrayImpl<T, 2>>(
166-
// mat: &mut Array<Array2MutImpl, 2>,
167-
// start: usize,
168-
// ) {
169-
// for row in start..mat.shape()[0] {
170-
// let norm = (0..mat.shape()[1])
171-
// .map(|i| mat.get([row, i]).unwrap().powi(2))
172-
// .sum::<T>()
173-
// .sqrt();
174-
// for i in 0..mat.shape()[1] {
175-
// *mat.get_mut([row, i]).unwrap() /= norm;
176-
// }
177-
// for r in row + 1..mat.shape()[0] {
178-
// let dot = (0..mat.shape()[1])
179-
// .map(|i| *mat.get([row, i]).unwrap() * *mat.get([r, i]).unwrap())
180-
// .sum::<T>();
181-
// for i in 0..mat.shape()[1] {
182-
// let sub = dot * *mat.get([row, i]).unwrap();
183-
// *mat.get_mut([r, i]).unwrap() -= sub;
184-
// }
185-
// }
186-
// }
187-
// }
188-
189164
#[cfg(test)]
190165
mod test {
191166
use super::*;

0 commit comments

Comments
 (0)