Skip to content

Revision of the geometry coordinates api - #104

Open
biancagi wants to merge 6 commits into
mainfrom
coordinates-api
Open

Revision of the geometry coordinates api#104
biancagi wants to merge 6 commits into
mainfrom
coordinates-api

Conversation

@biancagi

Copy link
Copy Markdown
Contributor

Summary

This PR revises the geometry coordinates API to provide a more compact and expressive interface for Cartesian, polar, and spherical coordinate systems.

In particular, Cartesian geometry is now represented by a dimension-specific type:

mito::geometry::cartesian<D>

which collects the coordinate type, coordinate factory, Euclidean metric, coordinate component functions, and basis vectors associated with the corresponding Cartesian space.

For example, the 2D Cartesian API becomes:

using coordinates_t = mito::geometry::cartesian<2>::coordinates_t;

constexpr auto x = mito::geometry::cartesian<2>::x;
constexpr auto y = mito::geometry::cartesian<2>::y;

constexpr auto e_x = mito::geometry::cartesian<2>::e_x;
constexpr auto e_y = mito::geometry::cartesian<2>::e_y;

auto coordinates =
    mito::geometry::cartesian<2>::coordinates({ 1.0, 2.0 });

Coordinates API

  • Introduce dimension-specific Cartesian geometry descriptors:

    • geometry::cartesian<1>
    • geometry::cartesian<2>
    • geometry::cartesian<3>
  • Collect the Cartesian coordinate type, coordinate factory, Euclidean metric, coordinate functions, and basis vectors within the corresponding geometry type.

  • Replace index-based Cartesian coordinate accessors such as

    cartesian::x_0<2>
    cartesian::x_1<2>
    cartesian::x_2<3>

    with the more natural

    cartesian<2>::x
    cartesian<2>::y
    
    cartesian<3>::x
    cartesian<3>::y
    cartesian<3>::z
  • Similarly rename Cartesian basis vectors from e_0, e_1, and e_2 to e_x, e_y, and e_z.

  • Move the polar and spherical APIs to geometry descriptor types as well:

    geometry::polar
    geometry::spherical

    exposing their coordinate types, coordinate factories, Euclidean metrics, coordinate functions, and basis vectors as static members.

API migration

Update benchmarks, tests, tutorials, Python bindings, and VTK utilities to use the new interface.

In particular:

geometry::coordinates_t<2, geometry::CARTESIAN>

becomes

geometry::cartesian<2>::coordinates_t

and explicit component functions such as

functions::component<coordinates_t, 0>

can now be replaced by the coordinate-system API:

geometry::cartesian<2>::x

The same convention is adopted consistently for Cartesian, polar, and spherical coordinates throughout the codebase.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 revises MiTo’s geometry coordinates API by moving Cartesian (dimension-specific), polar, and spherical coordinate-system “descriptors” into mito::geometry::{cartesian<D>, polar, spherical} types that bundle coordinate types, factories, metrics, component functions, and basis vectors, then migrates call sites to the new interface across tutorials, tests, benchmarks, bindings, and VTK utilities.

Changes:

  • Introduces mito::geometry::cartesian<1/2/3> descriptor specializations and migrates Cartesian component/basis access to ::x/::y/::z and ::e_x/::e_y/::e_z.
  • Moves polar and spherical APIs under mito::geometry::polar / mito::geometry::spherical descriptor types and migrates many usages to ::coordinates_t.
  • Updates broad codebase usage (tutorials/tests/benchmarks/bindings/VTK helpers) to the new coordinate-type aliases and factories.

Reviewed changes

Copilot reviewed 105 out of 105 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tutorial/5_divergence_theorem_2D_in_3D/main.cc Migrates tutorial to geometry::cartesian<3> descriptor API.
tutorial/4_divergence_theorem_2D/main.cc Migrates tutorial to geometry::cartesian<2> descriptor API.
tutorial/3_fields/main.cc Migrates tutorial to geometry::cartesian<2> descriptor API.
tests/mito.lib/quadrature/quadrature_triangle_2D.cc Updates quadrature test to cartesian<2> accessors.
tests/mito.lib/quadrature/quadrature_square_3D.cc Updates quadrature test to cartesian<3>::coordinates_t / factory.
tests/mito.lib/quadrature/quadrature_segment_3D.cc Updates quadrature test to cartesian<3>::coordinates_t / factory.
tests/mito.lib/quadrature/quadrature_segment_1D.cc Updates quadrature test to cartesian<1> descriptor API.
tests/mito.lib/operators/gradient_non_square.cc Updates operator test to cartesian<3>::x/y/z.
tests/mito.lib/operators/calculus_vector_field.cc Updates operator test to cartesian<2>::x/y.
tests/mito.lib/operators/calculus_scalar_field.cc Updates operator test to cartesian<2>::x/y.
tests/mito.lib/operators/calculus_identities.cc Updates identities test to cartesian<2> descriptor API.
tests/mito.lib/mesh/tetra_zero_subdivisions.cc Updates mesh test coordinate type to cartesian<3>::coordinates_t.
tests/mito.lib/mesh/tetra_triangle_3D.cc Updates mesh test coordinate type to cartesian<3>::coordinates_t.
tests/mito.lib/mesh/tetra_triangle_2D.cc Updates mesh test coordinate type to cartesian<2>::coordinates_t.
tests/mito.lib/mesh/tetra_tetrahedron_3D.cc Updates mesh test coordinate type to cartesian<3>::coordinates_t.
tests/mito.lib/mesh/tetra_segment_1D.cc Updates mesh test coordinate type to cartesian<1>::coordinates_t.
tests/mito.lib/mesh/tetra_rectangle_2D.cc Updates mesh test coordinate type to cartesian<2>::coordinates_t.
tests/mito.lib/mesh/tetra_multiple_subdivisions.cc Updates mesh test coordinate type to cartesian<2>::coordinates_t.
tests/mito.lib/mesh/tetra_cube_3D.cc Updates mesh test coordinate type to cartesian<3>::coordinates_t.
tests/mito.lib/mesh/summit_read_write.cc Updates mesh test coordinate type to cartesian<2>::coordinates_t.
tests/mito.lib/mesh/sphere.cc Updates mesh test coordinate type to cartesian<3>::coordinates_t.
tests/mito.lib/mesh/metis_partitioner.cc Updates mesh test coordinate type to cartesian<2>::coordinates_t.
tests/mito.lib/mesh/metis_partitioner_single_partition.cc Updates mesh test coordinate type to cartesian<2>::coordinates_t.
tests/mito.lib/mesh/metis_partitioner_mpi.cc Updates mesh test coordinate type to cartesian<2>::coordinates_t.
tests/mito.lib/mesh/metis_partitioner_mpi_load_mesh.cc Updates mesh test coordinate type to cartesian<2>::coordinates_t.
tests/mito.lib/mesh/metis_partitioner_load_mesh.cc Updates mesh test coordinate type to cartesian<2>::coordinates_t.
tests/mito.lib/mesh/half_ball.cc Migrates cartesian and spherical coordinate aliases to new descriptors.
tests/mito.lib/mesh/filter_ball.cc Updates mesh test coordinate type to cartesian<3>::coordinates_t.
tests/mito.lib/mesh/erase_element.cc Updates mesh test coordinate type to cartesian<2>::coordinates_t.
tests/mito.lib/mesh/erase_duplicates.cc Updates mesh test coordinate type to cartesian<2>::coordinates_t.
tests/mito.lib/mesh/disk_polar_cartesian.cc Migrates cartesian/polar coordinate aliases to new descriptors.
tests/mito.lib/mesh/disk_change_coordinates.cc Migrates cartesian/polar coordinate aliases to new descriptors.
tests/mito.lib/mesh/build_mesh.cc Updates mesh test coordinate type to cartesian<2>::coordinates_t.
tests/mito.lib/mesh/ball.cc Updates mesh test coordinate type to cartesian<3>::coordinates_t.
tests/mito.lib/manifolds/surface_half_sphere_spherical.cc Migrates spherical/cartesian coordinate aliases to new descriptors.
tests/mito.lib/manifolds/surface_half_sphere_cartesian.cc Updates manifold test to cartesian<3>::coordinates_t.
tests/mito.lib/manifolds/spherical_gradient.cc Updates manifold test to spherical::coordinates_t.
tests/mito.lib/manifolds/polar_gradient.cc Updates manifold test to polar::coordinates_t.
tests/mito.lib/manifolds/manifold_elements_view.cc Updates manifold test to cartesian<2>::coordinates_t.
tests/mito.lib/manifolds/euclidean_gradient.cc Migrates euclidean gradient test to cartesian<2> descriptor API.
tests/mito.lib/io/vtk_mesh_writer_polar_coordinates.cc Updates VTK writer test to polar::coordinates_t.
tests/mito.lib/io/vtk_mesh_writer_lattice_3D.cc Updates VTK writer test to cartesian<3>::coordinates_t.
tests/mito.lib/io/vtk_mesh_writer_3D.cc Updates VTK writer test to cartesian<3>::coordinates_t.
tests/mito.lib/io/vtk_mesh_writer_2D.cc Updates VTK writer test to cartesian<2>::coordinates_t.
tests/mito.lib/io/vtk_cloud_writer.cc Updates VTK writer test to cartesian<3>::coordinates_t.
tests/mito.lib/io/vtk_cloud_writer_spherical_coordinates.cc Updates VTK writer test to spherical::coordinates_t.
tests/mito.lib/io/summit_to_summit_mesh_2D.cc Updates Summit IO test to cartesian<2>::coordinates_t.
tests/mito.lib/io/summit_mesh_reader_segment_3D.cc Updates Summit reader test to cartesian<3>::coordinates_t.
tests/mito.lib/io/summit_mesh_reader_3D.cc Updates Summit reader test to cartesian<3>::coordinates_t.
tests/mito.lib/io/summit_mesh_reader_2D.cc Updates Summit reader test to cartesian<2>::coordinates_t.
tests/mito.lib/io/parallel_vtk_mesh_writer.cc Updates parallel VTK writer test to cartesian<3>::coordinates_t.
tests/mito.lib/io/parallel_vtk_mesh_field_writer.cc Updates parallel VTK field writer test to cartesian<3>::coordinates_t.
tests/mito.lib/io/parallel_vtk_cloud_writer.cc Updates parallel VTK cloud writer test to cartesian<3>::coordinates_t.
tests/mito.lib/io/parallel_vtk_cloud_field_writer.cc Updates parallel VTK cloud field writer test to cartesian<3>::coordinates_t.
tests/mito.lib/integration/write_tetra_mesh_to_vtk.cc Updates integration test to cartesian<3>::coordinates_t.
tests/mito.lib/integration/quadrature_load_mesh_2D.cc Updates integration test to cartesian<2>::x/y and coordinates_t.
tests/mito.lib/integration/quadrature_load_mesh_2D_mpi.cc Updates MPI integration test to cartesian<2>::x/y and coordinates_t.
tests/mito.lib/integration/quadrature_flip_segment_3D.cc Updates integration test to cartesian<3>::coordinates_t / factory.
tests/mito.lib/integration/divergence_theorem.cc Updates integration test to cartesian<2>::x/y and e_x/e_y.
tests/mito.lib/geometry/triangle_3D.cc Updates geometry test to cartesian<3>::coordinates_t and factory.
tests/mito.lib/geometry/triangle_2D.cc Updates geometry test to cartesian<2>::coordinates_t.
tests/mito.lib/geometry/tetrahedron_3D.cc Updates geometry test to cartesian<3>::coordinates_t (plus formatting).
tests/mito.lib/geometry/spherical_metric_space.cc Updates metric space test to spherical::coordinates_t.
tests/mito.lib/geometry/segment_2D.cc Updates geometry test to cartesian<2>::coordinates_t.
tests/mito.lib/geometry/polar_metric_space.cc Updates metric space test to polar::coordinates_t.
tests/mito.lib/geometry/point.cc Migrates point test cartesian/polar coordinate aliases to descriptors.
tests/mito.lib/geometry/metric.cc Migrates metric test to cartesian<2> descriptor API.
tests/mito.lib/geometry/induced_metric_triangle.cc Migrates induced metric tests to cartesian<2/3> descriptors.
tests/mito.lib/geometry/induced_metric_segment.cc Migrates induced metric segment tests to cartesian<1/2/3> descriptors.
tests/mito.lib/geometry/induced_metric_non_cartesian.cc Migrates non-cartesian induced metric tests to polar/spherical descriptors.
tests/mito.lib/geometry/euclidean_submanifold_metric_3D.cc Updates test to cartesian<3>::coordinates_t and factory.
tests/mito.lib/geometry/euclidean_metric_space.cc Updates metric space test to cartesian<2>::coordinates_t.
tests/mito.lib/geometry/euclidean_metric_3D.cc Updates metric test to cartesian<3>::coordinates_t.
tests/mito.lib/geometry/euclidean_metric_2D.cc Updates metric test to cartesian<2>::coordinates_t.
tests/mito.lib/geometry/euclidean_metric_1D.cc Updates metric test to cartesian<1>::coordinates_t.
tests/mito.lib/geometry/cube_volume.cc Updates geometry test to cartesian<3>::coordinates_t.
tests/mito.lib/geometry/coordinates.cc Updates coordinates test to cartesian<2>::coordinates(...).
tests/mito.lib/geometry/coordinate_transformation.cc Migrates transformation tests to cartesian/polar/spherical descriptors.
tests/mito.lib/geometry/coordinate_system.cc Updates coordinate system test to cartesian<2>::coordinates_t / factory.
tests/mito.lib/geometry/cell_directors.cc Updates test to cartesian<3>::coordinates_t.
tests/mito.lib/geometry/barycenter_triangle_3D.cc Updates barycenter test to cartesian<3>::coordinates(...).
tests/mito.lib/geometry/barycenter_triangle_2D.cc Updates barycenter test to cartesian<2>::coordinates(...).
tests/mito.lib/geometry/barycenter_tetrahedron_3D.cc Updates barycenter test to cartesian<3>::coordinates(...).
tests/mito.lib/geometry/barycenter_segment_3D.cc Updates barycenter test to cartesian<3>::coordinates(...).
tests/mito.lib/geometry/barycenter_segment_2D.cc Updates barycenter test to cartesian<2>::coordinates(...).
tests/mito.lib/geometry/barycenter_segment_1D.cc Updates barycenter test to cartesian<1>::coordinates(...).
tests/mito.lib/geometry/arc_length_integration.cc Migrates arc-length integration test to cartesian<1/2>::coordinates_t.
tests/mito.lib/fields/polar_metric_field.cc Touches polar-field test coordinate aliasing.
tests/mito.lib/fem/isoparametric_triangle.cc Updates FEM test to cartesian<2>::coordinates_t.
tests/mito.lib/fem/isoparametric_segment.cc Updates FEM test to cartesian<1>::coordinates_t.
tests/mito.lib/fem/fem_field.cc Updates FEM test to cartesian<2>::x/y and coordinates_t.
tests/mito.lib/fem/block_mass.cc Updates FEM test to cartesian<2>::coordinates_t.
tests/mito.lib/fem/block_mass_segment.cc Updates FEM test to cartesian<1>::coordinates_t.
tests/mito.lib/fem/block_grad_grad.cc Updates FEM test to cartesian<2>::coordinates_t.
tests/mito.lib/fem/block_grad_grad_segment.cc Updates FEM test to cartesian<1>::coordinates_t.
tests/mito.lib/discrete/mesh_field.cc Updates discrete test to cartesian<3>::coordinates_t.
tests/mito.lib/constraints/dirichlet.cc Updates constraints test to cartesian<2>::x/y and coordinates_t.
lib/mito/io/vtk/vtk_point.h Updates coordinate type aliasing for VTK point insertion logic.
lib/mito/geometry/spherical/api.h Introduces geometry::spherical descriptor struct API.
lib/mito/geometry/polar/api.h Introduces geometry::polar descriptor struct API.
lib/mito/geometry/cartesian/api.h Introduces geometry::cartesian<1/2/3> descriptor specializations.
extensions/mito/mito.cc Updates Python bindings to new cartesian<D>::coordinates_t aliases.
benchmarks/mito.lib/pdes/poisson.cc Updates benchmark to cartesian<2>::x/y and coordinates_t.
benchmarks/mito.lib/operators/laplacian.cc Updates benchmark to cartesian<2>::x/y and coordinates_t.
benchmarks/mito.lib/integration/integration.cc Updates benchmark to cartesian<2>::x/y and coordinates_t.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tutorial/5_divergence_theorem_2D_in_3D/main.cc
Comment thread lib/mito/io/vtk/vtk_point.h Outdated
Comment thread lib/mito/io/vtk/vtk_point.h Outdated
Comment thread extensions/mito/mito.cc Outdated
Comment thread tests/mito.lib/fields/polar_metric_field.cc
…stead of the more verbose geometry::coordinates_t<dim, family>
… more verbose {functions::component<coordinates_t, dim>}

Also, changed api of cartesian coordinates from {x_0}, {x_1}, {x_2} to x, y, z.
From {mito::geometry::cartesian::x<2>} to {mito::geometry::cartesian<2>::x}
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