Skip to content

EB anisotropic meshes - changes for cut_face_2d routine #4554

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

Merged
merged 7 commits into from
Jul 13, 2025

Conversation

nataraj2
Copy link
Contributor

@nataraj2 nataraj2 commented Jul 7, 2025

This PR makes the necessary changes in the variables - areafrac, nx, ny, centx, centy, Sx2, Sy2, Sxy, in the cut_face_2d routine, for anisotropic meshes (ie. when mesh spacings are not equal). The derivation is in the attached pdf in the link below. The changes are in Eqns. 35-37, 43-44, 46-47, 49-50, 55-56.

EB_anisotropic.pdf

Summary

Additional background

Checklist

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • changes answers in the test suite to more than roundoff level
  • are likely to significantly affect the results of downstream AMReX users
  • include documentation in the code and/or rst files, if appropriate

@asalmgren
Copy link
Member

@nataraj2 @WeiqunZhang -- take a look at the calling sequences -- note in cut_faces_2d we have

Real axm, Real axp, Real aym, Real ayp, Real bcx, Real bcy, Real dxval, Real dyval)

The point being that for the areas, the bcs and the d*val, the "x" version always comes before the "y" version.

Look now at the calling sequences, e.g.

lzm,lzp,lym,lyp,bcy,bcz,dx[2],dx[1])

Note that Mahesh's changes match -- dx[2] comes before dx[1] and lzm comes before lym ... but bcy comes before bcz.

This seems wrong??

@WeiqunZhang
Copy link
Member

Yes, I agree with @asalmgren that the orders seem wrong. I think they should always be dx[i] following by dx[j], where i < j. That's how we order face centroids. For y-face centroid, component 0 is for x and 1 for z.

@WeiqunZhang
Copy link
Member

Other than the order of dx, LGTM.

We probably also want to fix Sx2, Sy2 and Sxy in the future. They are used in build_cells that does the least squares fit.

@WeiqunZhang
Copy link
Member

I don't think this is correct. Are you saying there is a bug even in the uniform size case?

@nataraj2
Copy link
Contributor Author

nataraj2 commented Jul 13, 2025

See image below for the terminology used in the cut_face_2d calls - from @WeiqunZhang

 cut_face_2d(apz(i,j,k),fcz(i,j,k,0),fcz(i,j,k,1), // NOLINT(readability-suspicious-call-argument)
                            m2z(i,j,k,0),m2z(i,j,k,1),m2z(i,j,k,2),
                            lym,lyp,lxm,lxp,bcx,bcy);

lym denotes axm and not aym. Hence, the ordering of the bcs are correct as they are and the dx ordering has been corrected as @WeiqunZhang commented above.
The second order moments Sx2, Sy2 and Sxy have been corrected for anisotropic meshes and the pdf attached in the very first comment of this PR has the derivations as well.

PXL_20250713_171220571

@asalmgren asalmgren self-requested a review July 13, 2025 18:18
@WeiqunZhang WeiqunZhang merged commit d84fe3d into AMReX-Codes:development Jul 13, 2025
75 checks passed
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