Main solver module for matrix assembly and solving Handles LHS matrix assembly, RHS assembly, and backsolving. More...
#include "solver_mpi.hpp"
Public Member Functions | |
| void | assemblyBoltzman (int isp, int nqx, int nqy, bool remove_trap_contribution) |
| Assemble the non-zonal Boltzmann response. | |
| void | assemblyBoltzman_zf (int isp, int nqx, int nqy, bool remove_trap_contribution, bool oldAvgJac) |
| Assemble the zonal Boltzmann response. | |
| void | assemblyBoltzmannPade (int isp, int nqx, int nqy, bool remove_trap_contribution) |
| Assemble the Pade-approximated non-zonal Boltzmann response. | |
| void | assemblyBoltzmannPade_zf (int isp, int nqx, int nqy, bool remove_trap_contribution) |
| Assemble the Pade-approximated zonal Boltzmann response. | |
| void | assemblyLHSFinalize () |
| Finalize and reduce accumulated left-hand-side contributions. | |
| void | assemblyMassMatrix (int nqx, int nqy) |
| Assemble the tensor-product finite-element mass matrix. | |
| void | assemblyMatrix (int nqx, int nqy) |
| Assemble solver matrices using requested quadrature orders. | |
| void | assemblyPadeMatForRHS (int isp, int nqx, int nqy) |
| Assemble the Pade operator applied to the field-equation RHS. | |
| void | assemblyPolDrift_arbitrary_wavelength_fourier (int isp, int nqx, int nqy, int iy_start, int iy_end) |
| Assemble finite-Larmor-radius polarization coupling. | |
| void | assemblyPolDrift_longwavelength_fourier (int isp, int nqx, int nqy) |
| Assemble the long-wavelength polarization-drift operator. | |
| void | assemblyRHS_antenna (Kokkos::View< Complex * > &rhs_f, int nmat, int nqx, int nqy, Real phase_shift=0.0, const std::vector< Real > *sprof=nullptr, const std::vector< Real > *prof=nullptr, int nprof=0) |
| Add configured antenna forcing to a Fourier RHS. | |
| void | assemblyRHS_tests (Kokkos::View< Complex * > &rhs_f, int nmat, int nqx, int nqy) |
| Assemble an analytic solver-test right-hand side. | |
| void | backsolve_mass_f (const Kokkos::View< Complex * > &arr_f, Kokkos::View< Complex * > &out_f, int globalk) |
| Apply the complex Fourier-space inverse mass matrix. | |
| void | backsolve_mass_s (const Kokkos::View< Real * > &arr_f, Kokkos::View< Real * > &out_f) |
| Apply the real-space inverse mass matrix to one vector. | |
| void | backsolve_mass_sn (const Kokkos::View< Real * > &arr_f, Kokkos::View< Real * > &out_f, int nmode) |
| Apply the real inverse mass matrix for one poloidal mode. | |
| void | backsolve_rhs_f (Kokkos::View< Complex * > &rhs_f, int globalk, int matnum) |
| Solve one Fourier-mode field system in place. | |
| void | backsolve_rhs_f_host (Complex *rhs, int n, int globalk, int matnum) |
| Solve one Fourier system from contiguous host storage. | |
| void | backsolve_rhs_f_multi (const Kokkos::View< Complex ** > &rhs_f, int globalk, int matnum) |
| Solve multiple Fourier RHS columns for one toroidal mode. | |
| void | broadcast_matrix (int &ierr, MPI_Comm comm, int tgt, int me) |
| Broadcast the active assembled matrix from the target rank. | |
| Real | computeToroidalMassCoeff (int n) |
| Return the toroidal B-spline mass factor. | |
| void | copy_matrix_filter (int ixmin, int ixmax, int n, Kokkos::View< int * > &mmmincopy) |
| Copy retained poloidal-mode bounds over a radial range. | |
| void | destroySolverModule () |
| Destroy solver module (cleanup allocated arrays) | |
| void | dft1D (const Kokkos::View< Real * > &input, Kokkos::View< Complex * > &output) |
| Apply the solver one-dimensional real-to-complex DFT. | |
| void | dft_or_idft_cpx (const Kokkos::View< Complex * > &input, Kokkos::View< Complex * > &output, int isign) |
| Apply a complex forward or inverse DFT. | |
| void | dftInverse1D (const Kokkos::View< Complex * > &input, Kokkos::View< Real * > &output) |
| Apply the solver one-dimensional inverse DFT. | |
| void | dftInverse1D_full (const Kokkos::View< Complex * > &input, Kokkos::View< Real * > &output) |
| Apply the full-spectrum complex-to-real inverse transform. | |
| void | dftInverse1D_rc (const Kokkos::View< Complex * > &input, Kokkos::View< Real * > &output) |
| Apply the reduced complex-to-real inverse transform. | |
| void | domainOfIntegrationExtended (int imin, int isp, Real &smin, Real &smax, int &ixmin_int, int &ixmax_int) |
| Determine the extended radial integration domain. | |
| bool | fieldmodefilter (int i, int m, int n) const |
Test whether Fourier mode (m,n) is retained. | |
| void | finalizeMatrix () |
| Apply boundary conditions and factorize all assembled matrices. | |
| int | getLocalToroidalIndex (int n) const |
| Map a global toroidal mode to this rank's packed index. | |
| void | initSolverModule (int me_assembly, int tgt_assembly, int color, int nx_, int nz_, int nw_, Real wmax_, int kdx_, int em_kdx_, int dm_, bool electromagnetic_, bool em_control_variate_, bool pullback_, int fieldaligned_, bool longwavelength_, int na_half_rho_ref_, bool phase_factor_, const Kokkos::View< bool * > &isnfiltlocal_, const Kokkos::View< bool * > &isnfiltlocalysolved_, int NBmodeslocal_, const Kokkos::View< int * > &nfiltlocal_, int navgmax_, int testcase_, int internal_boundary_, bool pade_, int multi_matrix_, int inner_BC_, bool lapl_boundary_terms_) |
| Initialize distributed field-matrix assembly and solve state. | |
| void | multiply_mass_f (Kokkos::View< Complex * > &arr_f, int globalk) |
| Multiply a Fourier vector by its toroidal-mode mass matrix. | |
| void | print_matrix_gbmatf () |
| Print the assembled general-band matrix for solver debugging. | |
| void | reality_condition (std::vector< Complex > &v_dft, int ny, int ny2) |
| Complete conjugate symmetry for a real-valued field spectrum. | |
| void | reduce_matrix (int &ierr, MPI_Comm comm, int tgt, int me) |
| Reduce assembled matrix contributions to a target rank. | |
| SolverModule () | |
| Default constructor: zero-initializes all members. | |
| ~SolverModule () | |
| Destructor: cleans up allocated Kokkos views. | |
Static Public Member Functions | |
| static SolverModule & | instance () |
| Access the process-wide solver instance. | |
Public Attributes | |
| Kokkos::View< bool * > * | isnfiltlocal |
| Non-owning mask of toroidal modes retained on this rank. | |
| int | multi_matrix |
| Number/selector of separately factorized field matrices. | |
| int | NBmodeslocal |
| --— Public member variables (matching Fortran module-level public variables) --— | |
| Real | tim_dyad_cumul |
| Cumulative wall time spent assembling dyadic matrix terms [s]. | |
Main solver module for matrix assembly and solving Handles LHS matrix assembly, RHS assembly, and backsolving.
Refactored from all-static class to instance-based design:
| orb5x::SolverModule::SolverModule | ( | ) |
Default constructor: zero-initializes all members.
| orb5x::SolverModule::~SolverModule | ( | ) |
Destructor: cleans up allocated Kokkos views.
| void orb5x::SolverModule::assemblyBoltzman | ( | int | isp, |
| int | nqx, | ||
| int | nqy, | ||
| bool | remove_trap_contribution | ||
| ) |
Assemble the non-zonal Boltzmann response.
| [in] | isp | Zero-based species index. |
| [in] | nqx | Radial quadrature order. |
| [in] | nqy | Poloidal quadrature order. |
| [in] | remove_trap_contribution | Exclude trapped-particle response when true. |
| void orb5x::SolverModule::assemblyBoltzman_zf | ( | int | isp, |
| int | nqx, | ||
| int | nqy, | ||
| bool | remove_trap_contribution, | ||
| bool | oldAvgJac | ||
| ) |
Assemble the zonal Boltzmann response.
| [in] | isp | Zero-based species index. |
| [in] | nqx | Radial quadrature order. |
| [in] | nqy | Poloidal quadrature order. |
| [in] | remove_trap_contribution | Exclude trapped-particle response. |
| [in] | oldAvgJac | Use the legacy averaged-Jacobian algorithm. |
| void orb5x::SolverModule::assemblyBoltzmannPade | ( | int | isp, |
| int | nqx, | ||
| int | nqy, | ||
| bool | remove_trap_contribution | ||
| ) |
Assemble the Pade-approximated non-zonal Boltzmann response.
| [in] | isp | Zero-based species index. |
| [in] | nqx | Radial quadrature order. |
| [in] | nqy | Poloidal quadrature order. |
| [in] | remove_trap_contribution | Exclude trapped-particle response. |
| void orb5x::SolverModule::assemblyBoltzmannPade_zf | ( | int | isp, |
| int | nqx, | ||
| int | nqy, | ||
| bool | remove_trap_contribution | ||
| ) |
Assemble the Pade-approximated zonal Boltzmann response.
| [in] | isp | Zero-based species index. |
| [in] | nqx | Radial quadrature order. |
| [in] | nqy | Poloidal quadrature order. |
| [in] | remove_trap_contribution | Exclude trapped-particle response. |
| void orb5x::SolverModule::assemblyLHSFinalize | ( | ) |
Finalize and reduce accumulated left-hand-side contributions.
| void orb5x::SolverModule::assemblyMassMatrix | ( | int | nqx, |
| int | nqy | ||
| ) |
Assemble the tensor-product finite-element mass matrix.
| [in] | nqx | Radial quadrature order. |
| [in] | nqy | Poloidal quadrature order. |
| void orb5x::SolverModule::assemblyMatrix | ( | int | nqx, |
| int | nqy | ||
| ) |
Assemble solver matrices using requested quadrature orders.
| [in] | nqx | Radial quadrature order. |
| [in] | nqy | Poloidal quadrature order. |
| void orb5x::SolverModule::assemblyPadeMatForRHS | ( | int | isp, |
| int | nqx, | ||
| int | nqy | ||
| ) |
Assemble the Pade operator applied to the field-equation RHS.
| [in] | isp | Zero-based species index. |
| [in] | nqx | Radial quadrature order. |
| [in] | nqy | Poloidal quadrature order. |
| void orb5x::SolverModule::assemblyPolDrift_arbitrary_wavelength_fourier | ( | int | isp, |
| int | nqx, | ||
| int | nqy, | ||
| int | iy_start, | ||
| int | iy_end | ||
| ) |
Assemble finite-Larmor-radius polarization coupling.
| [in] | isp | Zero-based species index. |
| [in] | nqx | Radial quadrature order. |
| [in] | nqy | Poloidal quadrature order. |
| [in] | iy_start | First included poloidal/radial work index. |
| [in] | iy_end | Last included work index. |
| void orb5x::SolverModule::assemblyPolDrift_longwavelength_fourier | ( | int | isp, |
| int | nqx, | ||
| int | nqy | ||
| ) |
Assemble the long-wavelength polarization-drift operator.
| [in] | isp | Zero-based species index. |
| [in] | nqx | Radial quadrature order. |
| [in] | nqy | Poloidal quadrature order. |
| void orb5x::SolverModule::assemblyRHS_antenna | ( | Kokkos::View< Complex * > & | rhs_f, |
| int | nmat, | ||
| int | nqx, | ||
| int | nqy, | ||
| Real | phase_shift = 0.0, |
||
| const std::vector< Real > * | sprof = nullptr, |
||
| const std::vector< Real > * | prof = nullptr, |
||
| int | nprof = 0 |
||
| ) |
Add configured antenna forcing to a Fourier RHS.
| [in,out] | rhs_f | Fourier RHS receiving the forcing. |
| [in] | nmat | Toroidal/local matrix index. |
| [in] | nqx | Radial quadrature order. |
| [in] | nqy | Poloidal quadrature order. |
| [in] | phase_shift | Additional phase [rad]. |
| [in] | sprof | Optional radial profile coordinates. |
| [in] | prof | Optional profile amplitudes. |
| [in] | nprof | Number of valid profile samples. |
| void orb5x::SolverModule::assemblyRHS_tests | ( | Kokkos::View< Complex * > & | rhs_f, |
| int | nmat, | ||
| int | nqx, | ||
| int | nqy | ||
| ) |
Assemble an analytic solver-test right-hand side.
| [out] | rhs_f | Fourier RHS. |
| [in] | nmat | Toroidal/local matrix index. |
| [in] | nqx | Radial quadrature order. |
| [in] | nqy | Poloidal quadrature order. |
| void orb5x::SolverModule::backsolve_mass_f | ( | const Kokkos::View< Complex * > & | arr_f, |
| Kokkos::View< Complex * > & | out_f, | ||
| int | globalk | ||
| ) |
Apply the complex Fourier-space inverse mass matrix.
| [in] | arr_f | Projection-space coefficient vector. |
| [out] | out_f | Solution-space coefficient vector. |
| [in] | globalk | Signed global toroidal mode number. |
| void orb5x::SolverModule::backsolve_mass_s | ( | const Kokkos::View< Real * > & | arr_f, |
| Kokkos::View< Real * > & | out_f | ||
| ) |
Apply the real-space inverse mass matrix to one vector.
| [in] | arr_f | Projection-space real coefficients. |
| [out] | out_f | Solution-space real coefficients. |
| void orb5x::SolverModule::backsolve_mass_sn | ( | const Kokkos::View< Real * > & | arr_f, |
| Kokkos::View< Real * > & | out_f, | ||
| int | nmode | ||
| ) |
Apply the real inverse mass matrix for one poloidal mode.
| [in] | arr_f | Projection-space real coefficients. |
| [out] | out_f | Solution-space real coefficients. |
| [in] | nmode | Signed poloidal mode number. |
| void orb5x::SolverModule::backsolve_rhs_f | ( | Kokkos::View< Complex * > & | rhs_f, |
| int | globalk, | ||
| int | matnum | ||
| ) |
Solve one Fourier-mode field system in place.
| [in,out] | rhs_f | RHS replaced by solution coefficients. |
| [in] | globalk | Signed global toroidal mode number. |
| [in] | matnum | Factorized matrix selector. |
| void orb5x::SolverModule::backsolve_rhs_f_host | ( | Complex * | rhs, |
| int | n, | ||
| int | globalk, | ||
| int | matnum | ||
| ) |
Solve one Fourier system from contiguous host storage.
| [in,out] | rhs | Host RHS replaced by solution coefficients. |
| [in] | n | Number of accessible complex coefficients. |
| [in] | globalk | Signed global toroidal mode number. |
| [in] | matnum | Factorized matrix selector. |
| void orb5x::SolverModule::backsolve_rhs_f_multi | ( | const Kokkos::View< Complex ** > & | rhs_f, |
| int | globalk, | ||
| int | matnum | ||
| ) |
Solve multiple Fourier RHS columns for one toroidal mode.
| [in,out] | rhs_f | RHS matrix replaced by solution columns. |
| [in] | globalk | Signed global toroidal mode number. |
| [in] | matnum | Factorized matrix selector. |
| void orb5x::SolverModule::broadcast_matrix | ( | int & | ierr, |
| MPI_Comm | comm, | ||
| int | tgt, | ||
| int | me | ||
| ) |
Broadcast the active assembled matrix from the target rank.
| [out] | ierr | MPI status code. |
| [in] | comm | Assembly communicator. |
| [in] | tgt | Source rank in comm. |
| [in] | me | Calling rank in comm. |
| Real orb5x::SolverModule::computeToroidalMassCoeff | ( | int | n | ) |
Return the toroidal B-spline mass factor.
| [in] | n | Signed toroidal mode number. |
| void orb5x::SolverModule::copy_matrix_filter | ( | int | ixmin, |
| int | ixmax, | ||
| int | n, | ||
| Kokkos::View< int * > & | mmmincopy | ||
| ) |
Copy retained poloidal-mode bounds over a radial range.
| [in] | ixmin | First radial basis index. |
| [in] | ixmax | Last radial basis index. |
| [in] | n | Signed toroidal mode number. |
| [out] | mmmincopy | Packed lower-mode bounds. |
| void orb5x::SolverModule::destroySolverModule | ( | ) |
Destroy solver module (cleanup allocated arrays)
| void orb5x::SolverModule::dft1D | ( | const Kokkos::View< Real * > & | input, |
| Kokkos::View< Complex * > & | output | ||
| ) |
Apply the solver one-dimensional real-to-complex DFT.
| [in] | input | Real periodic samples. |
| [out] | output | Nonredundant complex Fourier coefficients. |
| void orb5x::SolverModule::dft_or_idft_cpx | ( | const Kokkos::View< Complex * > & | input, |
| Kokkos::View< Complex * > & | output, | ||
| int | isign | ||
| ) |
Apply a complex forward or inverse DFT.
| [in] | input | Complex periodic samples or coefficients. |
| [out] | output | Transformed complex values. |
| [in] | isign | Transform direction sign used by solver_mpi.F90. |
| void orb5x::SolverModule::dftInverse1D | ( | const Kokkos::View< Complex * > & | input, |
| Kokkos::View< Real * > & | output | ||
| ) |
Apply the solver one-dimensional inverse DFT.
| [in] | input | Nonredundant complex Fourier coefficients. |
| [out] | output | Reconstructed real periodic samples. |
| void orb5x::SolverModule::dftInverse1D_full | ( | const Kokkos::View< Complex * > & | input, |
| Kokkos::View< Real * > & | output | ||
| ) |
Apply the full-spectrum complex-to-real inverse transform.
| [in] | input | Full conjugate-symmetric complex spectrum. |
| [out] | output | Reconstructed real samples. |
| void orb5x::SolverModule::dftInverse1D_rc | ( | const Kokkos::View< Complex * > & | input, |
| Kokkos::View< Real * > & | output | ||
| ) |
Apply the reduced complex-to-real inverse transform.
| [in] | input | Reduced complex spectrum. |
| [out] | output | Reconstructed real samples. |
| void orb5x::SolverModule::domainOfIntegrationExtended | ( | int | imin, |
| int | isp, | ||
| Real & | smin, | ||
| Real & | smax, | ||
| int & | ixmin_int, | ||
| int & | ixmax_int | ||
| ) |
Determine the extended radial integration domain.
| [in] | imin | Central/minimum radial basis index. |
| [in] | isp | Zero-based species index. |
| [out] | smin | Lower physical radial coordinate. |
| [out] | smax | Upper physical radial coordinate. |
| [out] | ixmin_int | First included radial basis index. |
| [out] | ixmax_int | Last included radial basis index. |
domainOfIntegrationExtended in solver_mpi.F90. | bool orb5x::SolverModule::fieldmodefilter | ( | int | i, |
| int | m, | ||
| int | n | ||
| ) | const |
Test whether Fourier mode (m,n) is retained.
| [in] | i | Radial basis index. |
| [in] | m | Signed poloidal mode number. |
| [in] | n | Signed toroidal mode number. |
true when the mode lies within configured filter bounds. | void orb5x::SolverModule::finalizeMatrix | ( | ) |
Apply boundary conditions and factorize all assembled matrices.
| int orb5x::SolverModule::getLocalToroidalIndex | ( | int | n | ) | const |
Map a global toroidal mode to this rank's packed index.
| [in] | n | Signed global toroidal mode number. |
| void orb5x::SolverModule::initSolverModule | ( | int | me_assembly, |
| int | tgt_assembly, | ||
| int | color, | ||
| int | nx_, | ||
| int | nz_, | ||
| int | nw_, | ||
| Real | wmax_, | ||
| int | kdx_, | ||
| int | em_kdx_, | ||
| int | dm_, | ||
| bool | electromagnetic_, | ||
| bool | em_control_variate_, | ||
| bool | pullback_, | ||
| int | fieldaligned_, | ||
| bool | longwavelength_, | ||
| int | na_half_rho_ref_, | ||
| bool | phase_factor_, | ||
| const Kokkos::View< bool * > & | isnfiltlocal_, | ||
| const Kokkos::View< bool * > & | isnfiltlocalysolved_, | ||
| int | NBmodeslocal_, | ||
| const Kokkos::View< int * > & | nfiltlocal_, | ||
| int | navgmax_, | ||
| int | testcase_, | ||
| int | internal_boundary_, | ||
| bool | pade_, | ||
| int | multi_matrix_, | ||
| int | inner_BC_, | ||
| bool | lapl_boundary_terms_ | ||
| ) |
Initialize distributed field-matrix assembly and solve state.
| [in] | me_assembly | Rank in the assembly communicator. |
| [in] | tgt_assembly | Root rank for matrix assembly collectives. |
| [in] | color | Assembly load-balancing color. |
| [in] | nx_ | Radial interval count. |
| [in] | nz_ | Global toroidal interval count. |
| [in] | nw_ | Velocity-space quadrature interval count. |
| [in] | wmax_ | Upper normalized velocity-quadrature bound. |
| [in] | kdx_ | Electrostatic radial coupling range. |
| [in] | em_kdx_ | Electromagnetic radial coupling range. |
| [in] | dm_ | Half-width of poloidal-mode coupling. |
| [in] | electromagnetic_ | Assemble electromagnetic equations. |
| [in] | em_control_variate_ | Enable electromagnetic control variates. |
| [in] | pullback_ | Enable pullback mitigation terms. |
| [in] | fieldaligned_ | Field-aligned discretization selector. |
| [in] | longwavelength_ | Use the long-wavelength polarization operator. |
| [in] | na_half_rho_ref_ | Gyropoints over a reference half orbit. |
| [in] | phase_factor_ | Apply field-aligned Fourier phase factors. |
| [in] | isnfiltlocal_ | Modes assembled by this rank. |
| [in] | isnfiltlocalysolved_ | Modes backsolved by this rank. |
| [in] | NBmodeslocal_ | Number of packed local modes. |
| [in] | nfiltlocal_ | Packed signed local mode numbers. |
| [in] | navgmax_ | Maximum gyroaveraging-point count. |
| [in] | testcase_ | Analytic solver test-case selector. |
| [in] | internal_boundary_ | Internal radial-boundary selector. |
| [in] | pade_ | Enable the Pade gyroaveraging approximation. |
| [in] | multi_matrix_ | Multi-matrix configuration selector/count. |
| [in] | inner_BC_ | Inner radial boundary-condition selector. |
| [in] | lapl_boundary_terms_ | Include explicit Laplacian boundary terms. |
initSolverModule in solver_mpi.F90.
|
static |
Access the process-wide solver instance.
| void orb5x::SolverModule::multiply_mass_f | ( | Kokkos::View< Complex * > & | arr_f, |
| int | globalk | ||
| ) |
Multiply a Fourier vector by its toroidal-mode mass matrix.
| [in,out] | arr_f | Coefficients replaced by their mass projection. |
| [in] | globalk | Signed global toroidal mode number. |
| void orb5x::SolverModule::print_matrix_gbmatf | ( | ) |
Print the assembled general-band matrix for solver debugging.
| void orb5x::SolverModule::reality_condition | ( | std::vector< Complex > & | v_dft, |
| int | ny, | ||
| int | ny2 | ||
| ) |
Complete conjugate symmetry for a real-valued field spectrum.
| [in,out] | v_dft | Spectrum whose negative-frequency half is populated. |
| [in] | ny | Full periodic sample count. |
| [in] | ny2 | Nonredundant complex coefficient count. |
| void orb5x::SolverModule::reduce_matrix | ( | int & | ierr, |
| MPI_Comm | comm, | ||
| int | tgt, | ||
| int | me | ||
| ) |
Reduce assembled matrix contributions to a target rank.
| [out] | ierr | MPI status code. |
| [in] | comm | Assembly communicator. |
| [in] | tgt | Target rank in comm. |
| [in] | me | Calling rank in comm. |
| Kokkos::View<bool*>* orb5x::SolverModule::isnfiltlocal |
Non-owning mask of toroidal modes retained on this rank.
| int orb5x::SolverModule::multi_matrix |
Number/selector of separately factorized field matrices.
| int orb5x::SolverModule::NBmodeslocal |
--— Public member variables (matching Fortran module-level public variables) --—
| Real orb5x::SolverModule::tim_dyad_cumul |
Cumulative wall time spent assembling dyadic matrix terms [s].