Skip to content

Conversation

@vincmarks
Copy link

Changes

  • New boundary-condition functions added

    • boundary_condition_default_p4est_2D
    • boundary_condition_default_p4est_3D
    • boundary_condition_default_structured_1D
    • boundary_condition_default_structured_2D
    • boundary_condition_default_structured_3D
    • boundary_condition_default_tree_1D
    • boundary_condition_default_tree_2D
    • boundary_condition_default_tree_3D
      These functions apply the same boundary condition on every face of the mesh for P4est, structured, and tree meshes.
  • Documentation updated

    • Added a Boundary Condition section to the following pages:
      • Trixi.jl/docs/src/meshes/p4est_mesh.md
      • Trixi.jl/docs/src/meshes/structured_mesh.md
      • Trixi.jl/docs/src/meshes/tree_mesh.md

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2025

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.

Copy link
Member

@JoshuaLampert JoshuaLampert 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 the contribution! Would it maybe be a cleaner interface to have only one function boundary_condition_default(mesh, boundary_condition) , which dispatches on the mesh type? Then you can use another mesh, but still get the correct default boundary condition. This goes into the direction of #1510.
Could you also use the new functions in at least one of the elixirs each, such that they are tested?

@DanielDoehring
Copy link
Member

Thanks for your contribution!

I like the convenience, but maybe we start with the non-tree mesh types since for the latter (as you mentioned) this functionality actually already exists

# you can either use a single function to impose the BCs weakly in all
# 2*ndims == 4 directions or you can pass a tuple containing BCs for each direction
boundary_conditions = BoundaryConditionDirichlet(initial_condition)
solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)
coordinates_min = (-5.0, -5.0)
coordinates_max = (5.0, 5.0)
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 4,
n_cells_max = 30_000,
periodicity = false)
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
boundary_conditions = boundary_conditions)

@codecov
Copy link

codecov bot commented Aug 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.81%. Comparing base (1d75f8f) to head (f5538da).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2515   +/-   ##
=======================================
  Coverage   96.81%   96.81%           
=======================================
  Files         535      536    +1     
  Lines       42813    42829   +16     
=======================================
+ Hits        41446    41462   +16     
  Misses       1367     1367           
Flag Coverage Δ
unittests 96.81% <100.00%> (+<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 Aug 15, 2025
vincmarks and others added 15 commits September 25, 2025 14:45
Copy link
Member

@JoshuaLampert JoshuaLampert left a comment

Choose a reason for hiding this comment

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

Some more formatting comments below (you can also go to the "Files changed" tab and add suggestions to a batch, such that multiple suggestions can be bundled in one commit to keep the commit history clean).

@vincmarks
Copy link
Author

Some more formatting comments below (you can also go to the "Files changed" tab and add suggestions to a batch, such that multiple suggestions can be bundled in one commit to keep the commit history clean).

Thanks for the comments and the idea with the batch 👍

Comment on lines 211 to 219
if isa(mesh, TreeMesh)
ndims_mesh = ndims(mesh)
if ndims_mesh == 1
return boundary_condition_default_tree_1D(boundary_condition)
elseif ndims_mesh == 2
return boundary_condition_default_tree_2D(boundary_condition)
elseif ndims_mesh == 3
return boundary_condition_default_tree_3D(boundary_condition)
end
Copy link
Member

Choose a reason for hiding this comment

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

Could you please switch to a dispatch-based approach instead of having if statements based on the type? This makes it easier to extend the functionality in the future. For example, you would write

function boundary_condition_default(mesh::TreeMesh1D, boundary_condition)
    return (x_neg = boundary_condition,
            x_pos = boundary_condition)
end

and remove the functions boundary_condition_default_tree_1D etc.

# @eval due to @muladd
@eval Adapt.@adapt_structure(UnstructuredSortedBoundaryTypes)
end # @muladd
end#@muladd
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
end#@muladd
end # @muladd

Please revert the whitespace change.

Copy link
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! We are close to merging this PR.

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