Revision of the geometry coordinates api - #104
Conversation
There was a problem hiding this comment.
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/::zand::e_x/::e_y/::e_z. - Moves polar and spherical APIs under
mito::geometry::polar/mito::geometry::sphericaldescriptor 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.
1105994 to
dd7cdf1
Compare
…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}
dd7cdf1 to
dd58b98
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 117 out of 117 changed files in this pull request and generated 3 comments.
Suppressed comments (3)
tests/mito.lib/fields/polar_metric_field.cc:15
using mito::geometry::POLAR;is now unused because the coordinates type uses a fully-qualifiedmito::geometry::POLAR. This can trigger unused-using warnings and is easy to avoid by using the importedPOLAR(or by removing theusing).
// use polar coordinates
using mito::geometry::POLAR;
// the type of coordinates
using coordinates_t = mito::geometry::coordinates_t<2, mito::geometry::POLAR>;
lib/mito/geometry/cartesian/api.h:40
- This comment contains a non-breaking space character between “2D” and “Euclidean”, which is hard to spot and can be annoying in diffs/searches. Replacing it with a normal space keeps the file ASCII-clean.
// cartesian geometry in 2D Euclidean space
lib/mito/geometry/cartesian/api.h:70
- This comment contains a non-breaking space character between “3D” and “Euclidean”, which is hard to spot and can be annoying in diffs/searches. Replacing it with a normal space keeps the file ASCII-clean.
// cartesian geometry in 3D Euclidean space
| const geometry::coordinates_t<3, geometry::SPHERICAL> & coord, | ||
| vtkSmartPointer<vtkPoints> & pointsVtk) -> void | ||
| { | ||
| // cartesian coordinates in 2D | ||
| using cartesian_coord_t = mito::geometry::coordinates_t<3, mito::geometry::CARTESIAN>; | ||
| // cartesian coordinates in 3D | ||
| using cartesian_coord_t = mito::geometry::cartesian<3>::coordinates_t; |
| const geometry::coordinates_t<2, geometry::POLAR> & coord, | ||
| vtkSmartPointer<vtkPoints> & pointsVtk) -> void | ||
| { | ||
| // cartesian coordinates in 2D | ||
| using cartesian_coord_t = mito::geometry::coordinates_t<2, mito::geometry::CARTESIAN>; | ||
| using cartesian_coord_t = mito::geometry::cartesian<2>::coordinates_t; |
| // cartesian geometry in 1D | ||
| template <int D> | ||
| using coordinates_t = cartesian_coordinates_t<D>; | ||
| struct cartesian; | ||
|
|
||
| // the Euclidean metric tensor field | ||
| template <int D> | ||
| constexpr auto euclidean_metric = | ||
| geometry::euclidean_metric<cartesian_coordinates_t<D>>::field(); | ||
| // cartesian geometry in 1D Euclidean space |
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:
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:
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
with the more natural
Similarly rename Cartesian basis vectors from
e_0,e_1, ande_2toe_x,e_y, ande_z.Move the polar and spherical APIs to geometry descriptor types as well:
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:
becomes
and explicit component functions such as
can now be replaced by the coordinate-system API:
geometry::cartesian<2>::xThe same convention is adopted consistently for Cartesian, polar, and spherical coordinates throughout the codebase.