Skip to content

Make volume integrals, indicators, etc dimension agnostic#2488

Merged
ranocha merged 46 commits intotrixi-framework:mainfrom
DanielDoehring:CleanUpVolumeIntegrals
Oct 1, 2025
Merged

Make volume integrals, indicators, etc dimension agnostic#2488
ranocha merged 46 commits intotrixi-framework:mainfrom
DanielDoehring:CleanUpVolumeIntegrals

Conversation

@DanielDoehring
Copy link
Copy Markdown
Member

@DanielDoehring DanielDoehring commented Jul 21, 2025

Probably due to historical debt, the volume integrals have been implemented for every dimension. There is currently no reason to do so, as this results only in duplicated code and makes changes such as discussed in #2472 and #2149 unnecessary cumbersome.

Holds also true for some other functions (mostly create_cache)

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

@DanielDoehring DanielDoehring added discussion refactoring Refactoring code without functional changes labels Jul 21, 2025
@DanielDoehring DanielDoehring changed the title Make volume integrals dimension agnostic Make volume integrals, indicators, etc dimension agnostic Jul 21, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Jul 21, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.80%. Comparing base (b15c6ea) to head (996e364).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/solvers/dgsem/calc_volume_integral.jl 87.50% 4 Missing ⚠️
src/solvers/solvers.jl 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2488      +/-   ##
==========================================
+ Coverage   96.79%   96.80%   +0.01%     
==========================================
  Files         525      527       +2     
  Lines       42708    42611      -97     
==========================================
- Hits        41337    41248      -89     
+ Misses       1371     1363       -8     
Flag Coverage Δ
unittests 96.80% <88.89%> (+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.

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 for bringing this up. We have to discuss this in a larger group including @sloede and the other @trixi-framework/principal-developers

@JoshuaLampert
Copy link
Copy Markdown
Member

If we want this (and I am in favor of it), I would propose to put the dimension agnostic functions into dimension-general files, e.g., moving the calc_boundary_flux! functions from src/solvers/dgsem_structured/dg_*d.jl to src/solvers/dgsem_structured/dg.jl. Otherwise it's hard to find the file if you are, e.g., working on 2D, but the function is in the 1D file.

@DanielDoehring
Copy link
Copy Markdown
Member Author

If we want this (and I am in favor of it), I would propose to put the dimension agnostic functions into dimension-general files, e.g., moving the calc_boundary_flux! functions from src/solvers/dgsem_structured/dg_*d.jl to src/solvers/dgsem_structured/dg.jl. Otherwise it's hard to find the file if you are, e.g., working on 2D, but the function is in the 1D file.

That's an excellent idea!

@JoshuaLampert
Copy link
Copy Markdown
Member

Following a similar idea, wouldn't it also make sense to put mesh-agnostic functions (at least the ones, which are the same of all mesh types) into mesh-general files like https://github.com/trixi-framework/Trixi.jl/blob/531ee91d0dbe93e8fb8bf9f675b34f7982b9077e/src/solvers/dg.jl. Currently, we have quite some functions, which also allow non-TreeMeshes in the dgsem_tree subfolder.

@DanielDoehring
Copy link
Copy Markdown
Member Author

DanielDoehring commented Aug 11, 2025

Following a similar idea, wouldn't it also make sense to put mesh-agnostic functions (at least the ones, which are the same of all mesh types) into mesh-general files like https://github.com/trixi-framework/Trixi.jl/blob/531ee91d0dbe93e8fb8bf9f675b34f7982b9077e/src/solvers/dg.jl. Currently, we have quite some functions, which also allow non-TreeMeshes in the dgsem_tree subfolder.

I like the idea and I would be fine with adding a file like volume_integrals.jl somewhere in the src/solvers directory.
However, this is maybe againts the following convention/code structure?

Trixi.jl/src/solvers/dg.jl

Lines 830 to 837 in 531ee91

# Discretizations specific to each mesh type of Trixi.jl
# If some functionality is shared by multiple combinations of meshes/solvers,
# it is defined in the directory of the most basic mesh and solver type.
# The most basic solver type in Trixi.jl is DGSEM (historic reasons and background
# of the main contributors).
# We consider the `TreeMesh` to be the most basic mesh type since it is Cartesian
# and was the first mesh in Trixi.jl. The order of the other mesh types is the same
# as the include order below.

@JoshuaLampert
Copy link
Copy Markdown
Member

Yes, it would be against this code structure, but the question is, which code structure is easier to understand and work with. I was just last week talking to a Trixi.jl newcomer, who wants to contribute to Trixi.jl and was confused about seeing code relevant for the P4estMesh in the TreeMesh folder and therefore didn't find the relevant code. If we want to keep the current structure, I would at least highlight this structure more prominently in the docs, e.g., in the development section.

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.

Could you please move the comment explaining the flux differencing strategy for curved meshes to an appropriate location and ping me for approval of this PR afterward?

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

@ranocha ranocha merged commit ceafb99 into trixi-framework:main Oct 1, 2025
38 of 39 checks passed
ranocha added a commit that referenced this pull request Oct 1, 2025
* Make volume integrals dimension agnostic

* clean up indicators

* bring back dim spec version

* bring back indicators

* Apply suggestions from code review

* remove create cahce

* remove 3d

* move functions

* restructure

* comment

* comments

* rename

* fmt

* comment

* move

* test vals

* specify solver

* fmt

* comments

---------

Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
@DanielDoehring DanielDoehring deleted the CleanUpVolumeIntegrals branch October 1, 2025 06:45
DanielDoehring added a commit to DanielDoehring/Trixi.jl that referenced this pull request Feb 19, 2026
…ework#2488)

* Make volume integrals dimension agnostic

* clean up indicators

* bring back dim spec version

* bring back indicators

* Apply suggestions from code review

* remove create cahce

* remove 3d

* move functions

* restructure

* comment

* comments

* rename

* fmt

* comment

* move

* test vals

* specify solver

* fmt

* comments

---------

Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discussion refactoring Refactoring code without functional changes taal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants