Skip to content

Commit 16347e6

Browse files
python callback at restart (#5549)
This PR adds a python callback option after initialization at restart, enabling users to read user-defined checkpoint vars that could be written using the python call afterdiagnostics that already exists --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 17b0c3d commit 16347e6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Python/pywarpx/callbacks.py

+11
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ def callfuncsinlist(self, *args, **kw):
280280
"loadExternalFields": {},
281281
"beforeInitEsolve": {},
282282
"afterInitEsolve": {},
283+
"afterInitatRestart": {},
283284
"afterinit": {},
284285
"beforecollisions": {},
285286
"aftercollisions": {},
@@ -406,6 +407,16 @@ def installafterInitEsolve(f):
406407
installcallback("afterInitEsolve", f)
407408

408409

410+
# ----------------------------------------------------------------------------
411+
def callfromafterInitatRestart(f):
412+
installcallback("afterInitatRestart", f)
413+
return f
414+
415+
416+
def installafterInitatRestart(f):
417+
installcallback("afterInitatRestart", f)
418+
419+
409420
# ----------------------------------------------------------------------------
410421
def callfromafterinit(f):
411422
installcallback("afterinit", f)

Source/Initialization/WarpXInitData.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,9 @@ WarpX::InitData ()
610610
AddExternalFields(lev);
611611
}
612612
}
613+
else {
614+
ExecutePythonCallback("afterInitatRestart");
615+
}
613616

614617
if (restart_chkfile.empty() || write_diagnostics_on_restart) {
615618
// Write full diagnostics before the first iteration.

0 commit comments

Comments
 (0)