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

Upwind discretization of advection operator \( \vec v\cdot\nabla f\) More...

Public Types

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

Public Member Functions

 Advection ()=default
 
 Advection (const Geometry &g)
 Create Arakawa on a grid. More...
 
 Advection (const Geometry &g, bc bcx, bc bcy)
 Create Advection on a grid using different boundary conditions. More...
 
template<class ... Params>
void construct (Params &&...ps)
 Perfect forward parameters to one of the constructors. More...
 
template<class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 >
void upwind (value_type alpha, const ContainerType0 &vx, const ContainerType1 &vy, const ContainerType2 &f, value_type beta, ContainerType3 &result)
 Compute Advection term \( y = \alpha \vec v\cdot\nabla f + \beta y \). More...
 

Detailed Description

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

Upwind discretization of advection operator \( \vec v\cdot\nabla f\)

This is the upwind scheme where a backward derivative is used if v is positive and a forward derivative else For example

// v_x = -dy phi
dg::blas2::symv( -1., dy, phi, 0., vx);
// v_y = dx phi
dg::blas2::symv( 1., dx, phi, 0., vy);
// compute on Cartesian grid in 2d on device
// df = - v Grad f
advection.upwind( -1., vx, vy, f, 0., df);
void symv(MatrixType &&M, const ContainerType1 &x, ContainerType2 &y)
Definition: blas2.h:287
EllSparseBlockMat< real_type > dx(const aRealTopology2d< real_type > &g, bc bcx, direction dir=centered)
Create 2d derivative in x-direction.
Definition: derivatives.h:33
EllSparseBlockMat< real_type > dy(const aRealTopology2d< real_type > &g, bc bcy, direction dir=centered)
Create 2d derivative in y-direction.
Definition: derivatives.h:65
Upwind discretization of advection operator
Definition: advection.h:44
Note
This scheme brings its own numerical diffusion and thus does not need any other artificial viscosity mechanisms. The only places where the scheme might run into oscillations is if there is a stagnation point with v==0 at a fixed position
See also
A discussion of this and other advection schemes can be found here https://mwiesenberger.github.io/advection
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

Member Typedef Documentation

◆ container_type

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

◆ geometry_type

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

◆ matrix_type

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

◆ value_type

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

Constructor & Destructor Documentation

◆ Advection() [1/3]

template<class Geometry , class Matrix , class Container >
dg::Advection< Geometry, Matrix, Container >::Advection ( )
default

◆ Advection() [2/3]

template<class Geometry , class Matrix , class Container >
dg::Advection< Geometry, Matrix, Container >::Advection ( const Geometry &  g)

Create Arakawa on a grid.

Parameters
gThe grid

◆ Advection() [3/3]

template<class Geometry , class Matrix , class Container >
dg::Advection< Geometry, Matrix, Container >::Advection ( const Geometry &  g,
bc  bcx,
bc  bcy 
)

Create Advection on a grid using different boundary conditions.

Parameters
gThe grid
bcxThe boundary condition in x
bcyThe boundary condition in y

Member Function Documentation

◆ construct()

template<class Geometry , class Matrix , class Container >
template<class ... Params>
void dg::Advection< 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

◆ upwind()

template<class Geometry , class Matrix , class Container >
template<class ContainerType0 , class ContainerType1 , class ContainerType2 , class ContainerType3 >
void dg::Advection< Geometry, Matrix, Container >::upwind ( value_type  alpha,
const ContainerType0 &  vx,
const ContainerType1 &  vy,
const ContainerType2 &  f,
value_type  beta,
ContainerType3 &  result 
)

Compute Advection term \( y = \alpha \vec v\cdot\nabla f + \beta y \).

This uses the upwind advection mechanism, i.e. a backward derivative for positive v and a forward derivative else

Parameters
alphaconstant
vxVelocity in x direction
vyVelocity in y direction
ffunction
betaconstant
resultResult
Template Parameters
ContainerTypesmust be usable with Container in The dg dispatch system

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