Extension: Matrix functions
#include "dg/matrix/matrix.h"
dg::mat::PolCharge< Geometry, Matrix, Container > Class Template Reference

Various arbitary wavelength polarization charge operators of delta-f (df) and full-f (ff) More...

Public Types

using value_type = get_value_type< Container >
 

Public Member Functions

 PolCharge ()
 empty object ( no memory allocation) More...
 
 PolCharge (value_type alpha, std::vector< value_type > eps_gamma, const Geometry &g, direction dir=forward, value_type jfactor=1., std::string mode="df", bool commute=false)
 Construct from Grid. More...
 
 PolCharge (value_type alpha, std::vector< value_type > eps_gamma, const Geometry &g, bc bcx, bc bcy, direction dir=forward, value_type jfactor=1., std::string mode="df", bool commute=false)
 Construct from boundary conditions. More...
 
template<class ... Params>
void construct (Params &&...ps)
 Perfect forward parameters to one of the constructors. More...
 
template<class ContainerType0 >
void set_chi (const ContainerType0 &sigma)
 Change \(\chi\) in the elliptic or tensor elliptic operator. More...
 
template<class ContainerType0 >
void set_chi (const SparseTensor< ContainerType0 > &tau)
 Change \(\chi\) in the elliptic or tensor elliptic operator. More...
 
template<class ContainerType0 >
void set_iota (const ContainerType0 &sigma)
 Change \(\iota\) in the tensor elliptic operator. More...
 
void set_commute (bool commute)
 Set the commute. More...
 
bool get_commute () const
 Get the current state of commute. More...
 
const Container & weights () const
 Return the vector making the matrix symmetric. More...
 
const Container & precond () const
 Return the default preconditioner to use in conjugate gradient. More...
 
template<class ContainerType0 , class ContainerType1 >
void variation (const ContainerType0 &phi, ContainerType1 &varphi)
 
template<class ContainerType0 , class ContainerType1 >
void operator() (const ContainerType0 &x, ContainerType1 &y)
 Compute elliptic term and store in output. More...
 
template<class ContainerType0 , class ContainerType1 >
void symv (const ContainerType0 &x, ContainerType1 &y)
 Compute elliptic term and store in output. More...
 
template<class ContainerType0 , class ContainerType1 >
void symv (value_type alpha, const ContainerType0 &x, value_type beta, ContainerType1 &y)
 Compute elliptic term and add to output. More...
 

Detailed Description

template<class Geometry, class Matrix, class Container>
class dg::mat::PolCharge< Geometry, Matrix, Container >

Various arbitary wavelength polarization charge operators of delta-f (df) and full-f (ff)

"df"

\[ x = -\Delta \left(1+\alpha\Delta\right)^{-1} \phi \]

\[ \]

"ff"

\[ x = \sqrt{1+\alpha\Delta}^{-1}\left(-\nabla \cdot \chi \nabla\right)\sqrt{1+\alpha\Delta}^{-1}\phi \]

"ffO4"

\[ x = (1+\alpha\Delta)^{-1} \left(-\nabla \cdot \chi \nabla - \Delta \iota \Delta + \nabla \cdot\nabla \cdot 2\iota \nabla \nabla \right)(1+\alpha\Delta)^{-1} \phi \]

Member Typedef Documentation

◆ value_type

template<class Geometry , class Matrix , class Container >
using dg::mat::PolCharge< Geometry, Matrix, Container >::value_type = get_value_type<Container>

Constructor & Destructor Documentation

◆ PolCharge() [1/3]

template<class Geometry , class Matrix , class Container >
dg::mat::PolCharge< Geometry, Matrix, Container >::PolCharge ( )
inline

empty object ( no memory allocation)

◆ PolCharge() [2/3]

template<class Geometry , class Matrix , class Container >
dg::mat::PolCharge< Geometry, Matrix, Container >::PolCharge ( value_type  alpha,
std::vector< value_type eps_gamma,
const Geometry &  g,
direction  dir = forward,
value_type  jfactor = 1.,
std::string  mode = "df",
bool  commute = false 
)
inline

Construct from Grid.

Parameters
alphaalpha of the Helmholtz operator
eps_gammaepsilon (-vector) for the Helmholtz operator inversion or the sqrt Helmholtz operator inversion
gThe Grid, boundary conditions are taken from here
dirDirection of the right first derivative in x and y (i.e. dg::forward, dg::backward or dg::centered),
jfactor( \( = \alpha \) ) scale jump terms (1 is a good value but in some cases 0.1 or 0.01 might be better)
modearbitrary wavelength polarization charge mode ("df" / "ff" / "ffO4" are implemented)
commutefalse if Helmholtz operators (or their square root) are outside the elliptic or tensorelliptic operator and true otherwise

◆ PolCharge() [3/3]

template<class Geometry , class Matrix , class Container >
dg::mat::PolCharge< Geometry, Matrix, Container >::PolCharge ( value_type  alpha,
std::vector< value_type eps_gamma,
const Geometry &  g,
bc  bcx,
bc  bcy,
direction  dir = forward,
value_type  jfactor = 1.,
std::string  mode = "df",
bool  commute = false 
)
inline

Construct from boundary conditions.

Parameters
alphaalpha of the Helmholtz operator
eps_gammaepsilon (-vector) for the Helmholtz operator inversion or the sqrt Helmholtz operator inversion
gThe Grid, boundary conditions are taken from here
bcxboundary condition in x
bcyboundary contition in y
dirDirection of the right first derivative in x and y (i.e. dg::forward, dg::backward or dg::centered),
jfactor( \( = \alpha \) ) scale jump terms (1 is a good value but in some cases 0.1 or 0.01 might be better)
modearbitrary wavelength polarization charge mode ("df" / "ff" / "ffO4" (O as in Order!) are implemented)
commutefalse if Helmholtz operators (or their square root) are outside the elliptic or tensorelliptic operator and true otherwise

Member Function Documentation

◆ construct()

template<class Geometry , class Matrix , class Container >
template<class ... Params>
void dg::mat::PolCharge< Geometry, Matrix, Container >::construct ( Params &&...  ps)
inline

Perfect forward parameters to one of the constructors.

Template Parameters
Paramsdeduced by the compiler
Parameters
psparameters forwarded to constructors

◆ get_commute()

template<class Geometry , class Matrix , class Container >
bool dg::mat::PolCharge< Geometry, Matrix, Container >::get_commute ( ) const
inline

Get the current state of commute.

Returns
Either true or false.

◆ operator()()

template<class Geometry , class Matrix , class Container >
template<class ContainerType0 , class ContainerType1 >
void dg::mat::PolCharge< Geometry, Matrix, Container >::operator() ( const ContainerType0 &  x,
ContainerType1 &  y 
)
inline

Compute elliptic term and store in output.

i.e. y=M*x

Parameters
xleft-hand-side
yresult
Template Parameters
ContainerTypesmust be usable with Container in The dg dispatch system

◆ precond()

template<class Geometry , class Matrix , class Container >
const Container & dg::mat::PolCharge< Geometry, Matrix, Container >::precond ( ) const
inline

Return the default preconditioner to use in conjugate gradient.

Currently returns the inverse scalar part of \( \chi\). This is especially good when \( \chi\) exhibits large amplitudes or variations

Returns
the inverse of \(\chi\).

◆ set_chi() [1/2]

template<class Geometry , class Matrix , class Container >
template<class ContainerType0 >
void dg::mat::PolCharge< Geometry, Matrix, Container >::set_chi ( const ContainerType0 &  sigma)
inline

Change \(\chi\) in the elliptic or tensor elliptic operator.

Parameters
sigmaThe new scalar part in \(\chi\) (all elements must be >0)
Template Parameters
ContainerType0must be usable with Container in The dg dispatch system

◆ set_chi() [2/2]

template<class Geometry , class Matrix , class Container >
template<class ContainerType0 >
void dg::mat::PolCharge< Geometry, Matrix, Container >::set_chi ( const SparseTensor< ContainerType0 > &  tau)
inline

Change \(\chi\) in the elliptic or tensor elliptic operator.

Parameters
tauThe new tensor part in \(\chi\) (all elements must be >0)
Template Parameters
ContainerType0must be usable in dg::assign to Container

◆ set_commute()

template<class Geometry , class Matrix , class Container >
void dg::mat::PolCharge< Geometry, Matrix, Container >::set_commute ( bool  commute)
inline

Set the commute.

Parameters
commuteEither true or false.

◆ set_iota()

template<class Geometry , class Matrix , class Container >
template<class ContainerType0 >
void dg::mat::PolCharge< Geometry, Matrix, Container >::set_iota ( const ContainerType0 &  sigma)
inline

Change \(\iota\) in the tensor elliptic operator.

Parameters
sigmaThe new scalar part in \(\chi\) (all elements must be >0)
Template Parameters
ContainerType0must be usable with Container in The dg dispatch system

◆ symv() [1/2]

template<class Geometry , class Matrix , class Container >
template<class ContainerType0 , class ContainerType1 >
void dg::mat::PolCharge< Geometry, Matrix, Container >::symv ( const ContainerType0 &  x,
ContainerType1 &  y 
)
inline

Compute elliptic term and store in output.

i.e. y=M*x

Parameters
xleft-hand-side
yresult
Template Parameters
ContainerTypesmust be usable with Container in The dg dispatch system

◆ symv() [2/2]

template<class Geometry , class Matrix , class Container >
template<class ContainerType0 , class ContainerType1 >
void dg::mat::PolCharge< Geometry, Matrix, Container >::symv ( value_type  alpha,
const ContainerType0 &  x,
value_type  beta,
ContainerType1 &  y 
)
inline

Compute elliptic term and add to output.

i.e. y=alpha*M*x+beta*y

Parameters
alphaa scalar
xleft-hand-side
betaa scalar
yresult
Template Parameters
ContainerTypesmust be usable with Container in The dg dispatch system

◆ variation()

template<class Geometry , class Matrix , class Container >
template<class ContainerType0 , class ContainerType1 >
void dg::mat::PolCharge< Geometry, Matrix, Container >::variation ( const ContainerType0 &  phi,
ContainerType1 &  varphi 
)
inline

◆ weights()

template<class Geometry , class Matrix , class Container >
const Container & dg::mat::PolCharge< Geometry, Matrix, Container >::weights ( ) const
inline

Return the vector making the matrix symmetric.

i.e. the volume form

Returns
volume form including weights

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