Add information about which cells have sheath boundaries - #3468
Conversation
… a yhigh or ylow sheath boundary
| } | ||
|
|
||
| const FieldMetric& cell_sheath_ylow() const { | ||
| if (_cell_sheath_ylow.has_value()) { |
There was a problem hiding this comment.
warning: use of undeclared identifier '_cell_sheath_ylow' [clang-diagnostic-error]
if (_cell_sheath_ylow.has_value()) {
^|
|
||
| const FieldMetric& cell_sheath_ylow() const { | ||
| if (_cell_sheath_ylow.has_value()) { | ||
| return *_cell_sheath_ylow; |
There was a problem hiding this comment.
warning: reference to non-static member function must be called [clang-diagnostic-error]
return *_cell_sheath_ylow;
^|
|
||
| const FieldMetric& cell_sheath_ylow() const { | ||
| if (_cell_sheath_ylow.has_value()) { | ||
| return *_cell_sheath_ylow; |
There was a problem hiding this comment.
warning: use of undeclared identifier '_cell_sheath_ylow'; did you mean 'cell_sheath_ylow'? [clang-diagnostic-error]
| return *_cell_sheath_ylow; | |
| return *cell_sheath_ylow; |
Additional context
include/bout/coordinates.hxx:302: 'cell_sheath_ylow' declared here
const FieldMetric& cell_sheath_ylow() {
^| return *_cell_sheath_ylow; | ||
| } | ||
| _determine_cell_sheath(); | ||
| ASSERT2(_cell_sheath_ylow.has_value()); |
There was a problem hiding this comment.
warning: use of undeclared identifier '_cell_sheath_ylow' [clang-diagnostic-error]
ASSERT2(_cell_sheath_ylow.has_value());
^| } | ||
| _determine_cell_sheath(); | ||
| ASSERT2(_cell_sheath_ylow.has_value()); | ||
| return *_cell_sheath_ylow; |
There was a problem hiding this comment.
warning: reference to non-static member function must be called [clang-diagnostic-error]
return *_cell_sheath_ylow;
^| _cell_area_zhigh.reset(); | ||
| _cell_volume.reset(); | ||
| _cell_sheath_yhigh.reset(); | ||
| _cell_sheath_ylow.reset(); |
There was a problem hiding this comment.
warning: use of undeclared identifier '_cell_sheath_ylow'; did you mean 'cell_sheath_ylow'? [clang-diagnostic-error]
| _cell_sheath_ylow.reset(); | |
| cell_sheath_ylow.reset(); |
Additional context
include/bout/coordinates.hxx:293: 'cell_sheath_ylow' declared here
const FieldMetric& cell_sheath_ylow() const {
^| BOUT_OMP_SAFE(critical) | ||
| { | ||
| if (!_cell_volume.has_value()) { | ||
| FieldMetric sheath_yhigh = 0.0; |
There was a problem hiding this comment.
warning: variable 'sheath_yhigh' of type 'FieldMetric' (aka 'Field2D') can be declared 'const' [misc-const-correctness]
| FieldMetric sheath_yhigh = 0.0; | |
| FieldMetric const sheath_yhigh = 0.0; |
| { | ||
| if (!_cell_volume.has_value()) { | ||
| FieldMetric sheath_yhigh = 0.0; | ||
| FieldMetric sheath_ylow = 0.0; |
There was a problem hiding this comment.
warning: variable 'sheath_ylow' of type 'FieldMetric' (aka 'Field2D') can be declared 'const' [misc-const-correctness]
| FieldMetric sheath_ylow = 0.0; | |
| FieldMetric const sheath_ylow = 0.0; |
| if (!_cell_volume.has_value()) { | ||
| FieldMetric sheath_yhigh = 0.0; | ||
| FieldMetric sheath_ylow = 0.0; | ||
| YBoundary sheathbndry(YBndryType::sheath, nullptr, *localmesh); |
There was a problem hiding this comment.
warning: variable 'sheathbndry' of type 'YBoundary' can be declared 'const' [misc-const-correctness]
| YBoundary sheathbndry(YBndryType::sheath, nullptr, *localmesh); | |
| YBoundary const sheathbndry(YBndryType::sheath, nullptr, *localmesh); |
| if (pnt.dir() > 0) { | ||
| sheath_yhigh[i] = 1; | ||
| } else { | ||
| heath_ylow[i] = 1; |
There was a problem hiding this comment.
warning: use of undeclared identifier 'heath_ylow'; did you mean 'sheath_ylow'? [clang-diagnostic-error]
| heath_ylow[i] = 1; | |
| sheath_ylow[i] = 1; |
Additional context
src/mesh/coordinates.cxx:1230: 'sheath_ylow' declared here
FieldMetric sheath_ylow = 0.0;
^| void Coordinates::_determine_cell_sheath() const { | ||
| BOUT_OMP_SAFE(critical) | ||
| { | ||
| if (!_cell_sheath_yhigh.has_value() || !_cell_sheath_ylow.has_value()) { |
There was a problem hiding this comment.
warning: use of undeclared identifier '_cell_sheath_ylow' [clang-diagnostic-error]
if (!_cell_sheath_yhigh.has_value() || !_cell_sheath_ylow.has_value()) {
^| } | ||
| } | ||
| } | ||
| _cell_sheath_yhigh.emplace(sheath_yhigh); |
There was a problem hiding this comment.
warning: expected ')' [clang-diagnostic-error]
_cell_sheath_yhigh.emplace(sheath_yhigh);
^Additional context
src/mesh/coordinates.cxx:1233: to match this '('
sheathbndry.iter([&](auto& pnt) {
^| void Coordinates::_determine_cell_sheath() const { | ||
| BOUT_OMP_SAFE(critical) | ||
| { | ||
| if (!_cell_sheath_yhigh.has_value() || !_cell_sheath_ylow.has_value()) { | ||
| FieldMetric sheath_yhigh = 0.0; | ||
| FieldMetric sheath_ylow = 0.0; | ||
| YBoundary sheathbndry(YBndryType::sheath, nullptr, *localmesh); | ||
|
|
||
| sheathbndry.iter([&](auto& pnt) { | ||
| const auto& i = pnt.ind(); | ||
| if (abs(pnt.offset()) == 1) { | ||
| if (pnt.dir() > 0) { | ||
| sheath_yhigh[i] = 1; | ||
| } else { | ||
| sheath_ylow[i] = 1; | ||
| } | ||
| } | ||
| }); | ||
| _cell_sheath_yhigh.emplace(sheath_yhigh); | ||
| _cell_sheath_ylow.emplace(sheath_ylow); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
I do not think we should duplicate the code from YBoundary.
Also, this prevents the user from configuring which y boundary actually is a sheath boundary.
I think it would be nicer if we would store a YBoundary object in coordinates, set it up properly, i.e. with an Options object passed in, and then have an API to get a shared_ptr to that YBoundary object.
Then we also do not need to duplicate the YBoundary API.
Also, I doubt we need to clear the cache in any case, I would not be aware that we allow to change any of the things in a mesh, which would make a recomputation of it necessary.
There was a problem hiding this comment.
I see, makes sense. So I can close this PR? Would you implement this? I am not sure what you mean with your suggestion.
|
Ah, it is already there, just the docs need fixing: #3469 |
Currently, there is no straight forward way in Fci to determine if a cell has adjacent parallel sheath boundaries inside operators. This prevents e.g. turning of parallel diffusion into the boundaries, as explained in
#3462
The goal of this PR is to add this information as a member of coordinates. This is then easily accessible inside operators and can be used to adjust the calculation if needed. This is also a first try, I am not sure if there is an easier to way do this.