int checkCorrection(const Box& a_domain) { int eekflag = 0; const EBIndexSpace* const ebisPtr = Chombo_EBIS::instance(); CH_assert(ebisPtr->isDefined()); //create a dbl of split up into 2^D boxes Vector<Box> vbox; Vector<int> proc; domainSplit(a_domain, vbox, a_domain.size(0)/2); LoadBalance(proc, vbox); DisjointBoxLayout dbl(vbox, proc); LayoutData<bool> map1d(dbl); int ibox = 0; //make every other map 1d for (DataIterator dit = dbl.dataIterator(); dit.ok(); ++dit) { map1d[dit()] = (ibox%2 == 0); ibox++; } LevelData< BaseFab<int> > intmap(dbl, 1 , IntVect::Unit); Correct1D2D::makeIntMap(intmap, map1d, dbl); //this defines an ebisl with 2 ghost cells EBLevelGrid eblg(dbl, ProblemDomain(a_domain), 2, Chombo_EBIS::instance()) ; RealVect fluxVal = RealVect::Unit; Real dx = 1.0/a_domain.size(0); EBCellFactory fact(eblg.getEBISL()); LevelData<EBCellFAB> divU(dbl, 1, IntVect::Zero, fact); Correct1D2D correctinator(eblg, map1d, 1); correctinator.setToZero(); //this is important for (DataIterator dit = dbl.dataIterator(); dit.ok(); ++dit) { //make a flux that is borked on the 1d side of box boundaries EBFluxFAB fluxFunc( eblg.getEBISL()[dit()], dbl[dit()], 1); setBorkedFlux(fluxFunc, eblg.getEBISL()[dit()], dbl[dit()], fluxVal, intmap[dit()]); //increment 1d buffers in corrector for (int idir = 0; idir < SpaceDim; idir++) { correctinator.increment1D(fluxFunc[idir], 1./dx, dit()); correctinator.increment2D(fluxFunc[idir], 1./dx, dit()); } //now take the divergence of the flux. it should be zero except //at box boundaries on the 1d side divergence(divU[dit()], fluxFunc, eblg.getEBISL()[dit()], dbl[dit()], fluxVal, dx); } //find max value of divergence before corrections Real max, min; EBLevelDataOps::getMaxMin(max, min, divU, 0); pout() << "before correction max divU = " << max << ", min divU = " << min << endl; //correct solution due to mismatch at 1d-2d boundaries correctinator.correctSolution(divU); //recalc max min EBLevelDataOps::getMaxMin(max, min, divU, 0); pout() << "after correction max divU = " << max << ", min divU = " << min << endl; if (Abs(max-min) > 1.0e-3) { pout() << "corrector did not seem to correct" << endl; return -7; } return eekflag; }
bool slice3D(std::vector< Eigen::Transform<Real,3,Eigen::Affine> >& forwardTransforms, std::vector<vmesh::VelocityMesh<vmesh::GlobalID,vmesh::LocalID> *>& velocityMeshes, std::vector<vmesh::VelocityBlockContainer<vmesh::LocalID> *>& blockContainers, bool dynamicMesh) { uint nMeshes = velocityMeshes.size(); phiprof::start("compute-transform-intersections"); Real *intersections = new Real[nMeshes * Intersections::N_INTERSECTIONS ]; #pragma omp parallel for for (uint i = 0; i < nMeshes; ++i) { //Compute transform backward in time Eigen::Transform<Real, 3, Eigen::Affine> backwardTransform = forwardTransforms[i].inverse(); //Map order Z X Y (support rest later...) computeIntersections1st(intersections[i * Intersections::N_INTERSECTIONS + Intersections::Z], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Z_DI], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Z_DJ], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Z_DK], backwardTransform, velocityMeshes[i], 2); computeIntersections2nd(intersections[i * Intersections::N_INTERSECTIONS + Intersections::X], intersections[i * Intersections::N_INTERSECTIONS + Intersections::X_DI], intersections[i * Intersections::N_INTERSECTIONS + Intersections::X_DJ], intersections[i * Intersections::N_INTERSECTIONS + Intersections::X_DK], backwardTransform, velocityMeshes[i], 0); computeIntersections3rd(intersections[i * Intersections::N_INTERSECTIONS + Intersections::Y], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Y_DI], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Y_DJ], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Y_DK], backwardTransform, velocityMeshes[i], 1); } phiprof::start("compute-mapping"); #pragma omp parallel for for (uint i = 0; i < nMeshes; ++i) { /*< map along z*/ phiprof::start("map-z"); map1d(velocityMeshes[i], blockContainers[i], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Z], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Z_DI], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Z_DJ], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Z_DK], 2); phiprof::stop("map-z"); /*< map along x*/ phiprof::start("map-x"); map1d(velocityMeshes[i], blockContainers[i], intersections[i * Intersections::N_INTERSECTIONS + Intersections::X], intersections[i * Intersections::N_INTERSECTIONS + Intersections::X_DI], intersections[i * Intersections::N_INTERSECTIONS + Intersections::X_DJ], intersections[i * Intersections::N_INTERSECTIONS + Intersections::X_DK], 0); phiprof::stop("map-x"); phiprof::start("map-y"); /*< map along y*/ map1d(velocityMeshes[i], blockContainers[i], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Y], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Y_DI], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Y_DJ], intersections[i * Intersections::N_INTERSECTIONS + Intersections::Y_DK], 1); phiprof::stop("map-y"); } phiprof::stop("compute-mapping"); phiprof::stop("compute-transform-intersections"); delete[] intersections; }