Skip to content

Conversation

@bendudson
Copy link
Contributor

@bendudson bendudson commented Oct 3, 2025

Provides a variable "periodicY" that is 1 in the core and 0 outside.

This at least partly addresses #3171 by allowing input functions that distinguish core and PF regions.

Opinions on the name? @mikekryjak 's suggestion of is_periodic is good; periodicY is the name of the Mesh function that's used internally. Checks for periodicity in X or Z might also make sense in some cases.

Tests incoming...

bendudson and others added 2 commits October 3, 2025 09:39
Provides a variable "periodicY" that is 1 in the core and 0 outside.
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

addGenerator("where", std::make_shared<FieldWhere>(nullptr, nullptr, nullptr));

// Periodic in the Y direction?
addGenerator("periodicY", std::make_shared<FieldPeriodicY>(nullptr));
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::make_shared" is directly included [misc-include-cleaner]

                                  ^

FieldPeriodicY(Mesh* mesh) : mesh(mesh) {
// Note: Assumes symmetricGlobalX
local_inner_boundary =
0.5 * (mesh->GlobalX(mesh->xstart - 1) + mesh->GlobalX(mesh->xstart));
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 'local_inner_boundary' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

src/field/fieldgenerators.hxx:357:

-   FieldPeriodicY(Mesh* mesh) : mesh(mesh) {
+   FieldPeriodicY(Mesh* mesh) : mesh(mesh), local_inner_boundary(0.5 * (mesh->GlobalX(mesh->xstart - 1) + mesh->GlobalX(mesh->xstart))) {
Suggested change
0.5 * (mesh->GlobalX(mesh->xstart - 1) + mesh->GlobalX(mesh->xstart));

local_inner_boundary =
0.5 * (mesh->GlobalX(mesh->xstart - 1) + mesh->GlobalX(mesh->xstart));
local_outer_boundary =
0.5 * (mesh->GlobalX(mesh->xend + 1) + mesh->GlobalX(mesh->xend));
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 'local_outer_boundary' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

src/field/fieldgenerators.hxx:357:

-   FieldPeriodicY(Mesh* mesh) : mesh(mesh) {
+   FieldPeriodicY(Mesh* mesh) : mesh(mesh), local_outer_boundary(0.5 * (mesh->GlobalX(mesh->xend + 1) + mesh->GlobalX(mesh->xend))) {
Suggested change
0.5 * (mesh->GlobalX(mesh->xend + 1) + mesh->GlobalX(mesh->xend));

return std::make_shared<FieldPeriodicY>(ctx.getMesh());
}
BoutReal generate(const bout::generator::Context& ctx) override {
int local_index = mesh->xstart
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 'local_index' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int local_index = mesh->xstart
int const local_index = mesh->xstart

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

public:
FieldPeriodicY() = default;
FieldGeneratorPtr clone(const std::list<FieldGeneratorPtr> UNUSED(args)) override {
return std::make_shared<FieldPeriodicY>();
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: no header providing "std::make_shared" is directly included [misc-include-cleaner]

    return std::make_shared<FieldPeriodicY>();
                ^

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.

2 participants