11 #ifndef _AGGSTENCILI_H_ 12 #define _AGGSTENCILI_H_ 15 template <
class srcData_t,
class dstData_t>
19 const srcData_t & a_srcData,
20 const dstData_t & a_dstData)
23 m_ebstencil.resize(a_dstVoFs.size());
24 m_dstAccess.resize(a_dstVoFs.size());
26 for (
int idst = 0; idst < a_dstVoFs.size(); idst++)
28 const BaseIndex& dstVoF = *a_dstVoFs[idst];
29 m_dstAccess[idst].dataID = a_dstData.dataType(dstVoF);
30 m_dstAccess[idst].offset = a_dstData.offset(dstVoF, 0);
33 m_ebstencil[idst].resize(sten.
size());
34 for (
int isten = 0; isten < sten.
size(); isten++)
37 m_ebstencil[idst][isten].first.offset = a_srcData.offset(stencilVoF, sten.
variable(isten));
38 m_ebstencil[idst][isten].first.dataID = a_srcData.dataType(stencilVoF);
39 m_ebstencil[idst][isten].second = sten.
weight(isten);
45 template <
class srcData_t,
class dstData_t>
49 const srcData_t & a_phi,
50 const int & a_varDest,
51 const bool & a_incrementOnly)
const 53 int varSrc = 0;
int nComp = 1;
54 apply(a_lph, a_phi, varSrc, a_varDest, nComp, a_incrementOnly);
57 template <
class srcData_t,
class dstData_t>
61 const srcData_t & a_phi,
65 const bool & a_incrementOnly)
const 69 const int numtypelph = a_lph.numDataTypes();
70 const int numtypephi = a_phi.numDataTypes();
73 for (
int icomp = 0; icomp < a_nco; icomp++)
75 int varDst = a_dst + icomp;
76 int varSrc = a_src + icomp;
77 for (
int ivec = 0; ivec < numtypelph; ivec++)
79 dataPtrsLph[ivec] = a_lph.dataPtr(ivec, varDst);
82 for (
int ivec = 0; ivec < numtypephi; ivec++)
84 dataPtrsPhi[ivec] = a_phi.dataPtr(ivec, varSrc);
87 for (
int idst = 0; idst < m_ebstencil.size(); idst++)
89 Real* lphiPtr = dataPtrsLph[m_dstAccess[idst].dataID] + m_dstAccess[idst].offset;
90 Real& lphi = *lphiPtr;
95 const stencil_t& ebstencil = m_ebstencil[idst];
96 for (
int isten = 0; isten < ebstencil.
size(); isten++)
98 const Real& weight = ebstencil[isten].second;
99 const long& offset = ebstencil[isten].first.offset;
100 const int & dataID = ebstencil[isten].first.dataID;
101 const Real& phiVal = *(dataPtrsPhi[dataID] + offset);
102 lphi += phiVal*weight;
109 template <
class srcData_t,
class dstData_t>
116 m_cacheDst.resize( m_ebstencil.size(),
Vector<Real>(a_lph.nComp(), 0.));
119 for (
int ivar = 0; ivar < a_lph.nComp(); ivar++)
121 for (
int ivec = 0; ivec < dataPtrsLph.size(); ivec++)
123 dataPtrsLph[ivec] = a_lph.dataPtr(ivec, ivar);
126 for (
int idst = 0; idst < m_ebstencil.size(); idst++)
128 const Real* lphPtr = dataPtrsLph[m_dstAccess[idst].dataID] + m_dstAccess[idst].offset;
129 m_cacheDst[idst][ivar] = *lphPtr;
134 template <
class srcData_t,
class dstData_t>
141 for (
int ivar = 0; ivar < a_lph.nComp(); ivar++)
143 for (
int ivec = 0; ivec < dataPtrsLph.size(); ivec++)
145 dataPtrsLph[ivec] = a_lph.dataPtr(ivec, ivar);
148 for (
int idst = 0; idst < m_ebstencil.size(); idst++)
150 Real* lphPtr = dataPtrsLph[m_dstAccess[idst].dataID] + m_dstAccess[idst].offset;
151 *lphPtr = m_cacheDst[idst][ivar];
void uncache(dstData_t &a_phi) const
Definition: AggStencilI.H:137
A reference-counting handle class.
Definition: RefCountedPtr.H:173
virtual int size() const =0
one dimensional dynamic array
Definition: Vector.H:53
virtual const BaseIndex & index(int isten) const =0
index for other indicies to inherit
Definition: BaseIndex.H:26
AggStencil()
disallowed operators. Without code because Jeff says that is better.
#define CH_TIME(name)
Definition: CH_Timer.H:82
double Real
Definition: REAL.H:33
void cache(const dstData_t &a_lph) const
Definition: AggStencilI.H:112
size_t size() const
Definition: Vector.H:192
Definition: Stencils.H:26
long long int ch_flops
Definition: CH_Counters.H:30
void apply(dstData_t &a_lph, const srcData_t &a_phi, const int &a_varDest, const bool &a_incrementOnly) const
Definition: AggStencilI.H:48
virtual const Real & weight(int isten) const =0
virtual const int & variable(int isten) const =0