// ---------------------------------------------------------- void CoarseAverageEdge::averageGridData(FluxBox& a_coarsenedFine, const FluxBox& a_fine) const { for (int dir=0; dir<SpaceDim; dir++) { FArrayBox& coarseFab = a_coarsenedFine[dir]; const FArrayBox& fineFab = a_fine[dir]; const Box& coarseBox = coarseFab.box(); // set up refinement box int boxHi = m_nRef-1; IntVect hiVect(D_DECL(boxHi,boxHi,boxHi)); // don't want to index at all in dir direction -- // instead, want to just march along edge. hiVect.setVal(dir,0); IntVect loVect(D_DECL(0,0,0)); Box refBox(loVect, hiVect); FORT_AVERAGEEDGE( CHF_FRA(coarseFab), CHF_CONST_FRA(fineFab), CHF_BOX(coarseBox), CHF_CONST_INT(dir), CHF_CONST_INT(m_nRef), CHF_BOX(refBox)); } }
void EBMGAverage::averageFAB(EBCellFAB& a_coar, const Box& a_boxCoar, const EBCellFAB& a_refCoar, const DataIndex& a_datInd, const Interval& a_variables) const { CH_TIMERS("EBMGAverage::average"); CH_TIMER("regular_average", t1); CH_TIMER("irregular_average", t2); CH_assert(isDefined()); const Box& coarBox = a_boxCoar; //do all cells as if they were regular Box refBox(IntVect::Zero, IntVect::Zero); refBox.refine(m_refRat); int numFinePerCoar = refBox.numPts(); BaseFab<Real>& coarRegFAB = a_coar.getSingleValuedFAB(); const BaseFab<Real>& refCoarRegFAB = a_refCoar.getSingleValuedFAB(); //set to zero because the fortran is a bit simpleminded //and does stuff additively a_coar.setVal(0.); CH_START(t1); for (int comp = a_variables.begin(); comp <= a_variables.end(); comp++) { FORT_REGAVERAGE(CHF_FRA1(coarRegFAB,comp), CHF_CONST_FRA1(refCoarRegFAB,comp), CHF_BOX(coarBox), CHF_BOX(refBox), CHF_CONST_INT(numFinePerCoar), CHF_CONST_INT(m_refRat)); } CH_STOP(t1); //this is really volume-weighted averaging even though it does //not look that way. //so (in the traditional sense) we want to preserve //rhoc * volc = sum(rhof * volf) //this translates to //volfrac_C * rhoC = (1/numFinePerCoar)(sum(volFrac_F * rhoF)) //but the data input to this routine is all kappa weigthed so //the volumefractions have already been multiplied //which means // rhoC = (1/numFinePerCoar)(sum(rhoF)) //which is what this does CH_START(t2); for (int comp = a_variables.begin(); comp <= a_variables.end(); comp++) { m_averageEBStencil[a_datInd]->apply(a_coar, a_refCoar, false, comp); } CH_STOP(t2); }
void EBMGInterp::pwcInterpFAB(EBCellFAB& a_refCoar, const Box& a_coarBox, const EBCellFAB& a_coar, const DataIndex& a_datInd, const Interval& a_variables) const { CH_TIMERS("EBMGInterp::interp"); CH_TIMER("regular_interp", t1); CH_TIMER("irregular_interp", t2); CH_assert(isDefined()); const Box& coarBox = a_coarBox; for (int ivar = a_variables.begin(); ivar <= a_variables.end(); ivar++) { m_interpEBStencil[a_datInd]->cache(a_refCoar, ivar); //do all cells as if they were regular Box refBox(IntVect::Zero, IntVect::Zero); refBox.refine(m_refRat); const BaseFab<Real>& coarRegFAB = a_coar.getSingleValuedFAB(); BaseFab<Real>& refCoarRegFAB = a_refCoar.getSingleValuedFAB(); CH_START(t1); FORT_REGPROLONG(CHF_FRA1(refCoarRegFAB,ivar), CHF_CONST_FRA1(coarRegFAB,ivar), CHF_BOX(coarBox), CHF_BOX(refBox), CHF_CONST_INT(m_refRat)); CH_STOP(t1); m_interpEBStencil[a_datInd]->uncache(a_refCoar, ivar); CH_START(t2); m_interpEBStencil[a_datInd]->apply(a_refCoar, a_coar, true, ivar); CH_STOP(t2); } }
static void IncrementScaleRestyleCountIfNeeded(nsIFrame* aFrame, LayerActivity* aActivity) { const nsStyleDisplay* display = aFrame->StyleDisplay(); if (!display->mSpecifiedTransform) { // The transform was removed. aActivity->mPreviousTransformScale = Nothing(); IncrementMutationCount(&aActivity->mScaleRestyleCount); return; } // Compute the new scale due to the CSS transform property. nsPresContext* presContext = aFrame->PresContext(); RuleNodeCacheConditions dummy; nsStyleTransformMatrix::TransformReferenceBox refBox(aFrame); Matrix4x4 transform = nsStyleTransformMatrix::ReadTransforms(display->mSpecifiedTransform->mHead, aFrame->StyleContext(), presContext, dummy, refBox, presContext->AppUnitsPerCSSPixel()); Matrix transform2D; if (!transform.Is2D(&transform2D)) { // We don't attempt to handle 3D transforms; just assume the scale changed. aActivity->mPreviousTransformScale = Nothing(); IncrementMutationCount(&aActivity->mScaleRestyleCount); return; } gfxSize scale = ThebesMatrix(transform2D).ScaleFactors(true); if (aActivity->mPreviousTransformScale == Some(scale)) { return; // Nothing changed. } aActivity->mPreviousTransformScale = Some(scale); IncrementMutationCount(&aActivity->mScaleRestyleCount); }
void EBMGInterp::pwlInterpFAB(EBCellFAB& a_refCoar, const Box& a_coarBox, const EBCellFAB& a_coar, const DataIndex& a_datInd, const Interval& a_variables) const { CH_TIMERS("EBMGInterp::pwlinterpfab"); CH_TIMER("regular_interp", t1); CH_TIMER("irregular_interp", t2); CH_assert(isDefined()); //first interpolate piecewise constant. pwcInterpFAB(a_refCoar, a_coarBox, a_coar, a_datInd, a_variables); //then add in slope*distance. const Box& coarBox = a_coarBox; for (int ivar = a_variables.begin(); ivar <= a_variables.end(); ivar++) { //save stuff at irreg cells because fortran result will be garbage //and this is an incremental process m_linearEBStencil[a_datInd]->cache(a_refCoar, ivar); //do all cells as if they were regular Box refBox(IntVect::Zero, IntVect::Zero); refBox.refine(m_refRat); const BaseFab<Real>& coarRegFAB = a_coar.getSingleValuedFAB(); BaseFab<Real>& refCoarRegFAB = a_refCoar.getSingleValuedFAB(); CH_START(t1); Real dxf = 1.0/m_coarDomain.size(0); Real dxc = 2.0*dxf; //do every cell as regular for (int idir = 0; idir < SpaceDim; idir++) { FORT_PROLONGADDSLOPE(CHF_FRA1(refCoarRegFAB,ivar), CHF_CONST_FRA1(coarRegFAB,ivar), CHF_BOX(coarBox), CHF_BOX(refBox), CHF_INT(idir), CHF_REAL(dxf), CHF_REAL(dxc), CHF_CONST_INT(m_refRat)); } CH_STOP(t1); //replace garbage fortran put in with original values (at irregular cells) m_linearEBStencil[a_datInd]->uncache(a_refCoar, ivar); CH_START(t2); //do what fortran should have done at irregular cells. m_linearEBStencil[a_datInd]->apply(a_refCoar, a_coar, true, ivar); CH_STOP(t2); } }
void EBMGAverage:: defineStencils() { CH_TIME("EBMGInterp::defineStencils"); DisjointBoxLayout gridsStenCoar; EBISLayout ebislStenCoar; DisjointBoxLayout gridsStenFine; EBISLayout ebislStenFine; if (m_layoutChanged) { if (m_coarsenable) { gridsStenCoar = m_buffGrids; ebislStenCoar = m_buffEBISL; gridsStenFine = m_fineGrids; ebislStenFine = m_fineEBISL; } else { gridsStenCoar = m_coarGrids; ebislStenCoar = m_coarEBISL; gridsStenFine = m_buffGrids; ebislStenFine = m_buffEBISL; } } else { gridsStenCoar = m_coarGrids; ebislStenCoar = m_coarEBISL; gridsStenFine = m_fineGrids; ebislStenFine = m_fineEBISL; } { CH_TIME("graph walking"); LayoutData<Vector<VoFStencil> > averageStencil; LayoutData<VoFIterator > vofItIrregCoar; LayoutData<VoFIterator > vofItIrregFine; m_averageEBStencil.define(gridsStenCoar); averageStencil.define( gridsStenCoar); vofItIrregFine.define( gridsStenCoar); //not wrong. trust me. vofItIrregCoar.define( gridsStenCoar); for (DataIterator dit = gridsStenCoar.dataIterator(); dit.ok(); ++dit) { Box refBox(IntVect::Zero, IntVect::Zero); refBox.refine(m_refRat); int numFinePerCoar = refBox.numPts(); const Box& boxFine = gridsStenFine[dit()]; const EBISBox& ebisBoxFine = ebislStenFine[dit()]; const EBGraph& ebGraphFine = ebisBoxFine.getEBGraph(); const Box& boxCoar = gridsStenCoar[dit()]; const EBISBox& ebisBoxCoar = ebislStenCoar[dit()]; const EBGraph& ebGraphCoar = ebisBoxCoar.getEBGraph(); IntVectSet notRegularCoar = ebisBoxCoar.getIrregIVS(boxCoar); vofItIrregCoar[dit()].define(notRegularCoar, ebGraphCoar); IntVectSet ivsFine = refine(notRegularCoar, m_refRat); vofItIrregFine[dit()].define(ivsFine, ebGraphFine); const Vector<VolIndex>& allCoarVofs = vofItIrregCoar[dit()].getVector(); Vector<VoFStencil>& averageStencils = averageStencil[dit()]; averageStencils.resize(allCoarVofs.size()); for (int icoar = 0; icoar < allCoarVofs.size(); icoar++) { Vector<VolIndex> fineVofs; if (m_refRat > 2) { fineVofs = ebislStenCoar.refine(allCoarVofs[icoar], m_refRat, dit()); } else { fineVofs = ebislStenCoar[dit()].refine(allCoarVofs[icoar]); } VoFStencil& averageStencil = averageStencils[icoar]; for (int ifine = 0; ifine < fineVofs.size(); ifine++) { averageStencil.add(fineVofs[ifine], 1./numFinePerCoar); } } m_averageEBStencil[dit()] = RefCountedPtr<EBStencil>(new EBStencil(allCoarVofs, averageStencil[dit()], boxCoar, boxFine, ebisBoxCoar, ebisBoxFine, m_ghost, m_ghost)); } } }