Skip to content

[TrilinosApplication] Fix ReadMatrix and TrilinosExperimentalSpace function to use getLocalNumRows for local row count#14506

Open
loumalouomega wants to merge 8 commits into
masterfrom
trilinos/multi-version-support
Open

[TrilinosApplication] Fix ReadMatrix and TrilinosExperimentalSpace function to use getLocalNumRows for local row count#14506
loumalouomega wants to merge 8 commits into
masterfrom
trilinos/multi-version-support

Conversation

@loumalouomega

@loumalouomega loumalouomega commented Jun 17, 2026

Copy link
Copy Markdown
Member

name: ✨ Feature
about: Support Trilinos 16.1+ by adding API probe for row-count method


📝 Description

  • Problem: Trilinos 16.1 removed the deprecated getNodeNumRows() method from Tpetra::CrsMatrix.
    Builds against Trilinos 16.1+ fail with:
  error: 'class Tpetra::CrsMatrix<...>' has no member named 'getNodeNumRows';
         did you mean 'getLocalNumRows'?
  • Solution: Implemented a compile-time API probe using SFINAE overload resolution to detect which method is available:
    • Tries getLocalNumRows() first (Trilinos 16.1+)
    • Falls back to getNodeNumRows() (older versions)

This approach requires no version macros and works automatically across all Trilinos versions without user configuration.

Key changes

  • Added Detail::GetNumLocalRows<TMatrix>() helper that dispatches to the appropriate implementation at compile time.
  • Uses SFINAE overload ranking: int parameter prefers the newer API. long parameter acts as fallback.
  • Single call site updated in ReadMatrix() to use the helper.
  • Includes appropriate documentation in the helper functions.
  • Also applying the same pattern to other deprecated Tpetra calls in trilinos_space_experimental.h if those also fail on Trilinos 16.1.

Validation

  • Code now compiles against both Trilinos < 16.1 (with getNodeNumRows) and Trilinos 16.1 (with getLocalNumRows)
  • Functionality remains unchanged; no behavioral differences

🆕 Changelog

@loumalouomega loumalouomega requested a review from roigcarlo June 17, 2026 06:57
@loumalouomega loumalouomega requested review from a team as code owners June 17, 2026 06:57
@loumalouomega loumalouomega added Applications Hotfix External library Compilation Parallel-MPI Distributed memory parallelism for HPC / clusters FastPR This Pr is simple and / or has been already tested and the revision should be fast labels Jun 17, 2026
@loumalouomega loumalouomega enabled auto-merge June 17, 2026 06:57
@loumalouomega loumalouomega changed the title [TrilinosApplication] Fix ReadMatrix function to use getLocalNumRows for local row count [TrilinosApplication] Fix ReadMatrix and TrilinosExperimentalSpace function to use getLocalNumRows for local row count Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Applications Compilation External library FastPR This Pr is simple and / or has been already tested and the revision should be fast Hotfix Parallel-MPI Distributed memory parallelism for HPC / clusters

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant