Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
fd8cf04
fem: generalized jacobian measure using the area formula
Pawel024 Jan 15, 2026
3995dab
fem: completed base implementation of segments embedded in 2d
Pawel024 Jan 17, 2026
5ae76d1
fem: copy block_mass and block_grad_grad tests for embedded segments
Pawel024 Jan 20, 2026
e30e749
fem: copy tests from isoparametric_segment.cc for embedded segments
Pawel024 Jan 20, 2026
b943365
fem: add tests for gradient values and arc length to isoparametric_em…
Pawel024 Jan 20, 2026
d408726
fem: update block tests for embedded segments to use a diagonal segment
Pawel024 Jan 20, 2026
01741b6
fem: update paths to match fields redesign
Pawel024 Jan 23, 2026
4fe4832
fem: formatting edits
Pawel024 Jan 23, 2026
c1e17e2
tests/fem: formatting edits
Pawel024 Jan 23, 2026
b313d85
fem: replace hardcoded dimension values with the variable dim
Pawel024 Jan 23, 2026
2b9e098
fem: make base isoparametric segment class a template of the dimension
Pawel024 Jan 23, 2026
f3f3451
fem: update elements api to select the right simplex based on degree …
Pawel024 Jan 27, 2026
e81d32d
fem: expose volume form from manifold and pass it to the element classes
Pawel024 Jan 27, 2026
69a068c
fem: replace the jacobian_measure utility with element.volume_element
Pawel024 Jan 27, 2026
9ce302e
fem: update jacobian calculation in element classes to work for diffe…
Pawel024 Jan 27, 2026
e3210e7
tensor: add as_column_matrix factory, apply in IsoparametricSegmentP1…
Pawel024 Jan 27, 2026
7f96cf6
fem: use pyre::tensor::col and tensor::dyadic properly to avoid repet…
Pawel024 Jan 27, 2026
31c7e73
fem: contravariant gradient computation with the riemannian formula -…
Pawel024 Jan 27, 2026
4a08b11
tests/fem: adapt tests to work with the new elements API
Pawel024 Jan 27, 2026
e6d974a
fem: remove division by factorial in volume element computation, it's…
Pawel024 Jan 28, 2026
ff1f5c4
tests/fem: use a clockwise-rotated normal field to get positive volum…
Pawel024 Jan 28, 2026
4a1daa8
benchmarks: update the poisson benchmark to use the new elements api
Pawel024 Jan 28, 2026
65259dc
fem: update comments to use "n-simplex" instead of "nth order simplex…
Pawel024 Jan 28, 2026
fe3d6fc
Merge remote-tracking branch 'origin/main' into fem-1d-embedded-in-2d
Pawel024 Jan 29, 2026
0f27c1b
test/fem: test integration with volume form on arbitrary segments
Pawel024 Feb 5, 2026
3266552
Merge remote-tracking branch 'origin/main' into fem-1d-embedded-in-2d
Pawel024 Jul 16, 2026
90f52fd
operators: add gradient overload taking a metric field
Pawel024 Jul 19, 2026
f320b0f
fem: remove superseded {gradient.h}
Pawel024 Jul 19, 2026
cb810ae
tensor: remove {as_column_matrix}
Pawel024 Jul 19, 2026
5ec0ac7
fem/elements: generalize {finite_element_family} and discretizers ove…
Pawel024 Jul 19, 2026
96aec06
fem/elements: reimplement isoparametric elements on embedded manifolds
Pawel024 Jul 19, 2026
51df354
tests/fem: adapt embedded segment tests after the manifold redesign PR
Pawel024 Jul 19, 2026
1676150
tests/fem: add tests for embedded triangles equivalent to those for e…
Pawel024 Jul 20, 2026
1baca62
Update cmake-macos.yaml to check out pyre branch {main} instead of {t…
Pawel024 Jul 21, 2026
bc00e48
Update cmake-ubuntu.yaml to check out pyre branch {main} instead of {…
Pawel024 Jul 21, 2026
4a36359
tests/geometry: correction in comments
Pawel024 Jul 21, 2026
3a15afa
fem/blocks: remove unnecessarily added comment
Pawel024 Jul 21, 2026
7107e9a
tensor: remove accidentally added whiteline
Pawel024 Jul 21, 2026
a1a5065
tests/geometry: make a comment clearer
Pawel024 Jul 21, 2026
be1da27
Merge branch 'main' into fem-1d-embedded-in-2d
biancagi Aug 11, 2026
5dda78d
fem: adjustments to new blocks api
biancagi Aug 11, 2026
0be1c4b
major refactoring of functions integration and fem assembly around ce…
biancagi Aug 11, 2026
6dcae3b
tests: move measure tests for isoparametric embedded elements
biancagi Aug 17, 2026
1b16ab4
fem/elements: remove {volume_element} method from isoparametric elements
biancagi Aug 17, 2026
de8dae4
fem/elements: move {jacobian} to {ParametrizedElement}
biancagi Aug 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .cmake/mito_tests_mito_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ mito_test_driver(tests/mito.lib/geometry/point.cc)
mito_test_driver(tests/mito.lib/geometry/euclidean_metric_1D.cc)
mito_test_driver(tests/mito.lib/geometry/euclidean_metric_2D.cc)
mito_test_driver(tests/mito.lib/geometry/euclidean_metric_3D.cc)
mito_test_driver(tests/mito.lib/geometry/euclidean_submanifold_metric_2D.cc)
mito_test_driver(tests/mito.lib/geometry/euclidean_submanifold_metric_3D.cc)
mito_test_driver(tests/mito.lib/geometry/induced_metric_segment.cc)
mito_test_driver(tests/mito.lib/geometry/induced_metric_triangle.cc)
Expand All @@ -56,8 +57,12 @@ mito_test_driver(tests/mito.lib/discrete/mesh_field.cc)
# fem
mito_test_driver(tests/mito.lib/fem/block_grad_grad.cc)
mito_test_driver(tests/mito.lib/fem/block_grad_grad_segment.cc)
mito_test_driver(tests/mito.lib/fem/block_grad_grad_embedded_segment.cc)
mito_test_driver(tests/mito.lib/fem/block_grad_grad_embedded_triangle.cc)
mito_test_driver(tests/mito.lib/fem/block_mass.cc)
mito_test_driver(tests/mito.lib/fem/block_mass_segment.cc)
mito_test_driver(tests/mito.lib/fem/block_mass_embedded_segment.cc)
mito_test_driver(tests/mito.lib/fem/block_mass_embedded_triangle.cc)
mito_test_driver(tests/mito.lib/fem/block_algebra.cc)
mito_test_driver(tests/mito.lib/fem/shape_functions_triangle_construction.cc)
mito_test_driver(tests/mito.lib/fem/shape_functions_triangle_p1.cc)
Expand All @@ -66,6 +71,8 @@ mito_test_driver(tests/mito.lib/fem/isoparametric_triangle.cc)
mito_test_driver(tests/mito.lib/fem/fem_field.cc)
mito_test_driver(tests/mito.lib/fem/shape_functions_segment_p1.cc)
mito_test_driver(tests/mito.lib/fem/isoparametric_segment.cc)
mito_test_driver(tests/mito.lib/fem/isoparametric_embedded_segment.cc)
mito_test_driver(tests/mito.lib/fem/isoparametric_embedded_triangle.cc)

# io
mito_test_driver(tests/mito.lib/io/summit_mesh_reader_2D.cc)
Expand Down Expand Up @@ -189,8 +196,10 @@ mito_test_driver(tests/mito.lib/quadrature/quadrature_parametric_segment.cc)
mito_test_driver(tests/mito.lib/quadrature/quadrature_parametric_triangle.cc)
mito_test_driver(tests/mito.lib/quadrature/quadrature_parametric_tetrahedron.cc)
mito_test_driver(tests/mito.lib/quadrature/quadrature_segment_1D.cc)
mito_test_driver(tests/mito.lib/quadrature/quadrature_segment_2D.cc)
mito_test_driver(tests/mito.lib/quadrature/quadrature_segment_3D.cc)
mito_test_driver(tests/mito.lib/quadrature/quadrature_triangle_2D.cc)
mito_test_driver(tests/mito.lib/quadrature/quadrature_triangle_3D.cc)
mito_test_driver(tests/mito.lib/quadrature/quadrature_square_3D.cc)

# integration
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cmake-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
repository: pyre/pyre
fetch-depth: 0
path: ${{github.workspace}}/pyre
ref: tensor
ref: main

- name: retrieve pyre commit SHA
id: pyre-sha
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cmake-ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
repository: pyre/pyre
fetch-depth: 0
path: ${{github.workspace}}/pyre
ref: tensor
ref: main

- name: retrieve pyre commit SHA
id: pyre-sha
Expand Down
67 changes: 25 additions & 42 deletions lib/mito/fem/blocks/GradientGradientBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ namespace mito::fem::blocks {
// the type of the coefficient field
using coefficient_field_type = coefficientFieldT;

public:
// instantiate the quadrature rule
static constexpr auto quadrature_rule = quadrature_rule_type();

public:
// constructor
GradientGradientBlock(const coefficient_field_type & coefficient) :
Expand All @@ -39,53 +35,40 @@ namespace mito::fem::blocks {
requires element_of_type_c<elementT, element_type>
auto compute(const elementT & element) const -> elementary_shape
{
// the number of nodes per element
constexpr int n_nodes = element_type::n_nodes;

// the number of quadrature points per element
constexpr int n_quads = quadrature_rule_type::npoints;
// the parametric coordinates type
using parametric_coordinates_type = typename elementT::parametric_coordinates_type;

// the elementary matrix
elementary_shape elementary_matrix{};

// loop on the quadrature points
tensor::constexpr_for_1<n_quads>([&]<int q>() {
// the parametric coordinates of the quadrature point
constexpr auto xi = quadrature_rule.point(q);

// the coordinates of the quadrature point
auto x = element.parametrization()(xi);

// evaluate the coefficient field at the quadrature point
auto coefficient = _coefficient(x);
return manifolds::cell_integrator<quadrature_rule_type>(element.element())
.integrate(mito::functions::function([&](const parametric_coordinates_type & xi) {
// the elementary contribution at quadrature point {xi}
elementary_shape elementary_matrix{};

// the measure of the canonical simplex
constexpr auto measure =
element_type::mesh_cell_type::reference_simplex_type::measure;
// the number of nodes per element
constexpr int n_nodes = element_type::n_nodes;

// the quadrature weight at this point scaled with the area of the canonical simplex
constexpr auto w = measure * quadrature_rule.weight(q);
// the coordinates of the quadrature point
auto x = element.parametrization()(xi);

// precompute the common factor
auto factor = w * tensor::determinant(element.jacobian()(xi));
// evaluate the coefficient at the quadrature point
auto coefficient = _coefficient(x);

// loop on the nodes of the element
tensor::constexpr_for_1<n_nodes>([&]<int a>() {
// evaluate the spatial gradient of the element's a-th shape function at {xi}
auto dphi_a = element.template gradient<a>()(xi);
// loop on the nodes of the element
tensor::constexpr_for_1<n_nodes>([&]<int b>() {
// evaluate the spatial gradient of the element's b-th shape function at
// {xi}
auto dphi_b = element.template gradient<b>()(xi);
// populate the elementary contribution to the matrix
elementary_matrix[{ a, b }] += factor * dphi_a * (coefficient * dphi_b);
tensor::constexpr_for_1<n_nodes>([&]<int a>() {
// evaluate the spatial gradient of the a-th shape function at {xi}
auto dphi_a = element.template gradient<a>()(xi);
// loop on the nodes of the element
tensor::constexpr_for_1<n_nodes>([&]<int b>() {
// evaluate the spatial gradient of the b-th shape function at {xi}
auto dphi_b = element.template gradient<b>()(xi);
// populate the elementary contribution to the matrix
elementary_matrix[{ a, b }] = dphi_a * (coefficient * dphi_b);
});
});
});
});

// all done
return elementary_matrix;
// all done
return elementary_matrix;
}));
}

private:
Expand Down
47 changes: 18 additions & 29 deletions lib/mito/fem/blocks/L2NormBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@ namespace mito::fem::blocks {
class L2NormBlock {

public:
// my template parameters
// my finite element type
using element_type = finiteElementT;
using elementary_shape = tensor::scalar_t;
// my quadrature rule
using quadrature_rule_type = quadratureRuleT;
// my elementary shape
using elementary_shape = tensor::scalar_t;

// the type of the function to compute the L2 norm of
using function_type = functionT;

public:
// instantiate the quadrature rule
static constexpr auto quadrature_rule = quadrature_rule_type();

public:
// constructor
L2NormBlock(const function_type & function) : _function(function) {}
Expand All @@ -38,33 +36,24 @@ namespace mito::fem::blocks {
requires element_of_type_c<elementT, element_type>
auto compute(const elementT & element) const -> elementary_shape
{
// the number of quadrature points per element
constexpr int n_quads = quadrature_rule_type::npoints;

// the elementary contribution to the L2 norm
elementary_shape norm{};

// loop on the quadrature points
tensor::constexpr_for_1<n_quads>([&]<int q>() {
// the parametric coordinates of the quadrature point
constexpr auto xi = quadrature_rule.point(q);

// the measure of the canonical simplex
constexpr auto measure =
element_type::mesh_cell_type::reference_simplex_type::measure;
// the parametric coordinates type
using parametric_coordinates_type = typename elementT::parametric_coordinates_type;

// the quadrature weight at this point scaled with the area of the canonical simplex
constexpr auto w = measure * quadrature_rule.weight(q);
// the elementary matrix
return manifolds::cell_integrator<quadrature_rule_type>(element.element())
.integrate(mito::functions::function([&](const parametric_coordinates_type & xi) {
// the elementary contribution at quadrature point {xi}
elementary_shape norm{};

// precompute the common factor
auto factor = w * tensor::determinant(element.jacobian()(xi));
// evaluate the function at the quadrature point
auto fx = _function(xi);

// populate the elementary contribution to the matrix
norm += factor * _function(xi) * _function(xi);
});
// assemble the elementary contribution
norm = fx * fx;

// all done
return norm;
// all done
return norm;
}));
}

private:
Expand Down
67 changes: 27 additions & 40 deletions lib/mito/fem/blocks/ValueBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ namespace mito::fem::blocks {
// the type of the coefficient field
using coefficient_field_type = coefficientFieldT;

public:
// instantiate the quadrature rule
static constexpr auto quadrature_rule = quadrature_rule_type();

public:
// constructor
ValueBlock(const coefficient_field_type & coefficient) : _coefficient(coefficient) {}
Expand All @@ -39,44 +35,35 @@ namespace mito::fem::blocks {
requires(element_of_type_c<elementT, element_type>)
auto compute(const elementT & element) const -> elementary_shape
{
// the number of nodes per element
constexpr int n_nodes = element_type::n_nodes;

// the number of quadrature points per element
constexpr int n_quads = quadrature_rule_type::npoints;
// the parametric coordinates type
using parametric_coordinates_type = typename elementT::parametric_coordinates_type;

// the elementary vector
elementary_shape elementary_vector{};

// loop on the quadrature points
tensor::constexpr_for_1<n_quads>([&]<int q>() {
// the parametric coordinates of the quadrature point
constexpr auto xi = quadrature_rule.point(q);

// the coordinates of the quadrature point
auto coord = element.parametrization()(xi);

// the measure of the canonical simplex
constexpr auto measure =
element_type::mesh_cell_type::reference_simplex_type::measure;

// the quadrature weight at this point scaled with the area of the canonical simplex
constexpr auto w = measure * quadrature_rule.weight(q);

// precompute the common factor
auto factor = w * _coefficient(coord) * tensor::determinant(element.jacobian()(xi));

// loop on the nodes of the element
tensor::constexpr_for_1<n_nodes>([&]<int a>() {
// evaluate the a-th shape function at {xi}
auto phi_a = element.template shape<a>()(xi);
// populate the elementary contribution to the vector
elementary_vector[{ a }] += factor * phi_a;
});
});

// all done
return elementary_vector;
return manifolds::cell_integrator<quadrature_rule_type>(element.element())
.integrate(mito::functions::function([&](const parametric_coordinates_type & xi) {
// the elementary contribution at quadrature point {xi}
elementary_shape elementary_vector{};

// the number of nodes per element
constexpr int n_nodes = element_type::n_nodes;

// the coordinates of the quadrature point
auto x = element.parametrization()(xi);

// evaluate the coefficient at the quadrature point
auto coefficient = _coefficient(x);

// loop on the nodes of the element
tensor::constexpr_for_1<n_nodes>([&]<int a>() {
// evaluate the element's a-th shape function at {xi}
const auto phi_a = element.template shape<a>()(xi);
// populate the elementary contribution to the vector
elementary_vector[{ a }] = coefficient * phi_a;
});

// all done
return elementary_vector;
}));
}

private:
Expand Down
67 changes: 25 additions & 42 deletions lib/mito/fem/blocks/ValueGradientBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ namespace mito::fem::blocks {
// the type of the coefficient field
using coefficient_field_type = coefficientFieldT;

public:
// instantiate the quadrature rule
static constexpr auto quadrature_rule = quadrature_rule_type();

public:
// constructor
ValueGradientBlock(const coefficient_field_type & coefficient) : _coefficient(coefficient)
Expand All @@ -38,53 +34,40 @@ namespace mito::fem::blocks {
requires element_of_type_c<elementT, element_type>
auto compute(const elementT & element) const -> elementary_shape
{
// the number of nodes per element
constexpr int n_nodes = element_type::n_nodes;

// the number of quadrature points per element
constexpr int n_quads = quadrature_rule_type::npoints;
// the parametric coordinates type
using parametric_coordinates_type = typename elementT::parametric_coordinates_type;

// the elementary matrix
elementary_shape elementary_matrix{};

// loop on the quadrature points
tensor::constexpr_for_1<n_quads>([&]<int q>() {
// the parametric coordinates of the quadrature point
constexpr auto xi = quadrature_rule.point(q);

// the coordinates of the quadrature point
auto x = element.parametrization()(xi);

// evaluate the coefficient at the quadrature point
auto coefficient = _coefficient(x);
return manifolds::cell_integrator<quadrature_rule_type>(element.element())
.integrate(mito::functions::function([&](const parametric_coordinates_type & xi) {
// the elementary contribution at quadrature point {xi}
elementary_shape elementary_matrix{};

// the measure of the canonical simplex
constexpr auto measure =
element_type::mesh_cell_type::reference_simplex_type::measure;
// the number of nodes per element
constexpr int n_nodes = element_type::n_nodes;

// the quadrature weight at this point scaled with the area of the canonical simplex
constexpr auto w = measure * quadrature_rule.weight(q);
// the coordinates of the quadrature point
auto x = element.parametrization()(xi);

// precompute the common factor
auto factor = w * tensor::determinant(element.jacobian()(xi));
// evaluate the coefficient at the quadrature point
auto coefficient = _coefficient(x);

// loop on the nodes of the element
tensor::constexpr_for_1<n_nodes>([&]<int a>() {
// evaluate the element's a-th shape function at {xi}
auto phi_a = element.template shape<a>()(xi);
// loop on the nodes of the element
tensor::constexpr_for_1<n_nodes>([&]<int b>() {
// evaluate the spatial gradient of the element's b-th shape function at
// {xi}
auto dphi_b = element.template gradient<b>()(xi);
// populate the elementary contribution to the matrix
elementary_matrix[{ a, b }] += factor * phi_a * coefficient * dphi_b;
tensor::constexpr_for_1<n_nodes>([&]<int a>() {
// evaluate the element's a-th shape function at {xi}
const auto phi_a = element.template shape<a>()(xi);
// loop on the nodes of the element
tensor::constexpr_for_1<n_nodes>([&]<int b>() {
// evaluate the spatial gradient of the b-th shape function at {xi}
auto dphi_b = element.template gradient<b>()(xi);
// populate the elementary contribution to the matrix
elementary_matrix[{ a, b }] = phi_a * coefficient * dphi_b;
});
});
});
});

// all done
return elementary_matrix;
// all done
return elementary_matrix;
}));
}

private:
Expand Down
Loading
Loading