-
Notifications
You must be signed in to change notification settings - Fork 25
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
Adjusted cartesian mesh generation for 2D meshes #66
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #66 +/- ##
==========================================
- Coverage 17.95% 17.88% -0.07%
==========================================
Files 3 3
Lines 2323 2331 +8
==========================================
Hits 417 417
- Misses 1906 1914 +8 ☔ View full report in Codecov by Sentry. |
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.
Hey, @neysecco, hope you are doing well! Sorry for the delay, and thanks for the PR! Did a quick pass and overall the changes look good, but see my comments. I would not be too worried about backwards compatibility, for these options, so if you have any alternate ideas please let us know. Aside from that, we should add some examples or tests, or both. This could be something simple as just showing how to use the command, and compare the cgns output file to a reference file. For reference we do something similar for pyHyp tests.
@@ -922,7 +983,18 @@ def main(): | |||
sys.exit(0) | |||
|
|||
elif args.mode == "simpleCart": | |||
curGrid.simpleCart(args.dh, args.hExtra, args.nExtra, args.sym, args.mgcycle, args.outFile) | |||
# Change dh to a list of integers, since we had | |||
# to define it as a string in arg_parser to avoid |
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.
Most of the new code here is a duplication from explicitCart
. Refactoring this into a function processing the cart inputs would be great.
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.
This has been stale for over a year now. Fixed a couple of my own comments, but I suggest we merge this and add tests and other improvements in later PRs. @marcomangano please review if possible
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 agree we can add tests and cleanup the code at a later stage. The updated documentation and fixes are very useful.
I just have a comment below:
@@ -988,7 +987,7 @@ def func(P): | |||
x0bin = xmin + dxBin * binIndex | |||
xfbin = xmin + dxBin * (binIndex + 1) | |||
# Find cells that touch this interval and get their edges | |||
bol = -(((S[:-1] < x0bin) * (S[1:] < x0bin)) + ((S[:-1] > xfbin) * (S[1:] > xfbin))) | |||
bol = ~(((S[:-1] < x0bin) * (S[1:] < x0bin)) + ((S[:-1] > xfbin) * (S[1:] > xfbin))) |
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 don't understand this change.
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.
This is essentially inverting a boolean array. This is a bit cryptic, and perhaps numpys invert
would be more readable (see docs here).
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.
Oh ok yeah, it is a bit cryptic, you mean flipping the boolean values element-by-element? Could you just expand the comment in the code? Otherwise the PR is ready to go for me.
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 added a comment on this, but not sure if this is useful. Please take a look. In any case, Ney suggests that this is not a useful function, and we should perhaps deprecate in favor of explicitCart
and simpleCart
.
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.
Thanks for the updated comment, LGTM
Purpose
Hello everyone,
The explicitCart and simpleCart functions could not generate cartesian meshes for 2D cases when used from the command line. The issue was that we could not set multiple symmetry planes from the command line, even though the Python part of these functions already had this functionality.
I adapted the parser to read multiple symmetry planes and mesh spacings. This modification should be backward-compatible.
This is further explained in the documentation of these functions ("$ cgns_utils explicitCart -h" and "$ cgns_utils simpleCart -h").
I also made minor changes to the cartesian function due to changes in scipy.optimize inteface and Python3 standards. However, I strongly recommend that we remove this function, since explicitCart and simpleCart give better control over mesh spacings.
Type of change
Changes to the command-line interface
Testing
The code can be tested with:
$ cgns_utils explicitCart -3 -3 0 4 3 1 0.3,0.3,1.0 10.0 15 zmin,zmax 0 bg.cgns
The expected output is:
Grid Dimensions: [54, 51, 2]
Grid Ratios: [1.12192755 1.12387294 4. ]
A new file named bg.cgns will be created with a cartesian mesh for 2D simulation.
Checklist
flake8
andblack
to make sure the Python code adheres to PEP-8 and is consistently formattedfprettify
or C/C++ code withclang-format
as applicable