Skip to content
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 multifab method that takes an int for the direction #5473

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions Source/Python/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ where 'prefix' is the part of 'internal_name';' before the [])doc"
py::arg("scalar_name"),
py::arg("level"),
py::return_value_policy::reference_internal,
R"doc(Return scalar fields (MultiFabs) by name and level, e.g., ``\"rho_fp\"``, ``\"phi_fp"``, ...
R"doc(Return scalar fields (MultiFabs) by name and level. The name is in the form like``\"rho_fp\"``, ``\"phi_fp"``. The level is an integer with 0 being the lowest level.

The physical fields in WarpX have the following naming:

Expand All @@ -164,7 +164,30 @@ The physical fields in WarpX have the following naming:
py::arg("dir"),
py::arg("level"),
py::return_value_policy::reference_internal,
R"doc(Return the component of a vector field (MultiFab) by name, direction, and level, e.g., ``\"Efield_aux\"``, ``\"Efield_fp"``, ...
R"doc(Return the component of a vector field (MultiFab) by name, direction, and level. The name is in the form like ``\"Efield_aux\"``, ``\"Efield_fp"``, etc. The direction is a Direction instance, Direction(idir) where idir is an integer 0, 1, or 2. The level is an integer with 0 being the lowest level.

The physical fields in WarpX have the following naming:

- ``_fp`` are the "fine" patches, the regular resolution of a current mesh-refinement level
- ``_aux`` are temporary (auxiliar) patches at the same resolution as ``_fp``.
They usually include contributions from other levels and can be interpolated for gather routines of particles.
- ``_cp`` are "coarse" patches, at the same resolution (but not necessary values) as the ``_fp`` of ``level - 1``
(only for level 1 and higher).)doc"
)
.def("multifab",
[](WarpX & wx, std::string vector_name, int idir, int level) {
Direction const dir{idir};
if (wx.m_fields.has(vector_name, dir, level)) {
return wx.m_fields.get(vector_name, dir, level);
} else {
throw std::runtime_error("The vector field '" + vector_name + "' is unknown or is not allocated!");
}
},
py::arg("vector_name"),
py::arg("idir"),
py::arg("level"),
py::return_value_policy::reference_internal,
R"doc(Return the component of a vector field (MultiFab) by name, direction, and level. The name is in the form like ``\"Efield_aux\"``, ``\"Efield_fp"``, etc. The direction is an integer 0, 1, or 2. The level is an integer with 0 being the lowest level.

The physical fields in WarpX have the following naming:

Expand Down
Loading