Skip to content

Commit

Permalink
Add MultiFab method that takes an int for the direction (#5473)
Browse files Browse the repository at this point in the history
This adds a new way to call the `multifab` routine from Python, taking
an integer for the direction instead of requiring an instance of the
`Direction` class.

This also cleans up the documentation some for the other versions of the
routine.
  • Loading branch information
dpgrote authored Dec 6, 2024
1 parent a310309 commit 2318fd7
Showing 1 changed file with 25 additions and 2 deletions.
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

0 comments on commit 2318fd7

Please sign in to comment.