void CartesianCellDoubleConservativeLinearRefine::refine( hier::Patch& fine, const hier::Patch& coarse, const int dst_component, const int src_component, const hier::Box& fine_box, const hier::IntVector& ratio) const { const tbox::Dimension& dim(fine.getDim()); TBOX_ASSERT_DIM_OBJDIM_EQUALITY3(dim, coarse, fine_box, ratio); std::shared_ptr<pdat::CellData<double> > cdata( SAMRAI_SHARED_PTR_CAST<pdat::CellData<double>, hier::PatchData>( coarse.getPatchData(src_component))); std::shared_ptr<pdat::CellData<double> > fdata( SAMRAI_SHARED_PTR_CAST<pdat::CellData<double>, hier::PatchData>( fine.getPatchData(dst_component))); TBOX_ASSERT(cdata); TBOX_ASSERT(fdata); TBOX_ASSERT(cdata->getDepth() == fdata->getDepth()); const hier::Box cgbox(cdata->getGhostBox()); const hier::Index& cilo = cgbox.lower(); const hier::Index& cihi = cgbox.upper(); const hier::Index& filo = fdata->getGhostBox().lower(); const hier::Index& fihi = fdata->getGhostBox().upper(); const std::shared_ptr<CartesianPatchGeometry> cgeom( SAMRAI_SHARED_PTR_CAST<CartesianPatchGeometry, hier::PatchGeometry>( coarse.getPatchGeometry())); const std::shared_ptr<CartesianPatchGeometry> fgeom( SAMRAI_SHARED_PTR_CAST<CartesianPatchGeometry, hier::PatchGeometry>( fine.getPatchGeometry())); TBOX_ASSERT(cgeom); TBOX_ASSERT(fgeom); const hier::Box coarse_box = hier::Box::coarsen(fine_box, ratio); const hier::Index& ifirstc = coarse_box.lower(); const hier::Index& ilastc = coarse_box.upper(); const hier::Index& ifirstf = fine_box.lower(); const hier::Index& ilastf = fine_box.upper(); const hier::IntVector tmp_ghosts(dim, 0); std::vector<double> diff0(cgbox.numberCells(0) + 1); pdat::CellData<double> slope0(cgbox, 1, tmp_ghosts); for (int d = 0; d < fdata->getDepth(); ++d) { if ((dim == tbox::Dimension(1))) { SAMRAI_F77_FUNC(cartclinrefcelldoub1d, CARTCLINREFCELLDOUB1D) (ifirstc(0), ilastc(0), ifirstf(0), ilastf(0), cilo(0), cihi(0), filo(0), fihi(0), &ratio[0], cgeom->getDx(), fgeom->getDx(), cdata->getPointer(d), fdata->getPointer(d), &diff0[0], slope0.getPointer()); } else if ((dim == tbox::Dimension(2))) { std::vector<double> diff1(cgbox.numberCells(1) + 1); pdat::CellData<double> slope1(cgbox, 1, tmp_ghosts); SAMRAI_F77_FUNC(cartclinrefcelldoub2d, CARTCLINREFCELLDOUB2D) (ifirstc(0), ifirstc(1), ilastc(0), ilastc(1), ifirstf(0), ifirstf(1), ilastf(0), ilastf(1), cilo(0), cilo(1), cihi(0), cihi(1), filo(0), filo(1), fihi(0), fihi(1), &ratio[0], cgeom->getDx(), fgeom->getDx(), cdata->getPointer(d), fdata->getPointer(d), &diff0[0], slope0.getPointer(), &diff1[0], slope1.getPointer()); } else if ((dim == tbox::Dimension(3))) { std::vector<double> diff1(cgbox.numberCells(1) + 1); pdat::CellData<double> slope1(cgbox, 1, tmp_ghosts); std::vector<double> diff2(cgbox.numberCells(2) + 1); pdat::CellData<double> slope2(cgbox, 1, tmp_ghosts); SAMRAI_F77_FUNC(cartclinrefcelldoub3d, CARTCLINREFCELLDOUB3D) (ifirstc(0), ifirstc(1), ifirstc(2), ilastc(0), ilastc(1), ilastc(2), ifirstf(0), ifirstf(1), ifirstf(2), ilastf(0), ilastf(1), ilastf(2), cilo(0), cilo(1), cilo(2), cihi(0), cihi(1), cihi(2), filo(0), filo(1), filo(2), fihi(0), fihi(1), fihi(2), &ratio[0], cgeom->getDx(), fgeom->getDx(), cdata->getPointer(d), fdata->getPointer(d), &diff0[0], slope0.getPointer(), &diff1[0], slope1.getPointer(), &diff2[0], slope2.getPointer()); } else { TBOX_ERROR("CartesianCellDoubleConservativeLinearRefine error...\n" << "dim > 3 not supported." << std::endl); } } }
void CartesianSideFloatWeightedAverage::coarsen( hier::Patch& coarse, const hier::Patch& fine, const int dst_component, const int src_component, const hier::Box& coarse_box, const hier::IntVector& ratio) const { const tbox::Dimension& dim(fine.getDim()); TBOX_ASSERT_DIM_OBJDIM_EQUALITY3(dim, coarse, coarse_box, ratio); std::shared_ptr<pdat::SideData<float> > fdata( SAMRAI_SHARED_PTR_CAST<pdat::SideData<float>, hier::PatchData>( fine.getPatchData(src_component))); std::shared_ptr<pdat::SideData<float> > cdata( SAMRAI_SHARED_PTR_CAST<pdat::SideData<float>, hier::PatchData>( coarse.getPatchData(dst_component))); TBOX_ASSERT(fdata); TBOX_ASSERT(cdata); TBOX_ASSERT(cdata->getDepth() == fdata->getDepth()); const hier::IntVector& directions = cdata->getDirectionVector(); TBOX_ASSERT(directions == hier::IntVector::min(directions, fdata->getDirectionVector())); const hier::Index& filo = fdata->getGhostBox().lower(); const hier::Index& fihi = fdata->getGhostBox().upper(); const hier::Index& cilo = cdata->getGhostBox().lower(); const hier::Index& cihi = cdata->getGhostBox().upper(); const std::shared_ptr<CartesianPatchGeometry> fgeom( SAMRAI_SHARED_PTR_CAST<CartesianPatchGeometry, hier::PatchGeometry>( fine.getPatchGeometry())); const std::shared_ptr<CartesianPatchGeometry> cgeom( SAMRAI_SHARED_PTR_CAST<CartesianPatchGeometry, hier::PatchGeometry>( coarse.getPatchGeometry())); TBOX_ASSERT(fgeom); TBOX_ASSERT(cgeom); const hier::Index& ifirstc = coarse_box.lower(); const hier::Index& ilastc = coarse_box.upper(); for (int d = 0; d < cdata->getDepth(); ++d) { if ((dim == tbox::Dimension(1))) { if (directions(0)) { SAMRAI_F77_FUNC(cartwgtavgsideflot1d, CARTWGTAVGSIDEFLOT1D) (ifirstc(0), ilastc(0), filo(0), fihi(0), cilo(0), cihi(0), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(0, d), cdata->getPointer(0, d)); } } else if ((dim == tbox::Dimension(2))) { if (directions(0)) { SAMRAI_F77_FUNC(cartwgtavgsideflot2d0, CARTWGTAVGSIDEFLOT2D0) (ifirstc(0), ifirstc(1), ilastc(0), ilastc(1), filo(0), filo(1), fihi(0), fihi(1), cilo(0), cilo(1), cihi(0), cihi(1), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(0, d), cdata->getPointer(0, d)); } if (directions(1)) { SAMRAI_F77_FUNC(cartwgtavgsideflot2d1, CARTWGTAVGSIDEFLOT2D1) (ifirstc(0), ifirstc(1), ilastc(0), ilastc(1), filo(0), filo(1), fihi(0), fihi(1), cilo(0), cilo(1), cihi(0), cihi(1), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(1, d), cdata->getPointer(1, d)); } } else if ((dim == tbox::Dimension(3))) { if (directions(0)) { SAMRAI_F77_FUNC(cartwgtavgsideflot3d0, CARTWGTAVGSIDEFLOT3D0) (ifirstc(0), ifirstc(1), ifirstc(2), ilastc(0), ilastc(1), ilastc(2), filo(0), filo(1), filo(2), fihi(0), fihi(1), fihi(2), cilo(0), cilo(1), cilo(2), cihi(0), cihi(1), cihi(2), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(0, d), cdata->getPointer(0, d)); } if (directions(1)) { SAMRAI_F77_FUNC(cartwgtavgsideflot3d1, CARTWGTAVGSIDEFLOT3D1) (ifirstc(0), ifirstc(1), ifirstc(2), ilastc(0), ilastc(1), ilastc(2), filo(0), filo(1), filo(2), fihi(0), fihi(1), fihi(2), cilo(0), cilo(1), cilo(2), cihi(0), cihi(1), cihi(2), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(1, d), cdata->getPointer(1, d)); } if (directions(2)) { SAMRAI_F77_FUNC(cartwgtavgsideflot3d2, CARTWGTAVGSIDEFLOT3D2) (ifirstc(0), ifirstc(1), ifirstc(2), ilastc(0), ilastc(1), ilastc(2), filo(0), filo(1), filo(2), fihi(0), fihi(1), fihi(2), cilo(0), cilo(1), cilo(2), cihi(0), cihi(1), cihi(2), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(2, d), cdata->getPointer(2, d)); } } else { TBOX_ERROR("CartesianSideFloatWeightedAverage error...\n" << "dim > 3 not supported." << std::endl); } } }
void CartesianFaceDoubleWeightedAverage::coarsen( hier::Patch& coarse, const hier::Patch& fine, const int dst_component, const int src_component, const hier::Box& coarse_box, const hier::IntVector& ratio) const { const tbox::Dimension& dim(fine.getDim()); TBOX_ASSERT_DIM_OBJDIM_EQUALITY3(dim, coarse, coarse_box, ratio); std::shared_ptr<pdat::FaceData<double> > fdata( SAMRAI_SHARED_PTR_CAST<pdat::FaceData<double>, hier::PatchData>( fine.getPatchData(src_component))); std::shared_ptr<pdat::FaceData<double> > cdata( SAMRAI_SHARED_PTR_CAST<pdat::FaceData<double>, hier::PatchData>( coarse.getPatchData(dst_component))); TBOX_ASSERT(fdata); TBOX_ASSERT(cdata); TBOX_ASSERT(cdata->getDepth() == fdata->getDepth()); const hier::Index& filo = fdata->getGhostBox().lower(); const hier::Index& fihi = fdata->getGhostBox().upper(); const hier::Index& cilo = cdata->getGhostBox().lower(); const hier::Index& cihi = cdata->getGhostBox().upper(); const std::shared_ptr<CartesianPatchGeometry> fgeom( SAMRAI_SHARED_PTR_CAST<CartesianPatchGeometry, hier::PatchGeometry>( fine.getPatchGeometry())); const std::shared_ptr<CartesianPatchGeometry> cgeom( SAMRAI_SHARED_PTR_CAST<CartesianPatchGeometry, hier::PatchGeometry>( coarse.getPatchGeometry())); TBOX_ASSERT(fgeom); TBOX_ASSERT(cgeom); const hier::Index& ifirstc = coarse_box.lower(); const hier::Index& ilastc = coarse_box.upper(); for (int d = 0; d < cdata->getDepth(); ++d) { if ((dim == tbox::Dimension(1))) { SAMRAI_F77_FUNC(cartwgtavgfacedoub1d, CARTWGTAVGFACEDOUB1D) (ifirstc(0), ilastc(0), filo(0), fihi(0), cilo(0), cihi(0), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(0, d), cdata->getPointer(0, d)); } else if ((dim == tbox::Dimension(2))) { SAMRAI_F77_FUNC(cartwgtavgfacedoub2d0, CARTWGTAVGFACEDOUB2D0) (ifirstc(0), ifirstc(1), ilastc(0), ilastc(1), filo(0), filo(1), fihi(0), fihi(1), cilo(0), cilo(1), cihi(0), cihi(1), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(0, d), cdata->getPointer(0, d)); SAMRAI_F77_FUNC(cartwgtavgfacedoub2d1, CARTWGTAVGFACEDOUB2D1) (ifirstc(0), ifirstc(1), ilastc(0), ilastc(1), filo(0), filo(1), fihi(0), fihi(1), cilo(0), cilo(1), cihi(0), cihi(1), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(1, d), cdata->getPointer(1, d)); } else if ((dim == tbox::Dimension(3))) { SAMRAI_F77_FUNC(cartwgtavgfacedoub3d0, CARTWGTAVGFACEDOUB3D0) (ifirstc(0), ifirstc(1), ifirstc(2), ilastc(0), ilastc(1), ilastc(2), filo(0), filo(1), filo(2), fihi(0), fihi(1), fihi(2), cilo(0), cilo(1), cilo(2), cihi(0), cihi(1), cihi(2), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(0, d), cdata->getPointer(0, d)); SAMRAI_F77_FUNC(cartwgtavgfacedoub3d1, CARTWGTAVGFACEDOUB3D1) (ifirstc(0), ifirstc(1), ifirstc(2), ilastc(0), ilastc(1), ilastc(2), filo(0), filo(1), filo(2), fihi(0), fihi(1), fihi(2), cilo(0), cilo(1), cilo(2), cihi(0), cihi(1), cihi(2), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(1, d), cdata->getPointer(1, d)); SAMRAI_F77_FUNC(cartwgtavgfacedoub3d2, CARTWGTAVGFACEDOUB3D2) (ifirstc(0), ifirstc(1), ifirstc(2), ilastc(0), ilastc(1), ilastc(2), filo(0), filo(1), filo(2), fihi(0), fihi(1), fihi(2), cilo(0), cilo(1), cilo(2), cihi(0), cihi(1), cihi(2), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(2, d), cdata->getPointer(2, d)); } else if ((dim == tbox::Dimension(4))) { SAMRAI_F77_FUNC(cartwgtavgfacedoub4d0, CARTWGTAVGFACEDOUB4D0) (ifirstc(0), ifirstc(1), ifirstc(2), ifirstc(3), ilastc(0), ilastc(1), ilastc(2), ilastc(3), filo(0), filo(1), filo(2), filo(3), fihi(0), fihi(1), fihi(2), fihi(3), cilo(0), cilo(1), cilo(2), cilo(3), cihi(0), cihi(1), cihi(2), cihi(3), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(0, d), cdata->getPointer(0, d)); SAMRAI_F77_FUNC(cartwgtavgfacedoub4d1, CARTWGTAVGFACEDOUB4D1) (ifirstc(0), ifirstc(1), ifirstc(2), ifirstc(3), ilastc(0), ilastc(1), ilastc(2), ilastc(3), filo(0), filo(1), filo(2), filo(3), fihi(0), fihi(1), fihi(2), fihi(3), cilo(0), cilo(1), cilo(2), cilo(3), cihi(0), cihi(1), cihi(2), cihi(3), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(1, d), cdata->getPointer(1, d)); SAMRAI_F77_FUNC(cartwgtavgfacedoub4d2, CARTWGTAVGFACEDOUB4D2) (ifirstc(0), ifirstc(1), ifirstc(2), ifirstc(3), ilastc(0), ilastc(1), ilastc(2), ilastc(3), filo(0), filo(1), filo(2), filo(3), fihi(0), fihi(1), fihi(2), fihi(3), cilo(0), cilo(1), cilo(2), cilo(3), cihi(0), cihi(1), cihi(2), cihi(3), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(2, d), cdata->getPointer(2, d)); SAMRAI_F77_FUNC(cartwgtavgfacedoub4d3, CARTWGTAVGFACEDOUB4D3) (ifirstc(0), ifirstc(1), ifirstc(2), ifirstc(3), ilastc(0), ilastc(1), ilastc(2), ilastc(3), filo(0), filo(1), filo(2), filo(3), fihi(0), fihi(1), fihi(2), fihi(3), cilo(0), cilo(1), cilo(2), cilo(3), cihi(0), cihi(1), cihi(2), cihi(3), &ratio[0], fgeom->getDx(), cgeom->getDx(), fdata->getPointer(3, d), cdata->getPointer(3, d)); } else { TBOX_ERROR("CartesianFaceDoubleWeightedAverage error...\n" << "dim > 4 not supported." << std::endl); } } }
void CartesianNodeComplexLinearRefine::refine( hier::Patch& fine, const hier::Patch& coarse, const int dst_component, const int src_component, const hier::Box& fine_box, const hier::IntVector& ratio) const { const tbox::Dimension& dim(fine.getDim()); TBOX_ASSERT_DIM_OBJDIM_EQUALITY3(dim, coarse, fine_box, ratio); boost::shared_ptr<pdat::NodeData<dcomplex> > cdata( BOOST_CAST<pdat::NodeData<dcomplex>, hier::PatchData>( coarse.getPatchData(src_component))); boost::shared_ptr<pdat::NodeData<dcomplex> > fdata( BOOST_CAST<pdat::NodeData<dcomplex>, hier::PatchData>( fine.getPatchData(dst_component))); TBOX_ASSERT(cdata); TBOX_ASSERT(fdata); TBOX_ASSERT(cdata->getDepth() == fdata->getDepth()); const hier::Box cgbox(cdata->getGhostBox()); const hier::Index cilo = cgbox.lower(); const hier::Index cihi = cgbox.upper(); const hier::Index filo = fdata->getGhostBox().lower(); const hier::Index fihi = fdata->getGhostBox().upper(); const boost::shared_ptr<CartesianPatchGeometry> cgeom( BOOST_CAST<CartesianPatchGeometry, hier::PatchGeometry>( coarse.getPatchGeometry())); const boost::shared_ptr<CartesianPatchGeometry> fgeom( BOOST_CAST<CartesianPatchGeometry, hier::PatchGeometry>( fine.getPatchGeometry())); TBOX_ASSERT(cgeom); TBOX_ASSERT(fgeom); const hier::Box coarse_box = hier::Box::coarsen(fine_box, ratio); const hier::Index ifirstc = coarse_box.lower(); const hier::Index ilastc = coarse_box.upper(); const hier::Index ifirstf = fine_box.lower(); const hier::Index ilastf = fine_box.upper(); for (int d = 0; d < fdata->getDepth(); ++d) { if ((dim == tbox::Dimension(1))) { SAMRAI_F77_FUNC(cartlinrefnodecplx1d, CARTLINREFNODECPLX1D) (ifirstc(0), ilastc(0), ifirstf(0), ilastf(0), cilo(0), cihi(0), filo(0), fihi(0), &ratio[0], cgeom->getDx(), fgeom->getDx(), cdata->getPointer(d), fdata->getPointer(d)); } else if ((dim == tbox::Dimension(2))) { SAMRAI_F77_FUNC(cartlinrefnodecplx2d, CARTLINREFNODECPLX2D) (ifirstc(0), ifirstc(1), ilastc(0), ilastc(1), ifirstf(0), ifirstf(1), ilastf(0), ilastf(1), cilo(0), cilo(1), cihi(0), cihi(1), filo(0), filo(1), fihi(0), fihi(1), &ratio[0], cgeom->getDx(), fgeom->getDx(), cdata->getPointer(d), fdata->getPointer(d)); } else if ((dim == tbox::Dimension(3))) { SAMRAI_F77_FUNC(cartlinrefnodecplx3d, CARTLINREFNODECPLX3D) (ifirstc(0), ifirstc(1), ifirstc(2), ilastc(0), ilastc(1), ilastc(2), ifirstf(0), ifirstf(1), ifirstf(2), ilastf(0), ilastf(1), ilastf(2), cilo(0), cilo(1), cilo(2), cihi(0), cihi(1), cihi(2), filo(0), filo(1), filo(2), fihi(0), fihi(1), fihi(2), &ratio[0], cgeom->getDx(), fgeom->getDx(), cdata->getPointer(d), fdata->getPointer(d)); } else { TBOX_ERROR("CartesianNodeComplexLinearRefine error...\n" << "dim > 3 not supported." << std::endl); } } }