-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add unit test for LaplaceXZPetsc (3D metrics) #2207
Conversation
633d148
to
6823a38
Compare
Just rebased on top of the latest 3D metrics branch. @bshanahan please could you take a look at the forward operator? It's different from the version in the |
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.
Looks good to me. Thanks @ZedThree!
Did you forget to add the
|
Oops, good catch! Fiddling with the integrated test, I noticed it fails when using a more complicated geometry taken from another test:
which I think is because the forward operator used is: Field3D g = coord->g11 * D2DX2(f) + coord->g13 * D2DXDZ(f) + coord->g33 * D2DZ2(f); and I think this assumes Using this form in the unit test, with So I'm still not clear why the unit test is failing. I think the forward operator used: const auto AJ = A * coords->J;
const auto xx_coef = AJ * coords->g11;
const auto zz_coef = AJ * coords->g33;
const auto xz_coef = AJ * coords->g13;
const auto ddx_f = DDX(f);
const auto ddz_f = DDZ(f);
const auto xx = (DDX(xx_coef) * ddx_f) + (xx_coef * D2DX2(f));
const auto zz = (DDZ(zz_coef) * ddz_f) + (zz_coef * D2DZ2(f));
const auto xz = (DDX(xz_coef) * ddz_f) + (xz_coef * D2DXDZ(f));
const auto zx = (DDZ(xz_coef) * ddx_f) + (xz_coef * D2DXDZ(f));
auto result = ((xx + zz + xz + zx) / coords->J) + (B * f); reduces to the integrated test form (factor 2 in the cross-term? doesn't seem to make much difference removing |
If I remember right, On the unit test - if the forward operator is exactly correct, the grid size shouldn't matter. If it's a slightly different discretisation, then the coarse grid will make the errors large. |
Ah, that could very well be it. Is |
@ZedThree Yes I think so |
Naively setting the unit test forward operator to |
I think there might actually be a bug in // Note additional B*f term compared to existing implementation in integrated test
Field3D g_original_forward = coord->g11 * D2DX2(f) + coord->g13 * D2DXDZ(f) + coord->g33 * D2DZ2(f) + (B * f);
Field3D g_fv_forward = FV::Div_a_Laplace_perp(A, f) + (B * f);
Field3D g_full_forward = ((xx + zz + xz + zx) / coord->J) + (B * f);
Field3D g_cutdown_forward = ((xx_coef * D2DX2(f) + zz_coef * D2DZ2(f) + xz_coef * D2DXDZ(f)) / coord->J) + (B * f); Just removing Now here's the results of using
What I think this all means is that, yes, the finite volume operator is the correct forward operator, but there is at least one bug in either Setting the diagonal metric elements to scalars is not enough to make it fail, it looks like they need to spatially varying. Setting the off-diagonal components to arbitrary scalars in the input file is tricky, because the covariant terms can be negative. Looking at the code: That's probably about as far as I'm going to get, I think it needs someone who knows the operators better than me to investigate further. |
Reimplementing the integrated test in I think we might need a test with an analytic answer to work out where the issue is. |
It seems like the INVERT_SET and INVERT_RHS boundary conditions have identical code. Even if this isn't the bug, it means laplacexz-petsc needs closer review.
|
Yes, that's sensible. We know that there's an issue with either Closing this in favour of #2359 |
Geometry used was taken from boutproject/BOUT-dev#2207
Doesn't currently work, but I've probably messed up either the forward operator or the boundary conditions. Copied and stripped down from the 3D AMG unit test.