ORB5X 1.0.0
Performance-portable global electromagnetic gyrokinetic PIC code
orb5x::SolverModule Class Reference

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].
 

Detailed Description

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:

  • Member variables are now instance members (matching Fortran module variables)
  • Initialized in constructor / initSolverModule
  • A singleton accessor is provided for legacy code that expects static access

Constructor & Destructor Documentation

◆ SolverModule()

orb5x::SolverModule::SolverModule ( )

Default constructor: zero-initializes all members.

◆ ~SolverModule()

orb5x::SolverModule::~SolverModule ( )

Destructor: cleans up allocated Kokkos views.

Member Function Documentation

◆ assemblyBoltzman()

void orb5x::SolverModule::assemblyBoltzman ( int  isp,
int  nqx,
int  nqy,
bool  remove_trap_contribution 
)

Assemble the non-zonal Boltzmann response.

Parameters
[in]ispZero-based species index.
[in]nqxRadial quadrature order.
[in]nqyPoloidal quadrature order.
[in]remove_trap_contributionExclude trapped-particle response when true.

◆ assemblyBoltzman_zf()

void orb5x::SolverModule::assemblyBoltzman_zf ( int  isp,
int  nqx,
int  nqy,
bool  remove_trap_contribution,
bool  oldAvgJac 
)

Assemble the zonal Boltzmann response.

Parameters
[in]ispZero-based species index.
[in]nqxRadial quadrature order.
[in]nqyPoloidal quadrature order.
[in]remove_trap_contributionExclude trapped-particle response.
[in]oldAvgJacUse the legacy averaged-Jacobian algorithm.

◆ assemblyBoltzmannPade()

void orb5x::SolverModule::assemblyBoltzmannPade ( int  isp,
int  nqx,
int  nqy,
bool  remove_trap_contribution 
)

Assemble the Pade-approximated non-zonal Boltzmann response.

Parameters
[in]ispZero-based species index.
[in]nqxRadial quadrature order.
[in]nqyPoloidal quadrature order.
[in]remove_trap_contributionExclude trapped-particle response.

◆ assemblyBoltzmannPade_zf()

void orb5x::SolverModule::assemblyBoltzmannPade_zf ( int  isp,
int  nqx,
int  nqy,
bool  remove_trap_contribution 
)

Assemble the Pade-approximated zonal Boltzmann response.

Parameters
[in]ispZero-based species index.
[in]nqxRadial quadrature order.
[in]nqyPoloidal quadrature order.
[in]remove_trap_contributionExclude trapped-particle response.

◆ assemblyLHSFinalize()

void orb5x::SolverModule::assemblyLHSFinalize ( )

Finalize and reduce accumulated left-hand-side contributions.

◆ assemblyMassMatrix()

void orb5x::SolverModule::assemblyMassMatrix ( int  nqx,
int  nqy 
)

Assemble the tensor-product finite-element mass matrix.

Parameters
[in]nqxRadial quadrature order.
[in]nqyPoloidal quadrature order.

◆ assemblyMatrix()

void orb5x::SolverModule::assemblyMatrix ( int  nqx,
int  nqy 
)

Assemble solver matrices using requested quadrature orders.

Parameters
[in]nqxRadial quadrature order.
[in]nqyPoloidal quadrature order.

◆ assemblyPadeMatForRHS()

void orb5x::SolverModule::assemblyPadeMatForRHS ( int  isp,
int  nqx,
int  nqy 
)

Assemble the Pade operator applied to the field-equation RHS.

Parameters
[in]ispZero-based species index.
[in]nqxRadial quadrature order.
[in]nqyPoloidal quadrature order.

◆ assemblyPolDrift_arbitrary_wavelength_fourier()

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.

Parameters
[in]ispZero-based species index.
[in]nqxRadial quadrature order.
[in]nqyPoloidal quadrature order.
[in]iy_startFirst included poloidal/radial work index.
[in]iy_endLast included work index.

◆ assemblyPolDrift_longwavelength_fourier()

void orb5x::SolverModule::assemblyPolDrift_longwavelength_fourier ( int  isp,
int  nqx,
int  nqy 
)

Assemble the long-wavelength polarization-drift operator.

Parameters
[in]ispZero-based species index.
[in]nqxRadial quadrature order.
[in]nqyPoloidal quadrature order.

◆ assemblyRHS_antenna()

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.

Parameters
[in,out]rhs_fFourier RHS receiving the forcing.
[in]nmatToroidal/local matrix index.
[in]nqxRadial quadrature order.
[in]nqyPoloidal quadrature order.
[in]phase_shiftAdditional phase [rad].
[in]sprofOptional radial profile coordinates.
[in]profOptional profile amplitudes.
[in]nprofNumber of valid profile samples.

◆ assemblyRHS_tests()

void orb5x::SolverModule::assemblyRHS_tests ( Kokkos::View< Complex * > &  rhs_f,
int  nmat,
int  nqx,
int  nqy 
)

Assemble an analytic solver-test right-hand side.

Parameters
[out]rhs_fFourier RHS.
[in]nmatToroidal/local matrix index.
[in]nqxRadial quadrature order.
[in]nqyPoloidal quadrature order.

◆ backsolve_mass_f()

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.

Parameters
[in]arr_fProjection-space coefficient vector.
[out]out_fSolution-space coefficient vector.
[in]globalkSigned global toroidal mode number.

◆ backsolve_mass_s()

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.

Parameters
[in]arr_fProjection-space real coefficients.
[out]out_fSolution-space real coefficients.

◆ backsolve_mass_sn()

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.

Parameters
[in]arr_fProjection-space real coefficients.
[out]out_fSolution-space real coefficients.
[in]nmodeSigned poloidal mode number.

◆ backsolve_rhs_f()

void orb5x::SolverModule::backsolve_rhs_f ( Kokkos::View< Complex * > &  rhs_f,
int  globalk,
int  matnum 
)

Solve one Fourier-mode field system in place.

Parameters
[in,out]rhs_fRHS replaced by solution coefficients.
[in]globalkSigned global toroidal mode number.
[in]matnumFactorized matrix selector.

◆ backsolve_rhs_f_host()

void orb5x::SolverModule::backsolve_rhs_f_host ( Complex *  rhs,
int  n,
int  globalk,
int  matnum 
)

Solve one Fourier system from contiguous host storage.

Parameters
[in,out]rhsHost RHS replaced by solution coefficients.
[in]nNumber of accessible complex coefficients.
[in]globalkSigned global toroidal mode number.
[in]matnumFactorized matrix selector.

◆ backsolve_rhs_f_multi()

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.

Parameters
[in,out]rhs_fRHS matrix replaced by solution columns.
[in]globalkSigned global toroidal mode number.
[in]matnumFactorized matrix selector.

◆ broadcast_matrix()

void orb5x::SolverModule::broadcast_matrix ( int &  ierr,
MPI_Comm  comm,
int  tgt,
int  me 
)

Broadcast the active assembled matrix from the target rank.

Parameters
[out]ierrMPI status code.
[in]commAssembly communicator.
[in]tgtSource rank in comm.
[in]meCalling rank in comm.

◆ computeToroidalMassCoeff()

Real orb5x::SolverModule::computeToroidalMassCoeff ( int  n)

Return the toroidal B-spline mass factor.

Parameters
[in]nSigned toroidal mode number.
Returns
Dimensionless periodic B-spline coupling factor.

◆ copy_matrix_filter()

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.

Parameters
[in]ixminFirst radial basis index.
[in]ixmaxLast radial basis index.
[in]nSigned toroidal mode number.
[out]mmmincopyPacked lower-mode bounds.

◆ destroySolverModule()

void orb5x::SolverModule::destroySolverModule ( )

Destroy solver module (cleanup allocated arrays)

◆ dft1D()

void orb5x::SolverModule::dft1D ( const Kokkos::View< Real * > &  input,
Kokkos::View< Complex * > &  output 
)

Apply the solver one-dimensional real-to-complex DFT.

Parameters
[in]inputReal periodic samples.
[out]outputNonredundant complex Fourier coefficients.

◆ dft_or_idft_cpx()

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.

Parameters
[in]inputComplex periodic samples or coefficients.
[out]outputTransformed complex values.
[in]isignTransform direction sign used by solver_mpi.F90.

◆ dftInverse1D()

void orb5x::SolverModule::dftInverse1D ( const Kokkos::View< Complex * > &  input,
Kokkos::View< Real * > &  output 
)

Apply the solver one-dimensional inverse DFT.

Parameters
[in]inputNonredundant complex Fourier coefficients.
[out]outputReconstructed real periodic samples.

◆ dftInverse1D_full()

void orb5x::SolverModule::dftInverse1D_full ( const Kokkos::View< Complex * > &  input,
Kokkos::View< Real * > &  output 
)

Apply the full-spectrum complex-to-real inverse transform.

Parameters
[in]inputFull conjugate-symmetric complex spectrum.
[out]outputReconstructed real samples.

◆ dftInverse1D_rc()

void orb5x::SolverModule::dftInverse1D_rc ( const Kokkos::View< Complex * > &  input,
Kokkos::View< Real * > &  output 
)

Apply the reduced complex-to-real inverse transform.

Parameters
[in]inputReduced complex spectrum.
[out]outputReconstructed real samples.

◆ domainOfIntegrationExtended()

void orb5x::SolverModule::domainOfIntegrationExtended ( int  imin,
int  isp,
Real &  smin,
Real &  smax,
int &  ixmin_int,
int &  ixmax_int 
)

Determine the extended radial integration domain.

Parameters
[in]iminCentral/minimum radial basis index.
[in]ispZero-based species index.
[out]sminLower physical radial coordinate.
[out]smaxUpper physical radial coordinate.
[out]ixmin_intFirst included radial basis index.
[out]ixmax_intLast included radial basis index.
Note
Matches domainOfIntegrationExtended in solver_mpi.F90.

◆ fieldmodefilter()

bool orb5x::SolverModule::fieldmodefilter ( int  i,
int  m,
int  n 
) const

Test whether Fourier mode (m,n) is retained.

Parameters
[in]iRadial basis index.
[in]mSigned poloidal mode number.
[in]nSigned toroidal mode number.
Returns
true when the mode lies within configured filter bounds.

◆ finalizeMatrix()

void orb5x::SolverModule::finalizeMatrix ( )

Apply boundary conditions and factorize all assembled matrices.

◆ getLocalToroidalIndex()

int orb5x::SolverModule::getLocalToroidalIndex ( int  n) const

Map a global toroidal mode to this rank's packed index.

Parameters
[in]nSigned global toroidal mode number.
Returns
Zero-based local index, or a negative sentinel when not owned.

◆ initSolverModule()

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.

Parameters
[in]me_assemblyRank in the assembly communicator.
[in]tgt_assemblyRoot rank for matrix assembly collectives.
[in]colorAssembly 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.
Note
Refactored from initSolverModule in solver_mpi.F90.

◆ instance()

static SolverModule & orb5x::SolverModule::instance ( )
static

Access the process-wide solver instance.

Returns
Initialized or default-constructed solver module.

◆ multiply_mass_f()

void orb5x::SolverModule::multiply_mass_f ( Kokkos::View< Complex * > &  arr_f,
int  globalk 
)

Multiply a Fourier vector by its toroidal-mode mass matrix.

Parameters
[in,out]arr_fCoefficients replaced by their mass projection.
[in]globalkSigned global toroidal mode number.

◆ print_matrix_gbmatf()

void orb5x::SolverModule::print_matrix_gbmatf ( )

Print the assembled general-band matrix for solver debugging.

◆ reality_condition()

void orb5x::SolverModule::reality_condition ( std::vector< Complex > &  v_dft,
int  ny,
int  ny2 
)

Complete conjugate symmetry for a real-valued field spectrum.

Parameters
[in,out]v_dftSpectrum whose negative-frequency half is populated.
[in]nyFull periodic sample count.
[in]ny2Nonredundant complex coefficient count.

◆ reduce_matrix()

void orb5x::SolverModule::reduce_matrix ( int &  ierr,
MPI_Comm  comm,
int  tgt,
int  me 
)

Reduce assembled matrix contributions to a target rank.

Parameters
[out]ierrMPI status code.
[in]commAssembly communicator.
[in]tgtTarget rank in comm.
[in]meCalling rank in comm.

Member Data Documentation

◆ isnfiltlocal

Kokkos::View<bool*>* orb5x::SolverModule::isnfiltlocal

Non-owning mask of toroidal modes retained on this rank.

◆ multi_matrix

int orb5x::SolverModule::multi_matrix

Number/selector of separately factorized field matrices.

◆ NBmodeslocal

int orb5x::SolverModule::NBmodeslocal

--— Public member variables (matching Fortran module-level public variables) --—

◆ tim_dyad_cumul

Real orb5x::SolverModule::tim_dyad_cumul

Cumulative wall time spent assembling dyadic matrix terms [s].


The documentation for this class was generated from the following file: