diff options
author | 2021-11-05 09:58:54 -0700 | |
---|---|---|
committer | 2021-11-05 09:58:54 -0700 | |
commit | 3684af17bbbe04fdc6dd84ff2a646c8a77076b73 (patch) | |
tree | ba5a5492a9565ab7d957caa3281ed316d5d48cd1 /Python/pywarpx/_libwarpx.py | |
parent | 66731e4a97c052df78b486b92033707cedadb780 (diff) | |
download | WarpX-3684af17bbbe04fdc6dd84ff2a646c8a77076b73.tar.gz WarpX-3684af17bbbe04fdc6dd84ff2a646c8a77076b73.tar.zst WarpX-3684af17bbbe04fdc6dd84ff2a646c8a77076b73.zip |
Add Python Wrappers for F,G in PML (#2481)
* Add Python Wrappers for F,G in PML
* Add Getters for F,G Nodal Flags
* Fix Bug in <F,G>FPPMLWrapper (Default Level)
* Fix Bug in F,G Nodal Flags
* Use GetPML Method for F,G Nodal Flags
Diffstat (limited to 'Python/pywarpx/_libwarpx.py')
-rwxr-xr-x | Python/pywarpx/_libwarpx.py | 229 |
1 files changed, 229 insertions, 0 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py index e1f7d8fc4..817f64da5 100755 --- a/Python/pywarpx/_libwarpx.py +++ b/Python/pywarpx/_libwarpx.py @@ -197,10 +197,18 @@ libwarpx.warpx_getFfieldCP.restype = _LP_LP_c_real libwarpx.warpx_getFfieldCPLoVects.restype = _LP_c_int libwarpx.warpx_getFfieldFP.restype = _LP_LP_c_real libwarpx.warpx_getFfieldFPLoVects.restype = _LP_c_int +libwarpx.warpx_getFfieldCP_PML.restype = _LP_LP_c_real +libwarpx.warpx_getFfieldCPLoVects_PML.restype = _LP_c_int +libwarpx.warpx_getFfieldFP_PML.restype = _LP_LP_c_real +libwarpx.warpx_getFfieldFPLoVects_PML.restype = _LP_c_int libwarpx.warpx_getGfieldCP.restype = _LP_LP_c_real libwarpx.warpx_getGfieldCPLoVects.restype = _LP_c_int libwarpx.warpx_getGfieldFP.restype = _LP_LP_c_real libwarpx.warpx_getGfieldFPLoVects.restype = _LP_c_int +libwarpx.warpx_getGfieldCP_PML.restype = _LP_LP_c_real +libwarpx.warpx_getGfieldCPLoVects_PML.restype = _LP_c_int +libwarpx.warpx_getGfieldFP_PML.restype = _LP_LP_c_real +libwarpx.warpx_getGfieldFPLoVects_PML.restype = _LP_c_int libwarpx.warpx_getParticleBoundaryBufferSize.restype = ctypes.c_int libwarpx.warpx_getParticleBoundaryBuffer.restype = _LP_LP_c_particlereal libwarpx.warpx_getParticleBoundaryBufferScrapedSteps.restype = _LP_LP_c_int @@ -218,6 +226,8 @@ libwarpx.warpx_getRho_nodal_flag.restype = _LP_c_int libwarpx.warpx_getPhi_nodal_flag.restype = _LP_c_int libwarpx.warpx_getF_nodal_flag.restype = _LP_c_int libwarpx.warpx_getG_nodal_flag.restype = _LP_c_int +libwarpx.warpx_getF_pml_nodal_flag.restype = _LP_c_int +libwarpx.warpx_getG_pml_nodal_flag.restype = _LP_c_int #libwarpx.warpx_getPMLSigma.restype = _LP_c_real #libwarpx.warpx_getPMLSigmaStar.restype = _LP_c_real @@ -1502,6 +1512,62 @@ def get_mesh_F_fp(level, include_ghosts=True): return _get_mesh_field_list(libwarpx.warpx_getFfieldFP, level, None, include_ghosts) +def get_mesh_F_fp_pml(level, include_ghosts=True): + ''' + + This returns a list of numpy arrays containing the mesh F field + data on each grid for this process. This version returns the F field on + the fine patch for the PML on the given level. + + The data for the numpy arrays are not copied, but share the underlying + memory buffer with WarpX. The numpy arrays are fully writeable. + + Parameters + ---------- + + level : the AMR level to get the data for + include_ghosts : whether to include ghost zones or not + + Returns + ------- + + A List of numpy arrays. + + ''' + try: + return _get_mesh_field_list(libwarpx.warpx_getFfieldFP_PML, level, None, include_ghosts) + except ValueError: + raise Exception('PML not initialized') + + +def get_mesh_F_cp_pml(level, include_ghosts=True): + ''' + + This returns a list of numpy arrays containing the mesh F field + data on each grid for this process. This version returns the F field on + the coarse patch for the PML on the given level. + + The data for the numpy arrays are not copied, but share the underlying + memory buffer with WarpX. The numpy arrays are fully writeable. + + Parameters + ---------- + + level : the AMR level to get the data for + include_ghosts : whether to include ghost zones or not + + Returns + ------- + + A List of numpy arrays. + + ''' + try: + return _get_mesh_field_list(libwarpx.warpx_getFfieldCP_PML, level, None, include_ghosts) + except ValueError: + raise Exception('PML not initialized') + + def get_mesh_G_cp(level, include_ghosts=True): ''' @@ -1554,6 +1620,62 @@ def get_mesh_G_fp(level, include_ghosts=True): return _get_mesh_field_list(libwarpx.warpx_getGfieldFP, level, None, include_ghosts) +def get_mesh_G_cp_pml(level, include_ghosts=True): + ''' + + This returns a list of numpy arrays containing the mesh G field + data on each grid for this process. This version returns the G field on + the coarse patch for the PML on the given level. + + The data for the numpy arrays are not copied, but share the underlying + memory buffer with WarpX. The numpy arrays are fully writeable. + + Parameters + ---------- + + level : the AMR level to get the data for + include_ghosts : whether to include ghost zones or not + + Returns + ------- + + A List of numpy arrays. + + ''' + try: + return _get_mesh_field_list(libwarpx.warpx_getGfieldCP_PML, level, None, include_ghosts) + except ValueError: + raise Exception('PML not initialized') + + +def get_mesh_G_fp_pml(level, include_ghosts=True): + ''' + + This returns a list of numpy arrays containing the mesh G field + data on each grid for this process. This version returns the G field on + the fine patch for the PML on the given level. + + The data for the numpy arrays are not copied, but share the underlying + memory buffer with WarpX. The numpy arrays are fully writeable. + + Parameters + ---------- + + level : the AMR level to get the data for + include_ghosts : whether to include ghost zones or not + + Returns + ------- + + A List of numpy arrays. + + ''' + try: + return _get_mesh_field_list(libwarpx.warpx_getGfieldFP_PML, level, None, include_ghosts) + except ValueError: + raise Exception('PML not initialized') + + def _get_mesh_array_lovects(level, direction, include_ghosts=True, getlovectsfunc=None): assert(0 <= level and level <= libwarpx.warpx_finestLevel()) @@ -2042,6 +2164,54 @@ def get_mesh_F_fp_lovects(level, include_ghosts=True): return _get_mesh_array_lovects(level, None, include_ghosts, libwarpx.warpx_getFfieldFPLoVects) +def get_mesh_F_cp_lovects_pml(level, include_ghosts=True): + ''' + + This returns a list of the lo vectors of the arrays containing the mesh F field + data on each PML grid for this process. + + Parameters + ---------- + + level : the AMR level to get the data for + include_ghosts : whether to include ghost zones or not + + Returns + ------- + + A 2d numpy array of the lo vector for each grid with the shape (dims, number of grids) + + ''' + try: + return _get_mesh_array_lovects(level, None, include_ghosts, libwarpx.warpx_getFfieldCPLoVects_PML) + except ValueError: + raise Exception('PML not initialized') + + +def get_mesh_F_fp_lovects_pml(level, include_ghosts=True): + ''' + + This returns a list of the lo vectors of the arrays containing the mesh F field + data on each PML grid for this process. + + Parameters + ---------- + + level : the AMR level to get the data for + include_ghosts : whether to include ghost zones or not + + Returns + ------- + + A 2d numpy array of the lo vector for each grid with the shape (dims, number of grids) + + ''' + try: + return _get_mesh_array_lovects(level, None, include_ghosts, libwarpx.warpx_getFfieldFPLoVects_PML) + except ValueError: + raise Exception('PML not initialized') + + def get_mesh_G_cp_lovects(level, include_ghosts=True): ''' @@ -2084,6 +2254,53 @@ def get_mesh_G_fp_lovects(level, include_ghosts=True): return _get_mesh_array_lovects(level, None, include_ghosts, libwarpx.warpx_getGfieldFPLoVects) +def get_mesh_G_cp_lovects_pml(level, include_ghosts=True): + ''' + + This returns a list of the lo vectors of the arrays containing the mesh G field + data on each PML grid for this process. + + Parameters + ---------- + + level : the AMR level to get the data for + include_ghosts : whether to include ghost zones or not + + Returns + ------- + + A 2d numpy array of the lo vector for each grid with the shape (dims, number of grids) + + ''' + try: + return _get_mesh_array_lovects(level, None, include_ghosts, libwarpx.warpx_getGfieldCPLoVects_PML) + except ValueError: + raise Exception('PML not initialized') + + +def get_mesh_G_fp_lovects_pml(level, include_ghosts=True): + ''' + + This returns a list of the lo vectors of the arrays containing the mesh G field + data on each PML grid for this process. + + Parameters + ---------- + + level : the AMR level to get the data for + include_ghosts : whether to include ghost zones or not + + Returns + ------- + + A 2d numpy array of the lo vector for each grid with the shape (dims, number of grids) + + ''' + try: + return _get_mesh_array_lovects(level, None, include_ghosts, libwarpx.warpx_getGfieldFPLoVects_PML) + except ValueError: + raise Exception('PML not initialized') + def _get_nodal_flag(getdatafunc): data = getdatafunc() if not data: @@ -2185,3 +2402,15 @@ def get_G_nodal_flag(): This returns a 1d array of the nodal flags for G along each direction. A 1 means node centered, and 0 cell centered. ''' return _get_nodal_flag(libwarpx.warpx_getG_nodal_flag) + +def get_F_pml_nodal_flag(): + ''' + This returns a 1d array of the nodal flags for F in the PML along each direction. A 1 means node centered, and 0 cell centered. + ''' + return _get_nodal_flag(libwarpx.warpx_getF_pml_nodal_flag) + +def get_G_pml_nodal_flag(): + ''' + This returns a 1d array of the nodal flags for G in the PML along each direction. A 1 means node centered, and 0 cell centered. + ''' + return _get_nodal_flag(libwarpx.warpx_getG_pml_nodal_flag) |