void EBStenVarCoef:: cache(const EBCellFAB& a_phi, int a_ivar) { CH_assert(a_phi.getSingleValuedFAB().box() == m_grownBox); const Real* singleValuedPtrPhi = a_phi.getSingleValuedFAB().dataPtr(a_ivar); const Real* multiValuedPtrPhi = a_phi.getMultiValuedFAB().dataPtr(a_ivar); for (int isrc = 0; isrc < m_sourTerms.size(); isrc++) { //debugging hook //const VolIndex& srcVoF = m_srcVoFs[isrc]; if (m_sourTerms[isrc].multiValued) { m_cache[isrc] = *(multiValuedPtrPhi + m_sourTerms[isrc].offset); } else { m_cache[isrc] = *(singleValuedPtrPhi + m_sourTerms[isrc].offset); } } }
void EBStenVarCoef:: uncache(EBCellFAB& a_phi, int a_ivar) const { CH_assert(a_phi.getSingleValuedFAB().box() == m_grownBox); Real* singleValuedPtrPhi = a_phi.getSingleValuedFAB().dataPtr(a_ivar); Real* multiValuedPtrPhi = a_phi.getMultiValuedFAB().dataPtr(a_ivar); Real* phiPtr = NULL; for (int isrc = 0; isrc < m_sourTerms.size(); isrc++) { if (m_sourTerms[isrc].multiValued) { phiPtr = multiValuedPtrPhi + m_sourTerms[isrc].offset; } else { phiPtr = singleValuedPtrPhi + m_sourTerms[isrc].offset; } *phiPtr = m_cache[isrc]; } }
void EBStenVarCoef:: relax(EBCellFAB& a_phi, const EBCellFAB& a_rhs, const EBCellFAB& a_alphaWeight, const EBCellFAB& a_betaWeight, const EBCellFAB& a_lambda, Real a_alpha, Real a_beta) const { CH_TIME("EBStenVarCoef::relax"); CH_assert(a_rhs.getSingleValuedFAB().box() == m_grownBox); CH_assert(a_phi.getSingleValuedFAB().box() == m_grownBox); CH_assert(a_alphaWeight.getSingleValuedFAB().box() == m_grownBox); CH_assert(a_betaWeight.getSingleValuedFAB().box() == m_grownBox); CH_assert(a_lambda.getSingleValuedFAB().box() == m_grownBox); Real* singleValuedPtrPhi = a_phi.getSingleValuedFAB().dataPtr(0); const Real* singleValuedPtrRhs = a_rhs.getSingleValuedFAB().dataPtr(m_destVar); Real* multiValuedPtrPhi = a_phi.getMultiValuedFAB().dataPtr(0); const Real* multiValuedPtrRhs = a_rhs.getMultiValuedFAB().dataPtr(m_destVar); const Real* singleValuedPtrAlp = a_alphaWeight.getSingleValuedFAB().dataPtr(0); const Real* multiValuedPtrAlp = a_alphaWeight. getMultiValuedFAB().dataPtr(0); const Real* singleValuedPtrBet = a_betaWeight.getSingleValuedFAB().dataPtr(0); const Real* multiValuedPtrBet = a_betaWeight. getMultiValuedFAB().dataPtr(0); const Real* singleValuedPtrLam = a_lambda.getSingleValuedFAB().dataPtr(0); const Real* multiValuedPtrLam = a_lambda. getMultiValuedFAB().dataPtr(0); //plo is different from phi because of destvar //phi is for stencil evaluation. plo is for the local value at this variable Real* multiValuedPtrPlo = a_phi. getMultiValuedFAB().dataPtr(m_destVar); Real* singleValuedPtrPlo = a_phi.getSingleValuedFAB().dataPtr(m_destVar); for (int isrc = 0; isrc < m_stencil.size(); isrc++) { //const VolIndex& srcVoF = m_srcVoFs[isrc]; Real* phiPtr = NULL; const Real* rhsPtr = NULL; const Real* alpPtr = NULL; const Real* betPtr = NULL; const Real* lamPtr = NULL; if (m_sourTerms[isrc].multiValued) { rhsPtr = multiValuedPtrRhs + m_sourTerms[isrc].offset; phiPtr = multiValuedPtrPlo + m_sourTerms[isrc].offset; alpPtr = multiValuedPtrAlp + m_sourTerms[isrc].offset; betPtr = multiValuedPtrBet + m_sourTerms[isrc].offset; lamPtr = multiValuedPtrLam + m_sourTerms[isrc].offset; } else { rhsPtr = singleValuedPtrRhs + m_sourTerms[isrc].offset; phiPtr = singleValuedPtrPlo + m_sourTerms[isrc].offset; alpPtr = singleValuedPtrAlp + m_sourTerms[isrc].offset; betPtr = singleValuedPtrBet + m_sourTerms[isrc].offset; lamPtr = singleValuedPtrLam + m_sourTerms[isrc].offset; } Real& phi = *phiPtr; const Real& lambda = *lamPtr; const Real& rhs = *rhsPtr; const Real& alphaWeight = *alpPtr; const Real& betaWeight = *betPtr; Real lph = 0.; const varcsten_t& stenpt = m_stencil[isrc]; //single-valued for (int isingle = 0; isingle < stenpt.single.size(); isingle++) { const int & offset = stenpt.single[isingle].offset; const Real& phiVal = *(singleValuedPtrPhi + offset); const Real& weight = stenpt.single[isingle].weight; lph += phiVal*weight; } //multi-valued for (int imulti = 0; imulti < stenpt.multi.size(); imulti++) { const int & offset = stenpt.multi[imulti].offset; const Real& phiVal = *(multiValuedPtrPhi + offset); const Real& weight = stenpt.multi[imulti].weight; lph += phiVal*weight; } //at this point lph holds divF. add in identity terms //and multiply by factors lph = a_alpha*alphaWeight*phi + a_beta*betaWeight*lph; phi = phi + lambda*(rhs - lph); } }