-
Notifications
You must be signed in to change notification settings - Fork 191
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
Add: MultiFabRegister
#5230
Add: MultiFabRegister
#5230
Conversation
15c6119
to
b9c1d78
Compare
… hackathon-field-register
old vector is `std::array< std::unique_ptr<amrex::MultiFab>, 3 >`
/** Components (base vector directions) of vector/tensor fields. | ||
* | ||
* Because of different staggering, the components of vector/tensor fields are stored | ||
* in separate (i)MultiFab. | ||
* | ||
* @todo: synchronize with AMReX "enum class Direction" | ||
*/ | ||
struct Direction | ||
{ | ||
int dir = 0; | ||
|
||
bool operator<(const Direction& other) const | ||
{ | ||
return other.dir < this->dir; | ||
} | ||
|
||
/* TODO: just temporary int compatibility */ | ||
operator int() const { return dir; } | ||
}; |
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.
Since there is a Direction
available in AMReX, which should serve the same purpose, maybe we can try to use that one and see if it works for us. AMReX's direction is defined here:
enum class Direction : int { AMREX_D_DECL(x = 0, y = 1, z = 2) };
This could be another separate follow-up issue/PR.
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, see the @todo
in the Doxygen comment block above.
We currently need to add some implicit casts and comparison operators, thus we cannot use it.
Keep `[x]`, `[y]`, `[z]` suffixes for now to avoid breakage for Python users.
Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com>
Oh ha, clang-tidy is not a required test it seems. |
Settings updated and fix in #5309 |
Add a central location to store all
MultiFab
s in. Theablastr::fields::MultiFabRegister
provides us with a central location to allocate, initialize and exchange fields now.This is useful to add new fields at runtime (even Python!), access them from anywhere for read & write (incl. Python), alias them from anywhere, redistribute them on load balancing by default (unless you say: no, don't do this, during allocation), and to simplify function calls that access a lot of fields (e.g., solvers just need to pass the
ablastr::fields::MultiFabRegister & WarpX::m_fields
around instead of includingWarpX.H
).New Headers
New ABLASTR header:
New Type Aliases
and const variants.
New Functions
MultiFabRegister
provides calls to allocate & initialize (alloc_init
,alias_init
), test (has
), access (get
,get_mr_levels
,get_alldirs
,get_mr_levels_alldirs
), list (list
), remove (erase
,clear_level
), and remake on AMR/load balance (remake_level
).Please see the Doxygen page for all details.
These functions can be used both with
warpx::fields::FieldType
enums (preferred) as well asstd::string
(e.g., for purely runtime logic or Python hackery).TODO
Fields.H
:warpx::fields::FieldType
add per-enum-entry inline doc stringthrow
logic onget
with missing keys