Extension: Matrix functions
#include "dg/matrix/matrix.h"
Loading...
Searching...
No Matches
dg::mat::CauchyMatrixProduct< Geometry, Matrix, ComplexContainer > Struct Template Reference

Computation of \( \vec x = f(A,\vec d)\vec b\) or \( \vec x = f( \vec d, A) \vec b\) where \( A \) is a positive (semi)-definite matrix self-adjoint in the weights \( W\) . More...

Public Member Functions

 CauchyMatrixProduct ()=default
 
 CauchyMatrixProduct (double lm_eps, const Geometry &grid, unsigned stages, bool adjoint=true)
 
const dg::MultigridCG2d< Geometry, Matrix, ComplexContainer, dg::complex_symmetric > & multigrid () const
 Access the internal multigrid method to be able to construct matrices.
 
void clear_cache ()
 Clear the cached Eigenvalues of the matrix in the solve method.
 
void set_verbose (bool verbose)
 Verbose output to std::cout.
 
unsigned num_nodes () const
 Number of (complex) nodes used in the latest call to solve.
 
void set_adjoint (bool adjoint)
 Determine if adjoint or direct bivariate matrix function is computed.
 
bool get_adjoint () const
 Current value of the adjoint parameter.
 
template<class MatrixType , class UnaryFunc , class UnaryFuncD , class ContainerType0 , class ContainerType1 , class ContainerType2 >
void solve (ContainerType0 &x, UnaryFunc func, UnaryFuncD dxfunc, std::vector< MatrixType > &ops, const ContainerType1 &d, const ContainerType2 &b, std::vector< double > eps)
 Compute the bivariate matrix function.
 

Detailed Description

template<class Geometry, class Matrix, class ComplexContainer>
struct dg::mat::CauchyMatrixProduct< Geometry, Matrix, ComplexContainer >

Computation of \( \vec x = f(A,\vec d)\vec b\) or \( \vec x = f( \vec d, A) \vec b\) where \( A \) is a positive (semi)-definite matrix self-adjoint in the weights \( W\) .

This class implements the Cauchy contour integral method

\[ \begin{align} f( A, D) \vec b \approx \sum_{k=1}^{N} \frac{1}{z_k 1 - A} w_kf(z_k, D) \vec b\\ f( D, A) \vec b \approx \sum_{k=1}^{N} w_kf(z_k, D)\frac{1}{z_k 1 - A} \vec b\\ \end{align \]

The complex nodes and weights \( z_k\) and \( w_k\) are found by applying the Levenberg-Marquardt optimization to an initial Talbot curve. The number of nodes is such that the given error tolerance is fulfilled. The individual complex Helmholtz type equations are solved using a dg::MultigridCG2d COCG algorithm and we store the previous result at every timestep

The class automatically caches the extreme Eigenvalues of the matrix A. Furthermore, the previous solution(s) to the Helmholtz equations are stored. The solve method automatically recognises a change in D or the matrix function f and accordingly recomputes nodes and weighs and clears the previous solution cache. However, changes in A are not automatically recognised. If the matrix needs to change the clear_cache member function must be called before the next solve call in order to trigger a re-computation of the Eigenvalues.

Template Parameters
GeometryThe Geometry type in dg::MultigridCG2d
MatrixThe (real) derviative class for projection / interpolation in Multigrid
ComplexContainerA complex Container type

Constructor & Destructor Documentation

◆ CauchyMatrixProduct() [1/2]

template<class Geometry , class Matrix , class ComplexContainer >
dg::mat::CauchyMatrixProduct< Geometry, Matrix, ComplexContainer >::CauchyMatrixProduct ( )
default

◆ CauchyMatrixProduct() [2/2]

template<class Geometry , class Matrix , class ComplexContainer >
dg::mat::CauchyMatrixProduct< Geometry, Matrix, ComplexContainer >::CauchyMatrixProduct ( double lm_eps,
const Geometry & grid,
unsigned stages,
bool adjoint = true )
inline

Member Function Documentation

◆ clear_cache()

template<class Geometry , class Matrix , class ComplexContainer >
void dg::mat::CauchyMatrixProduct< Geometry, Matrix, ComplexContainer >::clear_cache ( )
inline

Clear the cached Eigenvalues of the matrix in the solve method.

Call if the matrix in the next call to the solve method changes (which typically should not happen); ignore otherwise.

◆ get_adjoint()

template<class Geometry , class Matrix , class ComplexContainer >
bool dg::mat::CauchyMatrixProduct< Geometry, Matrix, ComplexContainer >::get_adjoint ( ) const
inline

Current value of the adjoint parameter.

◆ multigrid()

template<class Geometry , class Matrix , class ComplexContainer >
const dg::MultigridCG2d< Geometry, Matrix, ComplexContainer, dg::complex_symmetric > & dg::mat::CauchyMatrixProduct< Geometry, Matrix, ComplexContainer >::multigrid ( ) const
inline

Access the internal multigrid method to be able to construct matrices.

◆ num_nodes()

template<class Geometry , class Matrix , class ComplexContainer >
unsigned dg::mat::CauchyMatrixProduct< Geometry, Matrix, ComplexContainer >::num_nodes ( ) const
inline

Number of (complex) nodes used in the latest call to solve.

Returns
Number of complex nodes

◆ set_adjoint()

template<class Geometry , class Matrix , class ComplexContainer >
void dg::mat::CauchyMatrixProduct< Geometry, Matrix, ComplexContainer >::set_adjoint ( bool adjoint)
inline

Determine if adjoint or direct bivariate matrix function is computed.

Attention
Changing this parameter resets the solution cache (i.e. previous stored solutions are zeroed)
Parameters
adjointIf true compute the matrix function \( f(A, d)b\), else compute \( f(d, A)b\)

◆ set_verbose()

template<class Geometry , class Matrix , class ComplexContainer >
void dg::mat::CauchyMatrixProduct< Geometry, Matrix, ComplexContainer >::set_verbose ( bool verbose)
inline

Verbose output to std::cout.

Parameters
verboseIf true output more information to std::cout

◆ solve()

template<class Geometry , class Matrix , class ComplexContainer >
template<class MatrixType , class UnaryFunc , class UnaryFuncD , class ContainerType0 , class ContainerType1 , class ContainerType2 >
void dg::mat::CauchyMatrixProduct< Geometry, Matrix, ComplexContainer >::solve ( ContainerType0 & x,
UnaryFunc func,
UnaryFuncD dxfunc,
std::vector< MatrixType > & ops,
const ContainerType1 & d,
const ContainerType2 & b,
std::vector< double > eps )
inline

Compute the bivariate matrix function.

In the first call the extreme Eigenvalues of ops[0] are computed and stored. In the following calls the cached Eigenvalues are used unless clear_cache is called beforehand.

In a first step we then determine if the previously used nodes and weights are still sufficient for the given parameters and optionally re-compute them. (The method tries to avoid recomputing the nodes if possible because of how long it may take). In a second step the num_nodes complex Helmholtz problems are solved using multigrid methods and initial guesses from previous solves.

Parameters
x(write-only) Contains solution on output
funcThe bivariate matrix function
dxfuncThe derivative of the bivariate matrix function
opsThe matrix discretized on the grid used in multigrid()
dThe diagonal vector
bthe right hand side
epsthe error tolerance forwarded to the multigrid().solve method

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