-
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
Open
neysecco
wants to merge
3
commits into
mdolab:main
Choose a base branch
from
neysecco:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -493,27 +493,77 @@ | |
) | ||
|
||
# ------------ Options for 'simpleCart' mode -------------------- | ||
p_sub = subparsers.add_parser("simpleCart", help="Generates a background cartesian mesh") | ||
p_sub = subparsers.add_parser( | ||
"simpleCart", | ||
help="""Generates a background cartesian mesh containing two | ||
regions: one internal region with uniform spacing dh | ||
and an extended region where mesh sizes grow following | ||
a geometric progression. The internal region is | ||
defined by the bounding box of the mesh present in gridFile.""", | ||
formatter_class=argparse.RawTextHelpFormatter, | ||
) | ||
p_sub.add_argument("gridFile", help="Name of input CGNS file") | ||
p_sub.add_argument("dh", help="Uniform spacing size", type=float) | ||
p_sub.add_argument("hExtra", help="Extension in each dimension", type=float) | ||
p_sub.add_argument("nExtra", help="Number of nodes to use for extension", type=int) | ||
p_sub.add_argument("sym", help="Normal for possible sym plane", type=str) | ||
p_sub.add_argument( | ||
"dh", | ||
help="""Uniform spacing size. If a single number is provided, | ||
the same spacing is applied to all three dimensions (x,y,z). | ||
But the user can also provide a set of three spacings | ||
separated by commas, for example: 0.1,0.2,0.3.""", | ||
type=str, | ||
) | ||
p_sub.add_argument("hExtra", help="Length of the extended region", type=float) | ||
p_sub.add_argument("nExtra", help="Number of nodes of the extended region", type=int) | ||
p_sub.add_argument( | ||
"sym", | ||
help="""Normal for possible sym planes. | ||
Possible options are xmin, ymin, zmin, xmax, ymax, zmax. | ||
The user can also define a combination of them using commas, | ||
for example: zmin,zmax. This is useful to generate 1-cell wide | ||
meshes for 2D cases (remember to set dh to the span length | ||
(mesh width) and mgcycle to 0). | ||
""", | ||
type=str, | ||
) | ||
p_sub.add_argument("mgcycle", help="Minimum MG cycle to enforce", type=int) | ||
p_sub.add_argument("outFile", help="Name of output CGNS file") | ||
|
||
# ------------ Options for 'explicitCart' mode -------------------- | ||
p_sub = subparsers.add_parser("explicitCart", help="Generates a background cartesian mesh") | ||
p_sub.add_argument("xmin", type=float, help="min x coordinate") | ||
p_sub.add_argument("ymin", type=float, help="min y coordinate") | ||
p_sub.add_argument("zmin", type=float, help="min z coordinate") | ||
p_sub.add_argument("xmax", type=float, help="max x coordinate") | ||
p_sub.add_argument("ymax", type=float, help="max y coordinate") | ||
p_sub.add_argument("zmax", type=float, help="max z coordinate") | ||
p_sub.add_argument("dh", help="Uniform spacing size", type=float) | ||
p_sub.add_argument("hExtra", help="Extension in each dimension", type=float) | ||
p_sub.add_argument("nExtra", help="Number of nodes to use for extension", type=int) | ||
p_sub.add_argument("sym", help="Normal for possible sym plane", type=str) | ||
p_sub = subparsers.add_parser( | ||
"explicitCart", | ||
help="""Generates a background cartesian mesh containing two | ||
regions: one internal region with uniform spacing dh | ||
and an extended region where mesh sizes grow following | ||
a geometric progression. The internal region is | ||
defined by the x,y,z coordinates given as explicit arguments.""", | ||
formatter_class=argparse.RawTextHelpFormatter, | ||
) | ||
p_sub.add_argument("xmin", type=float, help="min x coordinate of the internal region") | ||
p_sub.add_argument("ymin", type=float, help="min y coordinate of the internal region") | ||
p_sub.add_argument("zmin", type=float, help="min z coordinate of the internal region") | ||
p_sub.add_argument("xmax", type=float, help="max x coordinate of the internal region") | ||
p_sub.add_argument("ymax", type=float, help="max y coordinate of the internal region") | ||
p_sub.add_argument("zmax", type=float, help="max z coordinate of the internal region") | ||
p_sub.add_argument( | ||
"dh", | ||
help="""Uniform spacing size. If a single number is provided, | ||
the same spacing is applied to all three dimensions (x,y,z). | ||
But the user can also provide a set of three spacings | ||
separated by commas, for example: 0.1,0.2,0.3.""", | ||
type=str, | ||
) | ||
p_sub.add_argument("hExtra", help="Length of the extended region", type=float) | ||
p_sub.add_argument("nExtra", help="Number of nodes of the extended region", type=int) | ||
p_sub.add_argument( | ||
"sym", | ||
help="""Normal for possible sym planes. | ||
Possible options are xmin, ymin, zmin, xmax, ymax, zmax. | ||
The user can also define a combination of them using commas, | ||
for example: zmin,zmax. This is useful to generate 1-cell wide | ||
meshes for 2D cases (remember to set dh to the span length | ||
(mesh width) and mgcycle to 0). | ||
""", | ||
type=str, | ||
) | ||
p_sub.add_argument("mgcycle", help="Minimum MG cycle to enforce", type=int) | ||
p_sub.add_argument("outFile", help="Name of output CGNS file") | ||
|
||
|
@@ -784,7 +834,18 @@ | |
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 | ||
# to define it as a string in arg_parser to avoid | ||
# issues with variable number of inputs. | ||
# (The user could give a single dh, or a set of three values) | ||
dh = list(map(float, args.dh.split(","))) | ||
if len(dh) == 1: | ||
dh = dh[0] | ||
|
||
# A similar procedure is necessary for the symmetry planes argument | ||
sym = args.sym.split(",") | ||
|
||
simpleCart(xMin, xMax, dh, args.hExtra, args.nExtra, sym, args.mgcycle, args.outFile) | ||
|
||
sys.exit(0) | ||
|
||
|
@@ -922,7 +983,18 @@ | |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
# to define it as a string in arg_parser to avoid | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of the new code here is a duplication from |
||
# issues with variable number of inputs. | ||
# (The user could give a single dh, or a set of three values) | ||
dh = list(map(float, args.dh.split(","))) | ||
if len(dh) == 1: | ||
dh = dh[0] | ||
|
||
# A similar procedure is necessary for the symmetry planes argument | ||
sym = args.sym.split(",") | ||
|
||
curGrid.simpleCart(dh, args.hExtra, args.nExtra, sym, args.mgcycle, args.outFile) | ||
sys.exit(0) | ||
|
||
elif args.mode == "translate": | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Comment mentions int, but the type casting below is float.