Skip to content

MLMG: Specialize for fMultiFab#5484

Draft
ax3l wants to merge 3 commits into
AMReX-Codes:developmentfrom
ax3l:topic-nodal-mlmg-template
Draft

MLMG: Specialize for fMultiFab#5484
ax3l wants to merge 3 commits into
AMReX-Codes:developmentfrom
ax3l:topic-nodal-mlmg-template

Conversation

@ax3l

@ax3l ax3l commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary

Specialize the MLMG Solvers for fMultiFab, too.

Additional background

#5482

Checklist

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • changes answers in the test suite to more than roundoff level
  • are likely to significantly affect the results of downstream AMReX users
  • include documentation in the code and/or rst files, if appropriate

ax3l added 2 commits June 8, 2026 16:20
If we want to develop applications that can use double and single precision
switches at runtime, then we need to be able to generate both in the same
binary. This adds the corresponding templates (that default to the current
status quo) in particle containers.
Specialize the MLMG Solvers for fMultiFab, too.
Comment on lines +19 to +22
// Single-precision instantiations needed by the float nodal solve
// (MLNodeTensorLaplacianT<fMultiFab> via MLMGT<fMultiFab>).
template class MLMGT<fMultiFab>;
template class MLLinOpT<fMultiFab>;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably compiles 2x as long now, so might be worth a separate .cpp file

Comment on lines +723 to +724
template class MLNodeLinOpT<MultiFab>;
template class MLNodeLinOpT<fMultiFab>;

@ax3l ax3l Jun 9, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially worth a 2nd cpp file for double/float

Comment on lines +365 to +366
template class MLNodeTensorLaplacianT<MultiFab>;
template class MLNodeTensorLaplacianT<fMultiFab>;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially worth a 2nd .cpp file for float.

Two fixes for the HYPRE CI builds of the templated nodal MLMG operator
(MLNodeLinOp is now the alias MLNodeLinOpT<>):

- AMReX_HypreNodeLap.H forward-declared `class MLNodeLinOp;`, which conflicts
  with the alias (this header is included by AMReX_MLNodeLinOp.H). Forward-declare
  the template + alias instead.
- MLNodeLinOpT<MF>::makeHypreNodeLap is a regular member, so the explicit
  `template class MLNodeLinOpT<fMultiFab>;` instantiates it; it passes `this` to
  HypreNodeLap's `MLNodeLinOp const*` (== MLNodeLinOpT<MultiFab> const*) param.
  Guard it with `if constexpr (std::is_same_v<MF, MultiFab>)` (the HYPRE IJ
  interface is double-only, matching the requires(same_as<TMF,MultiFab>)
  constraint already on bottomSolveWithHypre/PETSc).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant