-
Notifications
You must be signed in to change notification settings - Fork 96
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
Do things automatically for FCI #3004
base: next
Are you sure you want to change the base?
Changes from 91 commits
3583476
4ec74ef
d096020
d2a81bf
ea5640f
089ddfa
de7d1de
8a1c230
8234ccf
9525e2c
b62082c
e147bc5
62d5bbe
5c32415
a4a28c6
0e28dc1
66bde04
adba877
cbaf894
5673f0c
9149bf4
a088700
32ea2fd
faac69c
0ee0d07
49cd985
4566405
4935742
01a436c
147a872
cee68f2
15aaa05
eba722b
30ea7e3
66ff716
10d320f
4b05708
60224e4
608bb5d
88741c5
09f609b
d46efba
1fb921e
4a79fb4
b5bd5f0
6819718
fa357c1
ca59edb
8b1fbba
23d309f
4bbd9ba
4fac018
29a195f
4ee8630
2e216be
faa1046
414247b
6ba17ed
b319807
b814c9b
1260730
4a6fdba
0aca4a5
413e54f
d5d7c6a
652be61
7d48dbd
59cd39d
127fc9a
9b68bf2
052e735
d6ddf3b
9fd8aa8
44084cc
81dcc62
fa27812
175f8d7
f189d4f
697c89e
2b47ecd
78611d0
0149bd0
a307426
cd288e9
003c466
089baa8
992681d
1d6ecb0
a63ecfc
2d9d524
7aa8d01
25fe475
255eccb
c69bff5
1505840
ae578be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,117 @@ | ||||||
#pragma once | ||||||
|
||||||
#include "bout/mesh.hxx" | ||||||
#include "bout/sys/parallel_stencils.hxx" | ||||||
#include "bout/sys/range.hxx" | ||||||
|
||||||
class BoundaryRegionIter { | ||||||
public: | ||||||
BoundaryRegionIter(int x, int y, int bx, int by, Mesh* mesh) | ||||||
dschwoerer marked this conversation as resolved.
Show resolved
Hide resolved
dschwoerer marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
: dir(bx + by), x(x), y(y), bx(bx), by(by), localmesh(mesh) { | ||||||
ASSERT3(bx * by == 0); | ||||||
} | ||||||
bool operator!=(const BoundaryRegionIter& rhs) { return ind() != rhs.ind(); } | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: method 'operator!=' can be made const [readability-make-member-function-const]
Suggested change
|
||||||
|
||||||
Ind3D ind() const { return xyz2ind(x, y, z); } | ||||||
BoundaryRegionIter& operator++() { | ||||||
ASSERT3(z < nz()); | ||||||
z++; | ||||||
if (z == nz()) { | ||||||
z = 0; | ||||||
_next(); | ||||||
} | ||||||
return *this; | ||||||
} | ||||||
virtual void _next() = 0; | ||||||
BoundaryRegionIter& operator*() { return *this; } | ||||||
|
||||||
void dirichlet_o2(Field3D& f, BoutReal value) const { | ||||||
ynext(f) = parallel_stencil::dirichlet_o2(1, f[ind()], 0.5, value); | ||||||
} | ||||||
|
||||||
BoutReal extrapolate_grad_o2(const Field3D& f) const { return f[ind()] - yprev(f); } | ||||||
|
||||||
BoutReal extrapolate_sheath_o2(const Field3D& f) const { | ||||||
return (f[ind()] * 3 - yprev(f)) * 0.5; | ||||||
} | ||||||
|
||||||
BoutReal extrapolate_next_o2(const Field3D& f) const { return 2 * f[ind()] - yprev(f); } | ||||||
|
||||||
BoutReal | ||||||
extrapolate_next_o2(const std::function<BoutReal(int yoffset, Ind3D ind)>& f) const { | ||||||
return 2 * f(0, ind()) - f(0, ind().yp(-by).xp(-bx)); | ||||||
} | ||||||
|
||||||
BoutReal interpolate_sheath(const Field3D& f) const { | ||||||
return (f[ind()] + ynext(f)) * 0.5; | ||||||
} | ||||||
|
||||||
BoutReal& ynext(Field3D& f) const { return f[ind().yp(by).xp(bx)]; } | ||||||
const BoutReal& ynext(const Field3D& f) const { return f[ind().yp(by).xp(bx)]; } | ||||||
BoutReal& yprev(Field3D& f) const { return f[ind().yp(-by).xp(-bx)]; } | ||||||
const BoutReal& yprev(const Field3D& f) const { return f[ind().yp(-by).xp(-bx)]; } | ||||||
|
||||||
const int dir; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: member 'dir' of type 'const int' is const qualified [cppcoreguidelines-avoid-const-or-ref-data-members] const int dir;
^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: member variable 'dir' has public visibility [cppcoreguidelines-non-private-member-variables-in-classes] const int dir;
^ |
||||||
|
||||||
protected: | ||||||
int z{0}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: member variable 'z' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] int z{0};
^ |
||||||
int x; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: member variable 'x' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] int x;
^ |
||||||
int y; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: member variable 'y' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] int y;
^ |
||||||
const int bx; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: member 'bx' of type 'const int' is const qualified [cppcoreguidelines-avoid-const-or-ref-data-members] const int bx;
^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: member variable 'bx' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] const int bx;
^ |
||||||
const int by; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: member 'by' of type 'const int' is const qualified [cppcoreguidelines-avoid-const-or-ref-data-members] const int by;
^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: member variable 'by' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes] const int by;
^ |
||||||
|
||||||
private: | ||||||
Mesh* localmesh; | ||||||
int nx() const { return localmesh->LocalNx; } | ||||||
int ny() const { return localmesh->LocalNy; } | ||||||
int nz() const { return localmesh->LocalNz; } | ||||||
|
||||||
Ind3D xyz2ind(int x, int y, int z) const { | ||||||
return Ind3D{(x * ny() + y) * nz() + z, ny(), nz()}; | ||||||
} | ||||||
}; | ||||||
|
||||||
class BoundaryRegionIterY : public BoundaryRegionIter { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: destructor of 'BoundaryRegionIterY' is public and non-virtual [cppcoreguidelines-virtual-class-destructor] class BoundaryRegionIterY : public BoundaryRegionIter {
^ Additional contextinclude/bout/boundary_iterator.hxx:73: make it public and virtual class BoundaryRegionIterY : public BoundaryRegionIter {
^ |
||||||
public: | ||||||
BoundaryRegionIterY(RangeIterator r, int y, int dir, bool is_end, Mesh* mesh) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: the parameter 'r' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: parameter name 'r' is too short, expected at least 3 characters [readability-identifier-length] BoundaryRegionIterY(RangeIterator r, int y, int dir, bool is_end, Mesh* mesh)
^ |
||||||
: BoundaryRegionIter(r.ind, y, 0, dir, mesh), r(r), is_end(is_end) {} | ||||||
|
||||||
bool operator!=(const BoundaryRegionIterY& rhs) { | ||||||
ASSERT2(y == rhs.y); | ||||||
if (is_end) { | ||||||
if (rhs.is_end) { | ||||||
return false; | ||||||
} | ||||||
return !rhs.r.isDone(); | ||||||
} | ||||||
if (rhs.is_end) { | ||||||
return !r.isDone(); | ||||||
} | ||||||
return x != rhs.x; | ||||||
} | ||||||
|
||||||
virtual void _next() override { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: 'virtual' is redundant since the function is already declared 'override' [cppcoreguidelines-explicit-virtual-functions]
Suggested change
|
||||||
++r; | ||||||
x = r.ind; | ||||||
} | ||||||
|
||||||
private: | ||||||
RangeIterator r; | ||||||
bool is_end; | ||||||
}; | ||||||
|
||||||
class NewBoundaryRegionY { | ||||||
public: | ||||||
NewBoundaryRegionY(Mesh* mesh, bool lower, RangeIterator r) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: the parameter 'r' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: parameter name 'r' is too short, expected at least 3 characters [readability-identifier-length] NewBoundaryRegionY(Mesh* mesh, bool lower, RangeIterator r)
^ |
||||||
: mesh(mesh), lower(lower), r(std::move(r)) {} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg]
Suggested change
|
||||||
BoundaryRegionIterY begin(bool begin = true) { | ||||||
return BoundaryRegionIterY(r, lower ? mesh->ystart : mesh->yend, lower ? -1 : +1, | ||||||
!begin, mesh); | ||||||
} | ||||||
BoundaryRegionIterY end() { return begin(false); } | ||||||
|
||||||
private: | ||||||
Mesh* mesh; | ||||||
bool lower; | ||||||
RangeIterator r; | ||||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,8 @@ public: | |
|
||
std::string name; | ||
|
||
bool isFci() const; | ||
|
||
#if CHECK > 0 | ||
// Routines to test guard/boundary cells set | ||
|
||
|
@@ -677,7 +679,27 @@ inline T floor(const T& var, BoutReal f, const std::string& rgn = "RGN_ALL") { | |
result[d] = f; | ||
} | ||
} | ||
|
||
if constexpr (bout::utils::is_Field3D<T>()) { | ||
#if BOUT_USE_FCI_AUTOMAGIC | ||
if (var.isFci()) { | ||
for (size_t i = 0; i < result.numberParallelSlices(); ++i) { | ||
BOUT_FOR(d, result.yup(i).getRegion(rgn)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: loop variable name 'd' is too short, expected at least 2 characters [readability-identifier-length] {
^ |
||
if (result.yup(i)[d] < f) { | ||
result.yup(i)[d] = f; | ||
} | ||
} | ||
BOUT_FOR(d, result.ydown(i).getRegion(rgn)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: loop variable name 'd' is too short, expected at least 2 characters [readability-identifier-length] }
^ |
||
if (result.ydown(i)[d] < f) { | ||
result.ydown(i)[d] = f; | ||
} | ||
} | ||
} | ||
} else | ||
#endif | ||
{ | ||
result.clearParallelSlices(); | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -135,8 +135,11 @@ public: | |||||
return *this; | ||||||
} | ||||||
|
||||||
/// Check if this field has yup and ydown fields | ||||||
/// Dummy functions to increase portability | ||||||
bool hasParallelSlices() const { return true; } | ||||||
void calcParallelSlices() const {} | ||||||
void clearParallelSlices() {} | ||||||
int numberParallelSlices() { return 0; } | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: method 'numberParallelSlices' can be made static [readability-convert-member-functions-to-static]
Suggested change
|
||||||
|
||||||
Field2D& yup(std::vector<Field2D>::size_type UNUSED(index) = 0) { return *this; } | ||||||
const Field2D& yup(std::vector<Field2D>::size_type UNUSED(index) = 0) const { | ||||||
|
@@ -280,7 +283,7 @@ public: | |||||
|
||||||
friend void swap(Field2D& first, Field2D& second) noexcept; | ||||||
|
||||||
int size() const override { return nx * ny; }; | ||||||
int size() const override { return nx * ny; } | ||||||
|
||||||
private: | ||||||
/// Internal data array. Handles allocation/freeing of memory | ||||||
|
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.
warning: destructor of 'BoundaryRegionIter' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
Additional context
include/bout/boundary_iterator.hxx:6: make it public and virtual