Proto  3.2
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Proto::Stencil< T > Class Template Reference

A Linear Stencil Operation. More...

#include <Proto_BoxData.H>

Inheritance diagram for Proto::Stencil< T >:
Inheritance graph
[legend]

Public Member Functions

template<unsigned int C, MemType MEMTYPE, unsigned int D, unsigned int E>
void apply (const BoxData< T, C, MEMTYPE, D, E > &a_src, BoxData< T, C, MEMTYPE, D, E > &a_dest, const Box &a_bx, bool a_initToZero=false, const T a_scale=1) const
 Apply Stencil Helper function. More...
 
template<unsigned int C, unsigned int D, unsigned int E>
void protoApply (const BoxData< T, C, HOST, D, E > &a_src, BoxData< T, C, HOST, D, E > &a_dst, const Box &a_box, bool a_initToZero=false, T a_scale=1)
 
template<unsigned int C, unsigned int D, unsigned int E>
void protoApply (const BoxData< T, C, DEVICE, D, E > &a_src, BoxData< T, C, DEVICE, D, E > &a_dst, const Box &a_box, bool a_initToZero=false, T a_scale=1)
 
template<unsigned int C, unsigned int D, unsigned int E>
void hostApply (const BoxData< T, C, MemType::HOST, D, E > &a_src, BoxData< T, C, MemType::HOST, D, E > &a_dst, const Box &a_box, bool a_initToZero=false, T a_scale=1) const
 
Constructors
 Stencil ()
 Default Constructor. More...
 
 Stencil (Shift a_shift, T a_coef, Point a_destRefratio=Point::Ones(), Point a_destShift=Point::Zeros(), Point a_srcRefratio=Point::Ones())
 General Constructor. More...
 
 ~Stencil ()
 
Operators
bool operator== (const Stencil< T > &a_stencil) const
 Equality Operator. More...
 
bool operator!= (const Stencil< T > &a_stencil) const
 Inquality Operator. More...
 
Stencil< T > operator* (const Stencil< T > &a_stencil) const
 Stencil Composition. More...
 
Stencil< T > operator* (const T a_coef) const
 Scalar Multiplication. More...
 
void operator*= (const Stencil< T > &a_stencil)
 In Place Stencil Composition. More...
 
void operator*= (const T a_coef)
 In Place Scalar Multiplication. More...
 
Stencil< T > operator+ (const Stencil< T > &a_stencil) const
 Stencil Addition. More...
 
Stencil< T > operator- (const Stencil< T > &a_stencil) const
 Stencil Subtraction (Convenience) More...
 
void operator+= (const Stencil< T > &a_stencil)
 In Place Stencil Addition. More...
 
void operator-= (const Stencil< T > &a_stencil)
 In Place Stencil Subtraction. More...
 
Stencil Binding and Application
template<unsigned int C, MemType MEMTYPE, unsigned int D, unsigned int E>
LazyStencil< T, C, MEMTYPE, D, E > operator() (const BoxData< T, C, MEMTYPE, D, E > &a_src, T a_scale=1) const
 Operate on BoxData. More...
 
template<unsigned int C, MemType MEMTYPE, unsigned int D, unsigned int E>
LazyStencil< T, C, MEMTYPE, D, E > operator() (const BoxData< T, C, MEMTYPE, D, E > &a_src, Box a_box, T a_scale=1) const
 Operate on BoxData (Overload with Box Input) More...
 

Static Public Member Functions

Stencil Library
static Stencil< T > Identity ()
 
static Stencil< T > Derivative (int a_n, int a_dir, int a_order=2)
 Stencil Library: Derivative. More...
 
static Stencil< T > Laplacian ()
 Stencil Library: Laplacian. More...
 
static Stencil< T > LaplacianFace (int a_dir, int a_order=2)
 Stencil Library: Perpendicular Laplacian. More...
 
static Stencil< T > CellToFace (int a_dir, Side::LoHiSide a_side=Side::Lo, int a_order=4)
 Stencil Library: Cell to Face Interpolation. More...
 
static Stencil< T > DiffCellToFace (int a_dir, Side::LoHiSide a_side=Side::Lo, int a_order=4)
 Stencil Library: Cell to Face Differentiation. More...
 
static Stencil< T > CellToFaceL (int a_dir, int a_order=4)
 Stencil Library: Upwind Cell to Face Interpolation. More...
 
static Stencil< T > CellToFaceH (int a_dir, int a_order=4)
 Stencil Library: Upwind Cell to Face Interpolation. More...
 
static Stencil< T > AvgDown (int a_refRatio)
 Stencil Library: Simple Average. More...
 
static Stencil< T > AvgDown (Point a_refRatio)
 Stencil Library: Anisotropic Average. More...
 
static Stencil< T > Sum (int a_refRatio)
 Stencil Library: Sum. More...
 
static Stencil< T > Sum (Point a_refRatio)
 Stencil Library: Sum. More...
 
static Stencil< T > AvgDownFace (int a_normDir, Side::LoHiSide a_side, int a_refRatio)
 Stencil Library: Simple Average over a Face. More...
 
static Stencil< T > AvgDownFace (int a_dir, Side::LoHiSide a_side, Point a_refRatio)
 Stencil Library: Simple Average over a Face. More...
 
static Stencil< T > FluxDivergence (int a_dir)
 Stencil Library: Flux Divergence. More...
 
static Stencil< T > faceToCell (int a_dir, int a_order=4)
 Interpolate from face average to cell average. More...
 
static Stencil< T > cornersToFaces (int a_dir, int a_order=4)
 Interpolate from corners to face average. More...
 
static Stencil< T > CornersToCells (int a_order=4)
 Interpolate from corners to cell average. More...
 

Private Member Functions

void addCoef (T a_coef, Point a_offset)
 Add Coefficient-Offset Pair. More...
 
void closeForDevice ()
 

Private Attributes

std::vector< T > m_coefs
 Coefficients of the Stencil. More...
 
std::vector< Pointm_offsets
 Offsets associated with the Stencil. More...
 
Point m_srcRefratio
 Refinement of source data. More...
 
Point m_destRefratio
 Refinement of destination data. More...
 
Point m_destShift
 Output shift in (refined) destination data. Meaningless without destination refinement. More...
 
Box m_span
 Bounding Box defining the largest offsets of *this. Defines Stencil's spatial footprint. More...
 
bool m_isClosed
 

Friends

template<typename TT , unsigned int C, MemType MEMTYPE, unsigned int D, unsigned int E>
class BoxData
 
template<typename TT , unsigned int C, MemType MEMTYPE, unsigned int D, unsigned int E>
BoxData< TT, C, MEMTYPE, D, E > & operator|= (BoxData< TT, C, MEMTYPE, D, E > &a_dest, LazyStencil< TT, C, MEMTYPE, D, E > &&a_op)
 
template<typename TT , unsigned int C, MemType MEMTYPE, unsigned int D, unsigned int E>
BoxData< TT, C, MEMTYPE, D, E > & operator+= (BoxData< TT, C, MEMTYPE, D, E > &a_dest, LazyStencil< TT, C, MEMTYPE, D, E > &&a_op)
 

Accessors and Queries

const std::vector< T > & coefs () const
 Get Vector of Coefficients. More...
 
Box span () const
 Span. More...
 
Point ghost () const
 Ghost. More...
 
PointsrcRatio ()
 Get Source Refinement Ratio. More...
 
const PointsrcRatio () const
 Get Source Refinement Ratio (Const) More...
 
PointdestRatio ()
 Get Destination Refinement Ratio. More...
 
const PointdestRatio () const
 Get Destination Refinement Ratio (Const) More...
 
PointdestShift ()
 Get Destination Shift. More...
 
const PointdestShift () const
 Get Destination Shift (Const) More...
 
bool closed () const
 Stencil Closed Query. More...
 
const std::vector< Point > & offsets () const
 Get Vector of Coefficients (Primitive) More...
 
unsigned long long int size () const
 Get Vector of Offsets. More...
 
unsigned long long int numFlops (const Box &a_box) const
 Num Flops. More...
 

Utility

void invert (int a_dir)
 Invert Stencil. More...
 
void transpose (unsigned int a, unsigned int b)
 Transpose Stencil. More...
 
Box range (Box a_domain) const
 Get Max Range Box. More...
 
Box domain (Box a_range) const
 Get Min Domain Box. More...
 
diagonal () const
 Get Diagonal Value. More...
 
void print () const
 Print. More...
 
Box indexRange (Box a_domain) const
 Get Max Index Range. More...
 
Box indexDomain (Box a_range) const
 Get Max Index Domain. More...
 

Detailed Description

template<typename T>
class Proto::Stencil< T >

A Linear Stencil Operation.

Encapsulates a linear stencil operation where coefficients are of type T. Stencil objects are built and used in a way that conforms to their nature as operators. For illustrative usage examples, refer to the following code snippets:

Examples: Build a Stencil from Shifts and coefficients:

Apply a Stencil with no Source / Dest Refinement to a BoxData:

The above examples illustrate the usage of Stencil to do computations in which the source and destination arrays are at the same refinement. Stencil is also capable of "prolong" and "restrict" type operations in which the destination and source respectively are refined. This functionality is useful for operations such as averaging and interpolation, or for algorithms like Red-Black Gauss Seidel Iteration in which it is necessary to evaluate a Stencil on "every other cell".

To facilitate these more exotic operations, the Stencil API allows the user to designate a source and/or destination refinement ratio. If these values are different from (1,...,1), then input Box object will be interpreted as an "index range" instead of a physical Box domain. The following code snippets illustrate some examples of this functionality.

Examples: Non-Trivial Source Refinement Ratio

Non-Trivial Destination Refinement Ratio

In the case of non-trivial destination refinement, an array of refRatio^DIM Stencils is often needed to fully populate the output. Proto provides a convenience structure called InterpStencil which is designed to mitigate this form of pedantry. See the associated documentation for additional information and example usage.

Member Function Documentation

◆ protoApply() [1/2]

template<typename T>
template<unsigned int C, unsigned int D, unsigned int E>
void Proto::Stencil< T >::protoApply ( const BoxData< T, C, HOST, D, E > &  a_src,
BoxData< T, C, HOST, D, E > &  a_dst,
const Box a_box,
bool  a_initToZero = false,
a_scale = 1 
)

◆ protoApply() [2/2]

template<typename T>
template<unsigned int C, unsigned int D, unsigned int E>
void Proto::Stencil< T >::protoApply ( const BoxData< T, C, DEVICE, D, E > &  a_src,
BoxData< T, C, DEVICE, D, E > &  a_dst,
const Box a_box,
bool  a_initToZero = false,
a_scale = 1 
)

◆ hostApply()

template<typename T>
template<unsigned int C, unsigned int D, unsigned int E>
void Proto::Stencil< T >::hostApply ( const BoxData< T, C, MemType::HOST, D, E > &  a_src,
BoxData< T, C, MemType::HOST, D, E > &  a_dst,
const Box a_box,
bool  a_initToZero = false,
a_scale = 1 
) const

◆ addCoef()

template<typename T>
void Proto::Stencil< T >::addCoef ( a_coef,
Point  a_offset 
)
private

Add Coefficient-Offset Pair.

Helper function that encapsulates all of the proper checks needed to add a coefficient-offset pair to a Stencil. Any new function that needs to add data to an existing Stencil should call this.

◆ closeForDevice()

template<typename T>
void Proto::Stencil< T >::closeForDevice ( )
inlineprivate

Member Data Documentation

◆ m_coefs

template<typename T>
std::vector<T> Proto::Stencil< T >::m_coefs
private

Coefficients of the Stencil.

◆ m_offsets

template<typename T>
std::vector<Point> Proto::Stencil< T >::m_offsets
private

Offsets associated with the Stencil.

◆ m_srcRefratio

template<typename T>
Point Proto::Stencil< T >::m_srcRefratio
private

Refinement of source data.

◆ m_destRefratio

template<typename T>
Point Proto::Stencil< T >::m_destRefratio
private

Refinement of destination data.

◆ m_destShift

template<typename T>
Point Proto::Stencil< T >::m_destShift
private

Output shift in (refined) destination data. Meaningless without destination refinement.

◆ m_span

template<typename T>
Box Proto::Stencil< T >::m_span
private

Bounding Box defining the largest offsets of *this. Defines Stencil's spatial footprint.

◆ m_isClosed

template<typename T>
bool Proto::Stencil< T >::m_isClosed
private

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