Skip to content

Conversation

@Pawel024
Copy link
Collaborator

@Pawel024 Pawel024 commented Jan 20, 2026

This pull request introduces a refactor and generalization of the FEM element infrastructure to support isoparametric elements on manifolds embedded in arbitrary coordinate systems and dimensions.

Key changes:

  • Refactored IsoparametricSegment and IsoparametricTriangle classes to be templated on coordinate type and volume form, supporting arbitrary embeddings and coordinate systems.
  • Introduced a new user-facing API in elements_library.h for selecting FE element types via isoparametric_simplex_t<degree, ManifoldT>, where ManifoldT encodes the coordinate system, cell, and volume form.
  • Started exposing the volume form from the manifold so that the discretizers can extract it with manifold.volume_form() and give it to the elements. Then, the elements contract the volume form with the tangent vectors to get the volume element.
  • Updated block assembly code to use the element's volume_element() instead of directly computing the determinant of the Jacobian
  • Updated tests and the Poisson benchmark to use the elements API and added new tests for embedded segment elements, covering:
    • partition of unity
    • gradient consistency
    • arc length on a diagonal (to verify Jacobian measure)
    • gradient values projected on a diagonal
    • stiffness and mass matrix values on a diagonal

@Pawel024 Pawel024 force-pushed the fem-1d-embedded-in-2d branch from f0ddd94 to 7f1690a Compare January 23, 2026 10:46
@Pawel024 Pawel024 force-pushed the fem-1d-embedded-in-2d branch from a50a8d4 to 2b9e098 Compare January 23, 2026 13:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for 1D finite elements embedded in 2D space (curves in 2D) using isoparametric linear segments. The implementation generalizes the finite element framework from cell-based to manifold-based types, enabling elements to work with both standard and embedded geometries across different coordinate systems.

Changes:

  • Introduced a new gradient computation utility (gradient.h) that handles both square Jacobians (non-embedded) and rectangular Jacobians (embedded manifolds) using Riemannian gradient formulas
  • Generalized finite element types to be templated on manifold types rather than cell types, with the manifold encapsulating coordinate system, volume form, and cell information
  • Updated all matrix assembly blocks to use a unified volume_element() method instead of Jacobian determinants, which now correctly handles embedded geometries
  • Added comprehensive tests for embedded segments verifying partition of unity, gradient consistency, arc length computation, and matrix assembly

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/mito/fem/gradient.h New utility for computing contravariant gradients with support for embedded manifolds using induced metric
lib/mito/tensor/factories.h Added as_column_matrix function to wrap vectors as D×1 matrices for Jacobian representation
lib/mito/manifolds/Manifold.h Exposed volume_form_type and added volume_form() accessor for element construction
lib/mito/fem/elements/elements_library.h New unified API for element type selection based on manifold and polynomial degree
lib/mito/fem/elements/IsoparametricSegment.h Templated on coordinates and volume form types; added metric space access
lib/mito/fem/elements/IsoparametricTriangle.h Templated on coordinates and volume form types; added metric space access
lib/mito/fem/elements/seg1/IsoparametricSegmentP1.h Updated to use new gradient computation and volume element methods
lib/mito/fem/elements/tri1/IsoparametricTriangleP1.h Updated to use new gradient computation and volume element methods
lib/mito/fem/elements/tri2/IsoparametricTriangleP2.h Updated to use new gradient computation and volume element methods
lib/mito/fem/elements/seg1/DiscretizerCG.h Updated to pass volume form to elements during discretization
lib/mito/fem/elements/tri1/DiscretizerCG.h Updated to pass volume form to elements during discretization
lib/mito/fem/elements/tri2/DiscretizerCG.h Updated to pass volume form to elements during discretization
lib/mito/fem/blocks/*.h Replaced Jacobian determinant with volume_element() for consistent integration measure
tests/mito.lib/fem/isoparametric_embedded_segment.cc New tests for embedded segments: partition of unity, gradient consistency, arc length, gradient values
tests/mito.lib/fem/block_mass_embedded_segment.cc New test verifying mass matrix assembly for unit-length diagonal embedded segment
tests/mito.lib/fem/block_grad_grad_embedded_segment.cc New test verifying stiffness matrix assembly for unit-length diagonal embedded segment
tests/mito.lib/fem/*.cc (existing) Updated to use manifold-based element types instead of cell-based types
.cmake/mito_tests_mito_lib.cmake Added new embedded segment test drivers to build system

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Pawel024 Pawel024 changed the title Add support for 1D FEM embedded in 2D with linear isoparametric segments Add support for FEM isoparametric elements (segments and triangles) generalized to an arbitrary dimension D of the physical space Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants