bool QRibbonButtonBar::realize() { if (!m_layouts_valid) { makeLayouts(); m_layouts_valid = true; } return true; }
int fluxRegTest() { int nref = 2; int eekflag = 0; ParmParse pp; Box domainCoar, domainFine; eekflag = makeGeometry(domainFine); if (eekflag != 0) return eekflag; domainCoar = coarsen(domainFine, nref); DisjointBoxLayout dblFine,dblCoar; eekflag = makeLayouts(dblCoar, dblFine, domainCoar, domainFine); Interval interv(0,0); EBISLayout ebislFine, ebislCoar; int nghost = 3; makeEBISL(ebislFine, dblFine, domainFine, nghost); makeEBISL(ebislCoar, dblCoar, domainCoar, nghost); EBCellFactory factFine(ebislFine); EBCellFactory factCoar(ebislCoar); IntVect ivghost = IntVect::Unit; LevelData<EBCellFAB> fineData(dblFine, 1,ivghost, factFine); LevelData<EBCellFAB> coarData(dblCoar, 1,ivghost, factCoar); LevelData<EBCellFAB> extraDense(dblCoar, 1,ivghost, factCoar); //set data and flux registers to zero for (DataIterator coarIt = coarData.dataIterator(); coarIt.ok(); ++coarIt) coarData[coarIt()].setVal(0.); for (DataIterator fineIt = fineData.dataIterator(); fineIt.ok(); ++fineIt) fineData[fineIt()].setVal(0.); { // pout() << "before constructor" << endl; EBFluxRegister fluxReg(dblFine, dblCoar, ebislFine, ebislCoar, domainCoar, nref, 1, Chombo_EBIS::instance()); // pout() << "after constructor" << endl; fluxReg.setToZero(); // pout() << "after settozero" << endl; //loop through directions Real scale = 1.0; Real fluxVal = 4.77; for (int idir = 0; idir < SpaceDim; idir++) { // pout() << "idir = " << idir << endl; // MPI_Barrier(Chombo_MPI::comm); //increment and decrement //flux registers with equal size fluxes for (DataIterator coarIt = coarData.dataIterator(); coarIt.ok(); ++coarIt) { const Box& boxCoar = dblCoar.get(coarIt()); const EBISBox& ebisBox = ebislCoar[coarIt()]; IntVectSet ivsBC(boxCoar); EBFaceFAB edgeFluxReg(ebisBox, boxCoar, idir, 1); BaseIFFAB<Real> edgeFluxIrr(ivsBC, ebisBox.getEBGraph(), idir, 1); edgeFluxReg.setVal(fluxVal); edgeFluxIrr.setVal(fluxVal); fluxReg.incrementCoarseRegular(edgeFluxReg, scale, coarIt(), interv, idir); // pout() << "after increment coar regular"<< endl; fluxReg.incrementCoarseIrregular(edgeFluxIrr, scale, coarIt(), interv, idir); // pout() << "after increment coar irregular"<< endl; } // pout() << "after increment coar"<< endl; // MPI_Barrier(Chombo_MPI::comm); for (DataIterator fineIt = fineData.dataIterator(); fineIt.ok(); ++fineIt) { const Box& boxFine = dblFine.get(fineIt()); const EBISBox& ebisBox = ebislFine[fineIt()]; IntVectSet ivsBF(boxFine); EBFaceFAB edgeFluxReg(ebisBox, boxFine, idir, 1); BaseIFFAB<Real> edgeFluxIrr(ivsBF, ebisBox.getEBGraph(), idir, 1); edgeFluxReg.setVal(fluxVal); edgeFluxIrr.setVal(fluxVal); for (SideIterator sit; sit.ok(); ++sit) { fluxReg.incrementFineRegular(edgeFluxReg, scale, fineIt(), interv, idir, sit()); fluxReg.incrementFineIrregular(edgeFluxIrr, scale, fineIt(), interv, idir, sit()); } } // pout() << "after increment fine"<< endl; // MPI_Barrier(Chombo_MPI::comm); } //reflux what ought to be zero into zero and the result should be zero //except where the coarse-fine boundary gets crossed by the embedded //boundary. That should get fixed by the extramass thing. fluxReg.reflux(coarData, interv, scale); // pout() << "after reflux"<< endl; for (DataIterator coarIt = coarData.dataIterator(); coarIt.ok(); ++coarIt) extraDense[coarIt()].setVal(0.); // now add extra density to soltuion //in the end the solution should return to zero fluxReg.incrementDensityArray(extraDense, interv, scale); } // pout() << "after fluxreg destruction" << endl; // pout() << "after incementDensityArray"<< endl; for (DataIterator coarIt = coarData.dataIterator(); coarIt.ok(); ++coarIt) coarData[coarIt()] += extraDense[coarIt()]; // MPI_Barrier(Chombo_MPI::comm); // pout() << "after += operation "<< endl; DataIterator datIt = coarData.dataIterator(); for (datIt.reset(); datIt.ok(); ++datIt) { const EBCellFAB& data = coarData[datIt()]; IntVectSet ivsBox(dblCoar.get(datIt())); const EBISBox& ebisBox = ebislCoar[datIt()]; Real rmax = 0.; Real rmin = 0.; for (VoFIterator vofit(ivsBox, ebisBox.getEBGraph()); vofit.ok(); ++vofit) { const VolIndex& vof = vofit(); rmax = Max(rmax, Abs(data(vof, 0))); rmin = Min(rmax, Abs(data(vof, 0))); #ifdef CH_USE_FLOAT Real tolerance = 1.0e-6; #else Real tolerance = 1.0e-10; #endif if ((rmax > tolerance)||(rmin > tolerance)) { pout() << "EBFluxRegister failed the test at " << " vof = " << vof << endl; pout() << " rmax: " << rmax << ", or" << " rmin: " << rmin << " >" << " tolerance: " << tolerance << ")" << endl; eekflag = 42; return eekflag; } } } // pout() << "about to return "<< endl; return eekflag; }