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

Arakawa's scheme for Poisson bracket \( \{ f,g\} \). 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

 ArakawaX ()=default
 
 ArakawaX (const Geometry &g)
 Create Arakawa on a grid. More...
 
 ArakawaX (const Geometry &g, bc bcx, bc bcy)
 Create Arakawa 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 >
void operator() (const ContainerType0 &lhs, const ContainerType1 &rhs, ContainerType2 &result)
 Compute Poisson bracket. More...
 
template<class ContainerType0 , class ContainerType1 , class ContainerType2 >
void operator() (value_type alpha, const ContainerType0 &lhs, const ContainerType1 &rhs, value_type beta, ContainerType2 &result)
 
template<class ContainerType0 >
void set_chi (const ContainerType0 &new_chi)
 Change Chi. More...
 
const Matrix & dx () const
 Return internally used x - derivative. More...
 
const Matrix & dy () const
 Return internally used y - derivative. More...
 

Detailed Description

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

Arakawa's scheme for Poisson bracket \( \{ f,g\} \).

Computes

\[ \{f,g\} := \chi/\sqrt{g_{2d}}\left(\partial_x f\partial_y g - \partial_y f\partial_x g\right) \]

where \( g_{2d} = g/g_{zz}\) is the two-dimensional volume element of the plane in 2x1 product space and \( \chi\) is an optional factor. If \( \chi=1\), then the discretization conserves, mass, energy and enstrophy.

const double lx = 2*M_PI;
const double ly = 2*M_PI;
double left( double x, double y) {
return sin(x)*cos(y);
}
double right( double x, double y) {
return sin(y)*cos(x);
}
double jacobian( double x, double y) {
return cos(x)*cos(y)*cos(x)*cos(y) - sin(x)*sin(y)*sin(x)*sin(y);
}
#define M_PI
M_PI is non-standard ... so MSVC complains.
Definition: functors.h:6
bc
Switch between boundary conditions.
Definition: enums.h:15
@ PER
periodic boundaries
Definition: enums.h:16
// create a Cartesian grid on the domain [0,lx]x[0,ly]
const dg::CartesianGrid2d grid( 0, lx, 0, ly, n, Nx, Ny, bcx, bcy);
// evaluate left and right hand side on the grid
const dg::DVec lhs = dg::construct<dg::DVec>( dg::evaluate( left, grid));
const dg::DVec rhs = dg::construct<dg::DVec>( dg::evaluate( right, grid));
dg::DVec jac(lhs);
// create an Arakawa object
//apply arakawa scheme
arakawa( lhs, rhs, jac);
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
Evaluate a 1d function on grid coordinates.
Definition: evaluation.h:67
thrust::device_vector< double > DVec
Device Vector. The device can be an OpenMP parallelized cpu or a gpu. This depends on the value of th...
Definition: typedefs.h:23
Arakawa's scheme for Poisson bracket .
Definition: arakawa.h:36
two-dimensional Grid with Cartesian metric
Definition: base_geometry.h:215
Note
This is the algorithm published in L. Einkemmer, M. Wiesenberger A conservative discontinuous Galerkin scheme for the 2D incompressible Navier-Stokes equations Computer Physics Communications 185, 2865-2873 (2014)
See also
A discussion of this and other advection schemes can also 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::ArakawaX< Geometry, Matrix, Container >::container_type = Container

◆ geometry_type

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

◆ matrix_type

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

◆ value_type

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

Constructor & Destructor Documentation

◆ ArakawaX() [1/3]

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

◆ ArakawaX() [2/3]

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

Create Arakawa on a grid.

Parameters
gThe grid
Note
chi defaults to 1

◆ ArakawaX() [3/3]

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

Create Arakawa on a grid using different boundary conditions.

Parameters
gThe grid
bcxThe boundary condition in x
bcyThe boundary condition in y
Note
chi defaults to 1

Member Function Documentation

◆ construct()

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

◆ dx()

template<class Geometry , class Matrix , class Container >
const Matrix & dg::ArakawaX< Geometry, Matrix, Container >::dx ( ) const
inline

Return internally used x - derivative.

The same as a call to dg::create::dx( g, bcx)

Returns
derivative

◆ dy()

template<class Geometry , class Matrix , class Container >
const Matrix & dg::ArakawaX< Geometry, Matrix, Container >::dy ( ) const
inline

Return internally used y - derivative.

The same as a call to dg::create::dy( g, bcy)

Returns
derivative

◆ operator()() [1/2]

template<class Geometry , class Matrix , class Container >
template<class ContainerType0 , class ContainerType1 , class ContainerType2 >
void dg::ArakawaX< Geometry, Matrix, Container >::operator() ( const ContainerType0 &  lhs,
const ContainerType1 &  rhs,
ContainerType2 &  result 
)
inline

Compute Poisson bracket.

Computes

\[ [f,g] := 1/\sqrt{g_{2d}}\left(\partial_x f\partial_y g - \partial_y f\partial_x g\right) \]

where \( g_{2d} = g/g_{zz}\) is the two-dimensional volume element of the plane in 2x1 product space.

Parameters
lhsleft hand side in x-space
rhsrights hand side in x-space
resultPoisson's bracket in x-space
Note
memops: 30
Template Parameters
ContainerTypesmust be usable with Container in The dg dispatch system

◆ operator()() [2/2]

template<class Geometry , class Matrix , class Container >
template<class ContainerType0 , class ContainerType1 , class ContainerType2 >
void dg::ArakawaX< Geometry, Matrix, Container >::operator() ( value_type  alpha,
const ContainerType0 &  lhs,
const ContainerType1 &  rhs,
value_type  beta,
ContainerType2 &  result 
)

◆ set_chi()

template<class Geometry , class Matrix , class Container >
template<class ContainerType0 >
void dg::ArakawaX< Geometry, Matrix, Container >::set_chi ( const ContainerType0 &  new_chi)
inline

Change Chi.

Parameters
new_chiThe new chi
Template Parameters
ContainerTypesmust be usable with Container in The dg dispatch system

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