|
XGC1
|
Functions/Subroutines | |
| subroutine | petsc_get_sizes (grid, bc, n_equation, n_boundary, xgc_petsc, petsc_xgc_bd) |
| Calculate (i) the number of equations (vertices) of the solver, (ii) the number of XGC boundary vertices included in the solver, (iii) (preliminary) mapping from XGC vertices to PETSc equations, (iv) mapping from XGC vertices to PETSc boundary conditions, all based the XGC boundary object passed as input. More... | |
| subroutine | petsc_get_bd_map (grid, bc, n_boundary, petsc_xgc_bd, petsc_bd_xgc) |
| Generate mapping from PETSc boundary conditions to XGC vertices. This requires the results of petsc_get_sizes because the number of boundary conditions is not known a priori. More... | |
| subroutine | getnnz (grid, nloc, low, high, d_nnz, o_nnz, xgc_petsc, nglobal, ierr) |
| Computes the number of non-zero entries nnz per row in the rank-local rows. More... | |
| subroutine | petsc_get_partitioning (grid, bc, b_factors, comm, num_pe, n_eq_tot_in, set_diffusion_matrix, xgc_petsc, petsc_xgc_bd, n_eq_loc, xgc_proc_out, proc_eq, ierr) |
| Generates a domain partitioning of part of the XGC mesh used by a solver (as defined by the boundary conditions bc) using Parmetis and generates a mapping between PETSc equation index and XGC MPI ranks (those in the communicator comm used by the solver). More... | |
| subroutine | petsc_get_mapping (nnode, bc, comm, num_pe, n_eq_tot, n_eq_loc, xgc_proc, proc_eq, xgc_petsc, petsc_xgc, petscloc_xgc) |
| Based on the Parmetis partition of the XGC domain, updates the mappings between XGC vertices and PETSc equations. More... | |
| subroutine | petsc_get_template_mat (grid, comm, n_eq_tot, n_eq_loc, xgc_petsc, solver_template_mat, ierr) |
| Uses pre-computed (petsc_get_partitioning) local matrix sizes and XGC vertex to PETSc equation mapping to set up a blank template matrix with sufficient pre-allocated memory. More... | |
| subroutine | petsc_get_scatter_multi_block (nnode, ksp, mat_all_blocks, mat_one_block, blocksize, varnames, n_eq_tot, n_eq_loc, petscloc_xgc, petsc_xgc, iss, to_petsc, from_petsc, ierr) |
| Sets up a PETSc scatter object for a (2D) multi-block field-split solver. More... | |
| subroutine | petsc_to_xgc (nnode, blocksize, from_petsc, field_petsc, field_xgc, ierr) |
| This routine scatters values from the distributed vector compatible with the block-matrix of the 2D diffusion model to local variables on the XGC solver grid. More... | |
| subroutine | xgc_to_petsc (nnode, blocksize, to_petsc, field_petsc, field_xgc, ierr) |
| This routine scatters values from local variable on the XGC solver grid to the distributed vector compatible with the block-matrix of the 2D diffusion model. More... | |
| subroutine | diffusion_matrix_init (diffusion_ts, grid, bc, solver_template_mat, ierr) |
| Set up a template matrix for XGC's anomalous diffusion time integrator. This is currently a system of either 4 (adiabatic electrons) or 7 (kinetic electrons) equations. Impurities are not supported yet. More... | |
| subroutine petsc_solver_module::diffusion_matrix_init | ( | type(xgc_ts) | diffusion_ts, |
| type(grid_type), intent(in) | grid, | ||
| integer, dimension(grid%nnode), intent(in) | bc, | ||
| intent(out) | solver_template_mat, | ||
| ierr | |||
| ) |
Set up a template matrix for XGC's anomalous diffusion time integrator. This is currently a system of either 4 (adiabatic electrons) or 7 (kinetic electrons) equations. Impurities are not supported yet.
| [in,out] | diffusion_ts | PETSc time integrator object (TS) for the diffusion solver |
| [in] | grid | XGC grid object, type(grid_type) |
| [in] | bc | Solver boundary mask, 1 if not in boundary vertex list |
| [out] | solver_template_mat | PETSc matrix with the template for the anomalous diffusion solver |
| [out] | ierr | PETSc error code. |


| subroutine petsc_solver_module::getnnz | ( | type(grid_type), intent(in) | grid, |
| nloc, | |||
| low, | |||
| high, | |||
| d_nnz, | |||
| o_nnz, | |||
| dimension(grid%nnode), intent(in) | xgc_petsc, | ||
| nglobal, | |||
| ierr | |||
| ) |
Computes the number of non-zero entries nnz per row in the rank-local rows.
| [in] | grid | XGC grid object, type(grid_type) |
| [in] | nloc | Number of equations on this rank, PetscInt |
| [in] | low | Global index of the first equation on this rank, PetscInt |
| [in] | high | Global index of the last equation on this rank, PetscInt |
| [out] | d_nnz | Number of non-zero entries in "diagonal" local part of the matrix |
| [out] | o_nnz | Number of non-zero entries in the "off-diagnonal" local part of the matrix. |
| [in] | xgc_petsc | Mapping between XGC grid vertices and PETSc equations |
| [in] | nglobal | Total number of equations, PetscInt |
| [in] | ierr | PETSc error code |

| subroutine petsc_solver_module::petsc_get_bd_map | ( | type(grid_type), intent(in) | grid, |
| integer, dimension(grid%nnode), intent(in) | bc, | ||
| intent(in) | n_boundary, | ||
| dimension(grid%nnode), intent(in) | petsc_xgc_bd, | ||
| dimension(n_boundary), intent(out) | petsc_bd_xgc | ||
| ) |
Generate mapping from PETSc boundary conditions to XGC vertices. This requires the results of petsc_get_sizes because the number of boundary conditions is not known a priori.
| [in] | grid | XGC solver mesh, type(grid_type) |
| [in] | bc | Solver boundary mask, 1 if not in boundary vertex list |
| [in] | n_boundary | Number of boundary values, PetscInt |
| [in] | petsc_xgc_bd | Mapping from XGC vertices to PETSc boundary conditions |
| [out] | petsc_bd_xgc | Mapping fron PETSc boundary conditions to XGC vertices |

| subroutine petsc_solver_module::petsc_get_mapping | ( | integer, intent(in) | nnode, |
| integer, dimension(nnode), intent(in) | bc, | ||
| integer, intent(in) | comm, | ||
| integer, intent(in) | num_pe, | ||
| intent(in) | n_eq_tot, | ||
| intent(in) | n_eq_loc, | ||
| dimension(n_eq_tot), intent(in) | xgc_proc, | ||
| dimension(0:num_pe), intent(inout) | proc_eq, | ||
| dimension(nnode), intent(out) | xgc_petsc, | ||
| dimension(n_eq_tot), intent(out) | petsc_xgc, | ||
| dimension(n_eq_loc), intent(out) | petscloc_xgc | ||
| ) |
Based on the Parmetis partition of the XGC domain, updates the mappings between XGC vertices and PETSc equations.
| [in] | nnode | Number of XGC vertices, integer |
| [in] | bc | Solver boundary mask, 1 if not in boundary vertex list |
| [in] | comm | MPI comunicator for distributed matrix solver, MPI_comm |
| [in] | n_eq_tot | Total number of PETSc equations, PetscInt |
| [in] | n_eq_loc | Local number of equations on the current rank, PetscInt |
| [in] | xgc_proc | Mapping from equation index to XGC rank, PetscInt |
| [in] | proc_eq | Mapping from XGC process to PETSc equation, integer |
| [out] | xgc_petsc | Mapping from XGC vertices to PETSc equation, integer |
| [out] | petsc_xgc | Mapping from PETSc equation index to XGC vertices, integer |
| [out] | petscloc_xgc | Mapping from local PETSc eq. to XGC vertices, integer |

| subroutine petsc_solver_module::petsc_get_partitioning | ( | type(grid_type), intent(in) | grid, |
| integer, dimension(grid%nnode), intent(in) | bc, | ||
| real(kind=8), dimension(grid%ntriangle, 6), intent(in) | b_factors, | ||
| integer, intent(in) | comm, | ||
| integer, intent(in) | num_pe, | ||
| intent(in) | n_eq_tot_in, | ||
| logical, intent(in) | set_diffusion_matrix, | ||
| dimension(grid%nnode), intent(in) | xgc_petsc, | ||
| dimension(grid%nnode), intent(in) | petsc_xgc_bd, | ||
| intent(out) | n_eq_loc, | ||
| dimension(n_eq_tot_in), intent(out) | xgc_proc_out, | ||
| dimension(0:num_pe), intent(out) | proc_eq, | ||
| intent(out) | ierr | ||
| ) |
Generates a domain partitioning of part of the XGC mesh used by a solver (as defined by the boundary conditions bc) using Parmetis and generates a mapping between PETSc equation index and XGC MPI ranks (those in the communicator comm used by the solver).
| [in] | grid | XGC solver mesh, type(grid_type) |
| [in] | bc | Solver boundary mask, 1 if not in boundary vertex list |
| [in] | comm | MPI communicator used by the solver, integer |
| [in] | num_pe | Number of MPI ranks in communicator comm, integer |
| [in] | n_eq_tot_in | Total number of equations (i.e. number of vertices in the solver), PetscInt |
| [in] | set_diffusion_matrix | Whether to set diffusion or Poisson/Ampere matrix |
| [out] | n_eq_loc | Number of equations on the current rank, PetscInt |
| [out] | xgc_proc | Mapping from PETSc equation to XGC rank, PetscInt |
| [out] | proc_eq | Mapping from XGC_process to PETSc equation number (in form of the boundaries of the domain partitioning) |
| [out] | ierr | Error code |


| subroutine petsc_solver_module::petsc_get_scatter_multi_block | ( | integer, intent(in) | nnode, |
| intent(in) | ksp, | ||
| mat_all_blocks, | |||
| mat_one_block, | |||
| intent(in) | blocksize, | ||
| character(*), dimension(0:blocksize-1), intent(in) | varnames, | ||
| intent(in) | n_eq_tot, | ||
| intent(in) | n_eq_loc, | ||
| dimension(n_eq_loc), intent(in) | petscloc_xgc, | ||
| dimension(n_eq_tot), intent(in) | petsc_xgc, | ||
| iss, | |||
| to_petsc, | |||
| from_petsc, | |||
| intent(out) | ierr | ||
| ) |
Sets up a PETSc scatter object for a (2D) multi-block field-split solver.
| [in] | nnode | Number of XGC mesh vertices |
| [in] | ksp | PETSc Krylov sub-space solver object, KSP |
| [in] | mat_all_blocks | Global matrix with all solver blocks, Mat |
| [in] | mat_one_block | Matrix of one single block, Mat |
| [in] | blocksize | Number of blocks, PetscInt |
| [in] | varnames | Names of the variables represented by each block, char |
| [in] | n_eq_tot | Number of equations in one block, PetscInt |
| [in] | n_eq_loc | Number of local equations in one block, PetscInt |
| [in] | petscloc_xgc | Rank-local mapping from PETSc equations to XGC vertices, PetscInt |
| [in] | petsc_xgc | Global mapping from PETSc equations to XGC vertices, PetscInt |
| [out] | iss | Index sets for mapping single blocks into the global matrix, IS |
| [out] | from_petsc | VecScatter object for scattering PETSc results to an XGC field, VecScatter |
| [out] | to_petsc | VecScatter object for scattering XGC vectors into the global PETSc block matrix |
| [out] | ierr | PETSc error code, PetscErrorCode |

| subroutine petsc_solver_module::petsc_get_sizes | ( | type(grid_type), intent(in) | grid, |
| integer, dimension(grid%nnode), intent(in) | bc, | ||
| intent(out) | n_equation, | ||
| intent(out) | n_boundary, | ||
| dimension(grid%nnode), intent(out) | xgc_petsc, | ||
| dimension(grid%nnode), intent(out) | petsc_xgc_bd | ||
| ) |
Calculate (i) the number of equations (vertices) of the solver, (ii) the number of XGC boundary vertices included in the solver, (iii) (preliminary) mapping from XGC vertices to PETSc equations, (iv) mapping from XGC vertices to PETSc boundary conditions, all based the XGC boundary object passed as input.
| [in] | grid | XGC solver mesh, type(grid_type) |
| [in] | bc | Solver boundary mask, 1 if not in boundary vertex list |
| [out] | n_equation | Number of PETSc equations (matrix rows), integer |
| [out] | n_boundary | Number of boundary conditions/vertices, integer |
| [out] | xgc_petsc | (Preliminary) mapping from XGC vertices to PETSc equations |
| [out] | petsc_xgc_bd | Mapping from XGC vertices to PETSc boundary conditions |

| subroutine petsc_solver_module::petsc_get_template_mat | ( | type(grid_type), intent(in) | grid, |
| integer, intent(in) | comm, | ||
| intent(in) | n_eq_tot, | ||
| intent(in) | n_eq_loc, | ||
| dimension(grid%nnode), intent(in) | xgc_petsc, | ||
| intent(out) | solver_template_mat, | ||
| ierr | |||
| ) |
Uses pre-computed (petsc_get_partitioning) local matrix sizes and XGC vertex to PETSc equation mapping to set up a blank template matrix with sufficient pre-allocated memory.
| [in] | grid | XGC grid object, type(grid_type) |
| [in] | comm | MPI communicator for template matrix, MPI_comm |
| [in] | n_eq_tot | Total number of equations, PetscInt |
| [in] | n_eq_loc | Number of local equations on the current rank, PetscInt |
| [in] | xgc_petsc | Mapping from XGC vertices to PETSc equation index |
| [out] | solver_template_mat | Template matrix with the desired partitioning and sufficient preallocated memory. |
| [out] | ierr | Error code |


| subroutine petsc_solver_module::petsc_to_xgc | ( | intent(in) | nnode, |
| intent(in) | blocksize, | ||
| dimension(0:blocksize-1), intent(in) | from_petsc, | ||
| intent(in) | field_petsc, | ||
| real (kind=8), dimension(nnode,blocksize), intent(inout) | field_xgc, | ||
| intent(out) | ierr | ||
| ) |
This routine scatters values from the distributed vector compatible with the block-matrix of the 2D diffusion model to local variables on the XGC solver grid.
| [in] | nnode | Number of vertices per plane in XGC mesh, PetscInt |
| [in] | blocksize | Number of equations, PetscInt |
| [in] | from_petsc | VecScatter object for moving data from PETSc Vec to XGC mesh data, VecScatter |
| [in] | field_petsc | PETSc vector with the data to be scattered, PETSc Vec |
| [in,out] | field_xgc | XGC mesh array to which data is scattered, real8 |
| [out] | ierr | Error code, PetscErrorCode |

| subroutine petsc_solver_module::xgc_to_petsc | ( | intent(in) | nnode, |
| intent(in) | blocksize, | ||
| dimension(0:blocksize-1), intent(in) | to_petsc, | ||
| field_petsc, | |||
| real (kind=8), dimension(nnode,blocksize), intent(in) | field_xgc, | ||
| intent(out) | ierr | ||
| ) |
This routine scatters values from local variable on the XGC solver grid to the distributed vector compatible with the block-matrix of the 2D diffusion model.
| [in] | nnode | Number of vertices per plane in XGC mesh, PetscInt |
| [in] | blocksize | Number of equations, PetscInt |
| [in] | from_petsc | VecScatter object for moving data from PETSc Vec to XGC mesh data, VecScatter |
| [in] | field_petsc | PETSc vector with the data to be scattered, PETSc Vec |
| [in,out] | field_xgc | XGC mesh array to which data is scattered, real8 |
| [out] | ierr | Error code, PetscErrorCode |
