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

Hermes-3 merges #1

Open
wants to merge 37 commits into
base: next
Choose a base branch
from
Open

Hermes-3 merges #1

wants to merge 37 commits into from

Conversation

mikekryjak
Copy link
Owner

@mikekryjak mikekryjak commented Jul 25, 2024

This is a Hermes-3 BOUT-dev merge to help with debugging a spurious slowdown in the nonlinear solves due to new, improved neutral transport equation flux limiter approach. The Hermes-3 PR for this work is here: mikekryjak/hermes-3#8

Merge of recent Next as of July 2024 with the CVODE modification to know when we're in a linear solve or not. This comes from this PR: boutproject#2932

And has further merges as per this latest commit: d7f88073f3ad707d624f8b9fed0a97a49596c542

I am also merging this with:

bendudson and others added 30 commits June 14, 2023 12:06
Enable 1D arrays of integers to be read from NetCDF files,
and made available via `Mesh::get()`. Mainly useful for
mesh construction.
When reading 1D vector of ints, check that the input is long enough,
and resize the output vector.
A short-term fix, allowing extra limiters to be added with inputs:

limiter_count : int
limiter_yinds : [int], length limiter_count
limiter_xstarts : [int], length limiter_count
limiter_xends : [int], length limiter_count

The limiter(s) are added between yinds[i] and yinds[i] + 1
Use the new track feature (better name required) to dump the different
components of the ddt() as well as the residuum for the evolved fields.
This keeps track of all the changes done to the field and stores them to
a OptionsObject.
This keeps track of all the changes done to the field and stores them to
a OptionsObject.
gcc 9.4 is unable to correctly parse the construction for the function
argument, if name.change is used directly. First making a copy seems to work
around that issue.
Copy link

@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

}

// Ensure that output variable has the correct size
var.resize(len);

Choose a reason for hiding this comment

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

warning: variable name 'it' is too short, expected at least 3 characters [readability-identifier-length]

  const auto* it = std::begin(full_var);
              ^

int limiter_count = 0;
Mesh::get(limiter_count, "limiter_count", 0);
if (limiter_count > 0) {
std::vector<int> limiter_yinds, limiter_xstarts, limiter_xends;

Choose a reason for hiding this comment

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

warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]

Suggested change
std::vector<int> limiter_yinds, limiter_xstarts, limiter_xends;
std::vector<int> limiter_yinds;
std::vector<int> limiter_xstarts;
std::vector<int> limiter_xends;

if (!source->get(this, limiter_xends, "limiter_xends", limiter_count)) {
throw BoutException("Couldn't read limiter_xend vector of length {} from mesh",
limiter_count);
}

Choose a reason for hiding this comment

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

warning: variable 'yind' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
}
int const yind = limiter_yinds[i];

throw BoutException("Couldn't read limiter_xend vector of length {} from mesh",
limiter_count);
}

Choose a reason for hiding this comment

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

warning: variable 'xstart' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int const xstart = limiter_xstarts[i];

limiter_count);
}

for (int i = 0; i < limiter_count; ++i) {

Choose a reason for hiding this comment

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

warning: variable 'xend' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
for (int i = 0; i < limiter_count; ++i) {
int const xend = limiter_xends[i];

Copy link
Owner Author

@mikekryjak mikekryjak left a comment

Choose a reason for hiding this comment

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

This one is just a merge of the automatic clang-format commits that desynced my local branch from the remote one.

Copy link

@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

template Options* Field3D::track<FieldPerp>(const FieldPerp&, std::string);

Options* Field3D::track(const BoutReal& change, std::string operation) {
if (tracking and tracking_state) {

Choose a reason for hiding this comment

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

warning: implicit conversion 'Options *' -> bool [readability-implicit-bool-conversion]

Suggested change
if (tracking and tracking_state) {
if ((tracking != nullptr) and tracking_state) {

template Options* Field3D::track<FieldPerp>(const FieldPerp&, std::string);

Options* Field3D::track(const BoutReal& change, std::string operation) {
if (tracking and tracking_state) {

Choose a reason for hiding this comment

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

warning: implicit conversion 'int' -> bool [readability-implicit-bool-conversion]

Suggested change
if (tracking and tracking_state) {
if (tracking and (tracking_state != 0)) {

// Ensure that output variable has the correct size
var.resize(len);

const auto* it = std::begin(full_var);

Choose a reason for hiding this comment

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

warning: variable name 'it' is too short, expected at least 3 characters [readability-identifier-length]

  const auto* it = std::begin(full_var);
              ^

}

for (int i = 0; i < limiter_count; ++i) {
int yind = limiter_yinds[i];

Choose a reason for hiding this comment

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

warning: variable 'yind' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int yind = limiter_yinds[i];
int const yind = limiter_yinds[i];


for (int i = 0; i < limiter_count; ++i) {
int yind = limiter_yinds[i];
int xstart = limiter_xstarts[i];

Choose a reason for hiding this comment

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

warning: variable 'xstart' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int xstart = limiter_xstarts[i];
int const xstart = limiter_xstarts[i];

.withDefault(false);

cvode_mem = CVodeMalloc(neq, solver_f, simtime, u, use_adam ? ADAMS : BDF, NEWTON, SS,
&reltol, &abstol, this, nullptr, optIn, iopt, ropt, machEnv);

Choose a reason for hiding this comment

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

warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]

                          &reltol, &abstol, this, nullptr, optIn, iopt, ropt, machEnv);
                                                                        ^

@@ -293,6 +358,54 @@ BoutReal PvodeSolver::run(BoutReal tout) {
// Check return flag
if (flag != SUCCESS) {
output_error.write("ERROR CVODE step failed, flag = {:d}\n", flag);
CVodeMemRec* cv_mem = (CVodeMem)cvode_mem;

Choose a reason for hiding this comment

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

warning: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]

    CVodeMemRec* cv_mem = (CVodeMem)cvode_mem;
                          ^

for (const auto& prefix : {"pre_"s, "residuum_"s}) {
std::vector<Field3D> list_of_fields{};
std::vector<bool> evolve_bndrys{};
for (const auto& f : f3d) {

Choose a reason for hiding this comment

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

warning: variable name 'f' is too short, expected at least 3 characters [readability-identifier-length]

          for (const auto& f : f3d) {
                           ^

prefix == "pre_"s ? udata : N_VDATA(cv_mem->cv_acor));
}

for (auto& f : f3d) {

Choose a reason for hiding this comment

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

warning: variable name 'f' is too short, expected at least 3 characters [readability-identifier-length]

        for (auto& f : f3d) {
                   ^

}
run_rhs(simtime);

for (auto& f : f3d) {

Choose a reason for hiding this comment

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

warning: variable name 'f' is too short, expected at least 3 characters [readability-identifier-length]

        for (auto& f : f3d) {
                   ^

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.

4 participants