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

Matrix Preconditione. More...

#include <MatrixPC.H>

Inheritance diagram for MatrixPC< 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

 MatrixPC ()=default
 Default constructor.
 
 ~MatrixPC () override=default
 Default destructor.
 
 MatrixPC (const MatrixPC &)=delete
 
MatrixPCoperator= (const MatrixPC &)=delete
 
 MatrixPC (MatrixPC &&) noexcept=delete
 
MatrixPCoperator= (MatrixPC &&) noexcept=delete
 
void Define (const T &, Ops *const) override
 Define the preconditioner.
 
void Update (const T &a_U) override
 Update the preconditioner.
 
int Assemble (const T &a_U)
 Assemble the matrix.
 
void Apply (T &, const T &) override
 Apply (solve) the preconditioner given a RHS.
 
void getPCMatrix (amrex::Gpu::DeviceVector< int > &a_r_indices_g, amrex::Gpu::DeviceVector< int > &a_num_nz, amrex::Gpu::DeviceVector< int > &a_c_indices_g, amrex::Gpu::DeviceVector< RT > &a_a_ij, int &a_n, int &a_ncols_max) override
 Get the sparse matrix form of the preconditioner.
 
void printParameters () const override
 Print parameters.
 
bool IsDefined () const override
 Check if the nonlinear solver has been defined.
 
void setName (const std::string &a_name) override
 Set the name for screen output and parsing inputs.
 
- 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
 
void CurTime (const RT a_time)
 Set the current time.
 
void CurTimeStep (const RT a_dt)
 Set the current time step size.
 

Protected Member Functions

void readParameters ()
 Read parameters.
 

Protected Attributes

bool m_is_defined = false
 
bool m_verbose = true
 
Ops * m_ops = nullptr
 
int m_num_amr_levels = 0
 
amrex::Vector< amrex::Geometrym_geom
 
int m_ndofs_l = 0
 
int m_ndofs_g = 0
 
bool m_pc_diag_only = false
 
int m_pc_mat_nnz = 1
 
int m_pc_mass_matrix_width = 0
 
bool m_pc_mass_matrix_include_ij = false
 
std::string m_name = "noname"
 
amrex::Gpu::DeviceVector< int > m_r_indices_g
 
amrex::Gpu::DeviceVector< int > m_num_nz
 
amrex::Gpu::DeviceVector< int > m_c_indices_g
 
amrex::Gpu::DeviceVector< amrex::Real > m_a_ij
 
const amrex::Vector< amrex::Array< amrex::MultiFab *, 3 > > * m_bcoefs = nullptr
 
int m_num_realloc = 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 MatrixPC< T, Ops >

Matrix Preconditione.

This class is templated on a solution-type class T and an operator class Ops. It implements a preconditioner based on constructing and solving the sparse matrix representation of the Jacobian. Currently, it implements constructing/assembling the sparse matrix. An external library with sparse matrix solvers (for example, PETSc) is needed to apply the preconditioner.

The Ops class must have the following function:

  • Return number of AMR levels
  • Return the amrex::Geometry object given an AMR level
  • Return hi and lo linear operator boundaries
  • Return the time step factor (theta) for the time integration scheme

The T class must have the following functions:

Member Typedef Documentation

◆ RT

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

Constructor & Destructor Documentation

◆ MatrixPC() [1/3]

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

Default constructor.

◆ ~MatrixPC()

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

Default destructor.

◆ MatrixPC() [2/3]

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

◆ MatrixPC() [3/3]

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

Member Function Documentation

◆ Apply()

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

Apply (solve) the preconditioner given a RHS.

Given a right-hand-side b, solve: A x = b where A is the linear operator, in this case, the curl-curl operator: A x = curl (alpha * curl (x) ) + beta * x

Implements Preconditioner< T, Ops >.

◆ Assemble()

template<class T, class Ops>
int MatrixPC< T, Ops >::Assemble ( const T & a_U)

Assemble the matrix.

Returns 0 if matrix assembly is successful; returns positive integer if allocated arrays are insufficient to hold all non-zero elements (return value is difference in current number of nonzero elements and the desired number).

◆ Define()

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

Define the preconditioner.

Implements Preconditioner< T, Ops >.

◆ getPCMatrix()

template<class T, class Ops>
void MatrixPC< T, Ops >::getPCMatrix ( amrex::Gpu::DeviceVector< int > & ,
amrex::Gpu::DeviceVector< int > & ,
amrex::Gpu::DeviceVector< int > & ,
amrex::Gpu::DeviceVector< RT > & ,
int & ,
int &  )
inlineoverridevirtual

Get the sparse matrix form of the preconditioner.

If the preconditioner is based on constructing and solving the sparse matrix form, this function will return the sparse matrix form. Base class implementation aborts with an error message to ensure this function is not called for operator-form preconditioners

Reimplemented from Preconditioner< T, Ops >.

◆ IsDefined()

template<class T, class Ops>
bool MatrixPC< 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>
MatrixPC & MatrixPC< T, Ops >::operator= ( const MatrixPC< T, Ops > & )
delete

◆ operator=() [2/2]

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

◆ printParameters()

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

Print parameters.

Reimplemented from Preconditioner< T, Ops >.

◆ readParameters()

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

Read parameters.

◆ setName()

template<class T, class Ops>
void MatrixPC< T, Ops >::setName ( const std::string & )
inlineoverridevirtual

Set the name for screen output and parsing inputs.

Reimplemented from Preconditioner< T, Ops >.

◆ Update()

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

Update the preconditioner.

Implements Preconditioner< T, Ops >.

Member Data Documentation

◆ m_a_ij

template<class T, class Ops>
amrex::Gpu::DeviceVector<amrex::Real> MatrixPC< T, Ops >::m_a_ij
protected

◆ m_bcoefs

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

◆ m_c_indices_g

template<class T, class Ops>
amrex::Gpu::DeviceVector<int> MatrixPC< T, Ops >::m_c_indices_g
protected

◆ m_geom

template<class T, class Ops>
amrex::Vector<amrex::Geometry> MatrixPC< T, Ops >::m_geom
protected

◆ m_is_defined

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

◆ m_name

template<class T, class Ops>
std::string MatrixPC< T, Ops >::m_name = "noname"
protected

◆ m_ndofs_g

template<class T, class Ops>
int MatrixPC< T, Ops >::m_ndofs_g = 0
protected

◆ m_ndofs_l

template<class T, class Ops>
int MatrixPC< T, Ops >::m_ndofs_l = 0
protected

◆ m_num_amr_levels

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

◆ m_num_nz

template<class T, class Ops>
amrex::Gpu::DeviceVector<int> MatrixPC< T, Ops >::m_num_nz
protected

◆ m_num_realloc

template<class T, class Ops>
int MatrixPC< T, Ops >::m_num_realloc = 0
protected

◆ m_ops

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

◆ m_pc_diag_only

template<class T, class Ops>
bool MatrixPC< T, Ops >::m_pc_diag_only = false
protected

◆ m_pc_mass_matrix_include_ij

template<class T, class Ops>
bool MatrixPC< T, Ops >::m_pc_mass_matrix_include_ij = false
protected

◆ m_pc_mass_matrix_width

template<class T, class Ops>
int MatrixPC< T, Ops >::m_pc_mass_matrix_width = 0
protected

◆ m_pc_mat_nnz

template<class T, class Ops>
int MatrixPC< T, Ops >::m_pc_mat_nnz = 1
protected

◆ m_r_indices_g

template<class T, class Ops>
amrex::Gpu::DeviceVector<int> MatrixPC< T, Ops >::m_r_indices_g
protected

◆ m_verbose

template<class T, class Ops>
bool MatrixPC< T, Ops >::m_verbose = true
protected

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