Skip to content

Feature/mhd edge native dissipative flux (reduce ghost number constraint). - #1319

Open
UCaromel wants to merge 2 commits into
PHAREHUB:masterfrom
UCaromel:feature/mhd-edge-native-dissipative-flux
Open

Feature/mhd edge native dissipative flux (reduce ghost number constraint).#1319
UCaromel wants to merge 2 commits into
PHAREHUB:masterfrom
UCaromel:feature/mhd-edge-native-dissipative-flux

Conversation

@UCaromel

Copy link
Copy Markdown
Contributor

Issue

#1283

What this implements

nbrGhostsFromReconstruction<R>() was roundUpToEven(R + 2), so WENOZ/MP5 MHD builds reserve 6 field ghost layers. The extra layer was bought by one thing: with hyper-resistivity on, laplJ was computed from reconstructed values, which required +1 cell in each directions.

The non-ideal (resistive and hyper-resistive) flux contributions now come from J at its native edge location, so the Laplacian never reaches past layer 2, the +1 shell is gone, and the constant becomes roundUpToEven(R + 1): WENOZ/MP5 6 → 4, Linear/WENO3/Constant unchanged (rounding absorbs it).

Design

E_diss = eta*J - coef*laplacian(J) is formed on the edge, multiplied there by the edge-projected transverse B — projection does not commute with multiplication, so the product must be formed before projecting — and the product is projected to the face. The flux's non-ideal terms are then the face projection of the same edge quantities the CT already uses to advance B, where before the two used different discretisations of ∇²J times different B's.

Tests

Harris bitwise identical in ideal. Differences in the order of O(1e-5) with spatial hyper resistivity on harris at 0.4 dx. Expected since different numerics, lowering at O(dx^2) (hyper constant) or O(dx^4) (hyper spatial). Expected as second order representation of the laplacian (multiplied by dx^2 in spatial case).

The resistive and hyper-resistive contributions to F_B and F_Etot were
built from face-side riemann-averaged quantities: the Laplacian of the
face-averaged jt, multiplied by the reconstructed bt. Taking a Laplacian
of a face quantity needs jt at face +/-1, which is why the Godunov flux
loop grew by one layer in the flux direction under hyper-resistivity, and
that shell is what forced the MHD ghost width to roundUpToEven(R+2).

Compute them on the edge instead: E_diss = eta*J - nu*lapl(J) is formed
where J natively lives, multiplied there by the transverse B projected
onto the same edge, and the product is projected to the face with six new
single-axis edge->face stencils. The product has to be formed before the
projection since projection does not commute with multiplication.

The Laplacian now stays within the reconstruction reach, so the flux
direction grow is gone. It also makes these terms the face projection of
the very quantities the CT already uses to advance B, where before the
two used different discretisations of lapl(J) times different B's.

The spatial hyper-resistivity coefficient stays face-side, assembled from
the native normal B plus the two edge-projected transverse components, so
no face->face projections are needed and rhot keeps its face meaning.

Consequences:
- bt_x/y/z and GodunovState exist only for the old face-side product and
  are removed, along with the fvm_state plumbing through the solver.
- UpwindConstrainedTransportState gains a HyperResistivity parameter: the
  spatial coefficient reads rhot, which was gated on Hall || Resistivity,
  so a Hall-less resistivity-less spatial-hyper build read an unregistered
  view.

Not bitwise when eta or nu is non-zero; identical when both are zero.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LvDjQHGycauAiPgCgH2xFK
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 54 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 75014cd0-f977-4f61-95f8-780e1914fb5c

📥 Commits

Reviewing files that changed from the base of the PR and between 0f4e186 and 8a26245.

📒 Files selected for processing (1)
  • pyphare/pyphare/core/gridlayout.py

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 40ef7138-4b24-4a59-81cf-5a37c71ca21b

📥 Commits

Reviewing files that changed from the base of the PR and between 686aefa and 0f4e186.

📒 Files selected for processing (2)
  • tests/core/utilities/ghost_width_calculator/test_ghost_width_calculator.cpp
  • tests/core/utilities/ghost_width_calculator/test_gridlayout_integration.cpp

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The MHD flux path now uses one constrained-transport state. Resistive and hyper-resistive terms are formed at edge locations, projected to faces, and accumulated into fluxes. Ghost-width calculations and tests reflect the revised stencil requirements.

Changes

MHD flux refactor

Layer / File(s) Summary
Grid and state contracts
src/core/utilities/ghost_width_calculator.hpp, src/core/data/grid/impl/yee/gridlayout_mhd_yee.hpp, src/core/numerics/constrained_transport/upwind_constrained_transport_utils.hpp, src/core/numerics/godunov_fluxes/godunov_fluxes.hpp
Ghost-width rules reserve one layer beyond the reconstruction stencil. Six edge-to-face interpolation methods were added. UpwindConstrainedTransportState now includes HyperResistivity in its template and resource-view conditions.
Non-ideal flux contract
src/core/numerics/MHD_equations/MHD_equations.hpp
resistive_contributions now accepts projected dissipative terms and accumulates them into magnetic and total-energy fluxes.
Godunov edge-based flux assembly
src/core/numerics/godunov_fluxes/godunov_fluxes.hpp, src/core/numerics/godunov_fluxes/godunov_utils.hpp
Godunov::operator() no longer accepts an FVM state. The separate GodunovState was removed. Resistive and hyper-resistive products are computed at edges and projected per face direction.
Shared constrained-transport state wiring
src/amr/solvers/solver_mhd_field_evolvers.hpp, src/amr/solvers/time_integrator/compute_fluxes.hpp
The finite-volume transformer and ComputeFluxes pass, register, and allocate only the constrained-transport state. Ghost-width expectations were updated in the utility tests and grid-layout integration tests.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 0f4e1

The PR changes internal MHD numerical flux and ghost-cell handling without an identified merge-blocking correctness, security, deployment, or availability issue. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: philipdeegan

Sequence Diagram(s)

sequenceDiagram
  participant Godunov
  participant GridLayoutImplYee
  participant MHDEquations
  Godunov->>Godunov: Compute edge-local resistive and hyper-resistive products
  Godunov->>GridLayoutImplYee: Project edge products to face locations
  Godunov->>MHDEquations: Accumulate projected terms into magnetic and energy fluxes
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.94% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: native edge dissipative fluxes and reduced ghost-layer requirements. It is specific and related to the pull request.
Description check ✅ Passed The description references issue #1283 and explains the implementation, design, numerical effects, and tests. The implementation section is empty, but the required information appears in the surroundi…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description references issue #1283 and explains the implementation, design, numerical effects, and tests. The implementation section is empty, but the required information appears in the surrounding sections.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@UCaromel
UCaromel force-pushed the feature/mhd-edge-native-dissipative-flux branch from 686aefa to 0f4e186 Compare August 31, 2026 14:54
…is gone

nbrGhostsFromReconstruction was roundUpToEven(R + 2). One of those layers
paid for ampere computing J on the ghost box shrinked by one; the other
paid for the hyper-resistivity flux shell, which no longer exists. WENOZ
and MP5 go from 6 ghosts to 4; Linear, WENO3 and Constant are unchanged
because the rounding to even absorbs the difference.

The remaining margin is zero by construction, so state it: the Godunov
class now static_asserts ghost_width >= nghosts + 1, which is what keeps
the transverse grow shell reading valid J.

The ghost width is one compile-time constant for the whole build, so in
coupled runs this also relaxes the hierarchy's minimum patch size, which
MHD was setting on its own.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LvDjQHGycauAiPgCgH2xFK
@UCaromel
UCaromel force-pushed the feature/mhd-edge-native-dissipative-flux branch from 0f4e186 to 8a26245 Compare August 31, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant