Rodin::Variational namespace

Namespace Rodin::Variational.

Directory src/Rodin/Variational

Module which provides the necessary tools for constructing and solving variational problems.

The Variational module is the core of the Rodin finite element framework. It provides classes for defining finite element spaces, trial and test functions, variational forms, boundary conditions, and problems.

Finite Element Spaces

  • P0 — Piecewise constant (discontinuous) finite element space
  • P0g — Global constant space (1 DOF for scalar, vdim for vector)
  • P1 — Piecewise linear (continuous) finite element space
  • H1 — Higher-order $ H^1 $ -conforming finite element space (arbitrary polynomial order)

Functions

  • TrialFunction — Represents the unknown solution $ u $ in a variational formulation
  • TestFunction — Represents the weighting function $ v $
  • GridFunction — A concrete function storing DOF values in a finite element space

Variational Forms

The module supports building variational problems of the form:

\[ \text{Find} \quad u \in U \quad \text{ s.t. } \quad \forall v \in V \quad a(u, v) = b(v) \ , \]

which are translated into linear algebra problems $ \mathbf{A}\mathbf{x} = \mathbf{b} $ .

Key expression classes:

  • Integral(A, B) — Domain integrals (bilinear or linear forms)
  • BoundaryIntegral(A, B) — Boundary integrals
  • FaceIntegral(A, B) — Integrals over all faces (interior + boundary)
  • InterfaceIntegral(A, B) — Integrals over interior faces only

Differential operators:

  • Grad(u) — Gradient operator
  • Div(u) — Divergence operator
  • Jacobian(u) — Jacobian (gradient of vector field)
  • Transpose(A) — Matrix transpose

Algebraic operators:

  • Dot(A, B) — Inner product / Frobenius contraction
  • Trace(A) — Matrix trace
  • Frobenius(A) — Frobenius norm
  • Component(u, i) — Extract $ i $ -th component of vector function

DG operators:

  • Jump(u) — Jump across internal faces: $ [u] = u^+ - u^- $
  • Average(u) — Average across internal faces: $ \{u\} = (u^+ + u^-)/2 $

Boundary conditions:

  • DirichletBC(u, g) — Essential boundary conditions
  • PeriodicBC(u, dofMap) — Periodic boundary conditions

Convenience functions:

  • RealFunction — Scalar function from constant or lambda
  • VectorFunction — Vector function from initializer list
  • Zero — Zero scalar/vector function
  • Pow, Exp, Sqrt, Sin, Cos, Tan, Abs, Min, Max — Pointwise math operations

Special operators:

  • BoundaryNormal(mesh) — Outward unit normal on $ \partial\Omega $
  • FaceNormal(mesh) — Unit normal on mesh faces
  • IdentityMatrix(n) $ n \times n $ identity matrix function
  • F::x, F::y, F::z — Coordinate projection functions
  • Re(u), Im(u), Conjugate(u) — Complex-valued function operators

Advanced operators:

  • Potential(K, u) — Integral convolution: $ \int K(\mathbf{x},\mathbf{y}) u(\mathbf{y}) \, d\mathbf{y} $
  • Flow(t, u, vel) — Flow composition $ u \circ \Phi_t $ (characteristic tracing for advection)
  • TraceOperator(u, attr) — Boundary trace $ u|_{\partial\Omega} $
  • LinearElasticityIntegral(u, v)(lambda, mu) — Hooke elasticity bilinear form

Problem

The Problem class assembles all forms and boundary conditions into a solvable linear system.

P1 Vh(mesh);
TrialFunction u(Vh);
TestFunction  v(Vh);

Problem poisson(u, v);
poisson = Integral(Grad(u), Grad(v))
        - Integral(f, v)
        + DirichletBC(u, Zero());

Solver::CG(poisson).solve();

Classes

template<class Solution, class TrialFES, class TestFES>
class BilinearForm<Solution, TrialFES, TestFES, ::Mat>
Bilinear form specialization that assembles into a PETSc matrix.
template<class Solution, class TrialFES, class TestFES, class Scalar>
class BilinearForm<Solution, TrialFES, TestFES, Math::Matrix<Scalar>>
Specialization of BilinearForm for a dense matrix operator.
template<class Solution, class TrialFES, class TestFES, class Scalar>
class BilinearForm<Solution, TrialFES, TestFES, Math::SparseMatrix<Scalar>>
Speciallization of BilinearForm for a matrix type.
template<class Operator>
class BilinearFormBase
Base class for bilinear form representations.
template<size_t K>
class FeketeTetrahedron
Cached Fekete-type nodes on the reference tetrahedron for degree K.
template<size_t K>
class FeketeTriangle
Cached Fekete-type nodes on the reference triangle for degree K.
template<class Derived>
class FiniteElementBase
Base class for finite elements.
template<class Derived>
class FiniteElementSpace<Geometry::Mesh<Context::MPI>, Derived>
Represents a finite element space defined on a distributed mesh.
template<class Derived>
class FunctionBase
Base class for functions defined on finite element meshes.
template<class FES>
class GridFunction<FES, ::Vec>
Grid function specialization storing DOF coefficients in a PETSc vector (Vec).
template<class FES>
class GridFunction<FES, Math::Vector<typename FormLanguage::Traits<FES>::ScalarType>>
Grid function storing its degrees of freedom in a dense Math::Vector over the space's scalar type (the standard local backend).
template<class Derived, class FES = typename FormLanguage::Traits<Derived>::FESType, class Data = typename FormLanguage::Traits<Derived>::DataType>
class GridFunctionBase
Base class for discrete finite element functions.
template<size_t K, class Scalar>
class H1<K, Math::SpatialVector<Scalar>, Geometry::Mesh<Context::MPI>>
Distributed vector-valued H1 finite element space for MPI meshes.
template<size_t K, class Scalar>
class H1<K, Scalar, Geometry::Mesh<Context::MPI>>
Distributed H1 finite element space for MPI meshes (scalar range).
class Integrator
Abstract base class for integrators in variational formulations.
template<class FES>
struct IsTestFunction<PETSc::Variational::TestFunction<FES>>
Marks PETSc test functions as valid test functions.
template<class Solution, class FES>
struct IsTrialFunction<PETSc::Variational::TrialFunction<Solution, FES>>
Marks PETSc trial functions as valid trial functions.
template<size_t K>
class JacobiPolynomial
Jacobi polynomial evaluator.
template<size_t K>
class LegendrePolynomial
Compile-time degree Legendre polynomial evaluator.
template<class Solution, class FES>
class LinearElasticityIntegral
Helper class to construct linear elasticity integrators.
template<class Solution, class FES, class LambdaDerived, class MuDerived>
class LinearElasticityIntegrator
Bilinear form integrator for linear elasticity.
template<class Solution, class MuDerived, class LambdaDerived, class Range, class Mesh>
class LinearElasticityIntegrator<Solution, P1<Range, Mesh>, MuDerived, LambdaDerived>
P1 linear elasticity bilinear form integrator.
template<class FES>
class LinearForm<FES, ::Vec>
Linear form specialization that assembles into a PETSc vector.
template<class Derived>
class NonLinearFormIntegrator
CRTP mixin for nonlinear form integrators.
template<class Range, class Mesh>
class P0
Degree 0 Lagrange finite element space.
template<class Range>
class P0<Range, Geometry::Mesh<Context::MPI>>
Distributed P0 finite element space for MPI meshes.
template<class Range>
class P0Element
Degree 0 Lagrange element.
template<>
class P0g<Math::SpatialVector<Real>, Geometry::Mesh<Context::MPI>>
Distributed vector P0g finite element space for MPI meshes.
template<>
class P0g<Real, Geometry::Mesh<Context::MPI>>
Distributed scalar P0g finite element space for MPI meshes.
template<class Range, class Mesh>
class P1
Degree 1 Lagrange finite element space.
template<class Range>
class P1<Range, Geometry::Mesh<Context::MPI>>
Distributed P1 finite element space for MPI meshes.
template<class Range>
class P1Element
Degree 1 Lagrange element.
template<class U, class V>
class Problem<PETSc::Math::LinearSystem, U, V>
PETSc variational problem for a single trial / test function pair.
template<class U1, class U2, class U3, class... Us>
class Problem<PETSc::Math::LinearSystem, U1, U2, U3, Us...>
PETSc variational problem for multiple coupled trial / test functions.
template<class F>
class RealFunction<F>
Represents a scalar function given by an arbitrary scalar function.
template<class NestedDerived>
class RealFunction<FunctionBase<NestedDerived>>
Real-valued function that wraps another real function expression.
template<>
class RealFunction<Integer>
Represents a constant scalar function initialized from an Integer.
template<>
class RealFunction<Real>
Represents a constant scalar function with type Real.
template<class Derived>
class RealFunctionBase
Base class for real-valued scalar functions.
class RelativeError
Utility class for computing relative errors.
template<class F>
class VectorFunction<F>
Vector function backed by a callable.
template<class Scalar>
class VectorFunction<Math::Vector<Scalar>>
Vector function backed by an existing dense vector.
template<class V, class ... Values>
class VectorFunction<V, Values...>
Represents a vector function which may be constructed from values which can be converted to objects of type RealFunction.
template<class Scalar, class Derived>
class VectorFunctionBase
Base class for vector-valued functions defined on a mesh.

Typedefs

using RealP0Element = P0Element<Real>
Alias for P0Element<Real>
using ComplexP0Element = P0Element<Complex>
Alias for P0Element<Complex>
template<class Scalar>
using VectorP0Element = P0Element<Math::SpatialVector<Scalar>>
Alias for P0Element<Math::SpatialVector<Scalar>>
using RealVectorP0Element = VectorP0Element<Real>
Alias for real vector P0Element.
using ComplexVectorP0Element = VectorP0Element<Complex>
Alias for complex vector P0Element.
using RealP1Element = P1Element<Real>
Alias for P1Element<Real>
using ComplexP1Element = P1Element<Complex>
Alias for P1Element<Complex>
template<class Scalar>
using VectorP1Element = P1Element<Math::SpatialVector<Scalar>>
Alias for P1Element<Math::SpatialVector<Scalar>>
using RealVectorP1Element = P1Element<Math::SpatialVector<Real>>
Alias for real vector P1Element.

Typedef documentation

template<class Scalar>
using Rodin::Variational::VectorP1Element = P1Element<Math::SpatialVector<Scalar>>

Alias for P1Element<Math::SpatialVector<Scalar>>

Template parameters
Scalar Scalar type for vector components