Add missing non-const BoundaryRegionIterBase::prev overload - #3484
Add missing non-const BoundaryRegionIterBase::prev overload#3484ZedThree wants to merge 5 commits into
BoundaryRegionIterBase::prev overload#3484Conversation
Missing non-const ref overload meant it was not possible to assign to `point.prev(f)`
|
Actually there's at least one other function missing and some functions duplicated between the base and derived classes. |
It might be beneficial to expose the
I think it would be best if they first go into next, together with #3482 |
`is_lower()` and `ind()` now defined solely in base class
The previous interface made it impossible to get the correct boundaries at the point of calling `Coordinates::getYBoundary`. This refactors that and `YBoundary` creation so that it can simply be specified with two bools `lower_y/upper_y`. Getting theses from `Options` is now taken care of by `Coordinates::getYBoundary`.
|
I'm still not convinced There's also another big pain point in the design: Instead I've refactored it to have two overloads: one that takes an We still only need to cache three |
I think the implementation of the sheath BC will tell. I am fine either way.
I do not understand. Why is it not sufficient? What control do you need? E.g. in #3483 I want to special handle sheath BCs. How do I do that with the new interface?
But that is super confusing. Sometimes the API means yup/ydown. Sometimes core/SOL.
But figuring out which values to pass is tricky (outside of unit tests). |
Just so everyone is on the same page, the current behaviour works like this:
So unless the Concretely, with this input file: [mesh]
lower_y = true
upper_y = trueit is not possible to turn off a single boundary condition at just one of the boundaries:
Even in the cases where this works, The behaviour in this PR works instead as follows:
Now, it will be possible to set up boundary conditions that can be toggled independently, while still falling back to a global input value. For example, one could have: [mesh]
lower_y = true
upper_y = true
[A]
lower_y = false
# use upper_y from [mesh]
[B]
# use !mesh:lower_y and !mesh:upper_y
# behaves like `not_sheath` previouslySo this PR gives us the most control while still a set of boundary conditions to be toggled together.
I mean, I agree, but this retains the existing behaviour. How do you think it should behave?
I'm not quite sure what you mean here. Parsing the options tree should be done during setup, and not during runtime (that is, not during I think the correct behaviour for any physics model is, in general, that a given component or numerical object (Laplacian solver, time solver, etc) should read from a specific individual section, with a fallback to a more generic section. So if a set of components should be linked together by default somehow, I would expect to see something like: Options& opt = options == nullptr ? Options::root()["mesh"] : *options;or lower_y = options["lower_y"].with_default(
Options::root()["mesh"]["lower_y"].with_default(false)
);The first one being a bit more idiomatic BOUT++.
Ah, I think you're saying that we read in either |
dschwoerer
left a comment
There was a problem hiding this comment.
Ah, thanks, I had indeed missed that the API with options was your preferred way of doing things now 👍
I do agree that that is a cleaner implementation, but only if the interfaces with the two bools are not used by user code. That should be an implementation detail.
It would help if you would update the documentation as well, I think that still refers to the YBndryType?
We should make sure that the Options API is used, and not the one passing in bools, as they are confusing to use.
| const bout::boundary::YBoundary& Coordinates::getYBoundary(bool lower_y, | ||
| bool upper_y) const { |
There was a problem hiding this comment.
I think this should be private.
The API naming is confusing, as it seems to talk about lower_y and upper_y, but that also might be inner_x / outer_x
There was a problem hiding this comment.
How about just lower/upper? Eventually, I'm hoping that something like this will be generic across all three dimensions, and so it will be good to have generic terminology
There was a problem hiding this comment.
I do not think that would work. lower_y / upper_y will always be in the SOL, at least in the common topologies I have seen. For FCI it is just different.
There was a problem hiding this comment.
I'm not sure what you mean. X and Y can have boundaries at either end, and Y may have more boundaries but these are still classified as either "lower" or "upper". FCI has parallel boundaries described as some combination of xin/xout and fwd/bwd; YBoundary operates over xin/xout.
Are you saying there are boundaries which could not be generically described as either lower or upper?
| class YBoundary { | ||
| public: | ||
| YBoundary(YBndryType type, Options* options_ptr, const Mesh& mesh); | ||
| YBoundary(const Mesh& mesh, bool lower_y, bool upper_y); |
There was a problem hiding this comment.
I think this should be private.
The API naming is confusing, as it seems to talk about lower_y and upper_y, but that also might be inner_x / outer_x
|
|
||
| namespace bout::boundary { | ||
| YBoundary::YBoundary(YBndryType type, Options* options_ptr, const Mesh& mesh) | ||
| YBoundary::YBoundary(const Mesh& mesh, bool lower_y, bool upper_y) |
There was a problem hiding this comment.
I think this should be private.
The API naming is confusing, as it seems to talk about lower_y and upper_y, but that also might be inner_x / outer_x
| dynamic_cast<FakeMesh*>(mesh)->createBoundaries(); | ||
| Field3D test = 1.0; | ||
| YBoundary sheath(YBndryType::all, nullptr, *mesh); | ||
| YBoundary sheath(*mesh, true, true); |
There was a problem hiding this comment.
I think this API should not be used (outside of unit tests, maybe)
Missing non-const ref overload meant it was not possible to assign to
point.prev(f)@dschwoerer Please can this go into the Hermes-3 BOUT++ update PR?