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

Adjusted cartesian mesh generation for 2D meshes #66

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

Conversation

neysecco
Copy link
Contributor

@neysecco neysecco commented Dec 1, 2023

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

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

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

  • 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

@neysecco neysecco requested a review from a team as a code owner December 1, 2023 13:24
Copy link

codecov bot commented Dec 1, 2023

Codecov Report

Attention: 34 lines in your changes are missing coverage. Please review.

Comparison is base (275f7cb) 17.84% compared to head (4b93a8f) 17.77%.

Files Patch % Lines
cgnsutilities/cgns_utils.py 0.00% 26 Missing ⚠️
cgnsutilities/cgnsutilities.py 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #66      +/-   ##
==========================================
- Coverage   17.84%   17.77%   -0.07%     
==========================================
  Files           3        3              
  Lines        2315     2323       +8     
==========================================
  Hits          413      413              
- Misses       1902     1910       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

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.

@@ -784,7 +834,18 @@ def main():
xMin = [args.xmin, args.ymin, args.zmin]
xMax = [args.xmax, args.ymax, args.zmax]

simpleCart(xMin, xMax, args.dh, args.hExtra, args.nExtra, args.sym, args.mgcycle, args.outFile)
# Change dh to a list of integers, since we had
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment mentions int, but the type casting below is float.

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@@ -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
Copy link
Contributor

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.

@marcomangano marcomangano mentioned this pull request Feb 27, 2024
13 tasks
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.

3 participants