-
Notifications
You must be signed in to change notification settings - Fork 50
270 efficient hwbb and ibb #287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…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...
… 270-efficient_hwbb_and_ibb
…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
…pare to MP2 and cylinder2025 results!
|
@PhiSpel @McBs README:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaxBille, could you revert these changes for cleaner history?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of course. Will try to overwrite file back to original from master branch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaxBille, these are useful comments! Can you add them in a separate PR, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaxBille didn't you add these changes separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| self.f_index_fwbb[:, 1], | ||
| self.f_index_fwbb[:, 2], | ||
| self.f_index_fwbb[:, 3]] | ||
| print("FWBB call, DONE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove redundant print? @MaxBille, check for more of those
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do; and will do in final version, together with obsolete comments and "old" code snippets
PhiSpel
left a comment
There was a problem hiding this 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
- Mirror the folder structure of /lettuce/.. for any files which are non-executables? (
Flow/obstacle_cylinder.py,Boundary/solid_boundary_data.py,boundary/linear_interpolated_bounce_back_boundary.py, etc.). This will make it easier to review and to later merge into the corresponding structure withinlettuce/ - Typo:
parameterizeshould beparametrize - Remove all lines containing
OLD - change default arguments to the values you suggested above
- since TODOs are already here as issues, you could remove those lines
- Do you need
torch.autograd? - Since you are using so many args, this could be useful to save all the overloads into local variables (should be simple enough to refactor): https://docs.python.org/3/library/argparse.html#the-namespace-object
- Remove redundant
if Truehttps://github.com/MaxBille/lettuce/blob/ea1705f8bce28146723efd2359d8f9ba8b81b185/examples/advanced_projects/efficient_bounce_back_obstacle/01a_script_cylinder_lowRe.py#L279 - Since you have so much input-parsing, wouldn't it make sense to create a separate file / function for this?
- I like the idea of saving the output in the Jupyter notebook. However, it is currently a bit out of place. I'd suggest naming only master-files
xy_[...]. So, if we keep the notebooks, move the scripts into a subfolder. That could look quite nice, too. - I do not get the last lines of
01a[...]. Could you move those comments to the corresponding lines of code or into the file head? https://github.com/MaxBille/lettuce/blob/ea1705f8bce28146723efd2359d8f9ba8b81b185/examples/advanced_projects/efficient_bounce_back_obstacle/01a_script_cylinder_lowRe.py#L320C3-L320C10
| self.f_collided_gt = None | ||
| # will be populated in initialize_f_collided() method | ||
|
|
||
| # DEPRECATED: got moved to method initialize f_collided |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove old code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be removed in final/release/merge version. I keep sections like this in the code, to remind me of past versions and various ways to do stuff.
| def make_no_streaming_mask(self, f_shape, context: Context): | ||
| # no_stream_mask has to be dimensions: (q,x,y,z) (z optional), but CAN be (x,y,z) (z optional). | ||
| # ...in the latter case, torch.where broadcasts the mask to (q,x,y,z), so ALL q populations of a lattice-node are marked equally | ||
| # return torch.tensor(self.mask, dtype=torch.bool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove old code
| # ...in the initial solution of your flow, especially if visualization or post-processing uses the field-values | ||
| # ...in the whole domain (including the boundary region)! | ||
|
|
||
| # return torch.tensor(self.mask, dtype=torch.bool) # self.context.convert_to_tensor(self.mask) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove old code
| self.f_index_gt[:, 3]], | ||
| self.flow.stencil.e[self.f_index_gt[:, 0]].float()) | ||
|
|
||
| # TODO: find a way to use pre- and post-Streaming Populations for bounce... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this done?
examples/advanced_projects/efficient_bounce_back_obstacle/obstacle_cylinder.py
Outdated
Show resolved
Hide resolved
examples/advanced_projects/efficient_bounce_back_obstacle/obstacle_cylinder.py
Outdated
Show resolved
Hide resolved
| mask=self.in_mask, | ||
| velocity=self.u_inlet) # (is this still true??): works with a 1 x D vector or an ny x D vector thanks to einsum-magic in EquilibriumBoundaryPU | ||
|
|
||
| lateral_boundary = None # stays None if lateral walls are not specified... (NOT IMPLEMENTED YET, see below) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may just remove all channel-related definitions for now. The most interesting part is how the cylinder is handled, right, @MaxBille ?
examples/advanced_projects/efficient_bounce_back_obstacle/obstacle_cylinder.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these changes break the old code or fix something? If they just work with everything else, OK. If they are required as a fix, please add this in a separate issue
…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)
…to fork/MaxBille/270-efficient_hwbb_and_ibb
…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)
…ed profile-data-post-processing und -plotting. implemented advanced vtk reporter (3D with step start and end and 2D for XY-slices)
…al of un-implemented reporter-files.
…r flow with 01_script_cylinder_simulation.py through ipynb: 00_run_parameterized_project.ipynb added "show" parameter to plotting-reporters methods, to not only plot and save but also show the plotted data
…to 270-efficient_hwbb_and_ibb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaxBille did you keep these changes intentionally?
| "h5py==3.11.0", | ||
| "matplotlib>=3.9.2", | ||
| "mmh3>=4.1.0", | ||
| "notebook>=7.4.7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MaxBille didn't you add these changes separately?
| -> use the ProfilePlotter in post-processing to further process | ||
| and plot data! | ||
| """ | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove double linebreak
| """ | ||
| output the mask as a vtk-file for visualizatione etc. | ||
| UPDATE 28.08.2024 (MBille: outputs mask as cell data. cell data represents the approx. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is UPDATE necessary? Can't this be a permanent comment?
Description
(Work in Progress)
Associated to issue #270 and related to feature requests #271 , #273 . See respective issue descriptions.
Checklist
__init__examples/advanced_flows/orexamples/simple_flows/tests/relevant files and changes
examples/advanced_projects/efficient_bounce_back_obstacle/00_run_parameterized_project.ipynbwith two examples of parametrized calls of the main simulation-script to run:01_script_cylinder_simulation.pycontains:simulation()ebb_simulation.pythat 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).obstacle_cylinder.py: advanced obstacle flow with a symmetrical 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.data_processing_and_plotting.pyutility.data_processing_and_plotting.pyutility. Gives statistics and frequency of a periodic signal (used for drag and lift in this project)data_processing_and_plotting.pyutility. It allows the loading of reference data, processing of profile reporter data and plotting of both.