Skip to content

270 efficient hwbb and ibb#287

Merged
PhiSpel merged 37 commits intolettucecfd:masterfrom
MaxBille:270-efficient_hwbb_and_ibb
Mar 25, 2026
Merged

270 efficient hwbb and ibb#287
PhiSpel merged 37 commits intolettucecfd:masterfrom
MaxBille:270-efficient_hwbb_and_ibb

Conversation

@MaxBille
Copy link
Copy Markdown
Collaborator

@MaxBille MaxBille commented Oct 28, 2025

Description

(ready for review)

Associated to issue #270 and related to feature requests #271 , #273 . See respective issue descriptions.

  • implementing fwbb, hwbb and ibb boundaries with efficiency improvement
  • implement cylinder flow as an example and test case

Checklist

  • This pull request is associated to an issue
  • This PR contains a description
  • Did you add a new method? If so, you need to
    • add method description
    • maybe mention class in the corresponding __init__
    • add an example using the method in examples/advanced_flows/ or examples/simple_flows/
    • add a test in tests/
      edit Philipp: won't add a test for these, since it's part of the advanced examples and not yet part of the lettuce core
  • Add someone else as reviewer and wait for approval before merging.

relevant files and changes

  • The advanced project lives in the directory:
    examples/advanced_projects/efficient_bounce_back_obstacle/
  • It contains a Jupyter Notebook 00_run_parameterized_project.ipynb with two examples of parametrized calls of the main simulation-script to run:
    • 2D, Re=200 simulation of a circular cylinder with periodic vortex shedding. Coefficients of drag and lift, as well as the Strouhal number are calculated
    • 3D, Re=3900 simulation of a circular cylinder with turbulent vortex shedding. Average velocity and Reynolds stress profiles are calculated and compared to reference values
  • The project writes data to specified output directories.
  • The project contains a folder with reference data in .csv format for average velocity and Reynolds stress profiles (/profile_reference_data). This data is loaded and plotted, by the respective functionalities in auxiliary_code/data_processing_and_plotting.py.
  • The main simulation script 01_script_cylinder_simulation.py contains:
    • argument parsing: physics, domain, solver-components, algorithms, reporters, observables, vtk output etc.
    • parameter-preprocessing
    • assembling of all solver components: stencil, context, flow, collision operator, simulation, reporter
    • the simulation run: call of simulation()
    • data post-processing and -plotting: calculation, plotting, saving data and plots to disk

additions and changes in lettuce-code:

  • Efficient bounce back boundary implementations with the ability to calculate the momentum exchange (MEA) between solid and fluid:
    • Fullway (FWBB)
    • Halfway (HWBB)
    • Linearly Interpolated (IBB or IBB1)
  • adapted simulation class ebb_simulation.py that improves the regular simulation class to use post-streaming boundaries and let boundaries get post-collision but pre-streaming information on populations, needed for their bounce back algorithm (for HWBB and IBB).
  • flow class obstacle_cylinder.py: advanced obstacle flow with a symmetrically placed circular cylinder in 2D or 3D that can be run with periodic or solid boundary channel walls and efficient bounce back boundaries for the solid cylinder itself.

nice-to-knows and further features:

  • at this point, the flow class calculates all interpolation constants (for the IBB) via an analytical function. In future versions, this might be outsourced to a CAD-kernel to use arbitrary solid geometry and calculate interpolation constants and masks (or index lists) from it. The use of the solid_boundary_data class enables unified and efficient containment of bounce back data (masks, population-indices, interpolation-constants,...)
  • mind the use of post_streaming_boundaries that are (at the point of writing) not native in lettuce master branch, because the simulation class does not allow them! (up to lettuce version 0.2.3 post-streaming was the standard for boundary conditions)
  • observables: coefficients of lift and drag relying on the MEA-capabilities of the efficient BB boundaries (see above)
    • plot_force_coefficients: part of the data_processing_and_plotting.py utility.
    • analyze_periodic_timeseries: part of the data_processing_and_plotting.py utility. Gives statistics and frequency of a periodic signal (used for drag and lift in this project)
  • Advanced vtk reporter: two advanced vtk reporters that allow the selection of start and stop (step) of reporting and pulling observables (velocity and pressure) to 0 on the solid (especially useful when using FWBB to suppress artificial observable values inside the solid). The VTKsliceReporter allows easy capture of 2D-slices for efficient visualization.
  • Average velocity and Reynolds stress profiles:
    • reporter: The profile reporter reports the spatially averaged velocity profiles at a given position
    • ProfilePlotter: part of the data_processing_and_plotting.py utility. It allows the loading of reference data, processing of profile reporter data and plotting of both.

MaxBille and others added 3 commits September 4, 2025 18:21
…aster.

including: obstacle_cylinder.py, example-Simulation-script, HWBB and IBB boundary conditions, MEA for Bounce back boundaries, drag and lift observables...
…aster.

including: obstacle_cylinder.py, example-Simulation-script, HWBB and IBB boundary conditions, MEA for Bounce back boundaries, drag and lift observables...
@MaxBille MaxBille marked this pull request as draft October 28, 2025 13:15
@MaxBille MaxBille requested review from McBs and PhiSpel October 28, 2025 13:16
@MaxBille MaxBille self-assigned this Oct 28, 2025
@MaxBille MaxBille added the enhancement New feature or request label Oct 28, 2025
…ed from MP2 and MA).

obstacle_cylinder.py implements the flow, the boundary classes are implemented in the respective files under /_boundary
WorkInProgress, see ToDOs
…ack boundaries to folder examples/advanced_projects/efficient_bounce_back_obstacle.

Includes boundary conditions, obstacle_cylinder.py and placeholders for simulation-scripts for Re40-300 and Re3900, and a jupyter-notebook to run the scripts interactively

_simulation.py: added comments for clarification
@MaxBille
Copy link
Copy Markdown
Collaborator Author

@PhiSpel @McBs
The cylinder flow is now "running" with fwbb, hwbb or ibb boundary condition. Validation of physical correctness pending, because respective observable-reporters have to be implemented in the next step.
See commit: (Commit SHA: ea1705f from 21.11.25).

README:

  • simulation can be run with:
    python 01a_script_cylinder_lowRe --outdir "./datafolder" --char_length_lu 10 --n_steps 1000 --bbbc_type ibb1 --reynolds_number 50 --domain_width_z_in_d 3
  • ebb_simulation is a child of simulation class which allows post_streaming_boundaries to be used. This is necessary for FWBB, HWBB and IBB in the efficient sparse implementation.
  • obstacle_cylinder is the flow class
  • solid_boundary_data is the container class which contains masks, f_index-lists and ibb-d-data
  • 01a_script_cylinder_lowRe.py is the parameterized script to run the simulation.

Copy link
Copy Markdown
Contributor

@PhiSpel PhiSpel left a comment

Choose a reason for hiding this comment

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

@MaxBille nice job so far!
Could you

MaxBille and others added 7 commits November 26, 2025 17:14
…ample to validate against MP2 and cylinder-paper data; to be tested...
- comments
- print-statements
- ToDos
- revert changes in .ipynbs (less clutter in later PR)
…numerically there are diffs. of ~1% in mean Drag... this might be due to the new pre/ost-boundary strategy of lettuce 2025.

Needs further investigation (issue already open).
Further improvements and corrections:
- implemented lateral walls option (for FWBB)
- removed some comments and old code sections.
NEXT will be output/data/vtk cleaning and example .ipynb script for execution
- methods for force coefficient plotting and analysis were outsourced to data_processing_and_plotting.py
- files for NaN-, HighMa-, and Progress-Reporter created (but work in progress)
@MaxBille MaxBille requested a review from PhiSpel December 18, 2025 14:40
@MaxBille
Copy link
Copy Markdown
Collaborator Author

@McBs @PhiSpel the current commit 8f12b6a is ready for the next review cycle. This is basically a final version so far.

@PhiSpel PhiSpel marked this pull request as ready for review December 18, 2025 15:02
@MaxBille
Copy link
Copy Markdown
Collaborator Author

@McBs PR is ready for review.
This contains the major content of MP2 (efficient bounce back boundaries, cylinder flow, force coefficients, some reporters,...).

@PhiSpel I applied most of your change-requests from Nov 26, 26

  • I left '#TODO' in the code in some cases, because it marks the location and describes possible implementations for additional and optional features. But these features should be implemented in a separate PR (and separate issue) to not bloat this one further. The code does not need these features to run.
  • Some of the requests from Nov 26, 26 are very good ideas and worth looking into with enough time and priority -> could be separate issues and/or PRs as well:
    • namespace object for parsing
    • separate file/function for parsing arguments to the namespace object

@PhiSpel
Copy link
Copy Markdown
Contributor

PhiSpel commented Mar 18, 2026

Some of the requests from Nov 26, 26 are very good ideas and worth looking into with enough time and priority -> could be separate issues and/or PRs as well:

* namespace object for parsing

* separate file/function for parsing arguments to the namespace object

@MaxBille should I create issues for these points for you to do later, or is this outside of your capacities?

@MaxBille
Copy link
Copy Markdown
Collaborator Author

Some of the requests from Nov 26, 26 are very good ideas and worth looking into with enough time and priority -> could be separate issues and/or PRs as well:

* namespace object for parsing

* separate file/function for parsing arguments to the namespace object

@MaxBille should I create issues for these points for you to do later, or is this outside of your capacities?

Doing this is out of my capacities, because of other priorities. Do you want to write an issue for these, or should I do that?
Likely it would make sense to write an issue, after this PR is merged, right?

Copy link
Copy Markdown
Contributor

@PhiSpel PhiSpel left a comment

Choose a reason for hiding this comment

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

lgtm, congratulations!!! 😃

@PhiSpel PhiSpel merged commit 121359d into lettucecfd:master Mar 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment