#include <Stencil.H>
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< Point > | m_offsets |
Offsets associated with the Stencil. Each offset corresponds to a coefficient in m_coef. | |
Point | m_srcRefratio |
Point | m_destRefratio |
Point | m_destShift |
Stencil< TCoef >::Stencil | ( | pair< Shift, TCoef > | a_pair, | |
Point | a_destRefratio = getOnes() , |
|||
Shift | a_destShift = getZeros() , |
|||
Point | a_srcRefratio = getOnes() | |||
) | [inline] |
Construct a stencil from a Shift, Coefficient pair.
References Stencil< T >::m_coef, Stencil< T >::m_destRefratio, Stencil< T >::m_destShift, Stencil< T >::m_offsets, Shift::m_shift, and Stencil< T >::m_srcRefratio.
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().
void Stencil< TCoef >::operator*= | ( | const TCoef & | a_coef | ) | [inline] |
Stencil< TCoef > Stencil< TCoef >::operator+ | ( | const Stencil< TCoef > | a_stencil | ) | const [inline] |
Calculates the sum of two Stencils of the same type T.
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().
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.
Stencil Stencil< T >::makeInterpStencil | ( | RectMDArray< Stencil< T > > | ) | [inline] |
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
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.
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|=().
const vector<T>& Stencil< T >::getCoefs | ( | ) | const [inline] |
Returns the coefficients of the Stencil.
References Stencil< T >::m_coef.
Referenced by componentApply().
Returns the offsets of the Stencil.
References Stencil< T >::m_offsets.
Referenced by componentApply().
void Stencil< T >::print | ( | ) | const [inline] |
Alternative printing function to stencilDump().
References Stencil< T >::m_coef, Stencil< T >::m_destRefratio, Stencil< T >::m_destShift, Stencil< T >::m_offsets, Stencil< T >::m_srcRefratio, and Point::print().
Coefficients of the Stencil.
Referenced by Stencil< T >::apply(), Stencil< T >::getCoefs(), Stencil< T >::operator*(), Stencil< T >::operator*=(), Stencil< T >::operator+(), Stencil< T >::print(), Stencil< T >::Stencil(), and Stencil< T >::stencilDump().
Offsets associated with the Stencil. Each offset corresponds to a coefficient in m_coef.
Referenced by Stencil< T >::apply(), Stencil< T >::getOffsets(), Stencil< T >::operator*(), Stencil< T >::operator+(), Stencil< T >::print(), Stencil< T >::Stencil(), and Stencil< T >::stencilDump().
Point Stencil< T >::m_srcRefratio [private] |
Point Stencil< T >::m_destRefratio [private] |
Point Stencil< T >::m_destShift [private] |