-
Notifications
You must be signed in to change notification settings - Fork 95
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
Fix Field3D::setBoundaryTo parallel boundary conditions #2962
base: next
Are you sure you want to change the base?
Changes from all commits
d9a2cf2
1aed8c5
3e5e8dd
c76446d
51e21b5
e5f5541
8726ba9
6d22c7d
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 |
---|---|---|
|
@@ -451,22 +451,88 @@ void Field3D::setBoundaryTo(const Field3D& f3d) { | |
|
||
allocate(); // Make sure data allocated | ||
|
||
/// Loop over boundary regions | ||
for (const auto& reg : fieldmesh->getBoundaries()) { | ||
/// Loop within each region | ||
for (reg->first(); !reg->isDone(); reg->next()) { | ||
for (int z = 0; z < nz; z++) { | ||
// Get value half-way between cells | ||
if (!fieldmesh->periodicX) { | ||
// X boundaries | ||
if (fieldmesh->firstX()) { | ||
for (int jy = fieldmesh->ystart; jy <= fieldmesh->yend; ++jy) { | ||
for (int jz = 0; jz < fieldmesh->LocalNz; jz++) { | ||
BoutReal const val = | ||
0.5 * (f3d(fieldmesh->xstart, jy, jz) + f3d(fieldmesh->xstart - 1, jy, jz)); | ||
0.5 * (f3d(fieldmesh->xstart, jy, jz) + f3d(fieldmesh->xstart - 1, jy, jz)); | ||
(*this)(fieldmesh->xstart - 1, jy, jz) = | ||
2. * val - (*this)(fieldmesh->xstart, jy, jz); | ||
} | ||
} | ||
} | ||
if (fieldmesh->lastX()) { | ||
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: use of undeclared identifier 'jy' [clang-diagnostic-error] BoutReal const val = 0.5 * (f3d(fieldmesh->xend, jy, jz) + f3d(fieldmesh->xend + 1, jy, jz));
^ 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: use of undeclared identifier 'jz' [clang-diagnostic-error] BoutReal const val = 0.5 * (f3d(fieldmesh->xend, jy, jz) + f3d(fieldmesh->xend + 1, jy, jz));
^ 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: use of undeclared identifier 'jy' [clang-diagnostic-error] BoutReal const val = 0.5 * (f3d(fieldmesh->xend, jy, jz) + f3d(fieldmesh->xend + 1, jy, jz));
^ 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: use of undeclared identifier 'jz' [clang-diagnostic-error] BoutReal const val = 0.5 * (f3d(fieldmesh->xend, jy, jz) + f3d(fieldmesh->xend + 1, jy, jz));
^ |
||
BoutReal const val = | ||
0.5 * (f3d(fieldmesh->xend, jy, jz) + f3d(fieldmesh->xend + 1, jy, jz)); | ||
for (int jz = 0; jz < fieldmesh->LocalNz; jz++) { | ||
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: use of undeclared identifier 'jy' [clang-diagnostic-error] 0.5 * (f3d(fieldmesh->xend, jy, jz) + f3d(fieldmesh->xend + 1, jy, jz));
^ 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: use of undeclared identifier 'jy' [clang-diagnostic-error] 0.5 * (f3d(fieldmesh->xend, jy, jz) + f3d(fieldmesh->xend + 1, jy, jz));
^ |
||
BoutReal val = | ||
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: use of undeclared identifier 'jy' [clang-diagnostic-error] (*this)(fieldmesh->xend + 1, jy, jz) =
^ |
||
0.5 * (f3d(reg->x, reg->y, z) + f3d(reg->x - reg->bx, reg->y - reg->by, z)); | ||
// Set to this value | ||
(*this)(reg->x, reg->y, z) = | ||
2. * val - (*this)(reg->x - reg->bx, reg->y - reg->by, z); | ||
0.5 * (f3d(fieldmesh->xend, jy, jz) + f3d(fieldmesh->xend + 1, jy, jz)); | ||
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: use of undeclared identifier 'jy' [clang-diagnostic-error] 2. * val - (*this)(fieldmesh->xend, jy, jz);
^ |
||
(*this)(fieldmesh->xend + 1, jy, jz) = | ||
2. * val - (*this)(fieldmesh->xend, jy, jz); | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Y boundaries | ||
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: expected unqualified-id [clang-diagnostic-error] if (f3d.hasParallelSlices()) {
^ |
||
|
||
if (f3d.hasParallelSlices()) { | ||
// Argument has parallel slices, so this field must as well. | ||
ASSERT1(hasParallelSlices()); | ||
|
||
for (auto& bndry : fieldmesh->getBoundariesPar()) { | ||
const Field3D& f3d_next = f3d.ynext(bndry->dir); | ||
Field3D& this_next = ynext(bndry->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: no member named 'z' in 'BoundaryRegionPar' [clang-diagnostic-error] const int z = bndry->z;
^ |
||
for (bndry->first(); !bndry->isDone(); bndry->next()) { | ||
const int x = bndry->x; | ||
const int y = bndry->y; | ||
const int z = bndry->z; | ||
BoutReal val = 0.5 * (f3d(x, y, z) + f3d_next(x, y + bndr->dir, z)); | ||
this_next(x, y + bndry->dir, z) = 2. * val - (*this)(x, y, z); | ||
} | ||
} | ||
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: expected unqualified-id [clang-diagnostic-error] } else {
^ |
||
|
||
} else { | ||
// Argument does not have parallel slices | ||
// Make sure that this field also doesn't have them because in that case | ||
// the parallel derivative operators would erroneously use parallel slices | ||
clearParallelSlices(); | ||
|
||
// Shift into field-aligned coordinates to apply Y boundary conditions. | ||
|
||
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 'r' is too short, expected at least 2 characters [readability-identifier-length] for (RangeIterator r = fieldmesh->iterateBndryLowerY(); !r.isDone(); r++) {
^ |
||
const Field3D f3d_fa = toFieldAligned(f3d); | ||
BoutReal const val = | ||
0.5 | ||
* (f3d_fa(r.ind, fieldmesh->ystart, jz) + f3d_fa(r.ind, fieldmesh->ystart - 1, jz)); | ||
|
||
for (RangeIterator r = fieldmesh->iterateBndryLowerY(); !r.isDone(); r++) { | ||
for (int jz = 0; jz < fieldmesh->LocalNz; jz++) { | ||
BoutReal val = 0.5 | ||
* (f3d_fa(r.ind, fieldmesh->ystart, jz) | ||
+ f3d_fa(r.ind, fieldmesh->ystart - 1, jz)); | ||
(*this)(r.ind, fieldmesh->ystart - 1, jz) = | ||
2. * val - (*this)(r.ind, fieldmesh->ystart, jz); | ||
} | ||
} | ||
|
||
for (RangeIterator r = fieldmesh->iterateBndryUpperY(); !r.isDone(); r++) { | ||
for (int jz = 0; jz < fieldmesh->LocalNz; jz++) { | ||
BoutReal val = | ||
0.5 | ||
* (f3d_fa(r.ind, fieldmesh->yend, jz) + f3d_fa(r.ind, fieldmesh->yend + 1, jz)); | ||
(*this)(r.ind, fieldmesh->yend + 1, jz) = | ||
2. * val - (*this)(r.ind, fieldmesh->yend, jz); | ||
} | ||
} | ||
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: extraneous closing brace ('}') [clang-diagnostic-error] }
^ |
||
|
||
(*this) = fromFieldAligned(*this); | ||
} | ||
} | ||
|
||
void Field3D::applyParallelBoundary() { | ||
|
||
TRACE("Field3D::applyParallelBoundary()"); | ||
|
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: expression result unused [clang-diagnostic-unused-value]