Skip to content

Support for purely parabolic PDEs via SemidiscretizationParabolic#2874

Open
tristanmontoya wants to merge 89 commits intomainfrom
tm/parabolic_solver
Open

Support for purely parabolic PDEs via SemidiscretizationParabolic#2874
tristanmontoya wants to merge 89 commits intomainfrom
tm/parabolic_solver

Conversation

@tristanmontoya
Copy link
Copy Markdown
Member

@tristanmontoya tristanmontoya commented Mar 21, 2026

The main purpose of this PR is to add SemidiscretizationParabolic to handle purely parabolic PDEs, including the new types LinearDiffusionEquation1D and LinearDiffusionEquation2D. It builds upon #2868, which renames "viscous" to "parabolic" when referring more generally to parabolic PDEs rather than fluid viscosity.

Implementation notes

  • Uses only one equations struct and doesn't require an unused hyperbolic part
  • rhs! is specialized on SemidiscretizationParabolic to call rhs_parabolic! only.
  • Still uses cache and cache_parabolic analogously to SemidiscretizationHyperbolicParabolic
  • We still require separate solver and solver_parabolic, with the latter used to dispatch the formulation for the parabolic terms, e.g., BR1 or LDG.
  • Eventually, we may want to refactor SemidiscretizationHyperbolicParabolic to include modular hyperbolic and parabolic components, in addition to "base" equation-independent features. As a first step, however, I have not modified any of the structure for mixed hyperbolic-parabolic problems.

Elixirs changed/added

  • examples/tree_1d_dgsem/elixir_diffusion_ldg.jl: migrated from zero-advection hyperbolic-parabolic setup to pure diffusion via LinearDiffusionEquation1D and SemidiscretizationParabolic.
  • examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl: updated the Newton-Krylov pure-diffusion example to use the dedicated parabolic API.
    examples/tree_2d_dgsem/elixir_diffusion_steady_state_linear_map.jl: switched the steady-state 2D diffusion example to LinearDiffusionEquation2D and SemidiscretizationParabolic.
  • examples/tree_1d_dgsem/elixir_diffusion_ldg_amr_boundary_layer.jl: new pure-diffusion AMR example with a boundary layer and mixed Dirichlet/Neumann boundary conditions.

Benchmarks

For a simple 1D diffusion example, I get a speedup of just under 1.5x by using a purely parabolic semidiscretization rather than a hyperbolic-parabolic semidiscretization with zero advection velocity (which was previously the only way to solve parabolic problems). Using this benchmark script, I get the following output:

Environment info ===================================================
Julia threads: 1
BLAS threads: 4
Trixi.jl version: 0.16.1-DEV
OrdinaryDiffEqLowStorageRK version: 1.12.0
Julia Version 1.10.10
Commit 95f30e51f41 (2025-06-27 09:51 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 10 × Apple M4
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

Timing/consistency results =========================================
Parabolic solve median: 60.025 ms
Hyperbolic-parabolic solve median: 87.251 ms
Median ratio (hyperbolic-parabolic/parabolic): 1.454x
Final-state relative difference (hyperbolic-parabolic vs parabolic): 0.000e+00

Other changes

  • I have added my name to the list of contributors in AUTHORS.md.
  • The diffusion/heat equation is now listed in README.md as an example of a scalar conservation law, as it is the canonical parabolic problem and users should know that it is supported.
  • NEWS.md has been updated to include this change as part of the v0.16 lifecycle.

LLM/AI usage

OpenAI Codex was used to generate some of the initial code. As the author of this PR, I have reviewed the code in its entirety and take full responsibility for its content.

tristanmontoya and others added 25 commits March 17, 2026 17:06
Co-authored-by: Daniel Doehring <daniel.doehring@rwth-aachen.de>
Co-authored-by: Daniel Doehring <daniel.doehring@rwth-aachen.de>
Co-authored-by: Daniel Doehring <daniel.doehring@rwth-aachen.de>
Co-authored-by: Daniel Doehring <daniel.doehring@rwth-aachen.de>
Co-authored-by: Daniel Doehring <daniel.doehring@rwth-aachen.de>
Co-authored-by: Daniel Doehring <daniel.doehring@rwth-aachen.de>
Co-authored-by: Daniel Doehring <daniel.doehring@rwth-aachen.de>
Co-authored-by: Daniel Doehring <daniel.doehring@rwth-aachen.de>
Co-authored-by: Daniel Doehring <daniel.doehring@rwth-aachen.de>
Co-authored-by: Daniel Doehring <daniel.doehring@rwth-aachen.de>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Review checklist

This checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging.

Purpose and scope

  • The PR has a single goal that is clear from the PR title and/or description.
  • All code changes represent a single set of modifications that logically belong together.
  • No more than 500 lines of code are changed or there is no obvious way to split the PR into multiple PRs.

Code quality

  • The code can be understood easily.
  • Newly introduced names for variables etc. are self-descriptive and consistent with existing naming conventions.
  • There are no redundancies that can be removed by simple modularization/refactoring.
  • There are no leftover debug statements or commented code sections.
  • The code adheres to our conventions and style guide, and to the Julia guidelines.

Documentation

  • New functions and types are documented with a docstring or top-level comment.
  • Relevant publications are referenced in docstrings (see example for formatting).
  • Inline comments are used to document longer or unusual code sections.
  • Comments describe intent ("why?") and not just functionality ("what?").
  • If the PR introduces a significant change or new feature, it is documented in NEWS.md with its PR number.

Testing

  • The PR passes all tests.
  • New or modified lines of code are covered by tests.
  • New or modified tests run in less then 10 seconds.

Performance

  • There are no type instabilities or memory allocations in performance-critical parts.
  • If the PR intent is to improve performance, before/after time measurements are posted in the PR.

Verification

  • The correctness of the code was verified using appropriate tests.
  • If new equations/methods are added, a convergence test has been run and the results
    are posted in the PR.

Created with ❤️ by the Trixi.jl community.

@tristanmontoya tristanmontoya changed the title Support for purely parabolic PDEs via SemidiscretizationParaboblic Support for purely parabolic PDEs via SemidiscretizationParabolic Mar 21, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 21, 2026

Codecov Report

❌ Patch coverage is 97.91667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.08%. Comparing base (16e465f) to head (d1f2b25).

Files with missing lines Patch % Lines
src/equations/linear_diffusion_equation_1d.jl 90.91% 1 Missing ⚠️
src/equations/linear_diffusion_equation_2d.jl 92.31% 1 Missing ⚠️
...semidiscretization/semidiscretization_parabolic.jl 98.65% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #2874    +/-   ##
========================================
  Coverage   97.08%   97.08%            
========================================
  Files         611      616     +5     
  Lines       47580    47690   +110     
========================================
+ Hits        46189    46297   +108     
- Misses       1391     1393     +2     
Flag Coverage Δ
unittests 97.08% <97.92%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DanielDoehring DanielDoehring added the enhancement New feature or request label Mar 21, 2026
@tristanmontoya
Copy link
Copy Markdown
Member Author

Benchmarks now added to PR description.

DanielDoehring
DanielDoehring previously approved these changes Mar 31, 2026
Copy link
Copy Markdown
Member

@DanielDoehring DanielDoehring left a comment

Choose a reason for hiding this comment

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

LGTM!

@tristanmontoya
Copy link
Copy Markdown
Member Author

tristanmontoya commented Apr 1, 2026

@vchuravy I assume the buildkite failures are unrelated to this PR?
Edit: I guess it succeeded here eventually.

@vchuravy
Copy link
Copy Markdown
Member

vchuravy commented Apr 2, 2026

I assume the buildkite failures are unrelated to this PR?

CI for AMDGPU doesn't have very many runners so that can sometimes be a bit slower.

Copy link
Copy Markdown
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

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

Thanks!

Comment on lines +211 to +212
function rhs!(du_ode, u_ode, semi::SemidiscretizationParabolic, t)
@unpack mesh, equations, boundary_conditions, source_terms, solver, solver_parabolic, cache, cache_parabolic = semi
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.

Do we really want this to be rhs! instead of rhs_parabolic!?

Copy link
Copy Markdown
Member Author

@tristanmontoya tristanmontoya Apr 2, 2026

Choose a reason for hiding this comment

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

This way, we don't have to specialize semidiscretize, which assumes the function is called rhs! in the generic case. Otherwise, we'd have to make semidiscretize for SemidiscretizationParabolic do the exact same thing as for a generic AbstractSemidiscretization, except renaming rhs! to rhs_parabolic!.

I also think the naming makes intuitive sense in that it designates the "right-hand side for a parabolic semidiscretization" rather than "the parabolic right-hand side of a semidiscretization" (the latter for which rhs_parabolic! makes sense in the context of a hyperbolic-parabolic problem).

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.

For clarity, I would rather argue that our current rhs! should be rhs_hyperbolic!. This is how we basically use it. Using rhs_parabolic! for parabolic terms would appear more natural to me.
Maybe you can add this to the agenda of the next Trixi.jl meeting? I would like to get input from a few additional people.

Copy link
Copy Markdown
Member Author

@tristanmontoya tristanmontoya Apr 3, 2026

Choose a reason for hiding this comment

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

Sure, I'll add it to the agenda. I see your point, and I'm not against the idea, but then we can't fall back to semidiscretize(::AbstractSemidiscretization) for both hyperbolic and parabolic problems unless we add another layer to make the outermost rhs! call dispatch directly to rhs_parabolic! or rhs_hyperbolic! as needed. Otherwise, I think there would be a lot of repeated code.

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't we have a small dispatch of the form default_rhs(::SemidiscretizationParabolic) = rhs_parabolic! and similarly for SemidiscretizationHyperbolic that is used in semidiscretize?

Comment on lines +66 to +67
* Several scalar conservation laws (e.g., linear advection, Burgers' equation, LWR traffic flow)
* Linear diffusion/heat equation
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 please synchronize

* Several scalar conservation laws (e.g., linear advection, Burgers' equation, LWR traffic flow)

as well?

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

None yet

Development

Successfully merging this pull request may close these issues.

4 participants