Skip to content
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

Custom GrowthRatios and more Schedule variables #94

Open
wants to merge 50 commits into
base: main
Choose a base branch
from

Conversation

DavidAnderegg
Copy link

@DavidAnderegg DavidAnderegg commented Sep 4, 2024

Purpose

This PR adds the ability to set custom growth ratios on each layer. Additionally, more 'schedule' variables are introduced.

This PR adjusts how some options work. Apart from prescribing a single value, it is now possible to define a list with per-layer values. Additionally, it is possible to instruct pyHyp to interpolate the value linearly throughout the extrusion.

This PR removes the volSmoothSchedule variable as the same functionality is now possible with volSmoothIter.

Lastly, a new variable growthRatios is introduced to explicitly set the growth ratio. If it is set, the marchDist option is ignored. This variable works like the other changes introduce here.

Expected time until merged

1 week

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (non-backwards-compatible fix or feature) - volSmoothSchedule is now obsolete and was removed
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Documentation update
  • Maintenance update
  • Other (please describe)

Testing

I adjusted the naca0012_rans and corner test to include an 'interpolation' and a 'per-layer' case. I also added a test for nConstantStart and nConstantEnd options. And finally, i added a test for simpleOCart with xBounds and no nearfield mesh.

Here are the new ref-files for the new tests: schedule_ref_files.zip

Here are the new ref-files for the new tests: refFiles.zip

Checklist

  • I have run flake8 and black to make sure the Python code adheres to PEP-8 and is consistently formatted
  • I have formatted the Fortran code with fprettify or C/C++ code with clang-format as applicable
  • I have run unit and regression tests which pass locally with my changes
  • I have added new tests that prove my fix is effective or that my feature works
  • I have added necessary documentation

@eirikurj
Copy link
Contributor

eirikurj commented Sep 4, 2024

@DavidAnderegg thanks for the PR. Will try to take a look as soon as I can. In the meantime, can you address the failing tests.

@DavidAnderegg
Copy link
Author

@eirikurj The tests fail because new the ref files have not been added. I attached a .zip in the description of this PR.

@eirikurj
Copy link
Contributor

eirikurj commented Sep 4, 2024

My bad, I only read the description in a rush and saw the test are failing. I can update the reference files. I skimmed the PR content, and it looks good, but will do a more thorough pass later.
I think it would be good if we can combine or refactor the RANS scripts to avoid code duplication. They are essentially all the same except for a few options. I suggest one of the two,

  1. refactor the geometry generation out into its own file that can be imported or run.
  2. use argparse with argument mode (or similar) to run each case and just update the relevant options based on the mode. This will have a smaller footprint.

@eirikurj
Copy link
Contributor

eirikurj commented Sep 4, 2024

I have updated the files. However, in line with my previous comment on refactoring the scripts I updated the names and inserted rans in the files i.e.,

naca0012_growth_ratios.cgns -> naca0012_rans_growth_ratios.cgns
naca0012_schedule.cgns      -> naca0012_rans_schedule.cgns

To avoid nightly builds failing, I named the archive with the updated files is pyhyp_ref_files_2024-09-04.tar.gz. You can update the script to pull this archive instead for testing. Once ready I will update the main.

@DavidAnderegg
Copy link
Author

DavidAnderegg commented Sep 26, 2024

@eirikurj I adjusted the code as explained in my previous comment. It is once again ready for review.

Please note: i also adjusted the description and added new ref-files.

updating MExt to support python 3.12 (mdolab#95)
Copy link
Contributor

@anilyil anilyil left a comment

Choose a reason for hiding this comment

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

Great work overall. I left some comments. I am really happy with the cleanup you did with fortran, it makes so much more sense to compute those parameters in python.

doc/options.yaml Show resolved Hide resolved
doc/options.yaml Show resolved Hide resolved
doc/options.yaml Show resolved Hide resolved
pyhyp/pyHyp.py Show resolved Hide resolved
pyhyp/pyHyp.py Outdated Show resolved Hide resolved
@DavidAnderegg
Copy link
Author

@anilyil, I adressed your comments. You might want to take a look again.

@anilyil anilyil self-requested a review October 14, 2024 04:17
anilyil
anilyil previously approved these changes Oct 14, 2024
Copy link
Contributor

@anilyil anilyil 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 updates. This is good to go for me.

@anilyil anilyil self-requested a review October 14, 2024 20:21
Copy link
Contributor

@anilyil anilyil left a comment

Choose a reason for hiding this comment

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

@DavidAnderegg we just realized the growth ratios printed with pyHypMulti is broken now. It just prints 0s. Can you look into this?

@DavidAnderegg
Copy link
Author

@anilyil I know why this happens... Yes, I will look into it.

@DavidAnderegg
Copy link
Author

@anilyil Grid Ratios for pyHypMulti print now correctly.

I also replaced that code with 'tabulate' because it is so much easier this way.

Copy link
Contributor

@eirikurj eirikurj left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. I did a quick pass and overall the changes are very good. Just a few very minor comments or questions. Let me know if anything is unclear. Also, can you prepare and link an archive with updated reference files for the tests. Want to test this locally and I will also need to upload it to our site.

examples/naca0012/naca0012_rans.py Outdated Show resolved Hide resolved
examples/naca0012/naca0012_rans.py Outdated Show resolved Hide resolved
pyhyp/pyHyp.py Outdated
@@ -405,8 +384,19 @@ def __init__(self, comm=None, options=None, debug=False):
if options is None:
raise Error("The options = keyword argument is *NOT* optional. " "It must always be provided")

# Deprecated options
deprecated_options = self._getDeprecatedOptions()
Copy link
Contributor

Choose a reason for hiding this comment

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

We use camelCase (there are exceptions) for our codebase. Please change naming (here and elsewhere) to make it consistent.

Copy link
Author

Choose a reason for hiding this comment

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

I will change it.

But are not any of the tools (flake8, black, ...) supposed to catch this?

pyhyp/pyHyp.py Outdated Show resolved Hide resolved
pyhyp/pyHyp.py Outdated Show resolved Hide resolved
pyhyp/pyHyp.py Outdated Show resolved Hide resolved
from baseclasses import BaseSolver
from baseclasses.utils import Error
from cgnsutilities.cgnsutilities import readGrid, combineGrids


class pyHypWarning(object):
Copy link
Contributor

Choose a reason for hiding this comment

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

While this is fine for now, I just wanted to note that we have been moving towards using the standard library warnings module. You can see baseclasses for examples of usage.

Copy link
Author

Choose a reason for hiding this comment

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

I can move to a standard library. I just copied the idea from ADflow. Let me know what you want?

pyhyp/pyHyp.py Outdated Show resolved Hide resolved
pyhyp/pyHyp.py Outdated Show resolved Hide resolved
pyhyp/pyHyp.py Outdated

return fullDeltaS, marchDist, growth_ratios

def get_growth_ratio_string(self, growth_ratios=None, n_decimals=3):
Copy link
Contributor

Choose a reason for hiding this comment

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

Add argument descriptions (same for other new functions). Also probably should make it "private" with an underscore, or is there a use case for the user here that I am missing?

Copy link
Author

Choose a reason for hiding this comment

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

I think this depends on your definition of private/public. I understood it like this: only accessed within the class = private; gets accessed outside of the class = public.

This function is called by pyHypMulti, which does not inherit from pyHyp. Thus it is accessed from the outside and should be public.

@DavidAnderegg
Copy link
Author

@eirikurj I adressed your comments. I only resolved the ones where I knew what to do. The unresolved ones either need an answer or a small discussion.

Regarding the ref files, I edited the PR description and updated the link to the ref-files.

Regarding function description. I left out the ones in the examples. Let me know if I should add it there aswell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants