diff options
author | 2022-01-19 09:01:47 -0800 | |
---|---|---|
committer | 2022-01-19 09:01:47 -0800 | |
commit | 4e9d98c528dfebf05aa9d07edf451eff29f37f65 (patch) | |
tree | 2a3ed3586aa7895455f40ec4f40d7b1bb2156ef6 /Source/FieldSolver/ElectrostaticSolver.cpp | |
parent | 73858579e90701b5f1fc1ef9009a8067294aa975 (diff) | |
download | WarpX-4e9d98c528dfebf05aa9d07edf451eff29f37f65.tar.gz WarpX-4e9d98c528dfebf05aa9d07edf451eff29f37f65.tar.zst WarpX-4e9d98c528dfebf05aa9d07edf451eff29f37f65.zip |
Refactor python callback handling (#2703)
* added support to uninstall an external Poisson solver and return to using the default MLMG solver; also updated some callbacks.py calls to Python3
* refactor callback handling - use a map to handle all the different callbacks
* warpx_callback_py_map does not need to link to C
* Apply suggestions from code review
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* further suggested changes from code review
* added function ExecutePythonCallback to reduce code duplication
* moved ExecutePythonCallback to WarpX_py
* added function IsPythonCallbackInstalled
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/FieldSolver/ElectrostaticSolver.cpp')
-rw-r--r-- | Source/FieldSolver/ElectrostaticSolver.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/Source/FieldSolver/ElectrostaticSolver.cpp b/Source/FieldSolver/ElectrostaticSolver.cpp index 18f90431f..e1d70be16 100644 --- a/Source/FieldSolver/ElectrostaticSolver.cpp +++ b/Source/FieldSolver/ElectrostaticSolver.cpp @@ -172,10 +172,7 @@ WarpX::AddSpaceChargeFieldLabFrame () std::array<Real, 3> beta = {0._rt}; // Compute the potential phi, by solving the Poisson equation - if (warpx_py_poissonsolver) { - WARPX_PROFILE("warpx_py_poissonsolver"); - warpx_py_poissonsolver(); - } + if ( IsPythonCallBackInstalled("poissonsolver") ) ExecutePythonCallback("poissonsolver"); else computePhi( rho_fp, phi_fp, beta, self_fields_required_precision, self_fields_absolute_tolerance, self_fields_max_iters, self_fields_verbosity ); @@ -185,7 +182,7 @@ WarpX::AddSpaceChargeFieldLabFrame () #ifndef AMREX_USE_EB computeE( Efield_fp, phi_fp, beta ); #else - if (warpx_py_poissonsolver) computeE( Efield_fp, phi_fp, beta ); + if ( IsPythonCallBackInstalled("poissonsolver") ) computeE( Efield_fp, phi_fp, beta ); #endif // Compute the magnetic field |