Skip to content

Replace pointer in Map class constructor with span - #2093

Open
dharinib98 wants to merge 1 commit into
4C-multiphysics:mainfrom
dharinib98:remove_pointer_map1
Open

Replace pointer in Map class constructor with span#2093
dharinib98 wants to merge 1 commit into
4C-multiphysics:mainfrom
dharinib98:remove_pointer_map1

Conversation

@dharinib98

@dharinib98 dharinib98 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Description and Context

refactor the current constructor to take std::span instead of a raw pointer

Related Issues and Pull Requests

#1391

@dharinib98 dharinib98 added this to the Migration to Tpetra milestone Jun 21, 2026
@dharinib98 dharinib98 added the taskforce: tpetra Issues related to the migration from Epetra to Tpetra label Jun 21, 2026

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 refactors Core::LinAlg::Map to take std::span<const int> for explicit GID lists (instead of raw pointer + length), as part of the ongoing work to prepare the Map abstraction for a later Tpetra transition (#1391).

Changes:

  • Changed the Core::LinAlg::Map constructor signature from (NumMyElements, const int*) to std::span<const int>.
  • Updated a large number of call sites across modules to pass spans (including tests).
  • Adjusted several helpers/utilities that previously relied on nullptr for empty maps to use empty spans.

Reviewed changes

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

Show a summary per file
File Description
src/xfem/4C_xfem_xfluid_contact_communicator.cpp Update Map construction to span-based API.
src/xfem/4C_xfem_xfield_field_coupling.cpp Update Map construction to span-based API.
src/xfem/4C_xfem_multi_field_mapextractor.cpp Update Map construction to span-based API.
src/xfem/4C_xfem_discretization.cpp Update Map construction to span-based API.
src/xfem/4C_xfem_discretization_utils.cpp Update Map construction to span-based API.
src/xfem/4C_xfem_coupling_mesh.cpp Update Map construction to span-based API.
src/structure_new/src/utils/4C_structure_new_monitor_dbc.cpp Update Map construction to span-based API.
src/structure_new/src/linear_solver/4C_structure_new_solver_factory.cpp Update Map construction to span-based API.
src/structure_new/src/4C_structure_new_timint_basedataglobalstate.cpp Update Map construction to span-based API.
src/stru_multi/4C_stru_multi_microstatic.cpp Update Map construction to span-based API.
src/stru_multi/4C_stru_multi_microstatic_service.cpp Update Map construction to span-based API.
src/stru_multi/4C_stru_multi_microstatic_npsupport.cpp Update Map construction to span-based API.
src/sti/4C_sti_monolithic.cpp Update Map construction to span-based API.
src/ssi/4C_ssi_manifold_utils.cpp Update Map construction to span-based API.
src/solver_nonlin_nox/4C_solver_nonlin_nox_matrixfree.cpp Update Map construction to span-based API.
src/scatra/4C_scatra_timint_meshtying_strategy_s2i.cpp Update Map construction to span-based API.
src/scatra/4C_scatra_timint_implicit.cpp Update Map construction to span-based API.
src/scatra/4C_scatra_timint_elch.cpp Update Map construction to span-based API.
src/scatra/4C_scatra_timint_elch_scl.cpp Update Map construction to span-based API.
src/reduced_lung/tests/4C_reduced_lung_junctions_test.cpp Update tests for span-based Map API.
src/reduced_lung/tests/4C_reduced_lung_helpers_test.cpp Update tests for span-based Map API.
src/reduced_lung/tests/4C_reduced_lung_boundary_conditions_test.cpp Update tests for span-based Map API.
src/reduced_lung/src/4C_reduced_lung_helpers.cpp Update Map construction to span-based API.
src/reduced_lung/src/1d_pipe_flow/4C_reduced_lung_1d_pipe_flow_main.cpp Update Map construction to span-based API.
src/red_airways/4C_red_airways_implicitintegration.cpp Update Map construction to span-based API.
src/post/4C_post_vtk_vtu_writer.cpp Update Map construction to span-based API.
src/post/4C_post_vtk_vtu_writer_node_based.cpp Update Map construction to span-based API.
src/post/4C_post_ensight_writer.cpp Update Map construction to span-based API.
src/post/4C_post_ensight_writer_nurbs.cpp Update Map construction to span-based API.
src/porofluid_pressure_based/4C_porofluid_pressure_based_utils.cpp Update Map construction to span-based API.
src/porofluid_pressure_based/4C_porofluid_pressure_based_algorithm.cpp Update Map construction to span-based API.
src/porofluid_pressure_based_elast_scatra/4C_porofluid_pressure_based_elast_scatra_base.cpp Update Map construction to span-based API.
src/porofluid_pressure_based_elast_scatra/4C_porofluid_pressure_based_elast_scatra_artery_coupling_linebased.cpp Update Map construction to span-based API.
src/poroelast/4C_poroelast_utils.cpp Update Map construction to span-based API.
src/poroelast/4C_poroelast_monolithicsplit.cpp Update Map construction to span-based API.
src/poroelast/4C_poroelast_base.cpp Update Map construction to span-based API.
src/poroelast_scatra/4C_poroelast_scatra_utils.cpp Update Map construction to span-based API.
src/particle/src/wall/4C_particle_wall.cpp Update Map construction to span-based API.
src/particle/src/engine/4C_particle_engine.cpp Update Map construction to span-based API.
src/mortar/src/4C_mortar_utils.cpp Update Map construction to span-based API.
src/mortar/src/4C_mortar_interface.cpp Update Map construction to span-based API.
src/mortar/src/4C_mortar_dofset.cpp Update Map construction to span-based API.
src/mat/4C_mat_micromaterial_evaluate.cpp Update Map construction to span-based API.
src/fsi/src/utils/4C_fsi_utils.cpp Update Map construction to span-based API.
src/fpsi/4C_fpsi_utils.cpp Update Map construction to span-based API.
src/fluid/4C_fluid_xwall.cpp Update Map construction to span-based API.
src/fluid/4C_fluid_volumetric_surfaceFlow_condition.cpp Update Map construction to span-based API.
src/fluid/4C_fluid_utils.cpp Update Map construction to span-based API.
src/fluid/4C_fluid_timint_stat_hdg.cpp Update Map construction to span-based API.
src/fluid/4C_fluid_timint_hdg.cpp Update Map construction to span-based API.
src/fluid/4C_fluid_timint_hdg_weak_comp.cpp Update Map construction to span-based API.
src/fluid/4C_fluid_discret_extractor.cpp Update Map construction to span-based API.
src/fluid_xfluid/4C_fluid_xfluid.cpp Update Map construction to span-based API.
src/fbi/src/4C_fbi_immersed_geometry_coupler.cpp Update Map construction to span-based API.
src/fbi/src/4C_fbi_beam_to_fluid_mortar_manager.cpp Update Map construction to span-based API.
src/fbi/src/4C_fbi_beam_to_fluid_meshtying_output_writer.cpp Update Map construction to span-based API.
src/deal_ii/src/4C_deal_ii_vector_conversion.cpp Update Map construction to span-based API.
src/coupling/src/volmortar/4C_coupling_volmortar.cpp Update Map construction to span-based API.
src/coupling/src/adapter/4C_coupling_adapter.cpp Update Map construction to span-based API.
src/core/rebalance/src/4C_rebalance.cpp Update Map construction to span-based API.
src/core/rebalance/src/4C_rebalance_graph_based.cpp Update Map construction to span-based API.
src/core/rebalance/src/4C_rebalance_binning_based.cpp Update Map construction to span-based API.
src/core/linalg/tests/4C_linalg_vector_test.np2.cpp Update tests for span-based Map API.
src/core/linalg/src/sparse/4C_linalg_utils_sparse_algebra_math.cpp Update Map construction to span-based API.
src/core/linalg/src/sparse/4C_linalg_utils_sparse_algebra_manipulation.cpp Update Map construction to span-based API.
src/core/linalg/src/sparse/4C_linalg_utils_sparse_algebra_create.cpp Update Map construction to span-based API.
src/core/linalg/src/sparse/4C_linalg_utils_sparse_algebra_assemble.cpp Update Map construction to span-based API.
src/core/linalg/src/sparse/4C_linalg_sparsematrix.cpp Update Map construction to span-based API.
src/core/linalg/src/sparse/4C_linalg_mapextractor.cpp Update Map construction to span-based API.
src/core/linalg/src/sparse/4C_linalg_map.hpp Change Map API to accept std::span<const int>.
src/core/linalg/src/sparse/4C_linalg_map.cpp Implement span-based constructor for Map.
src/core/linalg/src/sparse/4C_linalg_blocksparsematrix.cpp Update Map construction to span-based API.
src/core/linalg/src/dense/4C_linalg_utils_densematrix_communication.hpp Update Map construction to span-based API.
src/core/linalg/src/dense/4C_linalg_utils_densematrix_communication.cpp Update Map construction to span-based API.
src/core/io/src/4C_io_meshreader.cpp Update Map construction to span-based API.
src/core/io/src/4C_io_input_field.hpp Update Map construction to span-based API.
src/core/io/src/4C_io_hdf.cpp Update Map construction to span-based API.
src/core/io/src/4C_io_gridgenerator.cpp Update Map construction to span-based API.
src/core/fem/tests/discretization/4C_fem_discretization_nodal_coordinates_test.np3.cpp Update tests for span-based Map API.
src/core/fem/tests/discretization/4C_fem_discretization_nodal_coordinates_test.cpp Update tests for span-based Map API.
src/core/fem/src/nurbs_discretization/4C_fem_nurbs_discretization.cpp Update Map construction to span-based API.
src/core/fem/src/general/utils/4C_fem_general_utils_superconvergent_patch_recovery.cpp Update Map construction to span-based API.
src/core/fem/src/general/utils/4C_fem_general_utils_createdis.cpp Update Map construction to span-based API.
src/core/fem/src/general/utils/4C_fem_general_l2_projection.cpp Update Map construction to span-based API.
src/core/fem/src/dofset/4C_fem_dofset.cpp Update Map construction to span-based API.
src/core/fem/src/dofset/4C_fem_dofset_transparent.cpp Update Map construction to span-based API.
src/core/fem/src/dofset/4C_fem_dofset_definedmapping_wrapper.cpp Update Map construction to span-based API.
src/core/fem/src/discretization/4C_fem_discretization_utils.cpp Update Map construction to span-based API.
src/core/fem/src/discretization/4C_fem_discretization_utils_dbc.cpp Update Map construction to span-based API.
src/core/fem/src/discretization/4C_fem_discretization_partition.cpp Update Map construction to span-based API.
src/core/fem/src/discretization/4C_fem_discretization_fillcomplete.cpp Update Map construction to span-based API.
src/core/fem/src/discretization/4C_fem_discretization_faces.cpp Update Map construction to span-based API.
src/core/fem/src/condition/4C_fem_condition_point_coupling_redistribution.cpp Update Map construction to span-based API.
src/core/fem/src/condition/4C_fem_condition_periodic.cpp Update Map construction to span-based API.
src/core/fem/src/condition/4C_fem_condition_locsys.cpp Update Map construction to span-based API.
src/core/binstrategy/4C_binstrategy.cpp Update Map construction to span-based API.
src/core/binstrategy/4C_binstrategy_utils.cpp Update Map construction to span-based API.
src/contact/src/4C_contact_wear_interface.cpp Update Map construction to span-based API.
src/contact/src/4C_contact_selfcontact_binarytree.cpp Update Map construction to span-based API.
src/contact/src/4C_contact_meshtying_abstract_strategy.cpp Update Map construction to span-based API.
src/contact/src/4C_contact_interface.cpp Update Map construction to span-based API.
src/contact/src/4C_contact_interface_roundrobin.cpp Update Map construction to span-based API.
src/contact/src/4C_contact_abstract_strategy.cpp Update Map construction to span-based API.
src/constraint/4C_constraint_multipointconstraint3.cpp Update Map construction to span-based API.
src/constraint/4C_constraint_multipointconstraint2.cpp Update Map construction to span-based API.
src/constraint/4C_constraint_dofset.cpp Update Map construction to span-based API.
src/constraint_framework/4C_constraint_framework_submodelevaluator_nullspace.cpp Update Map construction to span-based API.
src/constraint_framework/4C_constraint_framework_embeddedmesh_solid_to_solid_mortar_manager.cpp Update Map construction to span-based API.
src/cardiovascular0d/4C_cardiovascular0d_dofset.cpp Update Map construction to span-based API.
src/beaminteraction/src/crosslinking/4C_beaminteraction_crosslinking_submodel_evaluator.cpp Update Map construction to span-based API.
src/beaminteraction/src/contact/beam_to_solid/4C_beaminteraction_contact_beam_to_solid_visualization_output_writer_visualization.cpp Update Map construction to span-based API.
src/beaminteraction/src/contact/beam_to_solid/4C_beaminteraction_contact_beam_to_solid_visualization_output_writer_utils.cpp Update Map construction to span-based API.
src/beaminteraction/src/contact/beam_to_solid/4C_beaminteraction_contact_beam_to_solid_mortar_manager.cpp Update Map construction to span-based API.
src/beaminteraction/src/4C_beaminteraction_str_model_evaluator.cpp Update Map construction to span-based API.
src/beaminteraction/src/4C_beaminteraction_calc_utils.cpp Update Map construction to span-based API.

Comment on lines 84 to +85
Core::LinAlg::Map nodecolmap(
-1, (int)reducednodecolmap.size(), reducednodecolmap.data(), 0, fullnodecolmap->get_comm());
-1, std::span<const int>(reducednoderowmap), 0, fullnodecolmap->get_comm());
Comment on lines +43 to +47
Core::LinAlg::Map::Map(int NumGlobalElements, std::span<const int> MyGlobalElements, int IndexBase,
const MPI_Comm& Comm)
: map_(MapVariant(std::in_place_type<Utils::OwnerOrView<Epetra_Map>>,
Utils::make_owner<Epetra_Map>(NumGlobalElements, NumMyElements, MyGlobalElements,
IndexBase, Core::Communication::as_epetra_comm(Comm))))
Utils::make_owner<Epetra_Map>(NumGlobalElements, MyGlobalElements.size(),
MyGlobalElements.data(), IndexBase, Core::Communication::as_epetra_comm(Comm))))
Comment on lines 204 to +205
return std::make_shared<Core::LinAlg::Map>(
-1, dstgids.size(), dstgids.data(), 0, srcmap->get_comm());
-1, std::span<const int>(dstgids), 0, srcmap->get_comm());
Comment on lines 119 to +120
std::shared_ptr<Core::LinAlg::Map> fullmap =
std::make_shared<Core::LinAlg::Map>(-1, gids.size(), gids.data(), 0, maps[0]->get_comm());
std::make_shared<Core::LinAlg::Map>(-1, std::span<const int>(gids), 0, maps[0]->get_comm());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

taskforce: tpetra Issues related to the migration from Epetra to Tpetra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants