-
Notifications
You must be signed in to change notification settings - Fork 33
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
Make fluxes separate variables #1043
Conversation
…block-orientation
…block-orientation
Ah, fair enough, I didn't consider that the memory would be the same for face field/edge flux variables anyway. Re: ghosts, sometimes KHARMA fills EMFs to the last ghost edges of domain boundaries, and expects a consistent face value, for e.g. preparing Dirichlet/frozen boundary conditions. But, this should be fine since the edge and face variables will both be (N+1)^3. I'm not aware of anyone requiring the last face value of any face-centered variable which could conceivably be marked a flux. So I guess the concern is purely aesthetic, and in any case non-blocking. |
@Yurlungur: Some documentation added/fixed to be consistent. |
The issue with the Because fluxes are now variables, a change to how The issue in Riot was that a |
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.
Nice cleanup!
I just got a couple of interface/doc comments -- nothing big.
@@ -265,8 +265,7 @@ TaskStatus CalculateFluxes(MeshBlockData<Real> *mbd) { | |||
|
|||
auto advected = mbd->Get("advected").data; | |||
|
|||
auto x1flux = mbd->Get("advected").flux[X1DIR].Get<4>(); | |||
|
|||
parthenon::ParArray4D<Real> x1flux = mbd->Get("bnd_flux::advected").data.Get(1, 0, 0); |
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.
This should be Get(0,0,0)
doesn't it?
And if so, what's this test doing if it passes when using the wrong fluxes?
Separately, (along with @Yurlungur similar comment on Get
below), what about a more intuitive interface like
GetFlux(varname, direction) that hides the flux name and extra 0
indices?
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.
Yes, it is disturbing that this test passes with that bug. I am not really sure what it is supposed to be doing though...
The Get
function called here is really ParArrayGeneric::Get(Args... args)
, so I don't think we can reasonably make a flux based overload. I don't think we really need to support it from MeshBlockData
either, since I don't think we want to encourage the pattern that is used here (variables should be accessed through packs rather than pulling out raw ParArray
s directly from MeshBlockData
). That being said, I agree that the ParArrayGeneric::Get
interface is a bit confusing and should possibly be changed. That is for another time though I think...
TaskID AddFluxCorrectionTasks(TaskID dependency, TaskList &tl, | ||
std::shared_ptr<MeshData<Real>> &md, bool multilevel) { | ||
if (!multilevel) return dependency; |
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.
I see how this makes the code path in the driver cleaner (wrt to dependencies) but somehow passing a variable in and just use it to immediately return feels odd (just commenting, not saying this should change).
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.
I tend to like this better than not taking multilevel
as an argument and having people include
auto flx_cor = prev_task;
if (multilevel) {
flx_cor = AddFluxCorrectionTasks(flx_cor, ...);
}
src/interface/sparse_pack.hpp
Outdated
template <class... Ts> | ||
KOKKOS_INLINE_FUNCTION any_nonflux(Ts &&...args) | ||
: base_t<true>(std::forward<Ts>(args)...) {} | ||
static std::string name() { return "^(?!bnd_flux::).+"; } |
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 ::
may or may not cause a problem as it's adisallowed character by the OpenPMD standard.
I'm actually not sure if this is a hard problem or not (as I assume that some default tools may not work with that approach, but we probably would dump these flux variable only for debugging anyway, don't we)?
Also, we could in principle overwrite the reserved pattern for output and do a name matching when reading them back in again.
static std::string name() { return "^(?!bnd_flux::).+"; } | ||
}; | ||
|
||
using any = any_nonautoflux; |
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.
May that have some unintended side-effects?
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.
I don't think so, since there are few places where any
is currently used and those places assumed that fluxes would not get sucked up when using any
. I think in the future we, should avoid using any
and use either any_nonautoflux
or any_withautoflux
.
PR Summary
Following # #764, this PR promotes fluxes to be their own variables and then implements flux correction through the regular boundary communication machinery. Now when a variable has the
Metadata::WithFluxes
flag set, a new variable is created with the flagsMetadata::Flux
andMetadata::OneCopy
and the namebnd_flux::
+ original var name (the prepending is required because of issue #1032). This variable is packed transparently so that packs that are created with fluxes pack associated flux variables automatically and calls topack.flux(...)
are unchanged. As a result, this PR should have no impact on downstream codes.Notes:
i
indices of a field (as is commonly done in Riot for instance).PR Checklist
NeighborBlock
#1042 is merged intodevelop