Skip to content

CCZ4: Optimize performance on GPUs #172

Draft
julianakwan wants to merge 24 commits into
developfrom
enhancement/refactor_vars2_kernel_fission2
Draft

CCZ4: Optimize performance on GPUs #172
julianakwan wants to merge 24 commits into
developfrom
enhancement/refactor_vars2_kernel_fission2

Conversation

@julianakwan

@julianakwan julianakwan commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

This PR builds on top of the recent changes due to refactoring the storing and loading of the data container vars.

Major changes:

  • Kernel fission: The CCZ4 RHS has been broken up into 3 kernels to reduce the register pressure and so that not all derivatives need to be stored in memory during the calculation of the RHS at once.
  • Enforce symmetric quantities: Only the necessary components of $d^2 h_{ij}/dx^2$ (and so on) have been stored as $h_{ij}$ is symmetric and the second derivatives are interchangeable as well.
  • Tensors: The tensor class has been removed in favour of AMReX Arrays because the latter are stored as 1D objects (even though the user interface supports Fortran multidimensional indexing) which is more performant on GPUs. Also each derivative was being stored as a tensor object of tensors so this switch should reduce the memory footprint as well. This closes Refactor Tensor class #132.

Still to do:

  • Propagate alias for the amrex::Arrays to all parts of the code: I have written TensorArray::Rank1 for amrex::Array1D<amrex::Real, 0, 3> but this needs to be done consistently.
  • Replace if statements for switching between BSSN and CCZ4 as requested (closes Remove branching with BSSN versus CCZ4 #145)
  • Investigate failing unit tests
  • General tidy up. Some of the naming conventions are not the best :(

@julianakwan julianakwan self-assigned this Apr 2, 2026
@julianakwan julianakwan added the enhancement New feature or request label Apr 2, 2026
@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown

This PR modifies the following files which are ignored by .lint-ignore:

Source/BlackHoles/BinaryBHInitialData.impl.hpp
Source/BlackHoles/BoostedBHInitialData.impl.hpp
Source/BlackHoles/TwoPuncturesInitialData.impl.hpp
Source/CCZ4/CCZ4RHS.impl.hpp
Source/CCZ4/Constraints.impl.hpp
Source/CCZ4/IntegratedMovingPunctureGauge.hpp
Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp
Tests/CCZ4GeometryUnitTests/CCZ4GeometryMathematicaValues.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy (v19.1.1) reports: 50 concern(s)
  • Examples/BinaryBH/BinaryBHLevel.cpp:122:37: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'specificEvalRHS' of similar type ('amrex::MultiFab &') are easily swapped by mistake

      122 | void BinaryBHLevel::specificEvalRHS(amrex::MultiFab &a_soln,
          |                                     ^~~~~~~~~~~~~~~~~~~~~~~~
      123 |                                     amrex::MultiFab &a_rhs,
          |                                     ~~~~~~~~~~~~~~~~~~~~~~
    BinaryBHLevel.cpp:122:54: note: the first parameter in the range is 'a_soln'
      122 | void BinaryBHLevel::specificEvalRHS(amrex::MultiFab &a_soln,
          |                                                      ^~~~~~
    BinaryBHLevel.cpp:123:54: note: the last parameter in the range is 'a_rhs'
      123 |                                     amrex::MultiFab &a_rhs,
          |                                                      ^~~~~
  • Source/BlackHoles/BoostedBHInitialData.hpp:22:12: warning: [cppcoreguidelines-pro-type-member-init]

    constructor does not initialize these fields: mass

       22 |     struct params_t
          |            ^
       23 |     {
       24 |         double mass;
          |                    
          |                    {}
  • Source/CCZ4/CCZ4Geometry.hpp:237:5: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'compute_christoffel' of similar type ('const int &') are easily swapped by mistake

      237 |     const amrex::Array2D<amrex::Real, 0, UNIQUE_IDX - 1, 0, AMREX_SPACEDIM - 1>
          |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      238 |         &d1_h,
          |         ~~~~~~
      239 |     const TensorArray::Rank2 &h_UU)
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:238:10: note: the first parameter in the range is 'd1_h'
      238 |         &d1_h,
          |          ^~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:239:31: note: the last parameter in the range is 'h_UU'
      239 |     const TensorArray::Rank2 &h_UU)
          |                               ^~~~
  • Source/CCZ4/CCZ4Geometry.hpp:274:20: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'compute_phys_chris' of similar type ('const int &') are easily swapped by mistake

      274 |                    const TensorArray::Rank2 &h_UU,
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      275 |                    const TensorArray::Rank3 &chris_ULL)
          |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:274:46: note: the first parameter in the range is 'h_UU'
      274 |                    const TensorArray::Rank2 &h_UU,
          |                                              ^~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:275:46: note: the last parameter in the range is 'chris_ULL'
      275 |                    const TensorArray::Rank3 &chris_ULL)
          |                                              ^~~~~~~~~
  • Source/CCZ4/CCZ4Geometry.hpp:334:5: warning: [bugprone-easily-swappable-parameters]

    4 adjacent parameters of 'compute_ricci_hat' of similar type ('const int &') are easily swapped by mistake

      334 |     const TensorArray::Rank2 &d1_Gamma,
          |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      335 |     const amrex::Array2D<amrex::Real, 0, UNIQUE_IDX - 1, 0, AMREX_SPACEDIM - 1>
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      336 |         &d1_h,
          |         ~~~~~~
      337 |     const TensorArray::Rank2Sym &d2_h, const TensorArray::Rank2 &h_UU,
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:334:31: note: the first parameter in the range is 'd1_Gamma'
      334 |     const TensorArray::Rank2 &d1_Gamma,
          |                               ^~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:337:66: note: the last parameter in the range is 'h_UU'
      337 |     const TensorArray::Rank2Sym &d2_h, const TensorArray::Rank2 &h_UU,
          |                                                                  ^~~~
  • Source/CCZ4/CCZ4Geometry.hpp:386:5: warning: [bugprone-easily-swappable-parameters]

    3 adjacent parameters of 'compute_ricci_Z' of similar type ('const int &') are easily swapped by mistake

      386 |     const TensorArray::Rank2 &d1_Gamma,
          |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      387 |     const amrex::Array2D<amrex::Real, 0, UNIQUE_IDX - 1, 0, AMREX_SPACEDIM - 1>
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      388 |         &d1_h,
          |         ~~~~~~
      389 |     const TensorArray::Rank2Sym &d2_h, const TensorArray::Rank1Sym &d2_chi,
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:386:31: note: the first parameter in the range is 'd1_Gamma'
      386 |     const TensorArray::Rank2 &d1_Gamma,
          |                               ^~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:389:34: note: the last parameter in the range is 'd2_h'
      389 |     const TensorArray::Rank2Sym &d2_h, const TensorArray::Rank1Sym &d2_chi,
          |                                  ^~~~
  • Source/CCZ4/CCZ4Geometry.hpp:416:21: warning: [cppcoreguidelines-init-variables]

    variable 'ricci_hat' is not initialized

       10 |         amrex::Real ricci_hat =
          |                     ^
          |                               = NAN
  • Source/CCZ4/CCZ4Geometry.hpp:438:1: warning: [readability-function-cognitive-complexity]

    function 'compute_d1_chris_contracted' has cognitive complexity of 72 (threshold 40)

      438 | compute_d1_chris_contracted(const TensorArray::Rank2 &h_UU,
          | ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:445:5: note: +1, including nesting penalty of 0, nesting level increased to 1
      445 |     FOR (i, j)
          |     ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/DimensionDefinitions.hpp:45:47: note: expanded from macro 'FOR'
       45 |     GET_MACRO6(__VA_ARGS__, FOR5, FOR4, FOR3, FOR2, FOR1, DUMMYFOR)(__VA_ARGS__)
          |                                               ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:445:5: note: +2, including nesting penalty of 1, nesting level increased to 2
      445 |     FOR (i, j)
          |     ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/DimensionDefinitions.hpp:45:47: note: expanded from macro 'FOR'
       45 |     GET_MACRO6(__VA_ARGS__, FOR5, FOR4, FOR3, FOR2, FOR1, DUMMYFOR)(__VA_ARGS__)
          |                                               ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:449:9: note: +3, including nesting penalty of 2, nesting level increased to 3
      449 |         FOR (m, n, p)
          |         ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/DimensionDefinitions.hpp:45:41: note: expanded from macro 'FOR'
       45 |     GET_MACRO6(__VA_ARGS__, FOR5, FOR4, FOR3, FOR2, FOR1, DUMMYFOR)(__VA_ARGS__)
          |                                         ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:449:9: note: +4, including nesting penalty of 3, nesting level increased to 4
      449 |         FOR (m, n, p)
          |         ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/DimensionDefinitions.hpp:45:41: note: expanded from macro 'FOR'
       45 |     GET_MACRO6(__VA_ARGS__, FOR5, FOR4, FOR3, FOR2, FOR1, DUMMYFOR)(__VA_ARGS__)
          |                                         ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:449:9: note: +5, including nesting penalty of 4, nesting level increased to 5
      449 |         FOR (m, n, p)
          |         ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/DimensionDefinitions.hpp:45:41: note: expanded from macro 'FOR'
       45 |     GET_MACRO6(__VA_ARGS__, FOR5, FOR4, FOR3, FOR2, FOR1, DUMMYFOR)(__VA_ARGS__)
          |                                         ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:452:13: note: +6, including nesting penalty of 5, nesting level increased to 6
      452 |             FOR (q, r)
          |             ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/DimensionDefinitions.hpp:45:47: note: expanded from macro 'FOR'
       45 |     GET_MACRO6(__VA_ARGS__, FOR5, FOR4, FOR3, FOR2, FOR1, DUMMYFOR)(__VA_ARGS__)
          |                                               ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:452:13: note: +7, including nesting penalty of 6, nesting level increased to 7
      452 |             FOR (q, r)
          |             ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/DimensionDefinitions.hpp:45:47: note: expanded from macro 'FOR'
       45 |     GET_MACRO6(__VA_ARGS__, FOR5, FOR4, FOR3, FOR2, FOR1, DUMMYFOR)(__VA_ARGS__)
          |                                               ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:455:35: note: +8, including nesting penalty of 7, nesting level increased to 8
      455 |                             (d1_h(VAR_IDX0(n, q), j) * d1_h(VAR_IDX0(m, p), r) +
          |                                   ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/Tensor.hpp:21:24: note: expanded from macro 'VAR_IDX0'
       21 | #define VAR_IDX0(i, j) VAR_IDX(0, (i), (j))
          |                        ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/Tensor.hpp:18:69: note: expanded from macro 'VAR_IDX'
       18 | #define VAR_IDX(ivar, i, j) ((ivar) + (i) + (j) + (((i) * (j) != 0) ? 1 : 0))
          |                                                                     ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:455:61: note: +8, including nesting penalty of 7, nesting level increased to 8
      455 |                             (d1_h(VAR_IDX0(n, q), j) * d1_h(VAR_IDX0(m, p), r) +
          |                                                             ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/Tensor.hpp:21:24: note: expanded from macro 'VAR_IDX0'
       21 | #define VAR_IDX0(i, j) VAR_IDX(0, (i), (j))
          |                        ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/Tensor.hpp:18:69: note: expanded from macro 'VAR_IDX'
       18 | #define VAR_IDX(ivar, i, j) ((ivar) + (i) + (j) + (((i) * (j) != 0) ? 1 : 0))
          |                                                                     ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:456:35: note: +8, including nesting penalty of 7, nesting level increased to 8
      456 |                              d1_h(VAR_IDX0(m, n), j) * d1_h(VAR_IDX0(p, q), r));
          |                                   ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/Tensor.hpp:21:24: note: expanded from macro 'VAR_IDX0'
       21 | #define VAR_IDX0(i, j) VAR_IDX(0, (i), (j))
          |                        ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/Tensor.hpp:18:69: note: expanded from macro 'VAR_IDX'
       18 | #define VAR_IDX(ivar, i, j) ((ivar) + (i) + (j) + (((i) * (j) != 0) ? 1 : 0))
          |                                                                     ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:456:61: note: +8, including nesting penalty of 7, nesting level increased to 8
      456 |                              d1_h(VAR_IDX0(m, n), j) * d1_h(VAR_IDX0(p, q), r));
          |                                                             ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/Tensor.hpp:21:24: note: expanded from macro 'VAR_IDX0'
       21 | #define VAR_IDX0(i, j) VAR_IDX(0, (i), (j))
          |                        ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/Tensor.hpp:18:69: note: expanded from macro 'VAR_IDX'
       18 | #define VAR_IDX(ivar, i, j) ((ivar) + (i) + (j) + (((i) * (j) != 0) ? 1 : 0))
          |                                                                     ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:461:23: note: +6, including nesting penalty of 5, nesting level increased to 6
      461 |                 (d2_h(VAR_IDX0(m, n), VAR_IDX0(j, p)) + d1_terms);
          |                       ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/Tensor.hpp:21:24: note: expanded from macro 'VAR_IDX0'
       21 | #define VAR_IDX0(i, j) VAR_IDX(0, (i), (j))
          |                        ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/Tensor.hpp:18:69: note: expanded from macro 'VAR_IDX'
       18 | #define VAR_IDX(ivar, i, j) ((ivar) + (i) + (j) + (((i) * (j) != 0) ? 1 : 0))
          |                                                                     ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:461:39: note: +6, including nesting penalty of 5, nesting level increased to 6
      461 |                 (d2_h(VAR_IDX0(m, n), VAR_IDX0(j, p)) + d1_terms);
          |                                       ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/Tensor.hpp:21:24: note: expanded from macro 'VAR_IDX0'
       21 | #define VAR_IDX0(i, j) VAR_IDX(0, (i), (j))
          |                        ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Grids/Tensor.hpp:18:69: note: expanded from macro 'VAR_IDX'
       18 | #define VAR_IDX(ivar, i, j) ((ivar) + (i) + (j) + (((i) * (j) != 0) ? 1 : 0))
          |                                                                     ^
  • Source/CCZ4/CCZ4Geometry.hpp:438:29: warning: [bugprone-easily-swappable-parameters]

    3 adjacent parameters of 'compute_d1_chris_contracted' of similar type ('const int &') are easily swapped by mistake

      438 | compute_d1_chris_contracted(const TensorArray::Rank2 &h_UU,
          |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      439 |                             const amrex::Array2D<amrex::Real, 0, UNIQUE_IDX - 1,
          |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      440 |                                                  0, AMREX_SPACEDIM - 1> &d1_h,
          |                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      441 |                             const TensorArray::Rank2Sym &d2_h)
          |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:438:55: note: the first parameter in the range is 'h_UU'
      438 | compute_d1_chris_contracted(const TensorArray::Rank2 &h_UU,
          |                                                       ^~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:441:58: note: the last parameter in the range is 'd2_h'
      441 |                             const TensorArray::Rank2Sym &d2_h)
          |                                                          ^~~~
  • Source/CCZ4/CCZ4Geometry.hpp:471:5: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'compute_ricci_Z_general' of similar type ('const int &') are easily swapped by mistake

      471 |     const TensorArray::Rank2 &d1_Gamma,
          |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      472 |     const amrex::Array2D<amrex::Real, 0, UNIQUE_IDX - 1, 0, AMREX_SPACEDIM - 1>
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      473 |         &d1_h,
          |         ~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:471:31: note: the first parameter in the range is 'd1_Gamma'
      471 |     const TensorArray::Rank2 &d1_Gamma,
          |                               ^~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:473:10: note: the last parameter in the range is 'd1_h'
      473 |         &d1_h,
          |          ^~~~
  • Source/CCZ4/CCZ4Geometry.hpp:474:42: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'compute_ricci_Z_general' of similar type ('const int &') are easily swapped by mistake

      474 |     const TensorArray::Rank1Sym &d2_chi, const TensorArray::Rank2Sym &d2_h,
          |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      475 |     const TensorArray::Rank2 &h_UU, const chris_t &chris, const double dZ_coeff)
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:474:71: note: the first parameter in the range is 'd2_h'
      474 |     const TensorArray::Rank1Sym &d2_chi, const TensorArray::Rank2Sym &d2_h,
          |                                                                       ^~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:475:31: note: the last parameter in the range is 'h_UU'
      475 |     const TensorArray::Rank2 &h_UU, const chris_t &chris, const double dZ_coeff)
          |                               ^~~~
  • Source/CCZ4/CCZ4Geometry.hpp:519:5: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'compute_ricci' of similar type ('const int &') are easily swapped by mistake

      519 |     const TensorArray::Rank2 &d1_Gamma,
          |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      520 |     const amrex::Array2D<amrex::Real, 0, UNIQUE_IDX - 1, 0, AMREX_SPACEDIM - 1>
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      521 |         &d1_h,
          |         ~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:519:31: note: the first parameter in the range is 'd1_Gamma'
      519 |     const TensorArray::Rank2 &d1_Gamma,
          |                               ^~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:521:10: note: the last parameter in the range is 'd1_h'
      521 |         &d1_h,
          |          ^~~~
  • Source/CCZ4/CCZ4Geometry.hpp:522:42: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'compute_ricci' of similar type ('const int &') are easily swapped by mistake

      522 |     const TensorArray::Rank1Sym &d2_chi, const TensorArray::Rank2Sym &d2_h,
          |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      523 |     const TensorArray::Rank2 &h_UU, const chris_t &chris)
          |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:522:71: note: the first parameter in the range is 'd2_h'
      522 |     const TensorArray::Rank1Sym &d2_chi, const TensorArray::Rank2Sym &d2_h,
          |                                                                       ^~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/CCZ4/CCZ4Geometry.hpp:523:31: note: the last parameter in the range is 'h_UU'
      523 |     const TensorArray::Rank2 &h_UU, const chris_t &chris)
          |                               ^~~~
  • Source/CCZ4/MovingPunctureGauge.hpp:52:5: warning: [readability-convert-member-functions-to-static]

    method 'rhs_gauge' can be made static

       50 |     AMREX_GPU_DEVICE AMREX_FORCE_INLINE void
          |                      static 
       51 |     // NOLINTBEGIN(bugprone-easily-swappable-parameters)
       52 |     rhs_gauge(const amrex::CellData<amrex::Real> &rhs_cell_data,
          |     ^
       53 |               const CCZ4Vars &vars, const amrex::Real &advec_lapse,
       54 |               const TensorArray::Rank1 &advec_shift,
       55 |               const TensorArray::Rank1 &advec_B,
       56 |               const TensorArray::Rank1 &advec_Gamma) const
          |                                                      ~~~~~
  • Source/Grids/FourthOrderDerivatives.hpp:366:5: warning: [readability-convert-member-functions-to-static]

    method 'advec_vector' can be made static

      365 |     [[nodiscard]] AMREX_GPU_DEVICE AMREX_FORCE_INLINE TensorArray::Rank1
          |                                    static 
      366 |     advec_vector(int ix, int iy, int iz,
          |     ^
      367 |                  const amrex::Array4<amrex::Real const> &state,
      368 |                  const TensorArray::Rank1 &shift_vector, const int ivar0) const
          |                                                                           ~~~~~
  • Source/Grids/FourthOrderDerivatives.hpp:381:5: warning: [readability-convert-member-functions-to-static]

    method 'advec_tensor' can be made static

      380 |     [[nodiscard]] AMREX_GPU_DEVICE AMREX_FORCE_INLINE TensorArray::Rank2
          |                                    static 
      381 |     advec_tensor(int ix, int iy, int iz,
          |     ^
      382 |                  const amrex::Array4<amrex::Real const> &state,
      383 |                  const TensorArray::Rank1 &shift_vector, const int ivar0) const
          |                                                                           ~~~~~
  • Source/Grids/FourthOrderDerivatives.hpp:397:5: warning: [readability-convert-member-functions-to-static]

    method 'advec_sym_tensor' can be made static

      396 |     [[nodiscard]] AMREX_GPU_DEVICE AMREX_FORCE_INLINE TensorArray::Rank1Sym
          |                                    static 
      397 |     advec_sym_tensor(int ix, int iy, int iz,
          |     ^
      398 |                      const amrex::Array4<amrex::Real const> &state,
      399 |                      const TensorArray::Rank1 &shift_vector,
      400 |                      const int ivar0) const
          |                                       ~~~~~
  • Source/Grids/FourthOrderDerivatives.hpp:478:5: warning: [readability-convert-member-functions-to-static]

    method 'add_dissipation' can be made static

      477 |     AMREX_GPU_DEVICE AMREX_FORCE_INLINE void
          |                      static 
      478 |     add_dissipation(int ix, int iy, int iz,
          |     ^
      479 |                     const amrex::CellData<amrex::Real> &rhs,
      480 |                     const amrex::Array4<amrex::Real const> &state,
      481 |                     const double sigma_coeff, int num_vars = NUM_VARS) const
          |                                                                        ~~~~~
  • Source/Grids/FourthOrderDerivatives.hpp:485:25: warning: [cppcoreguidelines-init-variables]

    variable 'diss' is not initialized

       14 |             amrex::Real diss =
          |                         ^
          |                              = NAN
  • Source/Grids/Tensor.hpp:18:9: warning: [cppcoreguidelines-macro-usage]

    function-like macro 'VAR_IDX' used; consider a 'constexpr' template function

       18 | #define VAR_IDX(ivar, i, j) ((ivar) + (i) + (j) + (((i) * (j) != 0) ? 1 : 0))
          |         ^
  • Source/Grids/Tensor.hpp:21:9: warning: [cppcoreguidelines-macro-usage]

    function-like macro 'VAR_IDX0' used; consider a 'constexpr' template function

       21 | #define VAR_IDX0(i, j) VAR_IDX(0, (i), (j))
          |         ^
  • Source/Grids/Tensor.hpp:23:35: warning: [bugprone-macro-parentheses]

    macro replacement list should be enclosed in parentheses

       23 | #define SPACETIME_DIM GR_SPACEDIM + 1
          |                                   ^  
          |                       (              )
  • Source/Grids/Tensor.hpp:26:9: warning: [cppcoreguidelines-macro-usage]

    macro 'UNIQUE_IDX' used to declare a constant; consider using a 'constexpr' constant

       26 | #define UNIQUE_IDX 6
          |         ^
  • Source/Maths/CoordinateTransformations.hpp:84:27: warning: [bugprone-easily-swappable-parameters]

    3 adjacent parameters of 'spherical_to_cartesian_LL' of similar type are easily swapped by mistake

       84 |                           const amrex::Real x, const double y, const double z)
          |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:84:45: note: the first parameter in the range is 'x'
       84 |                           const amrex::Real x, const double y, const double z)
          |                                             ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:84:77: note: the last parameter in the range is 'z'
       84 |                           const amrex::Real x, const double y, const double z)
          |                                                                             ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:84:27: note: after resolving type aliases, 'const amrex::Real' and 'const double' are the same
       84 |                           const amrex::Real x, const double y, const double z)
          |                           ^
  • Source/Maths/CoordinateTransformations.hpp:107:27: warning: [bugprone-easily-swappable-parameters]

    3 adjacent parameters of 'spherical_to_cartesian_UU' of similar type are easily swapped by mistake

      107 |                           const amrex::Real x, const double y, const double z)
          |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:107:45: note: the first parameter in the range is 'x'
      107 |                           const amrex::Real x, const double y, const double z)
          |                                             ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:107:77: note: the last parameter in the range is 'z'
      107 |                           const amrex::Real x, const double y, const double z)
          |                                                                             ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:107:27: note: after resolving type aliases, 'const amrex::Real' and 'const double' are the same
      107 |                           const amrex::Real x, const double y, const double z)
          |                           ^
  • Source/Maths/CoordinateTransformations.hpp:131:27: warning: [bugprone-easily-swappable-parameters]

    3 adjacent parameters of 'cartesian_to_spherical_LL' of similar type are easily swapped by mistake

      131 |                           const amrex::Real x, const double y, const double z)
          |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:131:45: note: the first parameter in the range is 'x'
      131 |                           const amrex::Real x, const double y, const double z)
          |                                             ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:131:77: note: the last parameter in the range is 'z'
      131 |                           const amrex::Real x, const double y, const double z)
          |                                                                             ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:131:27: note: after resolving type aliases, 'const amrex::Real' and 'const double' are the same
      131 |                           const amrex::Real x, const double y, const double z)
          |                           ^
  • Source/Maths/CoordinateTransformations.hpp:154:27: warning: [bugprone-easily-swappable-parameters]

    4 adjacent parameters of 'cartesian_to_spherical_UU' of convertible types are easily swapped by mistake

      154 | cartesian_to_spherical_UU(const TensorArray::Rank2 &cartesian_g_UU,
          |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      155 |                           amrex::Real x, double y, double z)
          |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:154:53: note: the first parameter in the range is 'cartesian_g_UU'
      154 | cartesian_to_spherical_UU(const TensorArray::Rank2 &cartesian_g_UU,
          |                                                     ^~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:155:59: note: the last parameter in the range is 'z'
      155 |                           amrex::Real x, double y, double z)
          |                                                           ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:154:27: note: 
      154 | cartesian_to_spherical_UU(const TensorArray::Rank2 &cartesian_g_UU,
          |                           ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:155:27: note: 'const int &' and 'amrex::Real' parameters accept and bind the same kind of values
      155 |                           amrex::Real x, double y, double z)
          |                           ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:155:27: note: 'const int &' and 'amrex::Real' may be implicitly converted: 'const int &' (as 'int') -> 'amrex::Real' (as 'double'), 'amrex::Real' (as 'double') -> 'const int &' (as 'int')
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:155:42: note: 'const int &' and 'double' parameters accept and bind the same kind of values
      155 |                           amrex::Real x, double y, double z)
          |                                          ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:155:42: note: 'const int &' and 'double' may be implicitly converted: 'const int &' (as 'int') -> 'double', 'double' -> 'const int &' (as 'int')
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:155:27: note: after resolving type aliases, 'amrex::Real' and 'double' are the same
      155 |                           amrex::Real x, double y, double z)
          |                           ^
  • Source/Maths/CoordinateTransformations.hpp:178:67: warning: [bugprone-easily-swappable-parameters]

    3 adjacent parameters of 'spherical_to_cartesian_U' of similar type are easily swapped by mistake

      178 | spherical_to_cartesian_U(const TensorArray::Rank1 &spherical_v_U, amrex::Real x,
          |                                                                   ^~~~~~~~~~~~~~
      179 |                          double y, double z)
          |                          ~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:178:79: note: the first parameter in the range is 'x'
      178 | spherical_to_cartesian_U(const TensorArray::Rank1 &spherical_v_U, amrex::Real x,
          |                                                                               ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:179:43: note: the last parameter in the range is 'z'
      179 |                          double y, double z)
          |                                           ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:178:67: note: after resolving type aliases, 'amrex::Real' and 'double' are the same
      178 | spherical_to_cartesian_U(const TensorArray::Rank1 &spherical_v_U, amrex::Real x,
          |                                                                   ^
  • Source/Maths/CoordinateTransformations.hpp:201:67: warning: [bugprone-easily-swappable-parameters]

    3 adjacent parameters of 'spherical_to_cartesian_L' of similar type are easily swapped by mistake

      201 | spherical_to_cartesian_L(const TensorArray::Rank1 &spherical_v_L, amrex::Real x,
          |                                                                   ^~~~~~~~~~~~~~
      202 |                          double y, double z)
          |                          ~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:201:79: note: the first parameter in the range is 'x'
      201 | spherical_to_cartesian_L(const TensorArray::Rank1 &spherical_v_L, amrex::Real x,
          |                                                                               ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:202:43: note: the last parameter in the range is 'z'
      202 |                          double y, double z)
          |                                           ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:201:67: note: after resolving type aliases, 'amrex::Real' and 'double' are the same
      201 | spherical_to_cartesian_L(const TensorArray::Rank1 &spherical_v_L, amrex::Real x,
          |                                                                   ^
  • Source/Maths/CoordinateTransformations.hpp:224:67: warning: [bugprone-easily-swappable-parameters]

    3 adjacent parameters of 'cartesian_to_spherical_U' of similar type are easily swapped by mistake

      224 | cartesian_to_spherical_U(const TensorArray::Rank1 &cartesian_v_U, amrex::Real x,
          |                                                                   ^~~~~~~~~~~~~~
      225 |                          double y, double z)
          |                          ~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:224:79: note: the first parameter in the range is 'x'
      224 | cartesian_to_spherical_U(const TensorArray::Rank1 &cartesian_v_U, amrex::Real x,
          |                                                                               ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:225:43: note: the last parameter in the range is 'z'
      225 |                          double y, double z)
          |                                           ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:224:67: note: after resolving type aliases, 'amrex::Real' and 'double' are the same
      224 | cartesian_to_spherical_U(const TensorArray::Rank1 &cartesian_v_U, amrex::Real x,
          |                                                                   ^
  • Source/Maths/CoordinateTransformations.hpp:247:67: warning: [bugprone-easily-swappable-parameters]

    3 adjacent parameters of 'cartesian_to_spherical_L' of similar type are easily swapped by mistake

      247 | cartesian_to_spherical_L(const TensorArray::Rank1 &cartesian_v_L, amrex::Real x,
          |                                                                   ^~~~~~~~~~~~~~
      248 |                          double y, double z)
          |                          ~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:247:79: note: the first parameter in the range is 'x'
      247 | cartesian_to_spherical_L(const TensorArray::Rank1 &cartesian_v_L, amrex::Real x,
          |                                                                               ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:248:43: note: the last parameter in the range is 'z'
      248 |                          double y, double z)
          |                                           ^
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/CoordinateTransformations.hpp:247:67: note: after resolving type aliases, 'amrex::Real' and 'double' are the same
      247 | cartesian_to_spherical_L(const TensorArray::Rank1 &cartesian_v_L, amrex::Real x,
          |                                                                   ^
  • Source/Maths/TensorAlgebra.hpp:74:17: warning: [cppcoreguidelines-init-variables]

    variable 'deth' is not initialized

       15 |     amrex::Real deth         = compute_determinant_sym(matrix);
          |                 ^
          |                      = NAN
  • Source/Maths/TensorAlgebra.hpp:101:17: warning: [cppcoreguidelines-init-variables]

    variable 'deth' is not initialized

      101 |     amrex::Real deth         = compute_determinant(matrix);
          |                 ^
          |                      = NAN
  • Source/Maths/TensorAlgebra.hpp:128:15: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'compute_trace' of similar type ('const int &') are easily swapped by mistake

      128 | compute_trace(const TensorArray::Rank2 &tensor_LL,
          |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      129 |               const TensorArray::Rank2 &inverse_metric)
          |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/TensorAlgebra.hpp:128:41: note: the first parameter in the range is 'tensor_LL'
      128 | compute_trace(const TensorArray::Rank2 &tensor_LL,
          |                                         ^~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/TensorAlgebra.hpp:129:41: note: the last parameter in the range is 'inverse_metric'
      129 |               const TensorArray::Rank2 &inverse_metric)
          |                                         ^~~~~~~~~~~~~~
  • Source/Maths/TensorAlgebra.hpp:257:11: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'raise_all' of similar type ('const int &') are easily swapped by mistake

      257 | raise_all(const TensorArray::Rank2 &tensor_LL,
          |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      258 |           const TensorArray::Rank2 &inverse_metric)
          |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/TensorAlgebra.hpp:257:37: note: the first parameter in the range is 'tensor_LL'
      257 | raise_all(const TensorArray::Rank2 &tensor_LL,
          |                                     ^~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/TensorAlgebra.hpp:258:37: note: the last parameter in the range is 'inverse_metric'
      258 |           const TensorArray::Rank2 &inverse_metric)
          |                                     ^~~~~~~~~~~~~~
  • Source/Maths/TensorAlgebra.hpp:286:11: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'lower_all' of similar type ('const int &') are easily swapped by mistake

      286 | lower_all(const TensorArray::Rank2 &tensor_UU, const TensorArray::Rank2 &metric)
          |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/TensorAlgebra.hpp:286:37: note: the first parameter in the range is 'tensor_UU'
      286 | lower_all(const TensorArray::Rank2 &tensor_UU, const TensorArray::Rank2 &metric)
          |                                     ^~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/TensorAlgebra.hpp:286:74: note: the last parameter in the range is 'metric'
      286 | lower_all(const TensorArray::Rank2 &tensor_UU, const TensorArray::Rank2 &metric)
          |                                                                          ^~~~~~
  • Source/Maths/TensorAlgebra.hpp:360:21: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'compute_christoffel' of similar type ('const int &') are easily swapped by mistake

      360 | compute_christoffel(const TensorArray::Rank3 &d1_metric,
          |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      361 |                     const TensorArray::Rank2 &h_UU)
          |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/TensorAlgebra.hpp:360:47: note: the first parameter in the range is 'd1_metric'
      360 | compute_christoffel(const TensorArray::Rank3 &d1_metric,
          |                                               ^~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Maths/TensorAlgebra.hpp:361:47: note: the last parameter in the range is 'h_UU'
      361 |                     const TensorArray::Rank2 &h_UU)
          |                                               ^~~~
  • Source/Matter/ScalarFieldAdvecVars.hpp:18:42: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'ScalarFieldAdvecVars<deriv_t>' of similar type are easily swapped by mistake

       18 |     ScalarFieldAdvecVars(int ix, int iy, int iz,
          |                                          ^~~~~~~
       19 |                          const amrex::Array4<const amrex::Real> &state,
          |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Matter/ScalarFieldAdvecVars.hpp:18:46: note: the first parameter in the range is 'iz'
       18 |     ScalarFieldAdvecVars(int ix, int iy, int iz,
          |                                              ^~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Matter/ScalarFieldAdvecVars.hpp:19:66: note: the last parameter in the range is 'state'
       19 |                          const amrex::Array4<const amrex::Real> &state,
          |                                                                  ^~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Matter/ScalarFieldAdvecVars.hpp:19:26: note: 'int' and 'const int &' parameters accept and bind the same kind of values
       19 |                          const amrex::Array4<const amrex::Real> &state,
          |                          ^
  • Source/Matter/ScalarFieldAdvecVars.hpp:24:9: warning: [cppcoreguidelines-prefer-member-initializer]

    'phi' should be initialized in a member initializer of the constructor

       21 |                          const deriv_t &a_deriv)
          |                                                 
          |                                                  : phi(a_deriv.advec_scalar(ix, iy, iz, state, shift_vector, c_phi))
       22 |     {
       23 |         // Calculate the advec quantities for all vars
       24 |         phi = a_deriv.advec_scalar(ix, iy, iz, state, shift_vector, c_phi);
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • Source/Matter/ScalarFieldAdvecVars.hpp:25:9: warning: [cppcoreguidelines-prefer-member-initializer]

    'Pi' should be initialized in a member initializer of the constructor

       21 |                          const deriv_t &a_deriv)
          |                                                 
          |                                                 , Pi(a_deriv.advec_scalar(ix, iy, iz, state, shift_vector, c_Pi))
       22 |     {
       23 |         // Calculate the advec quantities for all vars
       24 |         phi = a_deriv.advec_scalar(ix, iy, iz, state, shift_vector, c_phi);
       25 |         Pi  = a_deriv.advec_scalar(ix, iy, iz, state, shift_vector, c_Pi);
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • Source/Matter/ScalarFieldD1Vars.hpp:19:39: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'ScalarFieldD1Vars<deriv_t>' of similar type are easily swapped by mistake

       19 |     ScalarFieldD1Vars(int ix, int iy, int iz,
          |                                       ^~~~~~~
       20 |                       const amrex::Array4<const amrex::Real> &state,
          |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Matter/ScalarFieldD1Vars.hpp:19:43: note: the first parameter in the range is 'iz'
       19 |     ScalarFieldD1Vars(int ix, int iy, int iz,
          |                                           ^~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Matter/ScalarFieldD1Vars.hpp:20:63: note: the last parameter in the range is 'state'
       20 |                       const amrex::Array4<const amrex::Real> &state,
          |                                                               ^~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Matter/ScalarFieldD1Vars.hpp:20:23: note: 'int' and 'const int &' parameters accept and bind the same kind of values
       20 |                       const amrex::Array4<const amrex::Real> &state,
          |                       ^
  • Source/Matter/ScalarFieldD2Vars.hpp:18:39: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'ScalarFieldD2Vars<deriv_t>' of similar type are easily swapped by mistake

       18 |     ScalarFieldD2Vars(int ix, int iy, int iz,
          |                                       ^~~~~~~
       19 |                       const amrex::Array4<const amrex::Real> &state,
          |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Matter/ScalarFieldD2Vars.hpp:18:43: note: the first parameter in the range is 'iz'
       18 |     ScalarFieldD2Vars(int ix, int iy, int iz,
          |                                           ^~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Matter/ScalarFieldD2Vars.hpp:19:63: note: the last parameter in the range is 'state'
       19 |                       const amrex::Array4<const amrex::Real> &state,
          |                                                               ^~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Matter/ScalarFieldD2Vars.hpp:19:23: note: 'int' and 'const int &' parameters accept and bind the same kind of values
       19 |                       const amrex::Array4<const amrex::Real> &state,
          |                       ^
  • Source/Matter/Weyl4WithMatter.hpp:23:40: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'Weyl4WithMatter<matter_t>' of similar type ('const int') are easily swapped by mistake

       23 |                     const double a_dx, const int a_dcomp,
          |                                        ^~~~~~~~~~~~~~~~~~
       24 |                     const int a_formulation = CCZ4RHS<>::USE_CCZ4,
          |                     ~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Matter/Weyl4WithMatter.hpp:23:50: note: the first parameter in the range is 'a_dcomp'
       23 |                     const double a_dx, const int a_dcomp,
          |                                                  ^~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Matter/Weyl4WithMatter.hpp:24:31: note: the last parameter in the range is 'a_formulation'
       24 |                     const int a_formulation = CCZ4RHS<>::USE_CCZ4,
          |                               ^~~~~~~~~~~~~
  • Source/Tagging/ChiExtractionTagger.hpp:55:16: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'operator()' of similar type ('const int &') are easily swapped by mistake

       55 |                const amrex::Array4<amrex::TagBox::TagType> &tags,
          |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       56 |                const amrex::Array4<amrex::Real const> &state) const
          |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Tagging/ChiExtractionTagger.hpp:55:61: note: the first parameter in the range is 'tags'
       55 |                const amrex::Array4<amrex::TagBox::TagType> &tags,
          |                                                             ^~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Source/Tagging/ChiExtractionTagger.hpp:56:56: note: the last parameter in the range is 'state'
       56 |                const amrex::Array4<amrex::Real const> &state) const
          |                                                        ^~~~~
  • Source/Tagging/ChiTagger.hpp:37:16: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'operator()' of similar type ('const int &') are easily swapped by mistake

       37 |                const amrex::Array4<amrex::TagBox::TagType> &tags,
          |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       38 |                const amrex::Array4<amrex::Real const> &state) const
          |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../Source/Tagging/ChiTagger.hpp:37:61: note: the first parameter in the range is 'tags'
       37 |                const amrex::Array4<amrex::TagBox::TagType> &tags,
          |                                                             ^~~~
    ../../Source/Tagging/ChiTagger.hpp:38:56: note: the last parameter in the range is 'state'
       38 |                const amrex::Array4<amrex::Real const> &state) const
          |                                                        ^~~~~
  • Tests/BSSNMatterTest/BSSNMatterTest.cpp:136:34: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'operator()' of similar type ('int') are easily swapped by mistake

      136 |             [=] AMREX_GPU_DEVICE(int ibox, int ix, int iy, int iz)
          |                                  ^~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Tests/BSSNMatterTest/BSSNMatterTest.cpp:136:38: note: the first parameter in the range is 'ibox'
      136 |             [=] AMREX_GPU_DEVICE(int ibox, int ix, int iy, int iz)
          |                                      ^~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Tests/BSSNMatterTest/BSSNMatterTest.cpp:136:48: note: the last parameter in the range is 'ix'
      136 |             [=] AMREX_GPU_DEVICE(int ibox, int ix, int iy, int iz)
          |                                                ^~
  • Tests/CCZ4RHSTest/CCZ4RHSTest.cpp:149:13: warning: [bugprone-chained-comparison]

    chained comparison 'v0 < v1 > v2' may generate unintended results, use parentheses to specify order of evaluation or a logical operator to separate comparison expressions

      149 |             diff_fab.maxIndex<amrex::RunOn::Device>(box, max_diff,
          |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      150 |                                                     max_diff_index, ivar);
          |                                                     ~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Tests/CCZ4RHSTest/CCZ4RHSTest.cpp:149:13: note: operand 'v0' is here
      149 |             diff_fab.maxIndex<amrex::RunOn::Device>(box, max_diff,
          |             ^~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Tests/CCZ4RHSTest/CCZ4RHSTest.cpp:149:31: note: operand 'v1' is here
      149 |             diff_fab.maxIndex<amrex::RunOn::Device>(box, max_diff,
          |                               ^~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Tests/CCZ4RHSTest/CCZ4RHSTest.cpp:149:52: note: operand 'v2' is here
      149 |             diff_fab.maxIndex<amrex::RunOn::Device>(box, max_diff,
          |                                                    ^~~~~~~~~~~~~~~
      150 |                                                     max_diff_index, ivar);
          |                                                     ~~~~~~~~~~~~~~~~~~~~~
  • Tests/CoordinateTransformationsTest/CoordinateTransformationsTest.cpp:32:19: warning: [bugprone-easily-swappable-parameters]

    2 adjacent parameters of 'check_tensor' of similar type ('const int &') are easily swapped by mistake

       32 | void check_tensor(const TensorArray::Rank2 &tensor,
          |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       33 |                   const TensorArray::Rank2 &correct_tensor,
          |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Tests/CoordinateTransformationsTest/CoordinateTransformationsTest.cpp:32:45: note: the first parameter in the range is 'tensor'
       32 | void check_tensor(const TensorArray::Rank2 &tensor,
          |                                             ^~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Tests/CoordinateTransformationsTest/CoordinateTransformationsTest.cpp:33:45: note: the last parameter in the range is 'correct_tensor'
       33 |                   const TensorArray::Rank2 &correct_tensor,
          |                                             ^~~~~~~~~~~~~~
  • Tests/CoordinateTransformationsTest/CoordinateTransformationsTest.cpp:172:21: warning: [cppcoreguidelines-init-variables]

    variable 'area_element_check' is not initialized

       24 |         amrex::Real area_element_check = area_element_sphere(Mij_spher);
          |                     ^
          |                                        = NAN
  • Tests/DerivativeUnitTests/DerivativeTestsCompute.hpp:36:32: warning: [bugprone-easily-swappable-parameters]

    3 adjacent parameters of 'operator()' of similar type are easily swapped by mistake

       36 |     operator()(int ix, int iy, int iz, const amrex::Array4<amrex::Real> &out,
          |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       37 |                const amrex::Array4<amrex::Real const> &in) const
          |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Tests/DerivativeUnitTests/DerivativeTestsCompute.hpp:36:36: note: the first parameter in the range is 'iz'
       36 |     operator()(int ix, int iy, int iz, const amrex::Array4<amrex::Real> &out,
          |                                    ^~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Tests/DerivativeUnitTests/DerivativeTestsCompute.hpp:37:56: note: the last parameter in the range is 'in'
       37 |                const amrex::Array4<amrex::Real const> &in) const
          |                                                        ^~
    /home/runner/work/GRTeclyn/GRTeclyn/GRTeclyn/Tests/DerivativeUnitTests/DerivativeTestsCompute.hpp:36:40: note: 'int' and 'const int &' parameters accept and bind the same kind of values
       36 |     operator()(int ix, int iy, int iz, const amrex::Array4<amrex::Real> &out,
          |                                        ^

Have any feedback or feature suggestions? Share it here.

Comment thread Examples/BinaryBH/params_profile.txt
double &out_lapse, Tensor<1, double> &out_shift,
double &out_Theta,
Tensor<1, double> &out_Z3) const;
void interpolate_tp_vars(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we have ported these files yet, so should we include them here?

Comment thread Source/CCZ4/CCZ4D1Vars.hpp Outdated
Comment thread Source/CCZ4/CCZ4Geometry.hpp Outdated
Comment thread Source/CCZ4/CCZ4Geometry.hpp Outdated
Comment thread Source/Maths/TensorAlgebra.hpp Outdated
{
matter_term_Gamma += -16.0 * M_PI * m_G_Newton * vars.lapse() *
h_UU[i][j] * emtensor.j[j];
h_UU(i, j) * emtensor.j(j);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seeing this I wonder if we should change j to J in the emtensor... it isn't then very standard notation but I don't really like this j being confused with indexing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we could just use a different index variable here? I think it's always written as emtensor.j(idx) so it's not that ambiguous.

Comment thread Source/Matter/ScalarFieldD1Vars.hpp Outdated

this->rhs_equation(rhs_cell_data, vars, d1, d2, advec);
// calculate the vaccuum solution
this->compute_chi_and_h_ij(ix, iy, iz, rhs_state, state);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess it depends how we do the scalar example, but maybe we want to split these out too and just add the emtensor_rhs as another kernel?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think I want to have the () operator as a kind of wrapper with everything in it and then split out the equations in the scalar field example. Because there is no scalar field example right now, there isn't an example for users to see how to use the fissoned kernels so I want to leave this in there for now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree that we should split out the equations in the scalar field example when it is ported but I'm also fine with keeping this wrapper for the moment.

I don't think we can have a separate kernel for the emtensor_rhs as it's not independent from the other kernels. Note that the matter terms only come into the RHS for Aij, Theta, Gamma and the gauge so we only need to split it up into two parts (one for Aij, Theta and Gamma and one for the gauge). We should modify the interface here in this PR.

Comment thread Source/CCZ4/CCZ4Geometry.hpp Outdated
@KAClough

KAClough commented Apr 2, 2026

Copy link
Copy Markdown
Member

Lots of small comments and suggestions for naming but overall it looks great! I like the new Tensor arrays, and all the now consistent () brackets. I'm even happy to lose the D1Vars things.

@julianakwan julianakwan force-pushed the enhancement/refactor_vars2_kernel_fission2 branch from 1e4dd2c to 5e8f13e Compare April 8, 2026 16:51
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

This PR modifies the following files which are ignored by .lint-ignore:

Source/BlackHoles/BinaryBHInitialData.impl.hpp
Source/BlackHoles/BoostedBHInitialData.impl.hpp
Source/BlackHoles/TwoPuncturesInitialData.impl.hpp
Source/CCZ4/CCZ4RHS.impl.hpp
Source/CCZ4/Constraints.impl.hpp
Source/CCZ4/IntegratedMovingPunctureGauge.hpp
Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp
Tests/CCZ4GeometryUnitTests/CCZ4GeometryMathematicaValues.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

@julianakwan julianakwan force-pushed the enhancement/refactor_vars2_kernel_fission2 branch from 5e8f13e to b3d15fe Compare April 16, 2026 10:43
@github-actions

Copy link
Copy Markdown

This PR modifies the following files which are ignored by .lint-ignore:

Source/BlackHoles/BinaryBHInitialData.impl.hpp
Source/BlackHoles/BoostedBHInitialData.impl.hpp
Source/BlackHoles/TwoPuncturesInitialData.impl.hpp
Source/CCZ4/CCZ4RHS.impl.hpp
Source/CCZ4/Constraints.impl.hpp
Source/CCZ4/IntegratedMovingPunctureGauge.hpp
Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp
Tests/CCZ4GeometryUnitTests/CCZ4GeometryMathematicaValues.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

@julianakwan julianakwan force-pushed the enhancement/refactor_vars2_kernel_fission2 branch from b3d15fe to 619044a Compare April 17, 2026 13:06
@github-actions

Copy link
Copy Markdown

This PR modifies the following files which are ignored by .lint-ignore:

Source/BlackHoles/BinaryBHInitialData.impl.hpp
Source/BlackHoles/BoostedBHInitialData.impl.hpp
Source/BlackHoles/TwoPuncturesInitialData.impl.hpp
Source/CCZ4/CCZ4RHS.impl.hpp
Source/CCZ4/Constraints.impl.hpp
Source/CCZ4/IntegratedMovingPunctureGauge.hpp
Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp
Tests/CCZ4GeometryUnitTests/CCZ4GeometryMathematicaValues.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

@julianakwan

Copy link
Copy Markdown
Contributor Author

As discussed during the telecon on Thursday April 16, the precision requirement of the unit tests could probably be raised to $10^{-11}$, so I have ticked that check box off my to do list.

@julianakwan julianakwan force-pushed the enhancement/refactor_vars2_kernel_fission2 branch from 619044a to 811b545 Compare April 27, 2026 14:00
@github-actions

Copy link
Copy Markdown

This PR modifies the following files which are ignored by .lint-ignore:

Source/BlackHoles/BinaryBHInitialData.impl.hpp
Source/BlackHoles/BoostedBHInitialData.impl.hpp
Source/BlackHoles/TwoPuncturesInitialData.impl.hpp
Source/CCZ4/CCZ4RHS.impl.hpp
Source/CCZ4/Constraints.impl.hpp
Source/CCZ4/IntegratedMovingPunctureGauge.hpp
Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp
Tests/CCZ4GeometryUnitTests/CCZ4GeometryMathematicaValues.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

@julianakwan julianakwan moved this to In Progress in GRTeclyn Apr 28, 2026
Note that the functions have been overloaded such that the old way
of using the Tensor object is still available.
This will replace instances of the Tensor class with the
appropriate ArrayND class where N = 1,2 or 3 in the BinaryBH
example, Matter classes and unit tests. It does not replace
Tensors in classes that haven't been ported yet.
Previously the CCZ4 RHS was calculated by launching a single
ParallelFor region. This commit will split that region into
a separate ParallelFor for each term in the CCZ4 equation.
[skip-ci]

Specifically, this will join together the calculation of Gamma, Aij,
Theta, K into a single ParallelFor instance and chi and h_ij in
another. This is to avoid recomputing the Christoffel symbols and
Ricci Z which seems to be taking the longest time.
For example, d^2 h_ij/dydx is the same as d^2 h_ij/dxdy so we only
keep one copy. The indexing is done in the same way as for the
symmetric tensors so only the unique components are referenced.
Also test the effect of symmeterizing the second order derivatives
of other variables.
One uses AMReX ND Arrays for both the derivatives and Christoffel
symbols. The other uses Tensor objects to store both.

Switch between either to test the speedup/slowdown.
This removes the pre-calculation of chris_LLU which was slowing
down the computation of ricci_hat.
This will convert the remaining Tensor objects to amrex::Array1D,
amrex::Array2D or amrex::Array3D objects thus making the code
internally consistent.
This will bring up to date CCZ4RHS, CCZ4Geometry and
FourthOrderDerivatives for the new macros, and Array4 dimension
indexes introduced in b0c7edf.
This should remove the remaining Tensor objects used in the
calculation of the RHS.
Convert direct references to cell_data values to use CCZ4Vars
wrapper instead.
In previous commits, both the Tensor class and AMReX arrays were
available, now only AMReX arrays are used.
This commit will propagate the changes from the BinaryBH/CCZ4
equations to the Matter classes. Note that applying the gauge
and the KO dissipation are now split into two different functions
because these are split in the Matter RHS (gauge first then
dissipation).
Instead of writing e.g. amrex::Array1D<amrex::Real, 0, 3> we can now
write TensorArray::Rank1 and so on for the other ranks.

Also this will remove all remaining traces of the Tensor class,
including the tests and the derivatives.

@mirenradia mirenradia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this PR, Juliana and sorry for the large number of comments. I think most of them should be straightforward to fix.

One comment I want to highlight is that I think the tensor arguments of amrex::ArrayND are the inclusive bounds (including the upper bound) so maybe it should be e.g. amrex::Array1D<amrex::Real, 0, AMREX_SPACEDIM - 1> instead of AMREX_SPACEDIM in the third argument. I added this comment specifically in Tensor.hpp but these types are used elsewhere not via TensorArray aliases.

Comment on lines +168 to +171
amrex::AnyCTO(
amrex::TypeList<amrex::CompileTimeOptions<USE_BSSN, USE_CCZ4>>{},
{simParams().formulation},
[&](auto cto_func) { amrex::ParallelFor(a_rhs, cto_func); },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe it would be worth adding a brief comment explaining the point of using AnyCTO?

Comment on lines +162 to +166
enum formulations : int
{
USE_CCZ4 = 0,
USE_BSSN = 1
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it necessary to define this here? Can you use CCZ4RHS::USE_CCZ4 and CCZ4RHS::USE_BSSN below? If that doesn't work, maybe just move this enum to CCZ4RHS.hpp and remove the enum defined within the CCZ4RHS class definition.

Comment on lines +168 to +172
enum covariantZ4 : int
{
YES,
NO
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similarly, it would be better if this could be moved to the CCZ4RHS class.

{use_bssn, use_covariantZ4},
[&](auto cto_func) { amrex::ParallelFor(a_rhs, cto_func); },
[=] AMREX_GPU_DEVICE(int box_no, int ix, int iy, int iz,
auto formulation, auto control)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's make these names consistent

Suggested change
auto formulation, auto control)
auto formulation, auto covariant_Z4)


amrex::ParmParse pp;

int use_bssn{0};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you rename this to formulation or something similar rather than one of the formulation options?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here's somewhere you can add split matter RHS kernels!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This will be a pain as add_emtensor_rhs is a protected member of CCZ4RHSWithMatter. I would prefer to use the () operator and then split the kernels in an example. I think the same thing should be done with the CCZ4RHSTest by the way for consistency.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you also update the Mathematica script so that it generates in this format?

amrex::Real chi = 0.0;
Tensor<1, amrex::Real> Gamma;
Tensor<2, amrex::Real> h;
TensorArray::Rank1 Gamma{};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(Whole file comment) Can we make sure we're testing everything in CCZ4Geometry? I haven't cross-checked but I don't think this test has been changed much since all the changes there.

Comment on lines +120 to +128
current_ccz4_rhs.compute_chi_and_h_ij(
ix, iy, iz, current_out_array, in_c_array);
current_ccz4_rhs.compute_A_ij_and_Theta_and_Gamma<
formulation, use_covariantZ4>(ix, iy, iz, current_out_array,
in_c_array);
current_ccz4_rhs.apply_gauge(ix, iy, iz, current_out_array,
in_c_array);
current_ccz4_rhs.apply_dissipation(
ix, iy, iz, current_out_array, in_c_array);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you split them out into separate kernel invocations as you've done in the BinaryBH example?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we add in tests for the other functions in FourthOrderDerivatives e.g. diff1_vector, diff1_tensor, etc?

@KAClough KAClough requested a review from SamuelBrady May 6, 2026 11:51
@KAClough

KAClough commented May 6, 2026

Copy link
Copy Markdown
Member

FYI Since I am a bit swamped at the moment I have asked @SamuelBrady to do a more detailed review from the user perspective, and I'll just have another quick look once everything is final.

@SamuelBrady SamuelBrady 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.

Looks good and seems clear overall, just left a few new comments.

The main things that I think could cause confusion are the naming of Rank1Sym and Rank2Sym (which are rank 2 and rank 4 tensors), and knowing when to use symmetric vs regular tensors (which only makes sense once you know how they're stored). I think we could also have a clearer system for when we pass CellData vs Vars to other objects.

Comment thread Source/Grids/Tensor.hpp
#define VAR_IDX0(i, j) VAR_IDX(0, (i), (j))

constexpr operator arr_t &() { return arr; }
#define SPACETIME_DIM GR_SPACEDIM + 1

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.

Suggested change
#define SPACETIME_DIM GR_SPACEDIM + 1
#define SPACETIMEDIM GR_SPACEDIM + 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think SPACETIMEDIM is a bit hard to read because of the all caps...I think it has to be SPACETIME_DIM or SPACE_TIME_DIM.

Comment thread Source/Grids/Tensor.hpp Outdated
Comment thread Source/Grids/Tensor.hpp Outdated
Comment thread Source/CCZ4/CCZ4D2Vars.hpp Outdated
Comment thread Source/CCZ4/CCZ4D2Vars.hpp Outdated
Comment thread Source/CCZ4/Weyl4.impl.hpp Outdated
Comment thread Source/Grids/Tensor.hpp
constexpr operator const arr_t &() const { return arr; }
};
// Number of unique indices after accounting for symmetry
#define UNIQUE_IDX 6

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.

Also important to define in terms of AMREX_SPACEDIM if it's going to be used in loops, as suggested in other comments

Comment thread Source/Maths/CoordinateTransformations.hpp
Comment thread Source/CCZ4/CCZ4RHS.hpp

// Apply gauage (no derivatives needed here!)
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void
apply_gauge(int ix, int iy, int iz,

@SamuelBrady SamuelBrady May 8, 2026

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.

I'm not sure about the name apply_gauge, since the gauge itself is also being updated. Maybe something like include_gauge would be clearer

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this the rhs for the gauge? If so I would call it calculate_gauge_rhs() or something like that. I see the comment that no derivatives are needed, but that may not always be the case, so we may need to generalise it (but this can be done in another PR as commented elsewhere).

Comment on lines +257 to +263
d2(icomp, 0) = diff2(var_ptr, strides[0]);
d2(icomp, 3) = diff2(var_ptr, strides[1]);
d2(icomp, 5) = diff2(var_ptr, strides[2]);

d2(icomp, 1) = mixed_diff2(var_ptr, strides[0], strides[1]);
d2(icomp, 2) = mixed_diff2(var_ptr, strides[0], strides[2]);
d2(icomp, 4) = mixed_diff2(var_ptr, strides[1], strides[2]);

@SamuelBrady SamuelBrady May 8, 2026

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.

Could be clearer to use d2(icomp, VAR_IDX0(...)) here (and in other similar blocks), assuming it will be resolved at compile time

This will restore the original naming convention for the functions in
FourthOrderDerivatives, e.g. diff1_scalar, diff2_tensor

It also removes some of the test functions that I had previously
written to test the performance.

It will also replace some magic numbers: 3 -> AMREX_SPACEDIM
This will remove the branching in the RHS that depends on which
formulation (CCZ4 vs BSSN) and whether or not a covariant Z4 is
selected at runtime. It uses AMReX's CTO for any function
(not just ParallelFor).

The () operator of CCZ4RHSWithMatter is now also templated over
the formulation number and the usage of covariant Z4.
The CCZ4RHS unit test fails at the level of ~1e-12 but this is
dependent on the compiler e.g. ok for Intel oneAPI 2025.3.1 but fails
for GNU and LLVM. Also, I think the error tolerance has been set
arbitarily for the other tests also e.g. CCZ4GeometryTest is set to
1e-14 but BSSNMatterTest is 1e-10, even though the latter is also
a test of the RHS.
This introduces a new namespace SpaceTimeTensor in which the dimensions
are 0 - GR_SPACEDIM+1. I've also cleaned up some of the naming so
the number of unique entries in a 3 x 3 symmetric array is now called
UNIQUE_IDX.
I was allocating too many elements by 1 because the array limits were
inclusive, so 0 -> AMREX_SPACEDIM is now 0 -> AMREX_SPACEDIM-1
This will consolidate changes calls to CCZ4Geometry functions
to only use the CCZ4Vars wrapper (instead of CellData) and
remove unused overloaded functions. As a result, usage of
CCZ4D1Vars in Weyl4 and Constraints were removed.
This swaps the remaining references to cell_data in favour of the
CCZ4Vars wrapper.
This will allow passing the wrappers from the ScalarField class,
ScalarFieldD1Vars, ScalarFieldD2Vars, ScalarFieldAdvecVars
to enable (future) support for multiple scalar fields.
To discourage users from using the CCZ4 derivative wrappers,
the ScalarField class no longer inherits from the CCZ4
wrappers and these wrappers have been deleted.

This will also update the way tensors are referenced in the
CCZ4Geometry Unit Test, the BSSNMatter Unit Test and
Wey4WithMatter Unit Test.
@julianakwan julianakwan force-pushed the enhancement/refactor_vars2_kernel_fission2 branch from 811b545 to 0d364a0 Compare May 27, 2026 16:34
@github-actions

Copy link
Copy Markdown

This PR modifies the following files which are ignored by .lint-ignore:

Source/BlackHoles/BinaryBHInitialData.impl.hpp
Source/BlackHoles/BoostedBHInitialData.impl.hpp
Source/BlackHoles/TwoPuncturesInitialData.impl.hpp
Source/CCZ4/CCZ4RHS.impl.hpp
Source/CCZ4/Constraints.impl.hpp
Source/CCZ4/IntegratedMovingPunctureGauge.hpp
Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp
Tests/CCZ4GeometryUnitTests/CCZ4GeometryMathematicaValues.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

I've changed the function signatures to allow for passing the
necessary components to calculate the derivatives inside the
Matter RHS functions.
@github-actions

Copy link
Copy Markdown

This PR modifies the following files which are ignored by .lint-ignore:

Source/BlackHoles/BinaryBHInitialData.impl.hpp
Source/BlackHoles/BoostedBHInitialData.impl.hpp
Source/BlackHoles/TwoPuncturesInitialData.impl.hpp
Source/CCZ4/CCZ4RHS.impl.hpp
Source/CCZ4/Constraints.impl.hpp
Source/CCZ4/IntegratedMovingPunctureGauge.hpp
Source/CCZ4/Weyl4.impl.hpp
Source/Matter/CCZ4RHSWithMatter.impl.hpp
Source/Matter/ConstraintsWithMatter.impl.hpp
Source/Matter/EMTensor.impl.hpp
Source/Matter/ScalarField.impl.hpp
Source/Matter/Weyl4WithMatter.impl.hpp
Tests/CCZ4GeometryUnitTests/CCZ4GeometryMathematicaValues.hpp

Please consider removing the corresponding patterns from .lint-ignore so that these files can be linted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Remove branching with BSSN versus CCZ4 Refactor Tensor class

4 participants