1 #ifndef _PROTO_STENCIL_H_ 2 #define _PROTO_STENCIL_H_ 3 #include "Proto_BoxData.H" 4 #include "Proto_DisjointBoxLayout.H" 18 template <
typename T>
class Stencil;
57 template<
typename... vals>
58 inline explicit Shift(vals... args) : m_shift(args...) {}
120 return Shift(m_shift + a_shift.m_shift);
126 PROTO_ASSERT(((a_dir >= 0) && (a_dir < DIM)),
127 "Shift::operator[](int a_dir) invalid for a_dir = %i. a_dir must be in [0,DIM=%i)",
129 return m_shift[a_dir];
142 template <
typename T,
unsigned int C, MemType MEMTYPE,
unsigned char D,
unsigned char E>
154 template <
typename T,
unsigned int C, MemType MEMTYPE,
unsigned char D,
unsigned char E>
160 Box a_box, T a_scale);
164 inline unsigned long long int size(){
return m_stencil.size();}
168 std::vector<const Stencil<T>*> m_stencil;
169 std::vector<BoxData<T, C,MEMTYPE, D, E>*> m_src;
170 std::vector<Box> m_box;
171 std::vector<T> m_scale;
211 template <
typename T>
229 protoFreeGPU(d_coeff);
230 protoFreeGPU(d_offset);
237 inline void closeForDevice();
238 template <
typename TT,
unsigned int C, MemType MEMTYPE ,
unsigned char D,
unsigned char E>
241 template <
typename TT,
unsigned int C , MemType MEMTYPE,
unsigned char D,
unsigned char E>
244 template <
typename TT,
unsigned int C, MemType MEMTYPE,
unsigned char D,
unsigned char E>
248 template <
typename TT,
unsigned int C, MemType MEMTYPE,
unsigned char D,
unsigned char E>
312 void operator*=(
const T a_coef);
359 inline bool operator==(
Stencil<T>& a_stencil)
const;
373 inline const std::vector<T>&
coefs()
const {
return m_coefs;};
380 inline const T*
devCoefs()
const {
return d_coeff;};
394 inline const std::vector<Point>&
offsets()
const {
return m_offsets;};
401 inline unsigned long long int size()
const {
return m_coefs.size();}
426 inline Point spanPoint()
const;
432 inline Point ghost()
const;
439 inline unsigned long long int numFlops(
const Box& a_box)
const;
489 template<
unsigned int C, MemType MEMTYPE,
unsigned char D,
unsigned char E>
503 template<
unsigned int C, MemType MEMTYPE,
unsigned char D,
unsigned char E>
517 inline void invert(
int a_dir);
526 inline void transpose(
unsigned char a,
unsigned char b);
536 inline Box indexRange(
Box a_domain)
const;
547 inline Box indexDomain(
Box a_range)
const;
558 inline Box range(
Box a_domain)
const;
569 inline Box domain(
Box a_range)
const;
576 T diagonalValue()
const;
583 inline void print()
const;
605 static Stencil<T> Derivative(
int a_n,
int a_dir = 0,
int a_order = 2);
628 static Stencil<T> LaplacianFace(
int a_dir,
int a_order = 2);
635 static Stencil<T> CellToEdge(
int a_dir,
int a_order = 4);
641 static Stencil<T> DiffCellToEdge(
int a_dir,
int a_order = 4);
650 static Stencil<T> EdgeToCell(
int a_dir,
int a_order = 4);
661 static Stencil<T> CellToEdgeL(
int a_dir,
int a_order = 5);
672 static Stencil<T> CellToEdgeH(
int a_dir,
int a_order = 5);
681 static Stencil<T> AvgDown(
int a_refRatio = 2);
690 static Stencil<T> AvgDownEdge(
int a_dir,
int a_refRatio = 2);
717 template<
unsigned int C, MemType MEMTYPE,
unsigned char D,
unsigned char E>
721 bool a_initToZero =
false,
722 const T a_scale = 1)
const;
727 template<
unsigned int C,
unsigned char D,
unsigned char E, MemType MEMTYPE>
731 bool a_initToZero =
false,
735 template<
unsigned int C,
unsigned char D,
unsigned char E>
739 bool a_initToZero =
false,
740 T a_scale = 1)
const;
743 inline bool getIsClosed() {
return m_isClosed;}
753 void augment(T a_coef,
Point a_offset);
755 std::vector<T> m_coefs;
756 std::vector<Point> m_offsets;
758 Point m_destRefratio;
784 template <
typename T>
795 template <
typename T>
798 return a_stencil*a_coef;
820 template <
typename T,
unsigned int C, MemType MEMTYPE,
unsigned char D,
unsigned char E>
821 inline BoxData<T,C,MEMTYPE,D,E>&
operator|=(
BoxData<T,C,MEMTYPE,D,E>& a_dest,
LazyStencil<T,C,MEMTYPE,D,E>&& a_op);
842 template <
class T,
unsigned int C, MemType MEMTYPE,
unsigned char D,
unsigned char E>
843 BoxData<T,C,MEMTYPE,D,E>&
operator+=(
BoxData<T,C,MEMTYPE,D,E>& a_dest,
LazyStencil<T,C,MEMTYPE,D,E>&& a_op);
903 for (
int ii = 0; ii < DIM; ii++)
905 PROTO_ASSERT(a_ratio[ii] > 0,
906 "InterpStencil(Point ratio) invalid. All ratios must be 1 or greater");
909 m_s.resize(m_k.size());
933 PROTO_ASSERT(!m_closed,
934 "Components of InterpStencil are read-only once closed. Use InterpStencil::get instead.");
935 PROTO_ASSERT(m_k.contains(a_p),
936 "InterpStencil::operator()(Point p) invalid.\ 937 p is not a member of the InterStencil kernel");
939 return m_s[m_k.index(a_p)];
951 PROTO_ASSERT(m_k.contains(a_p),
952 "InterpStencil::operator()(Point p) invalid.\ 953 p is not a member of the InterStencil kernel");
955 return m_s[m_k.index(a_p)];
965 for (
int ii = 0; ii < m_s.size(); ii++)
967 span = span & m_s[ii].span().
low();
968 span = span & m_s[ii].span().
high();
973 inline Point spanPoint()
975 Box spanBox = span();
977 for (
int ii = 0; ii < DIM; ii++)
979 v[ii] = std::max(std::abs(spanBox.
low()[ii]), std::abs(spanBox.
high()[ii]));
994 template<
unsigned int C, MemType MEMTYPE,
unsigned char D,
unsigned char E>
996 T a_scale = 1)
const;
1008 template<
unsigned int C, MemType MEMTYPE,
unsigned char D,
unsigned char E>
1011 T a_scale = 1)
const;
1042 int a_order,
int a_refRatio);
1053 std::vector<Point>& a_shifts,
1065 std::vector<Point>& a_shifts,
1066 const std::vector<Point>& a_orders,
1083 inline typename std::vector<Stencil<T>>::iterator
begin(){
return m_s.begin();}
1088 inline typename std::vector<Stencil<T>>::iterator
end(){
return m_s.end();}
1094 inline bool empty(){
return (m_s.size() <= 0);}
1101 inline unsigned long long int size()
const {
return m_s.size();}
1105 std::vector<Stencil<T>> m_s;
1106 bool m_closed =
false;
1109 #include "implem/Proto_StencilImplem.H" 1110 #include "implem/Proto_StencilDefs.H" unsigned long long int size() const
Size.
Definition: Proto_Stencil.H:401
Stencil Shift.
Definition: Proto_Stencil.H:30
Point ratio() const
Return Destination Refinement Ratio.
Definition: Proto_Stencil.H:1078
static Shift Basis(int a_dir, int a_scale=1)
Basis Shift.
Definition: Proto_Stencil.H:73
bool empty()
Empty Query.
Definition: Proto_Stencil.H:1094
An Unevaluated Stencil Operation.
Definition: Proto_BoxData.H:66
Point high() const
Access High Corner.
Definition: Proto_Box.H:174
Point low() const
Access Low Corner.
Definition: Proto_Box.H:168
Point & destShift()
Get Destination Shift.
Definition: Proto_Stencil.H:466
Multidimensional Rectangular Array.
Definition: Proto_BoxData.H:458
BoxData< T, C, MEMTYPE, D, E > & operator|=(BoxData< T, C, MEMTYPE, D, E > &a_dest, LazyStencil< T, C, MEMTYPE, D, E > &&a_op)
Application by Replacement.
Definition: Proto_Stencil.H:424
const T * devCoefs() const
Get Vector of Coefficients.
Definition: Proto_Stencil.H:380
Point & shift()
Get Shift Point.
Definition: Proto_Stencil.H:93
Stencil< T > operator*(T a_coef) const
Scalar Multiplication.
Definition: Proto_Stencil.H:108
Point & srcRatio()
Get Source Refinement Ratio.
Definition: Proto_Stencil.H:447
InterpStencil()
Default Constructor.
Definition: Proto_Stencil.H:864
Point & destRatio()
Get Destination Refinement Ratio.
Definition: Proto_Stencil.H:457
A Linear Stencil Operation.
Definition: Proto_BoxData.H:64
Box span()
Span.
Definition: Proto_Stencil.H:962
const std::vector< Point > & offsets() const
Get Vector of Offsets.
Definition: Proto_Stencil.H:394
static CUDA_DECORATION Point Zeros()
Get Zeros.
Definition: Proto_Point.H:37
Interpolation Stencil.
Definition: Proto_Stencil.H:860
Point operator-(Point a_pt)
Unary Negation.
Definition: Proto_Point.H:432
std::vector< Stencil< T > >::iterator end()
Iterate Over Stencil Components.
Definition: Proto_Stencil.H:1088
An interval in DIM dimensional space.
Definition: Proto_Box.H:26
void define(Point a_ratio)
Define.
Definition: Proto_Stencil.H:901
const Point & srcRatio() const
Get Source Refinement Ratio (Const)
Definition: Proto_Stencil.H:450
static Shift Zeros()
Zero Shift.
Definition: Proto_Stencil.H:81
static CUDA_DECORATION Point Basis(int a_dir, int a_scale=1)
Get Basis.
Definition: Proto_Point.H:48
const Point & destShift() const
Get Destination Shift (Const)
Definition: Proto_Stencil.H:472
InterpStencil(int a_ratio)
Isotropic Constructor.
Definition: Proto_Stencil.H:876
bool operator!=(Stencil< T > &a_stencil) const
Inquality Operator.
Definition: Proto_Stencil.H:366
Shift(const Point &a_pt)
Point Constructor.
Definition: Proto_Stencil.H:47
int & operator[](int a_dir)
Componentwise Access.
Definition: Proto_Stencil.H:124
Stencil< T > & operator()(Point a_p)
Get Read-Write Stencil Subcomponent.
Definition: Proto_Stencil.H:931
const std::vector< T > & coefs() const
Get Vector of Coefficients.
Definition: Proto_Stencil.H:373
std::vector< Stencil< T > >::iterator begin()
Iterate Over Stencil Components.
Definition: Proto_Stencil.H:1083
Box span() const
Span.
Definition: Proto_Stencil.H:418
Definition: Proto_Box.H:11
const Point * devOffsets() const
Get Vector of Offsets.
Definition: Proto_Stencil.H:387
unsigned long long int size() const
Size Query.
Definition: Proto_Stencil.H:1101
Definition: Proto_Stencil.H:216
Integer Valued Vector.
Definition: Proto_Point.H:21
static Point Ones(int a_scale=1)
Get Ones.
Definition: Proto_Point.H:25
static Shift Ones(int a_scale=1)
Unit Shift.
Definition: Proto_Stencil.H:90
InterpStencil(Point a_ratio)
Anisotropic Constructor.
Definition: Proto_Stencil.H:888
const Point & destRatio() const
Get Destination Refinement Ratio (Const)
Definition: Proto_Stencil.H:460
BoxData< T, C, MEMTYPE, D, E > & operator+=(BoxData< T, C, MEMTYPE, D, E > &a_dest, LazyStencil< T, C, MEMTYPE, D, E > &&a_op)
Application by Increment.
Definition: Proto_Stencil.H:440
Shift()
Default Constructor.
Definition: Proto_Stencil.H:38
Shift operator*(const Shift &a_shift) const
Convolution.
Definition: Proto_Stencil.H:118
Shift(vals... args)
Variadic Constructor.
Definition: Proto_Stencil.H:58
Box kernel() const
Return Shift Kernel.
Definition: Proto_Stencil.H:1073