-
Notifications
You must be signed in to change notification settings - Fork 199
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
MultiFabRegister: throw
in get
#5356
Conversation
Throw a runtime exception instead of returning a `nullptr` if a field is requested via the getter.
cb253dd
to
2c2f48c
Compare
throw
in getthrow
in get
Discussed with @RemiLehe offline: The functions We will try to add to |
This is the only CI failure left after fb0dc3c:
I pushed 57e8e22 to try to fix the test. |
throw
in getthrow
in get
CI is green now and the PR is ready for review. |
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.
Excellent! Just a small Doxygen update needed and a few ideas for later improvements.
@@ -1298,16 +1298,16 @@ PML::PushPSATD (ablastr::fields::MultiFabRegister& fields, const int lev) | |||
{ | |||
ablastr::fields::VectorField pml_E_fp = fields.get_alldirs(FieldType::pml_E_fp, lev); | |||
ablastr::fields::VectorField pml_B_fp = fields.get_alldirs(FieldType::pml_B_fp, lev); | |||
ablastr::fields::ScalarField pml_F_fp = fields.get(FieldType::pml_F_fp, lev); | |||
ablastr::fields::ScalarField pml_G_fp = fields.get(FieldType::pml_G_fp, lev); | |||
ablastr::fields::ScalarField pml_F_fp = (fields.has(FieldType::pml_F_fp, lev)) ? fields.get(FieldType::pml_F_fp, lev) : nullptr; |
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.
hehe, that's one way to quickly get the behavior in without changing downstream :D okok, nice idea and we can make this more robust later.
field_on_level.push_back(internal_get(name, lvl)); | ||
if (lvl == 0 && skip_level_0) | ||
{ | ||
field_on_level.push_back(nullptr); |
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.
Is pushing back a nullptr
the clean approach or not pushing back anything (skip
might imply either).
Then on the other hand, I assume if we move the level indexing on skip
that can cause a lot of confusion, too (one argument to not use a Vector
for the list of pointers.)
Thus, ok for me to keep as you suggest for now.
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.
Thanks for reviewing my changes.
Yes, in some corner cases (e.g., F in the PML) I just pushed the issue to the next "layer". Those were changes that date back to last year, I might have been unsure about how to resolve those at the time.
I'll approve on my end and let @roelof-groenewald or @lucafedeli88 chime in further.
I would make sure that people have enough time to look at this PR and double check the changes, since they are not trivial.
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.
The changes are fine, but I wonder if we can rename the skip_level_0
variable to something else, maybe skip_level_0_for_coarse_patch
. The reason I say that is if someone reads the code in the future, seeing just skip_level_0 = true
, in something like ComputeSpaceChargeField()
it could seem like the potential is not calculated for level 0 at all. Does that make sense?
Thanks, @roelof-groenewald. I renamed the variable to |
I think renaming in the usage "usage" code constants to In the (Alternatively, do not add the new arg to the API at all and instead in user-code zero-out the 0-level coarse patch component on your |
Thanks, @ax3l. My bad, I went through the renaming too fast. I agree that it would make sense to use two different names. As for this,
I think I don't understand the suggestion. The reason for introducing the variable was that we have two methods, |
Perfect. Per last suggestion: oh yes, you are absolutely right that would not work 😂 ok, yes since this applies actually to all our cp, let's have it in the API (with the name back to the original). |
Close #5319
Follow-up to #5230
nullptr
if a field is requested via the getter.