HyTeG
Matrix-Free Finite Elements
Loading...
Searching...
No Matches
hyteg::dg::DGOperator Class Reference

#include <DGOperator.hpp>

Inheritance diagram for hyteg::dg::DGOperator:
Collaboration diagram for hyteg::dg::DGOperator:

Public Types

typedef DGFunction< real_t > dstType
 
typedef DGFunction< real_t > srcType
 

Public Member Functions

 DGOperator (const std::shared_ptr< PrimitiveStorage > &storage, uint_t minLevel, uint_t maxLevel, const std::shared_ptr< DGForm > &form)
 
void apply (const DGFunction< real_t > &src, const DGFunction< real_t > &dst, size_t level, DoFType flag, UpdateType updateType) const override
 
void enableTiming (const std::shared_ptr< walberla::WcTimingTree > &timingTree)
 
virtual void gemv (const typename SourceFunction::valueType &alpha, const DGFunction< real_t > &src, const typename DestinationFunction::valueType &beta, const DGFunction< real_t > &dst, size_t level, DoFType flag) const
 Implements the BLAS level 2 routine gemv:
 
uint_t getMaxLevel () const
 
uint_t getMinLevel () const
 
const std::shared_ptr< PrimitiveStoragegetStorage () const
 
void toMatrix (const std::shared_ptr< SparseMatrixProxy > &mat, const DGFunction< idx_t > &src, const DGFunction< idx_t > &dst, size_t level, DoFType flag) const override
 
virtual void toMatrix (const std::shared_ptr< SparseMatrixProxy > &mat, const typename srcType::template FunctionType< idx_t > &src, const typename dstType::template FunctionType< idx_t > &dst, size_t level, DoFType flag) const
 

Protected Member Functions

void startTiming (const std::string &timerString) const
 
void stopTiming (const std::string &timerString) const
 

Protected Attributes

const uint_t maxLevel_
 
const uint_t minLevel_
 
const std::shared_ptr< PrimitiveStoragestorage_
 
std::shared_ptr< walberla::WcTimingTreetimingTree_
 

Private Member Functions

template<typename VType >
void addLocalToGlobalMatrix (int dim, int numSrcDofs, int numDstDofs, VType *srcDofMemory, VType *dstDofMemory, VolumeDoFMemoryLayout srcMemLayout, VolumeDoFMemoryLayout dstMemLayout, Index srcElementIdx, Index dstElementIdx, uint_t srcMicroVolType, uint_t dstMicroVolType, uint_t level, std::shared_ptr< SparseMatrixProxy > mat, const MatrixXr &localMat) const
 Just a small helper method that writes the local matrix into the global sparse system.
 
template<typename VType >
void assembleAndOrApply (const DGFunction< VType > &src, const DGFunction< VType > &dst, size_t level, DoFType flag, const std::shared_ptr< SparseMatrixProxy > &mat, UpdateType updateType=Replace) const
 Helper function that can be used to either apply the operator, or to assemble the sparse matrix.
 

Private Attributes

std::shared_ptr< DGFormform_
 

Member Typedef Documentation

◆ dstType

typedef DGFunction< real_t > hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::dstType
inherited

◆ srcType

typedef DGFunction< real_t > hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::srcType
inherited

Constructor & Destructor Documentation

◆ DGOperator()

hyteg::dg::DGOperator::DGOperator ( const std::shared_ptr< PrimitiveStorage > & storage,
uint_t minLevel,
uint_t maxLevel,
const std::shared_ptr< DGForm > & form )

Member Function Documentation

◆ addLocalToGlobalMatrix()

template<typename VType >
void hyteg::dg::DGOperator::addLocalToGlobalMatrix ( int dim,
int numSrcDofs,
int numDstDofs,
VType * srcDofMemory,
VType * dstDofMemory,
VolumeDoFMemoryLayout srcMemLayout,
VolumeDoFMemoryLayout dstMemLayout,
Index srcElementIdx,
Index dstElementIdx,
uint_t srcMicroVolType,
uint_t dstMicroVolType,
uint_t level,
std::shared_ptr< SparseMatrixProxy > mat,
const MatrixXr & localMat ) const
inlineprivate

Just a small helper method that writes the local matrix into the global sparse system.

◆ apply()

void hyteg::dg::DGOperator::apply ( const DGFunction< real_t > & src,
const DGFunction< real_t > & dst,
size_t level,
DoFType flag,
UpdateType updateType ) const
overridevirtual

◆ assembleAndOrApply()

template<typename VType >
void hyteg::dg::DGOperator::assembleAndOrApply ( const DGFunction< VType > & src,
const DGFunction< VType > & dst,
size_t level,
DoFType flag,
const std::shared_ptr< SparseMatrixProxy > & mat,
UpdateType updateType = Replace ) const
inlineprivate

Helper function that can be used to either apply the operator, or to assemble the sparse matrix.

Since about 99% of the implementation is equal, it makes sense to fuse that here.

Which operation is performed depends on the pointer to the sparse matrix proxy and the value type. If the pointer is a nullptr, apply is executed.

Some notes on the implementation:

For DG implementations there are two main possibilities to evaluate the interface integrals.

The "naive" (not necessarily worse) approach is to loop over all interfaces in a dedicated loop e.g. after evaluating all volume integrals. Alternatively, the interface integrals are evaluated during the loop over the volumes.

This function implements the latter, with the advantage that each DoF is only written to exactly once, also there is only a single loop over the macro-volume. On the downside, each interface integral has to be evaluated twice.

A nice description is found in

Kronbichler, M., & Kormann, K. (2019). Fast matrix-free evaluation of discontinuous Galerkin finite element operators. ACM Transactions on Mathematical Software (TOMS), 45(3), 1-40.

◆ enableTiming()

void hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::enableTiming ( const std::shared_ptr< walberla::WcTimingTree > & timingTree)
inlineinherited

◆ gemv()

virtual void hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::gemv ( const typename SourceFunction::valueType & alpha,
const DGFunction< real_t > & src,
const typename DestinationFunction::valueType & beta,
const DGFunction< real_t > & dst,
size_t level,
DoFType flag ) const
inlinevirtualinherited

Implements the BLAS level 2 routine gemv:

y ← ɑAx + βy

where ɑ, β are scalars, A is this operator, x is the "src" function, and y is the "dst" function.

Note that the apply() method implements

y ← Ax + ɣy

where ɣ ∈ { 0, 1 } for UpdateType Replace and Add respectively. This is just a gemv with ɑ = 1 and β = ɣ.

◆ getMaxLevel()

uint_t hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::getMaxLevel ( ) const
inlineinherited

◆ getMinLevel()

uint_t hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::getMinLevel ( ) const
inlineinherited

◆ getStorage()

const std::shared_ptr< PrimitiveStorage > hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::getStorage ( ) const
inlineinherited

◆ startTiming()

void hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::startTiming ( const std::string & timerString) const
inlineprotectedinherited

◆ stopTiming()

void hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::stopTiming ( const std::string & timerString) const
inlineprotectedinherited

◆ toMatrix() [1/2]

void hyteg::dg::DGOperator::toMatrix ( const std::shared_ptr< SparseMatrixProxy > & mat,
const DGFunction< idx_t > & src,
const DGFunction< idx_t > & dst,
size_t level,
DoFType flag ) const
override

◆ toMatrix() [2/2]

virtual void hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::toMatrix ( const std::shared_ptr< SparseMatrixProxy > & mat,
const typename srcType::template FunctionType< idx_t > & src,
const typename dstType::template FunctionType< idx_t > & dst,
size_t level,
DoFType flag ) const
inlinevirtualinherited

Member Data Documentation

◆ form_

std::shared_ptr< DGForm > hyteg::dg::DGOperator::form_
private

◆ maxLevel_

const uint_t hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::maxLevel_
protectedinherited

◆ minLevel_

const uint_t hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::minLevel_
protectedinherited

◆ storage_

const std::shared_ptr< PrimitiveStorage > hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::storage_
protectedinherited

◆ timingTree_

std::shared_ptr< walberla::WcTimingTree > hyteg::Operator< DGFunction< real_t > , DGFunction< real_t > >::timingTree_
protectedinherited

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