-
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?
Changes from all commits
c4d6a76
9415f44
4b93a8f
24516e9
d3491fe
168f9be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -691,10 +691,10 @@ | |
print("Running Cartesian grid generator") | ||
|
||
# Preallocate arrays | ||
extensions = np.zeros((2, 3), order="F") | ||
nNodes = np.zeros(3, order="F") | ||
weightGR = np.zeros(3, order="F") | ||
numBins = np.zeros(3, order="F") | ||
extensions = np.zeros((2, 3), dtype=float) | ||
nNodes = np.zeros(3, dtype=int) | ||
weightGR = np.zeros(3, dtype=float) | ||
numBins = np.zeros(3, dtype=int) | ||
|
||
# Read four lines of the cartesian specs file | ||
with open(cartFile, "r") as f: | ||
|
@@ -844,8 +844,7 @@ | |
# Define tangent bunching law | ||
def tanDist(Sp1, Sp2, N): | ||
""" | ||
This is the tangential spacing developed by Ney Secco. | ||
This bunching law is coarse at the ends and fine at the middle | ||
The tangential spacing is coarse at the ends and fine at the middle | ||
of the interval, just like shown below: | ||
| | | | || | | | | | ||
|
||
|
@@ -988,7 +987,8 @@ | |
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))) | ||
# Note that ~ is an inverse operation (eqv. to np.invert) inverting the boolean array | ||
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 commentThe 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 commentThe 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 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. 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 commentThe 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 |
||
bolEdges = E[bol] | ||
# print bol | ||
# Compute edge mismatch and increment variable | ||
|
@@ -1013,7 +1013,10 @@ | |
|
||
# Optimize | ||
res = minimize( | ||
func, x_start, method="Nelder-Mead", options={"maxiter": 2000, "disp": True, "xtol": 1e-8, "ftol": 1e-8} | ||
func, | ||
x_start, | ||
method="Nelder-Mead", | ||
options={"maxiter": 2000, "disp": True, "xatol": 1e-8, "fatol": 1e-8}, | ||
) | ||
|
||
# Split variables | ||
|
@@ -1042,15 +1045,15 @@ | |
if nNodes[0] > 3: | ||
gx = max((Sx[1] - Sx[0]) / (Sx[2] - Sx[1]), (Sx[-1] - Sx[-2]) / (Sx[-2] - Sx[-3])) | ||
else: | ||
gx = None | ||
gx = 0.0 | ||
if nNodes[1] > 3: | ||
gy = max((Sy[1] - Sy[0]) / (Sy[2] - Sy[1]), (Sy[-1] - Sy[-2]) / (Sy[-2] - Sy[-3])) | ||
else: | ||
gy = None | ||
gy = 0.0 | ||
if nNodes[2] > 3: | ||
gz = max((Sz[1] - Sz[0]) / (Sz[2] - Sz[1]), (Sz[-1] - Sz[-2]) / (Sz[-2] - Sz[-3])) | ||
else: | ||
gz = None | ||
gz = 0.0 | ||
|
||
# Print growth ratios | ||
print("") | ||
|
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.