Discontinuous Galerkin Library
#include "dg/algorithm.h"
Loading...
Searching...
No Matches
advection.h
Go to the documentation of this file.
1#ifndef _DG_ADVECTION_H
2#define _DG_ADVECTION_H
3#include "blas.h"
4#include "topology/geometry.h"
5#include "enums.h"
8#ifdef MPI_VERSION
10#endif
15namespace dg
16{
17
18 //MW this scheme cannot be formulated as a weak form
19
41template< class Geometry, class Matrix, class Container >
43{
44 using geometry_type = Geometry;
48 Advection() = default;
53 Advection( const Geometry& g);
60 Advection( const Geometry& g, bc bcx, bc bcy);
61
68 template<class ...Params>
69 void construct( Params&& ...ps)
70 {
71 //construct and swap
72 *this = Advection( std::forward<Params>( ps)...);
73 }
74
87 template<class ContainerType0, class ContainerType1, class ContainerType2, class ContainerType3>
88 void upwind( value_type alpha, const ContainerType0& vx, const ContainerType1& vy, const ContainerType2& f, value_type beta, ContainerType3& result);
89
90 private:
91 Container m_temp0, m_temp1;
92 Matrix m_dxf, m_dyf, m_dxb, m_dyb;
93};
94
96template<class Geometry, class Matrix, class Container>
98 Advection( g, g.bcx(), g.bcy()) { }
99
100template<class Geometry, class Matrix, class Container>
101Advection<Geometry, Matrix, Container>::Advection( const Geometry& g, bc bcx, bc bcy):
102 m_temp0( dg::construct<Container>(dg::evaluate( one, g)) ), m_temp1(m_temp0),
103 m_dxf(dg::create::dx( g, bcx, dg::forward)),
104 m_dyf(dg::create::dy( g, bcy, dg::forward)),
105 m_dxb(dg::create::dx( g, bcx, dg::backward)),
106 m_dyb(dg::create::dy( g, bcy, dg::backward))
107{
108}
109
110template< class Geometry, class Matrix, class Container>
111template<class ContainerType0, class ContainerType1, class ContainerType2, class ContainerType3>
112void Advection<Geometry, Matrix, Container>::upwind( value_type alpha, const ContainerType0& vx, const ContainerType1& vy, const ContainerType2& f, value_type beta, ContainerType3& result)
113{
114 blas2::symv( m_dxb, f, m_temp0);
115 blas2::symv( m_dxf, f, m_temp1);
116 blas1::evaluate( result, dg::Axpby( alpha, beta), dg::UpwindProduct(), vx, m_temp0, m_temp1);
117 blas2::symv( m_dyb, f, m_temp0);
118 blas2::symv( m_dyf, f, m_temp1);
119 blas1::evaluate( result, dg::Axpby( alpha, value_type(1)), dg::UpwindProduct(), vy, m_temp0, m_temp1);
120}
122
123}//namespace dg
124
125
126#endif //_DG_ADVECTION_H
enums
Function discretization routines.
DG_DEVICE T one(T, Ts ...)
Definition functions.h:24
ContainerType construct(const from_ContainerType &from, Params &&... ps)
Generic way to construct an object of ContainerType given a from_ContainerType object and optional ad...
Definition blas1.h:792
void evaluate(ContainerType &y, BinarySubroutine f, Functor g, const ContainerType0 &x0, const ContainerTypes &...xs)
Definition blas1.h:612
void symv(MatrixType &&M, const ContainerType1 &x, ContainerType2 &y)
Definition blas2.h:325
bc
Switch between boundary conditions.
Definition enums.h:15
@ backward
backward derivative (cell to the left and current cell)
Definition enums.h:99
@ forward
forward derivative (cell to the right and current cell)
Definition enums.h:98
typename TensorTraits< std::decay_t< Vector > >::value_type get_value_type
Definition tensor_traits.h:45
auto evaluate(Functor &&f, const Topology &g)
Evaluate a function on grid coordinates
Definition evaluation.h:74
dg::HVec Container
dg::bc bcy
dg::bc bcx
Function discretization routines for mpi vectors.
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
Upwind discretization of advection operator
Definition advection.h:43
void upwind(value_type alpha, const ContainerType0 &vx, const ContainerType1 &vy, const ContainerType2 &f, value_type beta, ContainerType3 &result)
Compute Advection term .
Container container_type
Definition advection.h:46
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition advection.h:69
Advection(const Geometry &g, bc bcx, bc bcy)
Create Advection on a grid using different boundary conditions.
get_value_type< Container > value_type
Definition advection.h:47
Advection(const Geometry &g)
Create Arakawa on a grid.
Advection()=default
Geometry geometry_type
Definition advection.h:44
Ell Sparse Block Matrix format.
Definition sparseblockmat.h:46
Definition functors.h:330
double value_type