Date: 2026-01-20 Module: src/fem/interpolation Purpose: Comprehensive guide to BELFEM's shape function and integration system for finite element analysis
Revision History:
| Date | Version | Changes |
| 2026-01-20 | 1.0 | Initial comprehensive guide |
Table of Contents
- Common Pitfalls
- Overview
- Architecture
- Mental Model: The Four Pillars
- Lifetime & Mutation Contract
- Usage Examples
- Integration Data (The Main Workhorse)
- Nédélec Edge Elements
- Factory Patterns and Caching
- Element Support Matrix
- Integration Point System
- Derivative Matrix Conventions
- Performance Considerations
- Thread Safety and MPI
- Common Patterns
- Development Notes
Common Pitfalls
Place pitfalls first - these are the most common mistakes that lead to performance degradation or incorrect results.
1. Creating Factories/IntegrationData Inside Element Loops
for (Element* e : elements) {
InterpolationFunctionFactory factory;
InterpolationFunction* shape = factory.create_lagrange_function(e->type());
IntegrationData data(e->type());
data.populate(4);
for (uint k = 0; k < data.number_of_integration_points(); ++k) {
}
delete shape;
}
Why wrong: Each factory creation, shape function allocation, and IntegrationData precomputation is expensive, and none of it depends on the element, only on its type. In this loop it is repeated for every element.
Map< ElementType, IntegrationData * > tCache ;
{
const ElementType tType = tElement->type() ;
if ( ! tCache.key_exists( tType ) )
{
IntegrationData * tNew = new IntegrationData( tType );
tNew->populate( 4, IntegrationScheme::GAUSS );
tCache[ tType ] = tNew ;
}
const IntegrationData * tData = tCache( tType );
for ( uint k = 0; k < tData->number_of_integration_points(); ++k )
{
}
}
for ( auto & tEntry : tCache )
{
delete tEntry.second ;
}
tCache.clear() ;
Map (containers/cl_Map.hpp) tests for a key with key_exists(). operator[] inserts a missing key; operator() looks a key up and aborts with BELFEM_ERROR if it is missing.
2. Calling d2NdXi2 on an Unspecialized Template
InterpolationFunction* shape = factory.create_lagrange_function(ElementType::TET10);
Matrix<real> d2NdXi2;
shape->d2NdXi2(xi, d2NdXi2);
Second derivative support: every element the factory can create implements d2NdXi2; the BELFEM_ERROR in InterpolationFunctionTemplate is reached only for a template combination without a specialization, which the factory never instantiates.
3. Ignoring Facet Orientation for Slave Sides
IntegrationData tSlaveData( ElementType::TET4 );
tSlaveData.populate_for_slave(
tSlaveIndex,
0,
tOrder,
tScheme );
Problem: In contact, DG, and interface problems, the slave integration points must follow the master facet's node ordering. If orientation is ignored, the slave points can be placed at the wrong physical locations, corrupting interface fluxes.
tSlaveData.populate_for_slave( aFacet->index_on_slave(),
aFacet->orientation_on_slave() - 1,
tOrder,
tScheme );
Mesh::finalize() computes slave orientations for all facets by calling Mesh::compute_facet_orientations(). This step is skipped if set_compute_facet_orientation_flag( false ) was called. In the FEM kernel, fem::SideSet creates one IntegrationData object for each slave facet and orientation. fem::Calculator then selects the table using orientation_on_slave() - 1 (fem/kernel/cl_FEM_SideSet.cpp, fem/kernel/cl_FEM_Calculator.cpp, slave_integration_index_tet).
For a 2D slave element (TRI, and QUAD other than QUAD4TS/QUAD9TS), populate_for_slave() ignores aOrientation. A line facet of a volume TRI/QUAD has one orientation (mesh::number_of_orientations returns 1), and the slave points are generated by reversing the facet's point order.
When orientation matters:
- Contact mechanics (slave-master pairing)
- Discontinuous Galerkin (interior facet integration)
- Interface coupling (h-φ formulation coupling, thin-shell interfaces)
4. Confusing Auto Integration Order
IntegrationData data(ElementType::TRI6);
data.populate(0, IntegrationScheme::GAUSS);
Problem: Users assume 0 means "minimal" or "error". It actually triggers automatic order selection based on element type.
Auto order selection: BELFEM does not treat 0 as a minimal rule. It maps the element's interpolation order to a fixed integration order through auto_integration_order() (numerics/integration/fn_intpoints_auto_integration_order.cpp):
| Element interpolation order | Integration order |
| constant | 1 |
| linear | 4 |
| quadratic, serendipity | 7 |
| cubic | 10 |
| quartic | 13 |
| quintic | 16 |
These values are above 2p + 1, the degree of a mass-like product with a linearly varying coefficient on an affine element. The source does not document why these particular values were chosen.
This is a default, not an exactness guarantee. For distorted QUAD/HEX elements and for curved higher-order mappings, the Jacobian makes the integrand non-polynomial, so exact integration is not available anyway. Such integrands, and nonlinear ones, can still be under-integrated by the default.
The integer order does carry one guarantee: for IntegrationScheme::GAUSS, intpoints() returns a rule that integrates every polynomial of total degree up to that order exactly on the reference element, for every geometry it serves (locked by tests/fem/test_IntegrationExactness.cpp). Several rules deliver more than requested (the tensor-product rules, and the tetrahedron tables for orders 7 and 9), so the number is a floor, not the exact degree. It says nothing about mapped, non-polynomial integrands.
Recommendation: Explicitly specify order for clarity:
data.populate(7, IntegrationScheme::GAUSS);
5. Ownership Confusion with IntegrationData
InterpolationFunction* shape = factory.create_lagrange_function(ElementType::TET4);
IntegrationData data1(ElementType::TET4, shape, false);
delete shape;
InterpolationFunction* shape2 = factory.create_lagrange_function(ElementType::TET4);
IntegrationData data2(ElementType::TET4, shape2, true);
Problem: Memory leaks if caller doesn't understand ownership semantics.
Safe patterns:
IntegrationData data(ElementType::TET4);
data.populate(4);
InterpolationFunction* shape = factory.create_lagrange_function(ElementType::TET4);
IntegrationData data(ElementType::TET4, shape, true);
data.populate(4);
6. Using Linear Bernstein and Expecting Different Results
InterpolationFunction* bern = factory.create_bernstein_function(ElementType::TRI3);
Issue: For linear elements (TRI3, QUAD4, LINE2), Bernstein polynomials are mathematically identical to Lagrange polynomials. The factory returns InterpolationType::LAGRANGE for these cases.
Impact: Low (mathematically correct), but can confuse users expecting separate Bernstein implementation.
Documentation: Explicitly state: "Linear Bernstein = Linear Lagrange (factory returns Lagrange for efficiency)."
7. Reading det_J() Before the Shape Function Has Updated It
real detJ = edge->det_J();
const Matrix<real>& E = edge->E(k);
const Matrix<real>& C = edge->C(k);
Problem: det_J() returns a stored value. Which call updates it depends on the element:
| Element | det_J() is set by |
| EF_TRI3, EF_TET4, EF_QUAD4TS, EF_PENTA6TS, EF_HEX8TB | link() (one constant value per element) |
| EF_TRI6, EF_TET10 with straight edges | link() (one constant value per element) |
| EF_TRI6, EF_TET10 curved | E(k), C(k) and G(k), for point k |
| EF_HEX8, EF_HEX8TS | E(k), C(k) and G(k), for point k (update_nabla()) |
For the last two rows, reading det_J(), or calling a helper such as dV_ts() that reads it, before any accessor has run at point k returns the determinant from the previous integration point.
Safe pattern:
for (uint k = 0; k < npts; ++k) {
const Matrix<real>& E = edge->E(k);
const Matrix<real>& C = edge->C(k);
real detJ = edge->det_J();
}
Scope: This affects the elements that refresh det_J() per point: curved EF_TRI6 and EF_TET10, EF_HEX8 and EF_HEX8TS. If a new element caches Jacobian data lazily, document which accessor performs the update.
Overview
The interpolation module provides the core machinery for evaluating shape functions, their derivatives, and integration points in finite element analysis. It is designed for zero-overhead abstraction with extensive precomputation capabilities.
Purpose
- Shape function evaluation: N(ξ), ∂N/∂ξ, ∂²N/∂ξ² for all standard element geometries
- Integration point management: Gauss quadrature for volume and facet integration
- Precomputation: IntegrationData stores shape values/derivatives at integration points to avoid redundant computation in assembly loops
- Nédélec elements: Edge-based (H(curl)) shape functions for electromagnetic FEM
Key Features
- Template-based architecture: InterpolationFunctionTemplate<Geometry, Type, Dimension, Bases> provides compile-time specialization
- Factory pattern: InterpolationFunctionFactory and EdgeFunctionFactory create shape functions by element type
- Multiple interpolation families: Lagrange, Hermite, Bernstein, Bubble functions
- Integration schemes: Gauss quadrature with auto-order selection
- Facet integration: Master/slave facet handling with orientation for contact/DG
- Performance optimization: Precomputed IntegrationData is the recommended usage pattern
Design Philosophy
Following doc/coding_philosophy.md:
- Manual memory management: Factories return raw pointers; caller or IntegrationData owns
- Zero abstraction penalty: Release builds compile to direct array access (no virtual function overhead after precompute)
- Explicit ownership: IntegrationData constructor specifies ownership (aClaimOwnership flag)
- Caching-first: IntegrationData is designed to be cached and reused across elements of the same type
Architecture
File Organization
src/fem/interpolation/
├── cl_IF_InterpolationFunction.hpp # Abstract base class
├── cl_IF_InterpolationFunctionTemplate.hpp # Template implementation
├── cl_IF_InterpolationFunctionFactory.{hpp,cpp} # Factory for shape functions
├── cl_IF_IntegrationData.{hpp,cpp} # Precomputed integration bundle
├── cl_EdgeFunctionFactory.{hpp,cpp} # Factory for Nédélec elements
├── fn_IF_initialize_integration_points.* # Integration point generation
├── fn_IF_initialize_integration_points_on_facet.* # Facet integration points
├── fn_IF_initialize_shape_function.* # Shape function initialization
├── lagrange/ # Lagrange polynomial specializations
├── hermite/ # Hermite polynomial specializations
├── bernstein/ # Bernstein polynomial specializations
├── bubble/ # Bubble function stabilizations
└── nedelec/ # Nédélec edge element implementations
├── cl_EF_TRI3.{hpp,cpp} # 1st order triangle edge element
├── cl_EF_TRI6.{hpp,cpp} # 2nd order triangle edge element
├── cl_EF_TET4.{hpp,cpp} # 1st order tetrahedron edge element
├── cl_EF_TET10.{hpp,cpp} # 2nd order tetrahedron edge element
├── cl_EF_HEX8.{hpp,cpp} # 1st order hexahedron edge element
├── cl_EF_QUAD4TS.{hpp,cpp} # Thin shell with curl (quad)
├── cl_EF_PENTA6TS.{hpp,cpp} # Thin shell with curl (tri)
├── cl_EF_HEX8TS.{hpp,cpp} # Thin shell (hex)
├── cl_EF_HEX8TB.{hpp,cpp} # Side-connector wall element, 4 DOFs
├── cl_EF_LINE3.{hpp,cpp} # Proof of concept, not dispatched by the factory
└── fn_num_nedelec_dofs.hpp # DOF count per element type
Class Hierarchy
InterpolationFunction (abstract base)
├── InterpolationFunctionTemplate<G,T,D,B>
│ ├── Lagrange specializations (LINE2-5, TRI3-15, QUAD4-16, TET4-35, ...)
│ ├── Hermite specializations (LINE2, QUAD4)
│ ├── Bernstein specializations (LINE, TRI)
│ └── Bubble specializations (TRI3/6 edges, TET4/10 faces)
└── (Direct derivations for special cases)
EdgeFunction (abstract base for Nédélec)
├── EF_TRI3, EF_TRI6 # 2D electromagnetics
├── EF_TET4, EF_TET10, EF_HEX8 # 3D electromagnetics
├── EF_QUAD4TS, EF_PENTA6TS, EF_HEX8TS, EF_HEX8TB # Thin shells
└── EF_LINE3 # Proof of concept (not created by the factory)
IntegrationData (precompute bundle)
└── Owns or borrows an InterpolationFunction
InterpolationFunctionFactory
├── create_lagrange_function(ElementType)
├── create_hermite_function(ElementType)
├── create_bernstein_function(ElementType)
└── create_bubble_function(ElementType, uint aFacet)
EdgeFunctionFactory
└── create_edge_function(ElementType)
Mental Model: The Four Pillars
Understanding the interpolation module requires grasping four distinct but interconnected concepts:
Pillar 1: InterpolationFunction (Shape Function Interface)
What it is: Abstract base class defining the contract for evaluating shape functions.
Key methods:
virtual void N(const Vector<real> & aXi, Matrix<real> & aN) const = 0;
virtual void dNdXi(const Vector<real> & aXi, Matrix<real> & adNdXi) const = 0;
virtual void d2NdXi2(const Vector<real> & aXi, Matrix<real> & ad2NdXi2) const = 0;
virtual void param_coords(Matrix<real> & aXiHat) const = 0;
Matrix dimension contracts:
- aN: (1 × num_bases) - shape function values
- adNdXi: (num_dimensions × num_bases) - first derivatives
- ad2NdXi2: See Derivative Matrix Conventions
- aXiHat: (num_dimensions × num_nodes) - parametric node coordinates. For Lagrange elements the number of nodes equals the number of bases; for Hermite it does not (LINE2: 1 × 2 for 4 bases, QUAD4: 2 × 4 for 16 bases)
When to use directly: Rarely. Most users should use IntegrationData (Pillar 3).
When to derive custom classes: Implementing non-standard shape functions (e.g., NURBS, hierarchical p-refinement).
Pillar 2: InterpolationFunctionFactory (Creation)
What it is: Factory for creating shape function instances.
Usage pattern:
InterpolationFunctionFactory factory;
InterpolationFunction* shape = factory.create_lagrange_function(ElementType::TET10);
delete shape;
Methods:
- create_lagrange_function(ElementType) - Standard Lagrange polynomials
- create_hermite_function(ElementType) - C¹ Hermite polynomials (beams, plates)
- create_bernstein_function(ElementType) - Bézier-like basis
- create_bubble_function(ElementType, uint aFacet) - Stabilization bubbles (the second argument is a facet index, not a BubbleType)
Ownership: Factory returns raw pointer; caller must delete or transfer to IntegrationData.
Pillar 3: IntegrationData (The Main Workhorse)
What it is: Precomputed bundle of integration points, weights, and shape function values/derivatives.
Why it matters: This is the recommended way to use the interpolation module. It:
- Generates integration points (Gauss quadrature)
- Evaluates N, dNdXi, d2NdXi2 once at each point
- Stores results for O(1) access in assembly loops
Usage pattern:
IntegrationData data(ElementType::TET10);
data.populate(4, IntegrationScheme::GAUSS);
for (uint k = 0; k < data.number_of_integration_points(); ++k) {
const Matrix<real>& N = data.N(k);
const Matrix<real>& dN = data.dNdXi(k);
real w = data.weights()(k);
}
Critical for performance: See Factory Patterns and Caching.
Pillar 4: EdgeFunction (Nédélec for Electromagnetics)
What it is: Separate branch for vector-valued (H(curl)) shape functions used in electromagnetic FEM (h-φ formulation, Maxwell solvers).
Key difference from scalar shapes:
- Vector-valued: E(ξ) returns (ndim × ndofs) matrix
- Curl operator: C(k) returns curl matrix
- Requires linking to an FEM element: link( fem::Element * ) reads node coordinates and edge directions
Usage pattern:
EdgeFunctionFactory edgeFactory;
EdgeFunction* edge = edgeFactory.create_edge_function(ElementType::TET4);
edge->precompute(integrationPoints);
edge->link(femElement);
const Matrix<real>& E = edge->E(integrationPointIndex);
const Matrix<real>& C = edge->C(integrationPointIndex);
real detJ = edge->det_J();
delete edge;
Call precompute() first. For EF_TRI6 and EF_TET10 with straight edges, link() evaluates the Jacobian from the precomputed data. fem::Calculator follows the same sequence: it precomputes when it creates the edge function and links once per element (fem/kernel/cl_FEM_Calculator.cpp).
Prerequisites:
- Mesh must have edges/faces created (Mesh::create_edges(), Mesh::create_faces())
- Element must provide edge orientation data
- Edge DOFs are managed by DofManager (fem/kernel/cl_FEM_DofManager.hpp)
See: Nédélec Edge Elements for details.
Lifetime & Mutation Contract
Understanding when objects can be mutated and when they should be treated as immutable is critical for safe, performant code.
InterpolationFunction Lifetime & Mutability
Lifetime:
- Created by factory → Owned by caller or IntegrationData
- Must live until all dependent IntegrationData objects are destroyed (if borrowed)
- Safe to delete after IntegrationData with aClaimOwnership = true takes ownership
Mutability:
InterpolationFunction* shape = factory.create_lagrange_function(ElementType::TET10);
Vector<real> xi(3);
Matrix<real> N, dNdXi;
shape->N(xi, N);
shape->dNdXi(xi, dNdXi);
Contract: InterpolationFunction is effectively immutable after factory creation. All methods are const and thread-safe.
IntegrationData Lifetime & Mutability
Lifetime:
- Lives from construction to explicit delete (manual memory management)
- If owns shape function (aClaimOwnership = true), deletes it in destructor
- If borrows shape function (aClaimOwnership = false), caller must ensure shape outlives IntegrationData
Mutability - Two phases:
Phase 1: Mutable (Setup)
IntegrationData data(ElementType::TET10);
data.populate(2, IntegrationScheme::GAUSS);
data.populate(4, IntegrationScheme::GAUSS);
data.populate_for_master(2, 3);
Warning: Each populate() call overwrites previous integration data. Don't assume cached values survive re-population.
Phase 2: Immutable (After populate)
data.populate(4);
for (uint k = 0; k < data.number_of_integration_points(); ++k) {
const Matrix<real>& N = data.N(k);
const Matrix<real>& dN = data.dNdXi(k);
real w = data.weights()(k);
}
Contract: After final populate() call, treat IntegrationData as immutable for performance and thread safety.
Ownership Patterns
Pattern 1: IntegrationData Owns Shape (Recommended)
IntegrationData* data = new IntegrationData(ElementType::TET10);
data->populate(4);
delete data;
Lifetime: data owns shape → both deleted together.
Pattern 2: IntegrationData Borrows Shape
InterpolationFunctionFactory factory;
InterpolationFunction* shape = factory.create_lagrange_function(ElementType::TET10);
IntegrationData* data = new IntegrationData(ElementType::TET10, shape, false);
data->populate(4);
delete data;
delete shape;
Lifetime: Caller must ensure shape outlives data.
Pattern 3: Shared Shape Across Multiple IntegrationData
InterpolationFunction* shape = factory.create_lagrange_function(ElementType::TET10);
IntegrationData* volumeData = new IntegrationData(ElementType::TET10, shape, false);
volumeData->populate(4);
IntegrationData* facetData = new IntegrationData(ElementType::TET10, shape, false);
facetData->populate_for_master(2, 3);
delete volumeData;
delete facetData;
delete shape;
Use case: When you need volume and facet integration for the same element type.
EdgeFunction Lifetime & Mutability
Lifetime:
- Created by factory → Owned by caller
- Must be deleted explicitly after use
Mutability - Two phases:
Phase 1: Mutable (Setup)
EdgeFunction* edge = edgeFactory.create_edge_function(ElementType::TET4);
edge->precompute(gaussPoints);
edge->link(element);
Contract: precompute() and then link() must be called before accessing E(), C() or G().
Phase 2: Evaluation (After link)
for (uint k = 0; k < npts; ++k) {
const Matrix<real>& E = edge->E(k);
const Matrix<real>& C = edge->C(k);
real detJ = edge->det_J();
}
Warning: EdgeFunction is not thread-safe at any stage. E(), C() and G() write to member buffers, and some elements also update det_J() (see Common Pitfall 7). A returned reference remains valid only until the next call to the same accessor.
Summary Table
| Object | Creation | Mutable Phase | Immutable Phase | Thread-Safe After? |
| InterpolationFunction | Factory | Never (effectively const) | Always | ✅ Yes |
| IntegrationData | Constructor | During populate() calls | After final populate() | ✅ Yes |
| EdgeFunction | Factory | Always (precompute(), link(), E(), C(), G()) | Never | ❌ No |
Common Lifetime Bugs
Bug 1: Deleting borrowed shape too early
InterpolationFunction* shape = factory.create_lagrange_function(ElementType::TET10);
IntegrationData data(ElementType::TET10, shape, false);
data.populate(4);
delete shape;
data.N(0);
Fix: Ensure shape outlives data.
Bug 2: Re-populating in parallel region
IntegrationData data(ElementType::TET10);
data.populate(4);
#pragma omp parallel for
for (int i = 0; i < n; ++i) {
data.populate(2);
}
Fix: Populate once before parallel region.
Bug 3: Reusing EdgeFunction without re-linking
EdgeFunction* edge = edgeFactory.create_edge_function(ElementType::TET4);
edge->precompute(gaussPoints);
for (fem::Element* e : elements) {
}
Fix: Precompute once, then call link(e) for each element.
edge->precompute(gaussPoints);
for (fem::Element* e : elements) {
edge->link(e);
}
Usage Examples
Example 1: Basic Shape Function Evaluation
xi(0) = 1.0/3.0;
xi(1) = 1.0/3.0;
std::cout << i << ": N = " << N(0, i)
<< ", dN/dxi = " << dNdXi(0, i)
<< ", dN/deta = " << dNdXi(1, i) << std::endl;
}
delete shape;
Dense column-major matrix.
Definition cl_BZ_Matrix.hpp:28
Column vector.
Definition cl_BZ_Vector.hpp:42
Creates shape functions by element and interpolation type.
Definition cl_IF_InterpolationFunctionFactory.hpp:29
InterpolationFunction * create_lagrange_function(const ElementType aElementType)
Definition cl_IF_InterpolationFunctionFactory.cpp:107
the shape function base class
Definition cl_IF_InterpolationFunction.hpp:31
virtual void param_coords(Matrix< real > &aXiHat) const =0
returns a matrix containing the parameter coordinates of the nodes < number of dimensions x number of...
virtual uint number_of_bases() const =0
returns the number of bases for this shape function
virtual void N(const Vector< real > &aXi, Matrix< real > &aN) const =0
evaluates the shape function at a given point
virtual void dNdXi(const Vector< real > &aXi, Matrix< real > &adNdXi) const =0
calculates the first derivative of the shape function in parameter space
Definition cl_IFB_LINE3.hpp:21
unsigned int uint
Definition typedefs.hpp:30
@ TRI6
Definition Mesh_Enums.hpp:37
Output interpretation:
- N(0,i) = shape value at node i
- dNdXi(0,i) = ∂N_i/∂ξ
- dNdXi(1,i) = ∂N_i/∂η
Example 2: Integration Data for Element Assembly (Recommended)
uint npts = data.number_of_integration_points();
std::cout << "Number of integration points: " << npts << std::endl;
for (
uint k = 0; k < npts; ++k) {
real w_k = data.weights()(k);
}
Precomputed bundle of integration points, weights and shape-function values.
Definition cl_IF_IntegrationData.hpp:35
@ LAGRANGE
Definition Mesh_Enums.hpp:100
@ GAUSS
Definition en_IntegrationScheme.hpp:23
@ TET10
Definition Mesh_Enums.hpp:39
double real
Definition typedefs.hpp:36
Why this is recommended:
- Shape functions evaluated once during populate()
- Access via N(k), dNdXi(k) in loops returns a stored matrix; nothing is evaluated
Example 3: Hermite Shape Functions for Beam Elements
xi(0) = -1.0;
delete hermite;
InterpolationFunction * create_hermite_function(const ElementType aElementType)
Definition cl_IF_InterpolationFunctionFactory.cpp:263
@ LINE2
Definition Mesh_Enums.hpp:29
Hermite basis interpretation (LINE2, hermite/cl_IF_BEAM.hpp):
- N(0) = value at node 0
- N(1) = derivative with respect to ξ at node 0
- N(2) = value at node 1
- N(3) = derivative with respect to ξ at node 1
The slope bases are defined in ξ. Therefore, the coefficient of N(1) and N(3) is dw/dξ = (dx/dξ) · dw/dx, which is L/2 times the physical slope for a straight element of length L.
Example 4: Facet Integration for Boundary Conditions
uint masterFacetIndex = 2;
for (
uint k = 0; k < boundaryData.number_of_integration_points(); ++k) {
real w_k = boundaryData.weights()(k);
}
@ TET4
Definition Mesh_Enums.hpp:32
Master vs. Slave:
- Master facet: Own element's facet (for boundary conditions)
- Slave facet: Neighboring element's facet (for contact/DG, requires orientation)
Example 5: Slave Facet Integration with Orientation (Contact/DG)
uint slaveFacetIndex = 4;
@ HEX8
Definition Mesh_Enums.hpp:33
Orientation encoding: Facet::compute_orientation() finds the first corner node of the slave facet in the master facet's corner-node list. Its 1-based position is Facet::orientation_on_slave(). populate_for_slave() takes that value minus one.
The number of orientations per facet is given by mesh::number_of_orientations(): 3 for a TET facet, 4 for a HEX facet, 4 or 3 for the quad or triangle facets of a PENTA, 1 for the line facets of a volume TRI/QUAD, and 2 for the line facets of QUAD4TS/QUAD9TS.
Example 6: Nédélec Edge Elements for Electromagnetics
gauss.populate(4);
delete edge;
Creates edge functions by element type.
Definition cl_EdgeFunctionFactory.hpp:29
EdgeFunction * create_edge_function(const ElementType aElementType)
Definition cl_EdgeFunctionFactory.cpp:38
the edge function base class
Definition cl_EF_EdgeFunction.hpp:39
real abs_det_J() const
returns the current value of the determinant
Definition cl_EF_EdgeFunction.hpp:223
virtual const Matrix< real > & E(const uint aIndex)
Definition cl_EF_EdgeFunction.hpp:231
virtual void link(Element *aElement)=0
links the shape function with the element and precomputes data
real det_J() const
returns the current value of the determinant
Definition cl_EF_EdgeFunction.hpp:215
virtual const Matrix< real > & C(const uint aIndex=0)=0
Definition cl_EF_EdgeFunction.hpp:240
virtual void precompute(const Matrix< real > &aXi)=0
only needed for higher order elements
Nédélec DOF counts:
- TET4: 6 DOFs (one per edge)
- TET10: 20 DOFs (2 per edge for 2nd order)
- TRI3: 3 DOFs
- TRI6: 8 DOFs
Integration Data (The Main Workhorse)
IntegrationData is the recommended entry point for most users. It combines integration point generation with precomputed shape function evaluation.
Constructors
const bool aClaimOwnership);
InterpolationType
Definition Mesh_Enums.hpp:99
ElementType
Element types.
Definition Mesh_Enums.hpp:27
Ownership semantics:
- Constructor 1 with nullptr: Creates and owns shape function (deleted in destructor)
- Constructor 1 with a non-null aShapeFunction: Borrows it (caller must delete); aType is then not used
- Constructor 2 with aClaimOwnership = true: Owns provided shape function
- Constructor 2 with aClaimOwnership = false: Borrows shape function (caller must delete)
Recommended pattern: Use constructor 1 (auto-create and own):
Populate Methods
Volume Integration
void populate(
const uint aIntegrationOrder = 0,
IntegrationScheme
Definition en_IntegrationScheme.hpp:22
Parameters:
- aIntegrationOrder: Integration order (0 = auto-select based on element type)
- aScheme: one of IntegrationScheme (numerics/integration/en_IntegrationScheme.hpp):
- GAUSS: the default; tabulated rules for every geometry
- GAUSSCLASSIC: tensor-product Gauss-Legendre rules for QUAD and HEX; for every other geometry intpoints() falls back to GAUSS
- LOBATTO: Gauss-Lobatto, LINE only; other geometries abort with BELFEM_ERROR
Auto order: When aIntegrationOrder = 0, BELFEM calls auto_integration_order( aElementType ). It returns 4 / 7 / 10 / 13 / 16 for linear / quadratic (and serendipity) / cubic / quartic / quintic elements (see Common Pitfall 4).
For distorted QUAD/HEX elements and curved higher-order mappings, the Jacobian makes the integrand non-polynomial, so no fixed order integrates it exactly.
Usage:
data.populate(7);
data.populate();
Master Facet Integration (Boundary Conditions)
void populate_for_master(
const uint aMasterIndex,
const uint aIntegrationOrder = 0,
Parameters:
- aMasterIndex: Local facet index (0-based, element-dependent)
- TET4: 0-3 (4 triangular faces)
- HEX8: 0-5 (6 quadrilateral faces)
- etc.
Use case: Neumann boundary conditions, surface integrals
bcData.populate_for_master(2, 3);
for (
uint k = 0; k < bcData.number_of_integration_points(); ++k) {
real w = bcData.weights()(k);
}
Slave Facet Integration (Contact/DG)
void populate_for_slave(
const uint aSlaveIndex,
const uint aOrientation = 0,
const uint aIntegrationOrder = 0,
Parameters:
- aSlaveIndex: Local facet index on slave element
- aOrientation: 0-based orientation index, Facet::orientation_on_slave() - 1
- Range 0 .. mesh::number_of_orientations( type, facet ) - 1 (see Example 5)
- Ignored for TRI and for QUAD other than QUAD4TS/QUAD9TS (one orientation per line facet)
Use case: Contact mechanics, discontinuous Galerkin, interface coupling (h-φ, thin-shell)
slaveData.populate_for_slave(aFacet->index_on_slave(),
aFacet->orientation_on_slave() - 1,
3);
Orientation example (TRI facet on TET): if the slave facet's first corner node is at position 2 (1-based) in the master facet's corner list, then orientation_on_slave() is 2 and aOrientation is 1.
Access Methods
uint number_of_integration_points()
const;
Common usage:
for (
uint k = 0; k < data.number_of_integration_points(); ++k) {
real w = data.weights()(k);
}
Nédélec Edge Elements
Nédélec (or Whitney) elements are vector-valued shape functions for H(curl)-conforming FEM, primarily used in electromagnetic applications (Maxwell solvers, h-φ formulation).
What Makes Edge Elements Different
| Property | Scalar (Lagrange) | Edge (Nédélec) |
| DOF location | Nodes | Edges (tangential component) |
| Continuity | C⁰ (value) | Tangential component continuous |
| Output | Scalar N | Vector E (tangent-aligned) |
| Operator | Gradient (grad N) | Curl (curl E) |
| FEM space | H¹ (continuous) | H(curl) (tangential continuity) |
Supported Elements
| Element | DOFs | Order | Implementation |
| TRI3 | 3 | 1st | EF_TRI3 |
| TRI6 | 8 | 2nd | EF_TRI6 |
| TET4 | 6 | 1st | EF_TET4 |
| TET10 | 20 | 2nd | EF_TET10 |
| LINE3 | 2 | 2nd | EF_LINE3 — ⚠️ proof of concept, and not dispatched by EdgeFunctionFactory (no LINE3 case); see nedelec.md §6.5 |
| HEX8 | 12 | 1st | EF_HEX8 |
| QUAD4TS | 2 | Thin shell | EF_QUAD4TS (line-in-2D extrusion) |
| PENTA6TS | 6 | Thin shell | EF_PENTA6TS (triangle-in-3D extrusion) |
| HEX8TS | 8 | Thin shell | EF_HEX8TS (quad-in-3D extrusion) |
| HEX8TB | 4 | Thin wall | EF_HEX8TB (side-connector wall element, longitudinal edges only) |
| QUAD9TS, PENTA18TS | 3, 16 (num_nedelec_dofs) | Thin shell | none: EdgeFunctionFactory aborts with BELFEM_ERROR (quadratic thin-shell edge functions are not implemented) |
DOF count formula:
- 1st order: num_edges (one DOF per edge)
- TRI3: 3 DOFs (3 edges)
- TET4: 6 DOFs (6 edges)
- 2nd order: 2 × num_edges + num_faces × face_dofs
- TRI6: 8 DOFs (3 edges × 2 = 6 edge DOFs + 1 face × 2 = 2 face DOFs)
- TET10: 20 DOFs (6 edges × 2 = 12 edge DOFs + 4 faces × 2 = 8 face DOFs)
- Thin-shell elements use reduced DOF counts from dimensional reduction — see nedelec_thinshell.md for the construction.
For a deeper treatment of the Nédélec theory in BELFEM, see:
- nedelec.md — general framework, EdgeFunction base class, volume elements, unit-circulation convention
- nedelec_thinshell.md — thin-shell (QUAD4TS, PENTA6TS) elements
EdgeFunction API
public:
};
}
virtual void update_nabla(const uint aIndex)
Definition cl_EF_EdgeFunction.hpp:249
virtual const Matrix< real > & G(const uint aIndex=0)=0
real sum_w() const
returns the sum of all integration weights
Definition cl_EF_EdgeFunction.hpp:207
uint ndofs() const
Definition cl_EF_EdgeFunction.hpp:199
Definition cl_FEM_Element.hpp:41
The base-class E(), C() and update_nabla() bodies abort with BELFEM_ERROR; every element the factory creates overrides E() and C().
Matrix dimensions:
- E(k): (ndim × ndofs) - interpolates edge DOFs to physical vector field
- C(k): 3D: (3 × ndofs), vector curl; 2D: (1 × ndofs), scalar curl
- G(k): (ndim² × ndofs) - gradient of each basis function, column-major vectorized (layout documented at mGrad in nedelec/cl_EF_EdgeFunction.hpp)
Usage Pattern
gauss.populate(4);
edge->precompute(gauss.points());
edge->link(femElement);
for (
uint k = 0; k < gauss.number_of_integration_points(); ++k) {
real detJ = edge->det_J();
real w = gauss.weights()(k);
}
delete edge;
Prerequisites for Edge Elements
Mesh must have edges created:
Element must provide:
- Edge connectivity (which nodes form each edge)
- Edge orientation (tangent direction convention)
- Node coordinates (for Jacobian computation)
Typical use cases:
- h-φ formulation for superconductor magnets (h-field uses edge elements)
- Time-harmonic Maxwell's equations
- Magnetostatics with multiply-connected domains (via cohomology cuts)
Curved vs. Straight Element Optimization
Higher-order Nédélec elements (TRI6, TET10) select their evaluation routines in link() through member-function pointers, depending on whether the mesh element is curved. Abridged from EF_TRI6:
void (
EF_TRI6::*mFunInterpolation )(
const uint aIndex );
if( tElement->is_curved() )
{
mFunInterpolation = & EF_TRI6::E_curved ;
mFunCurl = & EF_TRI6::C_curved ;
mFunGrad = & EF_TRI6::G_curved ;
}
else
{
this->compute_nabla( 0 );
mFunInterpolation = & EF_TRI6::compute_E ;
mFunCurl = & EF_TRI6::C_straight ;
mFunGrad = & EF_TRI6::G_straight ;
}
{
( this->*mFunCurl )( aIndex );
return mC ;
}
Definition cl_EF_TRI6.hpp:25
const Matrix< real > & C(const uint aIndex=0) override
curl operator for h-field
Definition cl_EF_TRI6.hpp:214
EF_TET10 uses the same mechanism with the pointers mFunInterpolation (E_curved / E_straight), mFunDerivatives (E_xi_curved / E_xi_straight, used by C()) and mFunGrad (G_curved / G_straight).
Performance impact: On a straight element the Jacobian is computed once in link() rather than at every integration point.
Factory Patterns and Caching
The Performance Problem
data.populate(4);
delete shape;
}
Why catastrophic:
- 10,000 elements × (factory creation + shape allocation + IntegrationData precompute)
- Each precompute allocates and evaluates N, dNdXi and d2NdXi2 at every integration point (11 points for TET10 at order 4)
- Total: about 10,000 × 11 = 110,000 redundant evaluations of each of the three
The Solution: Cache by Element Type
{
{
tCache[ tType ] = tNew ;
}
{
}
}
for ( auto & tEntry : tCache )
{
delete tEntry.second ;
}
Hash map (unordered key-value).
Definition cl_Map.hpp:75
void clear()
clear map
Definition cl_Map.hpp:131
bool key_exists(const Key &aKey) const
Definition cl_Map.hpp:161
uint number_of_integration_points() const
tells how many integration points are used
Definition cl_IF_IntegrationData.hpp:265
const Matrix< real > & dNdXi(const uint aIndex) const
return the first derivative of N
Definition cl_IF_IntegrationData.hpp:323
const Matrix< real > & N(const uint aIndex) const
return the node shape function as Matrix (scalar field)
Definition cl_IF_IntegrationData.hpp:307
void populate(const uint aIntegrationOrder=0, const IntegrationScheme aScheme=IntegrationScheme::GAUSS)
default function for popularization
Definition cl_IF_IntegrationData.cpp:75
Performance gain: the shape functions are evaluated once per element type instead of once per element. No benchmark of the speed-up is kept in the repository.
Advanced: Multi-Order Caching
struct IntegrationKey {
bool operator<(const IntegrationKey& other) const {
if (type != other.type) return type < other.type;
if (order != other.order) return order < other.order;
return scheme < other.scheme;
}
};
std::map<IntegrationKey, IntegrationData*> cache;
if (!cache.count(key)) {
}
Block-Level Caching Pattern (BELFEM Best Practice)
for (
Element* e : block->elements()) {
}
}
}
Definition cl_FEM_Block.hpp:35
When blocks are mixed: Fall back to element-type caching (Map-based approach).
Element Support Matrix
Lagrange Elements
| Geometry | Order 1 | Order 2 | Order 3 | Order 4 |
| LINE | LINE2 | LINE3 | LINE4 | LINE5 |
| TRI | TRI3 | TRI6 | TRI10 | TRI15 |
| QUAD | QUAD4 | QUAD8, QUAD9 | QUAD16 | — |
| TET | TET4 | TET10 | TET20 | TET35 |
| PENTA | PENTA6 | PENTA15, PENTA18 | — | — |
| PYRA | PYRA5 | PYRA13, PYRA14 | — | — |
| HEX | HEX8 | HEX20, HEX27 | HEX64 | — |
Note: QUAD8, HEX20 are serendipity elements (no interior nodes).
Thin-shell types: create_lagrange_function() maps the thin-shell element types onto the volume Lagrange function of the same node layout: QUAD4TS → QUAD4, QUAD9TS → QUAD9, PENTA6TS → PENTA6, PENTA18TS → PENTA18, HEX8TS and HEX8TB → HEX8.
Hermite Elements (C¹ Continuity)
| Element | Bases | Derivatives at Nodes | Use Case |
| LINE2 | 4 | Value + slope | Euler-Bernoulli beams (cubic) |
| QUAD4 | 16 | Value + ∂/∂x + ∂/∂y + ∂²/∂x∂y | Kirchhoff plates (bicubic) |
Hermite basis interpretation:
- Each node contributes multiple DOFs (value + derivatives)
- Ensures C¹ continuity across elements (continuous value and slope)
Bernstein Elements
| Element | Order | Bases | Note |
| LINE2 | 1 | 2 | Returns LAGRANGE (identical) |
| LINE3 | 2 | 3 | True Bernstein basis |
| TRI3 | 1 | 3 | Returns LAGRANGE (identical) |
| TRI6 | 2 | 6 | True Bernstein basis |
Mathematical note: Bernstein polynomials = Lagrange polynomials for linear elements. Factory returns Lagrange for efficiency.
Bubble Functions (Stabilization)
Bubble functions are facet-attached enrichment functions (one per edge in 2D, one per face in 3D) used for stabilization in mixed formulations (e.g., inf-sup stability); each vanishes on every facet except its own.
| Element | Bubble Type | Facet functions | Bases per function | Use Case |
| TRI3 | Edge | 3 (one per edge) | 1 | Stabilize TRI3-based mixed methods |
| TRI6 | Edge | 3 | 2 | Stabilize TRI6-based mixed methods |
| TET4 | Face | 4 (one per face) | 1 | Stabilize TET4-based mixed methods |
| TET10 | Face | 4 | 3 | Stabilize TET10-based mixed methods |
create_bubble_function( aElementType, aFacet ) returns the function of one facet; its number_of_bases() is the "Bases per function" column (cl_IF_InterpolationFunctionFactory.cpp).
Bubble basis properties:
- Zero on every facet except the one it belongs to
- Non-zero in element interior
- Can be statically condensed (eliminated before global assembly)
Second Derivative Support
Every element the factory can create implements d2NdXi2 (LINE, TRI, QUAD, TET, PENTA, PYRA, HEX, plus the Hermite, Bernstein and bubble specializations). The BELFEM_ERROR in InterpolationFunctionTemplate is reached only for a template combination without a specialization, which the factory never instantiates.
Integration Point System
Volume Integration
const uint aIntegrationOrder = 0,
);
void initialize_integration_points(const ElementType &aElementType, Vector< real > &aWeights, Matrix< real > &aPoints, const uint aIntegrationOrder, const IntegrationScheme aIntegrationScheme)
Definition fn_IF_initialize_integration_points.cpp:22
Output:
- aWeights: (npts,) integration weights
- aPoints: parametric coordinates of the points, one column per point. TRI and TET rules carry ndim + 1 rows: the last row is the remaining barycentric coordinate, 1 − ξ − η (− ζ). Shape functions read only the first ndim rows
Example:
Facet Integration
);
void initialize_integration_points_on_facet(const ElementType aElementType, const uint aSideIndex, Vector< real > &aWeights, Matrix< real > &aPoints, const uint aIntegrationOrder, const IntegrationScheme aIntegrationScheme)
Definition fn_IF_initialize_integration_points_on_facet.cpp:27
Parameters:
- aFacetIndex: Local facet index (0-based)
- TET4: 0-3 (triangular faces)
- HEX8: 0-5 (quad faces)
Output:
- aPoints: Parametric coordinates in the parent element's coordinate system
- Points lie on the specified facet
Example:
Facet Integration with Orientation (Advanced)
For slave facets in contact/DG:
);
void intpoints_tet(const uint aMasterIndex, Vector< real > &aWeights, Matrix< real > &aPoints, const uint aIntegrationOrder, const IntegrationScheme aIntegrationScheme=IntegrationScheme::GAUSS)
Definition fn_IF_initialize_integration_points_on_facet.cpp:298
Orientation: 0-based index, Facet::orientation_on_slave() - 1 (see Example 5).
Supported geometries in IntegrationData::populate_for_slave():
- TET (via intpoints_tet)
- PENTA (via intpoints_penta)
- HEX (via intpoints_hex)
- QUAD4TS, QUAD9TS (via intpoints_quad, with orientation)
- TRI and other QUAD (via populate_for_slave_tri, orientation ignored)
PYRA has an oriented slave rule (facetintpoints::intpoints_pyra), but populate_for_slave() has no PYRA case and aborts with BELFEM_ERROR.
Derivative Matrix Conventions
First Derivatives (dNdXi)
Dimension: (ndim × nbases)
Interpretation:
Example (TRI6):
real dN1_dxi = dNdXi(0, 0);
real dN1_deta = dNdXi(1, 0);
real dN6_dxi = dNdXi(0, 5);
real dN6_deta = dNdXi(1, 5);
Second Derivatives (d2NdXi2)
Storage format depends on dimensionality:
1D Elements (LINE)
Dimension: (1 × nbases)
virtual void d2NdXi2(const Vector< real > &aXi, Matrix< real > &ad2NdXi2) const =0
calculates the second derivative of the shape function in parameter space
2D Elements (TRI, QUAD)
Dimension: (3 × nbases)
Row layout:
Example (TRI6):
real d2N1_dxi2 = d2N(0, 0);
real d2N1_deta2 = d2N(1, 0);
real d2N1_dxideta = d2N(2, 0);
3D Elements (TET, PENTA, PYRA, HEX)
Dimension: (6 × nbases)
Row layout:
Example (TET10):
real d2N1_dxi2 = d2N(0, 0);
real d2N1_deta2 = d2N(1, 0);
real d2N1_dzeta2 = d2N(2, 0);
real d2N1_detadzeta = d2N(3, 0);
real d2N1_dxidzeta = d2N(4, 0);
real d2N1_dxideta = d2N(5, 0);
Why This Layout?
Voigt notation compatibility: The row ordering matches stress/strain tensor storage in solid mechanics:
ε = [ε_xx ε_xy] → Voigt: [ε_xx, ε_yy, γ_xy]
[ε_xy ε_yy]
Use in plate/shell elements: Second derivatives directly form curvature matrices.
Performance Considerations
Direct Evaluation vs. IntegrationData
Creating and evaluating a shape function for every element repeats work that depends only on the element type. With a cached IntegrationData, the assembly loop reads stored matrices instead. The repository contains no benchmark comparing the two approaches.
Recommendation: use a cached IntegrationData in assembly loops.
Memory Footprint
IntegrationData storage (TET10, order 4), payload only:
mWeights: 11 ×
sizeof(
real) = 88 bytes
mPoints: 4 × 11 × sizeof(
real) = 352 bytes
mN: 11 × (1 × 10) × sizeof(
real) = 880 bytes
mPhi: 11 × 10 × sizeof(
real) = 880 bytes
mNvector: 11 × (3 × 30) × sizeof(
real) = 7,920 bytes
mdNdXi: 11 × (3 × 10) × sizeof(
real) = 2,640 bytes
md2NdXi2: 11 × (6 × 10) × sizeof(
real) = 5,280 bytes
Total: ~18 KB per element type
The size grows with the number of points and bases, but a cache holds one entry per element type and order, so it stays small compared to mesh data.
When NOT to Precompute
Adaptive quadrature: If integration points change per element (e.g., adaptive p-refinement), precomputation loses value.
Solution: Use InterpolationFunction directly for dynamic integration schemes.
Thread Safety and MPI
Thread Safety
BELFEM parallelizes with MPI rather than threads, and its internals are deliberately not thread-safe (see doc/coding_philosophy.md). This module adds no locks. The classes manage their own state as follows:
InterpolationFunction:
- N, dNdXi, d2NdXi2, param_coords are const and write only into the caller's output matrix
IntegrationData:
- populate*() reallocates and overwrites every table
- The accessors are const and return references to stored tables
EdgeFunction:
- precompute(), link(), E(), C() and G() all write member state (see the Lifetime & Mutation Contract)
Factories:
- Both factories have no data members
Containers: Map::operator[] is non-const and inserts a missing key; use key_exists() and operator() for lookups. Cell is indexed with operator(); it has no operator[].
Code that calls into this module from threads must provide its own protection, for example with #pragma omp critical.
MPI Compatibility
All classes are MPI-compatible by design:
- No global state (each rank creates independent instances)
- No communication required for shape functions/integration
- Works seamlessly with distributed meshes
Edge elements with distributed meshes:
edge->precompute(gaussPoints);
edge->link(localElement);
Common Patterns
Pattern 1: Single Element Type Assembly
{
{
}
}
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
const Vector< real > & weights() const
return the integration weights
Definition cl_IF_IntegrationData.hpp:273
BELFEM_ASSERT is compiled out of release builds, so in a release build an element of another type is not detected here. Use BELFEM_ERROR where the check must also run in release builds.
Pattern 2: Multi-Type Mesh with Dispatch
{
{
tCache[ tType ] = tNew ;
}
}
for ( auto & tEntry : tCache )
{
delete tEntry.second ;
}
Pattern 3: Boundary Condition Application
One IntegrationData per local facet index, built before the facet loop. fem::SideSet builds its master tables the same way (fem/kernel/cl_FEM_SideSet.cpp).
for (
uint f = 0; f < tNumFacets; ++f )
{
tMasterData( f )->populate_for_master( f, 3 );
}
{
if ( tSideSet->id() != aNeumannID ) continue ;
{
"unexpected master element type" );
{
}
}
}
{
delete tData ;
}
A bounds-checked wrapper around std::vector.
Definition cl_Cell.hpp:45
Definition cl_Facet.hpp:24
Definition cl_SideSet.hpp:29
unsigned int number_of_facets(const enum ElementType aElementType)
Definition meshtools.cpp:662
Pattern 4: Edge Element Assembly for Electromagnetics
tGauss.populate( 4 );
tEdge->precompute( tGauss.points() );
{
tEdge->link( tElement );
for (
uint k = 0; k < tGauss.number_of_integration_points(); ++k )
{
const real tDetJ = tEdge->det_J() ;
const real tW = tGauss.weights()( k );
}
}
delete tEdge ;
Development Notes
Adding New Element Types
Steps:
- Create shape function class:
- Lagrange: Add to lagrange/ subdirectory
- Hermite: Add to hermite/ subdirectory
- Bernstein: Add to bernstein/ subdirectory
- Specialize template or derive from base:
template <>
3,
20
};
shape function templated class G : Geometry T : Type D : Dimension B : Number of Basis
Definition cl_IF_InterpolationFunctionTemplate.hpp:32
GeometryType
Definition Mesh_Enums.hpp:70
- Add to factory:
case ElementType::NEW_ELEMENT:
- Add integration points:
- Test:
- Partition of unity: ∑ N_i(ξ) = 1
- Patch test: Constant strain produces constant stress
- Derivative verification (numerical vs. analytical)
- Document:
- Update element support matrix in README.md
- Add to this guide's element list
- Note any limitations (e.g., d2NdXi2 support)
Adding Nédélec Elements
Steps:
- Create EF_<NAME> class in nedelec/ subdirectory:
void link(
Element* aElement)
override;
};
- Implement curl operator:
- Reference Nédélec (1980) or Monk (2003) for basis definitions
- Test against analytical solutions (e.g., constant field)
- Add to EdgeFunctionFactory:
case ElementType::NEW_ELEMENT:
return new EF_NEW();
- Update num_nedelec_dofs():
case ElementType::NEW_ELEMENT:
return <number_of_edges>;
- Document:
- Add to Nédélec element table
- Specify DOF count and order
Known Limitations
- EdgeFunctionFactory has no LINE2 or LINE3 case:
- num_nedelec_dofs() (nedelec/fn_num_nedelec_dofs.hpp) returns 1 and 2 for LINE2 and LINE3
- EdgeFunctionFactory::create_edge_function() aborts for both; EF_LINE3 exists but is not created by the factory
- No quadratic thin-shell edge functions: num_nedelec_dofs() returns 3 for QUAD9TS and 16 for PENTA18TS, but EdgeFunctionFactory::create_edge_function() aborts with BELFEM_ERROR for both.
- Bernstein linear → Lagrange transparency:
- Document explicitly that linear Bernstein returns Lagrange
- Or create separate Bernstein template specializations reporting correct type
Testing Shape Functions
Partition of unity test:
xi(0) = 0.3; xi(1) = 0.4;
}
auto sum(const Vector< T > &aA) -> decltype(sum(aA.vector_data()))
Definition fn_sum.hpp:49
Derivative verification (finite difference):
xi(0) = 0.3; xi(1) = 0.4;
xi_plus = xi; xi_plus(0) += h;
shape->
N(xi_plus, N_plus);
shape->
dNdXi(xi, dN_analytical);
real dN_numerical = (N_plus(0,i) - N(0,i)) / h;
real error = std::abs(dN_numerical - dN_analytical(0,i));
}
See Also
Internal Documentation
- FEM Kernel: ../../kernel/doc/ - Uses IntegrationData for assembly
- Mesh Module: ../../../mesh/doc/ - Element definitions, facet orientations
- Homology Module: ../../../homology/doc/ - Cohomology cuts for Nédélec elements
- Linear Algebra: ../../../linalg/doc/ - Matrix/Vector for shape storage
Literature
Shape Functions:
- Zienkiewicz & Taylor, "The Finite Element Method" Vol. 1, Ch. 6-7
- Hughes, "The Finite Element Method", Ch. 3 (Isoparametric elements)
- Bathe, "Finite Element Procedures", Ch. 5
Nédélec Elements:
- Nédélec (1980), "Mixed finite elements in ℝ³", Numer. Math. 35, 315-341
- Monk (2003), "Finite Element Methods for Maxwell's Equations", Oxford
- BELFEM papers: literature/papers/fem/messe2023.txt (h-φ formulation), literature/papers/fem/arsenault2023.txt (magnetodynamic coupling)
Integration:
- Stroud (1971), "Approximate Calculation of Multiple Integrals"
- Dunavant (1985), "High degree efficient symmetrical Gaussian quadrature rules for the triangle", Int. J. Numer. Methods Eng. 21, 1129-1148
Project References
- Project README: ../../../../README.md
- Claude Instructions: ../../../../CLAUDE.md
- Coding Philosophy: ../../../../doc/coding_philosophy.md
- Documentation Guidelines: ../../../../doc/documentation_guidelines.md
Contributors: Based on code by Christian Messe and Gregory Giard
Prepared by the BELFEM development team.