Rodin::FormLanguage namespace

Namespace Rodin::FormLanguage.

Directory src/Rodin/FormLanguage

Module for writing high level abstract expressions.

The FormLanguage module provides the expression template infrastructure underlying Rodin's variational form language. It enables composing mathematical expressions that are lazily evaluated during assembly.

Key Classes

  • FormLanguage::Base — Root base class for all form language objects. Provides unique identification (UUID), object lifetime management via shared ownership, and polymorphic copy(). Not thread-safe: use thread_local caching for per-thread output in evaluation methods.
  • FormLanguage::Traits<T> — Type trait template. Each form language type provides a specialization defining associated types (ScalarType, RangeType, FESType, etc.). Always specialize Traits for new types.
  • FormLanguage::List — Container for variational form components (integrals, boundary conditions) that makes up the body of a Problem.

Expression Template Pattern

Operators like Grad, Div, Dot are CRTP-based expression templates:

auto stiffness = Integral(Grad(u), Grad(v)); // expression, not yet evaluated
auto load = Integral(f, v);                   // another expression
Problem p(u, v);
p = stiffness - load + DirichletBC(u, Zero()); // combined expression

Expressions store operands via std::reference_wrapper (non-owning) or std::unique_ptr (owning, for temporaries). No computation occurs until assembly iterates over mesh cells and evaluates the expression at quadrature points.

Object Lifetime

The Base::object() helpers manage temporary object lifetimes. When an expression captures a temporary (e.g. a lambda-constructed RealFunction), the temporary is stored in a shared_ptr table within the expression, ensuring it lives as long as the expression does.

Classes

class Base
Base class for all objects in Rodin's FormLanguage system.
template<class T, class = void>
struct ColsAtCompileTime
Compile-time column count of a type; -1 when unavailable.
template<class T>
struct ColsAtCompileTime<T, std::void_t<decltype(std::decay_t<T>::ColsAtCompileTime)>>
Compile-time column count for Eigen-like types exposing ColsAtCompileTime.
template<typename>
struct Debug
Template for debugging form language types.
template<class LHS, class RHS>
struct Division
Type trait for deducing the result type of division.
template<class LHS, class RHS>
struct Dot
Type trait for deducing the result type of dot product.
template<class T>
struct IsEigenObject
Type trait to check if a type is an Eigen object.
template<class T>
struct IsMatrixRange
Type trait: whether T has matrix range (a spatial matrix or a multi-column Eigen object).
template<class T>
struct IsPlainObject
Type trait to identify Eigen plain object types.
template<class Derived>
struct IsPlainObject<Eigen::PlainObjectBase<Derived>>
Specialization for Eigen::PlainObjectBase types.
template<class T>
struct IsSpatialMatrix
Type trait: whether T is a Math::SpatialMatrix.
template<class Scalar>
struct IsSpatialMatrix<Math::SpatialMatrix<Scalar>>
Type trait specialization for Math::SpatialMatrix.
template<class T>
struct IsSpatialVector
Type trait: whether T is a Math::SpatialVector.
template<class Scalar>
struct IsSpatialVector<Math::SpatialVector<Scalar>>
Type trait specialization for Math::SpatialVector.
template<class T>
struct IsVectorRange
Type trait: whether T has vector range (a spatial vector or a single-column Eigen object).
template<class T>
class List
Container for polymorphic form language objects.
template<class LHS, class RHS>
struct Minus
Type trait for deducing the result type of subtraction.
template<class LHS, class RHS>
struct Mult
Type trait for deducing the result type of multiplication.
template<class T>
struct RangeKindOf
Deduces the RangeKind of a type T.
template<class LHS, class RHS>
struct Sum
Type trait for deducing the result type of addition.
template<class ... Args>
struct Traits
Type traits for form language objects.
template<>
struct Traits<Boolean>
Traits specialization for Boolean type.
template<>
struct Traits<Complex>
Traits specialization for Complex type.
template<class Context>
struct Traits<Geometry::Mesh<Context>>
Traits specialization for Mesh types.
template<>
struct Traits<Integer>
Traits specialization for Integer type.
template<class Number, size_t S>
struct Traits<Math::FixedSizeVector<Number, S>>
Type traits for a Math::FixedSizeVector: exposes the scalar type and the compile-time size.
template<class Operator, class Vector>
struct Traits<Math::LinearSystem<Operator, Vector>>
Type traits for a Math::LinearSystem: exposes the operator, vector, and scalar types.
template<class Number>
struct Traits<Math::Matrix<Number>>
Type traits for a dense Math::Matrix: exposes the scalar type.
template<class Number>
struct Traits<Math::SparseMatrix<Number>>
Type traits for a Math::SparseMatrix: exposes the scalar type.
template<class Number>
struct Traits<Math::Vector<Number>>
Type traits for a dynamic Math::Vector: exposes the scalar type.
template<class FES>
struct Traits<PETSc::Variational::GridFunction<FES>>
Form-language traits specialization for PETSc grid functions.
template<class FES>
struct Traits<PETSc::Variational::TestFunction<FES>>
Form-language traits specialization for PETSc test functions.
template<class Solution, class FES>
struct Traits<PETSc::Variational::TrialFunction<Solution, FES>>
Form-language traits specialization for PETSc trial functions.
template<>
struct Traits<Real>
Traits specialization for Real type.
template<class LinearSystem>
struct Traits<Solver::BiCGSTAB<LinearSystem>>
Form-language traits for BiCGSTAB solvers.
template<class LinearSystem>
struct Traits<Solver::CG<LinearSystem>>
Form-language traits for CG solvers.
template<class LinearSystem>
struct Traits<Solver::DGMRES<LinearSystem>>
Form-language traits for DGMRES solvers.
template<class LinearSystem>
struct Traits<Solver::GMRES<LinearSystem>>
Form-language traits for GMRES solvers.
template<class LinearSystem>
struct Traits<Solver::HouseholderQR<LinearSystem>>
Form-language traits for HouseholderQR solvers.
template<class LinearSystem>
struct Traits<Solver::IDRS<LinearSystem>>
Form-language traits for IDRS solvers.
template<class LinearSystem>
struct Traits<Solver::IDRSTABL<LinearSystem>>
Form-language traits for IDRSTABL solvers.
template<>
struct Traits<Solver::KSP>
Traits specialization for Solver::KSP (Rodin wrapper for PETSc KSP).
template<class LinearSystem>
struct Traits<Solver::LDLT<LinearSystem>>
Form-language traits for LDLT solvers.
template<class LinearSystem>
struct Traits<Solver::LeastSquaresCG<LinearSystem>>
Form-language traits for LeastSquaresCG solvers.
template<class LinearSystem>
struct Traits<Solver::LinearSolverBase<LinearSystem>>
Form-language traits for linear solver bases.
template<class LinearSystem>
struct Traits<Solver::MINRES<LinearSystem>>
Form-language traits for MINRES solvers.
template<class LinearSystem>
struct Traits<Solver::PartialPivLU<LinearSystem>>
Form-language traits for PartialPivLU solvers.
template<class LinearSystem>
struct Traits<Solver::SimplicialLDLT<LinearSystem>>
Form-language traits for SimplicialLDLT solvers.
template<class LinearSystem>
struct Traits<Solver::SimplicialLLT<LinearSystem>>
Form-language traits for SimplicialLLT solvers.
template<class LinearSystem>
struct Traits<Solver::SparseLU<LinearSystem>>
Form-language traits for SparseLU solvers.
template<class LinearSystem>
struct Traits<Solver::SparseQR<LinearSystem>>
Form-language traits for SparseQR solvers.
template<class Solution, class TrialFES, class TestFES, class Operator>
struct Traits<Variational::BilinearForm<Solution, TrialFES, TestFES, Operator>>
Traits for bilinear forms.
template<class Operator>
struct Traits<Variational::BilinearFormBase<Operator>>
Traits for bilinear form bases.
template<class Derived>
struct Traits<Variational::FunctionBase<Derived>>
Form-language traits for variational functions.
template<class FES, class Data>
struct Traits<Variational::GridFunction<FES, Data>>
Traits for GridFunction: exposes the space and data types.
template<class Derived, class FES, class Data>
struct Traits<Variational::GridFunctionBase<Derived, FES, Data>>
Traits for GridFunctionBase: exposes the space and data types.
template<class Derived>
struct Traits<Variational::RealFunctionBase<Derived>>
Traits for the CRTP base of real-valued functions.
template<class Scalar, class Derived>
struct Traits<Variational::VectorFunctionBase<Scalar, Derived>>
Traits for vector-valued function bases.
template<>
struct Traits<::Mat>
Traits specialization for PETSc matrices.
template<>
struct Traits<::Vec>
Traits specialization for PETSc vectors.
template<class Operand>
struct UnaryMinus
Type trait for deducing the result type of unary negation.

Enums

enum class RangeKind { Boolean, Integer, Real, Complex, Vector, Matrix, Unknown }
Type trait for deducing the result type of addition.

Variables

template<class T>
auto RangeKindOfV constexpr
Convenience variable template for RangeKindOf<T>::Value.

Enum documentation

enum class Rodin::FormLanguage::RangeKind

Type trait for deducing the result type of addition.

Determines the type of $ \text{LHS} + \text{RHS} $ at compile time.

Categorization of a value's range (scalar, vector or matrix kind).

Variable documentation

template<class T>
auto Rodin::FormLanguage::RangeKindOfV constexpr

Convenience variable template for RangeKindOf<T>::Value.