-
Notifications
You must be signed in to change notification settings - Fork 18
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
Nonorthogonal with minimal differential operators MMS test. #285
base: master
Are you sure you want to change the base?
Conversation
A version of FV::Div_a_Grad_perp that includes all metric components, including g12 (X-Y non-orthogonal) and g13 (X-Z nonorthogonal) terms. Aim to test and then merge upstream into BOUT++
Testing, using operator that includes nonorthogonal mesh corrections
…ile as this causes problems when loading from xbout.
…re descriptive name.
… order with fit function, add comments.
… x y z coordinates instead of R Z.
…sults yet provided.
…g sympy for maximum flexibility.
…ement with try, except block.
… of convergence for orthogonal grid operator with a simple metric constant in x, y, z.
…erators implemented for orthogonal and nonorthogonal grids.
…st master version of xBOUT.
Can you either change this PR to go into master or open a new one that goes into master: Like this it is hard to see the changes you introduced. Unfortunately I cannot do that, as I am not a collaborator :-( |
Changed base to master in response to @dschwoerer's review. Making master the base obscures slightly the changes made in |
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.
Amazing work. Thanks @mrhardman !
BoutReal BOUTMIN(const BoutReal& a, const BoutReal& b, const BoutReal& c, | ||
const BoutReal& d) { |
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.
BoutReal BOUTMIN(const BoutReal& a, const BoutReal& b, const BoutReal& c, | |
const BoutReal& d) { | |
BoutReal BOUTMIN(const BoutReal a, const BoutReal b, const BoutReal c, | |
const BoutReal d) { |
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.
This seems orthogonal to this PR -- can you please explain what the suggested change does here? I don't know for sure whether or not this line is covered by a test.
BoutReal r1 = (a < b) ? a : b; | ||
BoutReal r2 = (c < d) ? c : d; | ||
return (r1 < r2) ? r1 : r2; |
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.
Which I think should be equivalent to
BoutReal r1 = (a < b) ? a : b; | |
BoutReal r2 = (c < d) ? c : d; | |
return (r1 < r2) ? r1 : r2; | |
return std::min({a, b, c, d}); |
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.
This seems orthogonal to this PR -- can you please explain what the suggested change does here? I don't know for sure whether or not this line is covered by a test.
aup = a.yup(); | ||
adown = a.ydown(); | ||
|
||
mesh->communicate(fddx_xhigh); |
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.
Note that this does not work for fci.
for fci the right thing would be to do the above calculation also for the parallel slices.
mesh->communicate(fddx_xhigh); | |
if (f.isFci()) { | |
throw BoutException("This is not implemented for FCI.\n" | |
"The above calculation needs to be done for the parallel slices as well"); | |
} | |
mesh->communicate(fddx_xhigh); |
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.
f.isFci()
appears not be be a valid call in this branch, errors appear on compilation. Could you please make a PR into this PR with valid changes?
for (int i = mesh->xstart - 1; i <= mesh->xend; i++) { | ||
for (int j = mesh->ystart; j <= mesh->yend; j++) { | ||
for (int k = 0; k < mesh->LocalNz; k++) { | ||
// Calculate flux from i to i+1 | ||
|
||
const int kp = (k + 1) % mesh->LocalNz; | ||
const int km = (k - 1 + mesh->LocalNz) % mesh->LocalNz; |
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.
same as above
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.
Can you please be more specific with a code suggestion? I do not understand the code-base well enough to guess what you mean here.
David Bold correction making sure appropriate error message is present if FCI is used. Co-authored-by: David Bold <[email protected]>
Co-authored-by: David Bold <[email protected]>
…b.com/bendudson/hermes-3 into nonorthogonal-divops-mms-test-minimal
This reverts commit ca23fb9.
@dschwoerer Could you please make a PR with your suggestions into this PR? It looks like some of the functions that you expect to be available are not. |
Fixes to the
Div_a_Grad_perp_nonorthog(a, f)
operator (commit 3d11cb7, commit 2e5e827), merge with master, and new automatic tests integrated withctest
showing a correct implementation. Theses tests arehermes-3/tests/mms/orthogonal_test.py
andhermes-3/tests/mms/nonorthogonal_test.py
, and may be run interactively by, e.g.,or
These tests can be readily extended to test new nonorthogonal operators and the other existing operators in the Hermes-3 code base.
See
/hermes-3/tests/mmsREADME.md
for some documentation. Comments and requests appreciated.Thanks to @dschwoerer for providing an initial MMS test to develop. Thanks to @johnomotani for numerous suggestions and bugfixes.
Below is the plot output from the tests, showing the error (blue), the expected (orange), and the fit of the error (green). Increase the range of$\Delta$ by increasing $N_x = N_y = N_z$ , the cost of the test rapidly increases with
ntest
in thetest_input
dictionary inhermes-3/tests/mms/orthogonal_test.py
andhermes-3/tests/mms/nonorthogonal_test.py
. Note that since the number of grid pointsntest
.FV::Div_a_Grad_perp(a, f)
with orthogonal metricDiv_a_Grad_perp_nonorthog(a, f)
with orthogonal metricDiv_a_Grad_perp_nonorthog(a, f)
with nonorthogonal metric