Skip to content

Commit

Permalink
add gett_new and getistep functions wrappers; fix typos in `callb…
Browse files Browse the repository at this point in the history
…acks.py`; avoid error in getting `rho` from `fields.py`
  • Loading branch information
roelof-groenewald committed Jul 13, 2023
1 parent dc44a2b commit 9eabe50
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Python/pywarpx/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def installbeforeInitEsolve(f):

# ----------------------------------------------------------------------------
def callfromafterInitEsolve(f):
installafterInitEsolve('afterInitEsolve', f)
installcallback('afterInitEsolve', f)
return f
def installafterInitEsolve(f):
installcallback('afterInitEsolve', f)
Expand Down Expand Up @@ -440,7 +440,7 @@ def onbreaksignal(f):
installcallback('onbreaksignal', f)
return f
def installonbreaksignal(f):
_onbreaksignal.installfuncinlist(f)
installcallback('onbreaksignal', f)

# ----------------------------------------------------------------------------
def callfromparticleinjection(f):
Expand Down
2 changes: 1 addition & 1 deletion Python/pywarpx/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def __getitem__(self, index):
raise Exception('Too many indices given')

# Expand the indices to length 3
ii = self._get_indices(index, None)
ii = self._get_indices(index, slice(None))
ic = index[-1]

ixmin, iymin, izmin = self._get_min_indices()
Expand Down
14 changes: 14 additions & 0 deletions Source/Python/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ void init_WarpX (py::module& m)
.def("multi_particle_container", &WarpX::GetPartContainer,
py::return_value_policy::reference_internal
)

// Expose functions to get the current simulation step and time
.def("getistep",
[](WarpX const & wx, int lev){
return wx.getistep(lev);
},
py::arg("lev")
)
.def("gett_new",
[](WarpX const & wx, int lev){
return wx.gett_new(lev);
},
py::arg("lev")
)
;

py::class_<warpx::Config>(m, "Config")
Expand Down
2 changes: 0 additions & 2 deletions Source/Python/WarpXWrappers.H
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ extern "C" {
void warpx_UpdateAuxilaryData ();
void warpx_PushParticlesandDepose (amrex::Real cur_time);

int warpx_getistep (int lev);
void warpx_setistep (int lev, int ii);
amrex::Real warpx_gett_new (int lev);
void warpx_sett_new (int lev, amrex::Real time);
amrex::Real warpx_getdt (int lev);

Expand Down
8 changes: 0 additions & 8 deletions Source/Python/WarpXWrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,18 +447,10 @@
warpx.PushParticlesandDepose(cur_time);
}

int warpx_getistep (int lev) {
const WarpX& warpx = WarpX::GetInstance();
return warpx.getistep(lev);
}
void warpx_setistep (int lev, int ii) {
WarpX& warpx = WarpX::GetInstance();
warpx.setistep(lev, ii);
}
amrex::Real warpx_gett_new (int lev) {
const WarpX& warpx = WarpX::GetInstance();
return warpx.gett_new(lev);
}
void warpx_sett_new (int lev, amrex::Real time) {
WarpX& warpx = WarpX::GetInstance();
warpx.sett_new(lev, time);
Expand Down

0 comments on commit 9eabe50

Please sign in to comment.