Discontinuous Galerkin Library
#include "dg/algorithm.h"
dg::Helmholtz2< Geometry, Matrix, Container > Struct Template Reference

DEPRECATED, Matrix class that represents a more general Helmholtz-type operator. More...

Public Types

using container_type = Container
 
using geometry_type = Geometry
 
using matrix_type = Matrix
 
using value_type = get_value_type< Container >
 

Public Member Functions

 Helmholtz2 ()
 empty object ( no memory allocation) More...
 
 Helmholtz2 (const Geometry &g, value_type alpha=1., direction dir=dg::forward, value_type jfactor=1.)
 Construct Helmholtz2 operator. More...
 
 Helmholtz2 (const Geometry &g, bc bcx, bc bcy, value_type alpha=1., direction dir=dg::forward, value_type jfactor=1.)
 Construct Helmholtz2 operator. More...
 
void construct (const Geometry &g, bc bcx, bc bcy, value_type alpha=1, direction dir=dg::forward, value_type jfactor=1.)
 Construct Helmholtz2 operator. More...
 
void construct (const Geometry &g, value_type alpha=1, direction dir=dg::forward, value_type jfactor=1.)
 Construct Helmholtz2 operator. More...
 
void symv (const Container &x, Container &y)
 apply operator More...
 
const Container & weights () const
 Return the weights making the operator self-adjoint. More...
 
const Container & precond () const
 Preconditioner to use in conjugate gradient solvers. More...
 
value_typealpha ()
 Change alpha. More...
 
value_type alpha () const
 Access alpha. More...
 
void set_chi (const Container &chi)
 Set Chi in the above formula. More...
 
const Container & chi () const
 Access chi. More...
 

Detailed Description

template<class Geometry, class Matrix, class Container>
struct dg::Helmholtz2< Geometry, Matrix, Container >

DEPRECATED, Matrix class that represents a more general Helmholtz-type operator.

Discretization of

\[ \left[ \chi +2 \alpha\Delta + \alpha^2\Delta \left(\chi^{-1}\Delta \right)\right] \]

where \( \chi\) is a function and \(\alpha\) a scalar.

Template Parameters
GeometryA type that is or derives from one of the abstract geometry base classes ( aGeometry2d, aGeometry3d, aMPIGeometry2d, ...). Geometry determines which Matrix and Container types can be used:
MatrixA class for which the dg::blas2::symv functions are callable in connection with the Container class and to which the return type of dg::create::dx() can be converted using dg::blas2::transfer. The Matrix type can be one of:
ContainerA data container class for which the blas1 functionality is overloaded and to which the return type of blas1::subroutine() can be converted using dg::assign. We assume that Container is copyable/assignable and has a swap member function. In connection with Geometry this is one of
Note
The Laplacian in this formula is positive as opposed to the negative sign in the Elliptic operator
Attention
It is MUCH better to solve the normal Helmholtz operator twice, consecutively, than solving the Helmholtz2 operator once. The following code snippet shows how to do it:
std::cout << "Alternative test with two Helmholtz operators\n";
gamma1inv.set_chi( chi);
dg::PCG<dg::DVec> pcgO( x, grid2d.size());
dg::PCG<dg::DVec> pcgOO( x, grid2d.size());
t.tic();
unsigned number1 = pcgO.solve( gamma1inv, phi, rholap, 1., w2d, eps/100);
unsigned number2 = pcgOO.solve( gamma1inv, x, phi, 1., w2d, eps/100);
t.toc();
//Evaluation
dg::blas1::axpby( 1., sol, -1., x);
Preconditioned conjugate gradient method to solve .
Definition: pcg.h:57
void axpby(get_value_type< ContainerType > alpha, const ContainerType1 &x, get_value_type< ContainerType > beta, ContainerType &y)
Definition: blas1.h:231
void pointwiseDot(get_value_type< ContainerType > alpha, const ContainerType1 &x1, const ContainerType2 &x2, get_value_type< ContainerType > beta, ContainerType &y)
Definition: blas1.h:336
@ centered
centered derivative (cell to the left and right and current cell)
Definition: enums.h:100
A general Helmholtz-type operator .
Definition: helmholtz.h:34
void set_chi(const ContainerType0 &chi)
Set Chi in the above formula.
Definition: helmholtz.h:109
const Container & chi() const
Access chi.
Definition: helmholtz.h:258
value_type & alpha()
Change alpha.
Definition: helmholtz.h:241

Member Typedef Documentation

◆ container_type

template<class Geometry , class Matrix , class Container >
using dg::Helmholtz2< Geometry, Matrix, Container >::container_type = Container

◆ geometry_type

template<class Geometry , class Matrix , class Container >
using dg::Helmholtz2< Geometry, Matrix, Container >::geometry_type = Geometry

◆ matrix_type

template<class Geometry , class Matrix , class Container >
using dg::Helmholtz2< Geometry, Matrix, Container >::matrix_type = Matrix

◆ value_type

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

Constructor & Destructor Documentation

◆ Helmholtz2() [1/3]

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

empty object ( no memory allocation)

◆ Helmholtz2() [2/3]

template<class Geometry , class Matrix , class Container >
dg::Helmholtz2< Geometry, Matrix, Container >::Helmholtz2 ( const Geometry &  g,
value_type  alpha = 1.,
direction  dir = dg::forward,
value_type  jfactor = 1. 
)
inline

Construct Helmholtz2 operator.

Parameters
gThe grid to use
alphaScalar in the above formula
dirDirection of the Laplace operator
jfactorThe jfactor used in the Laplace operator (probably 1 is always the best factor but one never knows...)
Note
The default value of \(\chi\) is one

◆ Helmholtz2() [3/3]

template<class Geometry , class Matrix , class Container >
dg::Helmholtz2< Geometry, Matrix, Container >::Helmholtz2 ( const Geometry &  g,
bc  bcx,
bc  bcy,
value_type  alpha = 1.,
direction  dir = dg::forward,
value_type  jfactor = 1. 
)
inline

Construct Helmholtz2 operator.

Parameters
gThe grid to use
bcxboundary condition in x
bcyboundary contition in y
alphaScalar in the above formula
dirDirection of the Laplace operator
jfactorThe jfactor used in the Laplace operator (probably 1 is always the best factor but one never knows...)
Note
The default value of \(\chi\) is one

Member Function Documentation

◆ alpha() [1/2]

template<class Geometry , class Matrix , class Container >
value_type & dg::Helmholtz2< Geometry, Matrix, Container >::alpha ( )
inline

Change alpha.

Returns
reference to alpha

◆ alpha() [2/2]

template<class Geometry , class Matrix , class Container >
value_type dg::Helmholtz2< Geometry, Matrix, Container >::alpha ( ) const
inline

Access alpha.

Returns
alpha

◆ chi()

template<class Geometry , class Matrix , class Container >
const Container & dg::Helmholtz2< Geometry, Matrix, Container >::chi ( ) const
inline

Access chi.

Returns
chi

◆ construct() [1/2]

template<class Geometry , class Matrix , class Container >
void dg::Helmholtz2< Geometry, Matrix, Container >::construct ( const Geometry &  g,
bc  bcx,
bc  bcy,
value_type  alpha = 1,
direction  dir = dg::forward,
value_type  jfactor = 1. 
)
inline

Construct Helmholtz2 operator.

Parameters
gThe grid to use
bcxboundary condition in x
bcyboundary contition in y
alphaScalar in the above formula
dirDirection of the Laplace operator
jfactorThe jfactor used in the Laplace operator (probably 1 is always the best factor but one never knows...)
Note
The default value of \(\chi\) is one

◆ construct() [2/2]

template<class Geometry , class Matrix , class Container >
void dg::Helmholtz2< Geometry, Matrix, Container >::construct ( const Geometry &  g,
value_type  alpha = 1,
direction  dir = dg::forward,
value_type  jfactor = 1. 
)
inline

Construct Helmholtz2 operator.

Parameters
gThe grid to use
alphaScalar in the above formula
dirDirection of the Laplace operator
jfactorThe jfactor used in the Laplace operator (probably 1 is always the best factor but one never knows...)
Note
The default value of \(\chi\) is one

◆ precond()

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

Preconditioner to use in conjugate gradient solvers.

Returns
1 by default

◆ set_chi()

template<class Geometry , class Matrix , class Container >
void dg::Helmholtz2< Geometry, Matrix, Container >::set_chi ( const Container &  chi)
inline

Set Chi in the above formula.

Parameters
chinew container

◆ symv()

template<class Geometry , class Matrix , class Container >
void dg::Helmholtz2< Geometry, Matrix, Container >::symv ( const Container &  x,
Container &  y 
)
inline

apply operator

Computes

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

to make the matrix symmetric

Parameters
xlhs (is constant up to changes in ghost cells)
yrhs contains solution
Note
Takes care of sign in laplaceM and thus multiplies by -alpha

◆ weights()

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

Return the weights making the operator self-adjoint.

i.e. the volume form

Returns
volume form including weights

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