Stencil< T > Class Template Reference

#include <Stencil.H>

List of all members.


Detailed Description

template<class T>
class Stencil< T >

An object which contains a set of offsets and coefficients associated with the application of a stencil.

Public Member Functions

 Stencil ()
 Default Constructor.
 Stencil (pair< Shift, T > a_pair, Point a_destRefratio=getOnes(), Shift a_destShift=getZeros(), Point a_srcRefratio=getOnes())
 Construct a stencil from a Shift, Coefficient pair.
Stencil< T > operator* (const Stencil< T > a_stencil) const
 Defines "*" operator on Stencils.
void operator*= (const T &a_coef)
 Multiplication in place by a scalar of type T.
Stencil< T > operator+ (const Stencil< T > a_stencil) const
 Calculates the sum of two Stencils of the same type T.
void stencilDump () const
 Prints the information in *this. Note that print() does this also in a slightly different format.
void setDestRefratio (Point a_pt)
 Sets the value of m_destRefratio.
void setSrcRefratio (Point a_pt)
 Sets the value of m_srcRefratio.
void setDestShift (Point a_pt)
 Sets the value of m_destShift.
Stencil makeInterpStencil (RectMDArray< Stencil >)
std::tuple< const Stencil< T >
*, const RectMDArray< T >
*, const Box * > 
operator() (const RectMDArray< T > &a_phi, const Box &a_bx) const
 Defines how a Stencil operates on a RectMDArray.
const vector< T > & getCoefs () const
 Returns the coefficients of the Stencil.
const vector< Point > & getOffsets () const
 Returns the offsets of the Stencil.
void print () const
 Alternative printing function to stencilDump().

Static Public Member Functions

static void apply (const Stencil< T > &a_stencil, const RectMDArray< T > &a_phi, RectMDArray< T > &a_lofPhi, const Box &a_bx)
 Applies a Stencil to a_phi and stores it in a_lofphi.

Private Member Functions

 Stencil (vector< T > a_vecT, vector< Point > a_vecPt, Point a_destRefratio=getOnes(), Point a_destShift=getZeros(), Point a_srcRefratio=getOnes())

Private Attributes

vector< T > m_coef
 Coefficients of the Stencil.
vector< Pointm_offsets
 Offsets associated with the Stencil. Each offset corresponds to a coefficient in m_coef.
Point m_srcRefratio
Point m_destRefratio
Point m_destShift

Constructor & Destructor Documentation

template<class TCoef>
Stencil< TCoef >::Stencil (  )  [inline]

Default Constructor.

Referenced by Stencil< T >::operator*(), and Stencil< T >::operator+().

template<class TCoef>
Stencil< TCoef >::Stencil ( pair< Shift, TCoef >  a_pair,
Point  a_destRefratio = getOnes(),
Shift  a_destShift = getZeros(),
Point  a_srcRefratio = getOnes() 
) [inline]

template<class TCoef>
Stencil< TCoef >::Stencil ( vector< TCoef >  a_vecT,
vector< Point a_vecPt,
Point  a_destRefratio = getOnes(),
Point  a_destShift = getZeros(),
Point  a_srcRefratio = getOnes() 
) [inline, private]


Member Function Documentation

template<class TCoef>
Stencil< TCoef > Stencil< TCoef >::operator* ( const Stencil< TCoef >  a_stencil  )  const [inline]

Defines "*" operator on Stencils.

The product of two Stencils is defined as the composition of the two. Two stencils with shifts in the same direction will be combined into one shift which has a coefficient equal to the sum of the original shifts.

References Stencil< T >::m_coef, Stencil< T >::m_destRefratio, Stencil< T >::m_destShift, Stencil< T >::m_offsets, Stencil< T >::m_srcRefratio, and Stencil< T >::Stencil().

template<class TCoef>
void Stencil< TCoef >::operator*= ( const TCoef &  a_coef  )  [inline]

Multiplication in place by a scalar of type T.

References Stencil< T >::m_coef.

template<class TCoef>
Stencil< TCoef > Stencil< TCoef >::operator+ ( const Stencil< TCoef >  a_stencil  )  const [inline]

Calculates the sum of two Stencils of the same type T.

Todo:
Currently * and + do the same thing. Check to see how they are meant to work.

References Stencil< T >::m_coef, Stencil< T >::m_destRefratio, Stencil< T >::m_destShift, Stencil< T >::m_offsets, Stencil< T >::m_srcRefratio, and Stencil< T >::Stencil().

template<class TCoef>
void Stencil< TCoef >::stencilDump (  )  const [inline]

Prints the information in *this. Note that print() does this also in a slightly different format.

Output format is: coefs and offsets: <index> , <coefficient> , <shift> ; ... sourceRef, destRef, and destShift: <srcRef> , <destRef> , <destShift>

References Stencil< T >::m_coef, Stencil< T >::m_destRefratio, Stencil< T >::m_destShift, Stencil< T >::m_offsets, and Stencil< T >::m_srcRefratio.

template<class T>
void Stencil< T >::setDestRefratio ( Point  a_pt  )  [inline]

Sets the value of m_destRefratio.

References Stencil< T >::m_destRefratio.

template<class T>
void Stencil< T >::setSrcRefratio ( Point  a_pt  )  [inline]

Sets the value of m_srcRefratio.

References Stencil< T >::m_srcRefratio.

template<class T>
void Stencil< T >::setDestShift ( Point  a_pt  )  [inline]

Sets the value of m_destShift.

References Stencil< T >::m_destShift.

template<class T>
Stencil Stencil< T >::makeInterpStencil ( RectMDArray< Stencil< T > >   )  [inline]

Todo:
Not Implemented. Determine what this function is supposed to do.

template<class T>
std::tuple<const Stencil<T>*, const RectMDArray<T>*, const Box*> Stencil< T >::operator() ( const RectMDArray< T > &  a_phi,
const Box a_bx 
) const [inline]

Defines how a Stencil operates on a RectMDArray.

This is the secret sauce of making a Stencil into an operator, using C++ forwarding. A real extended DSL would allow us to use right-binding for operator(), but standard C++ cannot use right-binding, or return-type disambiguation. Instead, this operator returns a tuple containing this, a_phi, and a_bx. The application of the stencil to a_phi is handled by apply() through the += and |= operators. Syntactic Example:

    // build the desired stencil S...
    // initialize input and output RectMDArrays IN and OUT and the domain Box B...
    OUT += S(IN,B) // S(IN) is added to OUT in B
    // OR ... 
    OUT |= S(IN,B) // S(IN) replaces the data in OUT in B
See the documentation for operator+= and operator|= in the file Stencil.H for additional documentation.

template<class T>
void Stencil< T >::apply ( const Stencil< T > &  a_stencil,
const RectMDArray< T > &  a_phi,
RectMDArray< T > &  a_lofPhi,
const Box a_bx 
) [inline, static]

Applies a Stencil to a_phi and stores it in a_lofphi.

Stencil application function.

This function is called by the += and |= operators. See the documentation of these operators in the Stencil.H file for more information.

Bug:
Timer code does not appear to be working and has been commented out.

References CH_TIMERS, RectMDArray< T, C, D, E >::getBox(), Box::getHighCorner(), Box::getIndex(), Box::getLowCorner(), getOnes(), getUnitv(), RectMDArray< T, C, D, E >::index(), Stencil< T >::m_coef, Stencil< T >::m_destRefratio, Stencil< T >::m_destShift, Stencil< T >::m_offsets, and Stencil< T >::m_srcRefratio.

Referenced by operator+=(), and operator|=().

template<class T>
const vector<T>& Stencil< T >::getCoefs (  )  const [inline]

Returns the coefficients of the Stencil.

References Stencil< T >::m_coef.

Referenced by componentApply().

template<class T>
const vector<Point>& Stencil< T >::getOffsets (  )  const [inline]

Returns the offsets of the Stencil.

References Stencil< T >::m_offsets.

Referenced by componentApply().

template<class T>
void Stencil< T >::print (  )  const [inline]


Member Data Documentation

template<class T>
vector<T> Stencil< T >::m_coef [private]

template<class T>
vector<Point> Stencil< T >::m_offsets [private]

template<class T>
Point Stencil< T >::m_srcRefratio [private]

template<class T>
Point Stencil< T >::m_destRefratio [private]

template<class T>
Point Stencil< T >::m_destShift [private]


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

Generated on Fri Mar 11 12:53:44 2016 for AMRStencil by  doxygen 1.5.5