Rodin/Variational/P0/P0Element.h file

P0 (piecewise constant) finite element implementation.

This file provides the P0Element class template for piecewise constant finite elements. P0 elements have:

  • One degree of freedom per element (at the barycenter)
  • Constant basis function: $ \phi(x) = 1 $
  • Zero gradient: $ \nabla \phi = 0 $

Supported Specializations

Scalar P0Element<Scalar>:

  • Works with Real and Complex scalar types
  • Single DOF at element barycenter
  • Constant value throughout element

Vector P0Element<Math::SpatialVector<Scalar>>:

  • Component-wise constant vector fields
  • $ d $ DOFs per element (one per vector component)
  • Basis functions: $ \boldsymbol{\phi}_i = \mathbf{e}_j $ where $ j = i \mod d $

Usage Example

using namespace Rodin::Variational;

// Scalar P0 element (real or complex)
RealP0Element p0_real(Polytope::Type::Triangle);
ComplexP0Element p0_complex(Polytope::Type::Triangle);

// Vector P0 element (2D)
VectorP0Element p0_vec(2, Polytope::Type::Triangle);  // 2 DOFs

P0 elements are commonly used in discontinuous Galerkin (DG) methods, mixed finite element formulations, and as test spaces for finite volume schemes.