WarpX
Loading...
Searching...
No Matches
JacobiPC< T, Ops > Class Template Reference

Point-Jacobi Preconditioner. More...

#include <JacobiPC.H>

Inheritance diagram for JacobiPC< T, Ops >:
Preconditioner< T, Ops >

Public Types

using RT = typename T::value_type
 
- Public Types inherited from Preconditioner< T, Ops >
using RT = typename T::value_type
 

Public Member Functions

 JacobiPC ()=default
 
 ~JacobiPC () override=default
 
 JacobiPC (const JacobiPC &)=delete
 
JacobiPCoperator= (const JacobiPC &)=delete
 
 JacobiPC (JacobiPC &&) noexcept=delete
 
JacobiPCoperator= (JacobiPC &&) noexcept=delete
 
void Define (const T &, Ops *) override
 Define the preconditioner.
 
void Update (const T &a_U) override
 Update the preconditioner.
 
void Apply (T &, const T &) override
 Solve (I + M) x = b via damped Jacobi iteration.
 
void printParameters () const override
 Print parameters.
 
bool IsDefined () const override
 Check if the nonlinear solver has been defined.
 
RT computeResidualNorm (const T &a_x, const T &a_b) const
 Compute ||b - (I+M)*x|| for residual monitoring. Uses the ghost-padded m_x_ghost (which must already be populated and boundary-filled) for stencil neighbor access. For diagonal-only mass matrices (ncomp=1), uses the fast diagonal formula from x directly.
 
- Public Member Functions inherited from Preconditioner< T, Ops >
 Preconditioner ()=default
 Default constructor.
 
virtual ~Preconditioner ()=default
 Default destructor.
 
 Preconditioner (const Preconditioner &)=default
 
Preconditioneroperator= (const Preconditioner &)=default
 
 Preconditioner (Preconditioner &&) noexcept=default
 
Preconditioneroperator= (Preconditioner &&) noexcept=default
 
virtual void getPCMatrix (amrex::Gpu::DeviceVector< int > &, amrex::Gpu::DeviceVector< int > &, amrex::Gpu::DeviceVector< int > &, amrex::Gpu::DeviceVector< RT > &, int &, int &)
 Get the sparse matrix form of the preconditioner.
 
virtual void setName (const std::string &)
 Set the name for screen output and parsing inputs.
 
void CurTime (const RT a_time)
 Set the current time.
 
void CurTimeStep (const RT a_dt)
 Set the current time step size.
 

Protected Types

using MFArr = amrex::Array<amrex::MultiFab,3>
 

Protected Member Functions

void readParameters ()
 
void copyToGhostAndFill (const amrex::Vector< amrex::Array< amrex::MultiFab *, 3 > > &a_x_mfarrvec)
 

Protected Attributes

bool m_is_defined = false
 
bool m_verbose = false
 
int m_max_iter = 200
 
RT m_omega = RT(1.0)
 
bool m_adaptive_omega = true
 
RT m_atol = 1.0e-16
 
RT m_rtol = 1.0e-4
 
Ops * m_ops = nullptr
 
int m_num_amr_levels = 0
 
const amrex::Vector< amrex::Array< amrex::MultiFab *, 3 > > * m_bcoefs = nullptr
 
bool m_has_offdiag = false
 
bool m_work_defined = false
 
amrex::Vector< amrex::Array< amrex::MultiFab, 3 > > m_work
 
amrex::Vector< amrex::Array< amrex::MultiFab, 3 > > m_x_ghost
 
int m_stencil_width = 0
 
- Protected Attributes inherited from Preconditioner< T, Ops >
RT m_time = 0.0
 
RT m_dt = 0.0
 

Detailed Description

template<class T, class Ops>
class JacobiPC< T, Ops >

Point-Jacobi Preconditioner.

Approximately solves (I + M) x = b using damped Jacobi iterations, where M is the scaled mass matrix (plasma response dJ/dE).

When the mass matrix is purely diagonal (mass_matrices_pc_width=0), the solve is exact in one step: x = b / (1 + M_diag). When the mass matrix has off-diagonal stencil entries, damped Jacobi iterations are performed.

Adaptive omega (enabled by default): the relaxation parameter omega starts at 1.0 and is automatically reduced (by a factor of 0.9) when the Jacobi residual increases, indicating that the current omega is too large for the spectral properties of the mass matrix. The adapted omega is cached for subsequent Apply() calls. This handles marginally diagonally dominant or non-symmetric mass matrices. When the user explicitly sets pc_jacobi.omega, adaptive behavior is disabled (can be re-enabled with pc_jacobi.adaptive_omega = true).

Matrix Elements Layout: The mass matrix MultiFab stores stencil coefficients as components. For a field direction dim, the per-spatial-direction component counts are given by GetMassMatricesPCnComp(dim, d). The total number of components is the product over spatial dimensions. The diagonal component is at index (nComp-1)/2. The stencil offset for component c is decoded from the component index using the per-direction counts.

Note: WarpXSolverVec MultiFabs have zero ghost cells. This class allocates its own ghost-padded temporaries (m_x_ghost) for stencil neighbor access. All FillBoundary calls operate on these temporaries.

Member Typedef Documentation

◆ MFArr

template<class T, class Ops>
using JacobiPC< T, Ops >::MFArr = amrex::Array<amrex::MultiFab,3>
protected

◆ RT

template<class T, class Ops>
using JacobiPC< T, Ops >::RT = typename T::value_type

Constructor & Destructor Documentation

◆ JacobiPC() [1/3]

template<class T, class Ops>
JacobiPC< T, Ops >::JacobiPC ( )
default

◆ ~JacobiPC()

template<class T, class Ops>
JacobiPC< T, Ops >::~JacobiPC ( )
overridedefault

◆ JacobiPC() [2/3]

template<class T, class Ops>
JacobiPC< T, Ops >::JacobiPC ( const JacobiPC< T, Ops > & )
delete

◆ JacobiPC() [3/3]

template<class T, class Ops>
JacobiPC< T, Ops >::JacobiPC ( JacobiPC< T, Ops > && )
deletenoexcept

Member Function Documentation

◆ Apply()

template<class T, class Ops>
void JacobiPC< T, Ops >::Apply ( T & a_x,
const T & a_b )
overridevirtual

Solve (I + M) x = b via damped Jacobi iteration.

Implements Preconditioner< T, Ops >.

◆ computeResidualNorm()

template<class T, class Ops>
auto JacobiPC< T, Ops >::computeResidualNorm ( const T & a_x,
const T & a_b ) const

Compute ||b - (I+M)*x|| for residual monitoring. Uses the ghost-padded m_x_ghost (which must already be populated and boundary-filled) for stencil neighbor access. For diagonal-only mass matrices (ncomp=1), uses the fast diagonal formula from x directly.

◆ copyToGhostAndFill()

template<class T, class Ops>
void JacobiPC< T, Ops >::copyToGhostAndFill ( const amrex::Vector< amrex::Array< amrex::MultiFab *, 3 > > & a_x_mfarrvec)
protected

◆ Define()

template<class T, class Ops>
void JacobiPC< T, Ops >::Define ( const T & ,
Ops *  )
overridevirtual

Define the preconditioner.

Implements Preconditioner< T, Ops >.

◆ IsDefined()

template<class T, class Ops>
bool JacobiPC< T, Ops >::IsDefined ( ) const
inlinenodiscardoverridevirtual

Check if the nonlinear solver has been defined.

Implements Preconditioner< T, Ops >.

◆ operator=() [1/2]

template<class T, class Ops>
JacobiPC & JacobiPC< T, Ops >::operator= ( const JacobiPC< T, Ops > & )
delete

◆ operator=() [2/2]

template<class T, class Ops>
JacobiPC & JacobiPC< T, Ops >::operator= ( JacobiPC< T, Ops > && )
deletenoexcept

◆ printParameters()

template<class T, class Ops>
void JacobiPC< T, Ops >::printParameters ( ) const
overridevirtual

Print parameters.

Reimplemented from Preconditioner< T, Ops >.

◆ readParameters()

template<class T, class Ops>
void JacobiPC< T, Ops >::readParameters ( )
protected

◆ Update()

template<class T, class Ops>
void JacobiPC< T, Ops >::Update ( const T & a_U)
overridevirtual

Update the preconditioner.

Implements Preconditioner< T, Ops >.

Member Data Documentation

◆ m_adaptive_omega

template<class T, class Ops>
bool JacobiPC< T, Ops >::m_adaptive_omega = true
protected

◆ m_atol

template<class T, class Ops>
RT JacobiPC< T, Ops >::m_atol = 1.0e-16
protected

◆ m_bcoefs

template<class T, class Ops>
const amrex::Vector<amrex::Array<amrex::MultiFab*,3> >* JacobiPC< T, Ops >::m_bcoefs = nullptr
protected

◆ m_has_offdiag

template<class T, class Ops>
bool JacobiPC< T, Ops >::m_has_offdiag = false
protected

◆ m_is_defined

template<class T, class Ops>
bool JacobiPC< T, Ops >::m_is_defined = false
protected

◆ m_max_iter

template<class T, class Ops>
int JacobiPC< T, Ops >::m_max_iter = 200
protected

◆ m_num_amr_levels

template<class T, class Ops>
int JacobiPC< T, Ops >::m_num_amr_levels = 0
protected

◆ m_omega

template<class T, class Ops>
RT JacobiPC< T, Ops >::m_omega = RT(1.0)
protected

◆ m_ops

template<class T, class Ops>
Ops* JacobiPC< T, Ops >::m_ops = nullptr
protected

◆ m_rtol

template<class T, class Ops>
RT JacobiPC< T, Ops >::m_rtol = 1.0e-4
protected

◆ m_stencil_width

template<class T, class Ops>
int JacobiPC< T, Ops >::m_stencil_width = 0
protected

◆ m_verbose

template<class T, class Ops>
bool JacobiPC< T, Ops >::m_verbose = false
protected

◆ m_work

template<class T, class Ops>
amrex::Vector<amrex::Array<amrex::MultiFab,3> > JacobiPC< T, Ops >::m_work
protected

◆ m_work_defined

template<class T, class Ops>
bool JacobiPC< T, Ops >::m_work_defined = false
protected

◆ m_x_ghost

template<class T, class Ops>
amrex::Vector<amrex::Array<amrex::MultiFab,3> > JacobiPC< T, Ops >::m_x_ghost
protected

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