Skip to content
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

SNB and InvertParDiv for nonuniform grids #2572

Merged
merged 10 commits into from
Jan 14, 2023
Merged

SNB and InvertParDiv for nonuniform grids #2572

merged 10 commits into from
Jan 14, 2023

Conversation

bendudson
Copy link
Contributor

SNB solver was giving incorrect fluxes on non-uniform grids because the InvertPar solver doesn't handle these consistently.

  • Added InvertParDeriv class that solves equations of the form A + Div_par(B Grad_par) similar to InvertPar which solves A + B Grad2_par2 + ....
  • Changed SNB solver to use the new InvertParDiv
  • Added a test to the SNB integrated test, checking heat fluxes on non-uniform grid

bendudson and others added 4 commits August 18, 2022 17:58
Solves `A + Div_par( B Grad_par )` in divergence form. Adapted from
`InvertPar` which uses `Grad2_par2 = Grad_par(Grad_par)` in
non-conservative form.
Enables the fluxes at the boundaries to be fixes to be the same as
the Spitzer-Harm calculation.
The integral of Div(Q) over the domain should be the same for SNB and
S-H methods, because the Neumann boundary conditions on H should
ensure this.
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

include/bout/invert_pardiv.hxx Outdated Show resolved Hide resolved
include/bout/invert_pardiv.hxx Show resolved Hide resolved
include/bout/invert_pardiv.hxx Outdated Show resolved Hide resolved
include/bout/invert_pardiv.hxx Outdated Show resolved Hide resolved
include/bout/invert_pardiv.hxx Show resolved Hide resolved
src/invert/pardiv/impls/cyclic/pardiv_cyclic.hxx Outdated Show resolved Hide resolved
src/invert/pardiv/invert_pardiv.cxx Outdated Show resolved Hide resolved
tests/integrated/test-snb/test_snb.cxx Outdated Show resolved Hide resolved
bendudson and others added 2 commits August 19, 2022 12:55
Runs in open domain with boundaries, checking that the boundary
fluxes are the same for SH and SNB calculations even with non-uniform mesh.
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

tests/integrated/test-snb/test_snb.cxx Show resolved Hide resolved
tests/integrated/test-snb/test_snb.cxx Show resolved Hide resolved
Strangely, changing calculation of dy, J from float to double makes
difference between SNB and SH heat fluxes larger.
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

tests/integrated/test-snb/test_snb.cxx Show resolved Hide resolved
Forgot to add, so wouldn't be compiled in Autotools build
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
ZedThree
ZedThree previously approved these changes Aug 31, 2022
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions


if (closed) {
// Twist-shift
int rank;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'rank' is not initialized [cppcoreguidelines-init-variables]

Suggested change
int rank;
int rank = 0;

if (closed) {
// Twist-shift
int rank;
int np;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'np' is not initialized [cppcoreguidelines-init-variables]

Suggested change
int np;
int np = 0;

@ZedThree ZedThree added this to the BOUT-6.0 milestone Sep 14, 2022
@mikekryjak
Copy link

Tested on SD1D in 1D:
The current state of this branch hugely improves energy conservation on a non-uniform grid, but there is still an unphysically sharp temperature gradient in the final few cells. The scale of this seems proportional to the cell size (by eye). The size of this gradient was as much as half of the total upstream temperature (i.e. the upstream temperature becomes double what is expected) which drops over only a handful of cells.

The behaviour disappears when using a uniform grid.

@bendudson bendudson merged commit 23af1b8 into next Jan 14, 2023
@bendudson bendudson deleted the snb-nonuniform branch January 14, 2023 21:00
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.

None yet

3 participants