/* ************************************************************************* * * Compute the boxes for the stencil around a given patch box * ************************************************************************* */ void FirstLayerCellVariableFillPattern::computeStencilBoxes( hier::BoxContainer& stencil_boxes, const hier::Box& dst_box) const { TBOX_ASSERT(stencil_boxes.size() == 0); hier::Box ghost_box( hier::Box::grow(dst_box, hier::IntVector::getOne(dst_box.getDim()))); stencil_boxes.removeIntersections(ghost_box, dst_box); }
void NodeOverlap::getSourceBoxContainer(hier::BoxContainer& src_boxes) const { TBOX_ASSERT(src_boxes.empty()); src_boxes = d_dst_boxes; if (!src_boxes.empty()) { const tbox::Dimension& dim = src_boxes.front().getDim(); for (hier::BoxContainer::iterator bi = src_boxes.begin(); bi != src_boxes.end(); ++bi) { bi->setUpper(bi->upper() - hier::IntVector::getOne(dim)); d_transformation.inverseTransform(*bi); bi->setUpper(bi->upper() + hier::IntVector::getOne(dim)); } } }
NodeOverlap::NodeOverlap( const hier::BoxContainer& boxes, const hier::Transformation& transformation): d_is_overlap_empty(boxes.empty()), d_transformation(transformation), d_dst_boxes(boxes) { }
/* ************************************************************************* * * Set up a EdgeOverlap oject using the given boxes and offset * ************************************************************************* */ std::shared_ptr<hier::BoxOverlap> OuteredgeGeometry::setUpOverlap( const hier::BoxContainer& boxes, const hier::Transformation& transformation) const { const tbox::Dimension& dim(transformation.getOffset().getDim()); std::vector<hier::BoxContainer> dst_boxes(dim.getValue()); for (hier::BoxContainer::const_iterator b = boxes.begin(); b != boxes.end(); ++b) { for (int d = 0; d < dim.getValue(); ++d) { hier::Box edge_box(EdgeGeometry::toEdgeBox(*b, d)); dst_boxes[d].pushBack(edge_box); } } // Create the edge overlap data object using the boxes and transformation return std::make_shared<EdgeOverlap>(dst_boxes, transformation); }
/* ************************************************************************* * * Set up a FaceOverlap oject using the given boxes and offset * ************************************************************************* */ boost::shared_ptr<hier::BoxOverlap> OuterfaceGeometry::setUpOverlap( const hier::BoxContainer& boxes, const hier::Transformation& transformation) const { const tbox::Dimension& dim(transformation.getOffset().getDim()); std::vector<hier::BoxContainer> dst_boxes(dim.getValue()); for (hier::BoxContainer::const_iterator b = boxes.begin(); b != boxes.end(); ++b) { for (tbox::Dimension::dir_t d = 0; d < dim.getValue(); ++d) { hier::Box face_box(FaceGeometry::toFaceBox(*b, d)); dst_boxes[d].pushBack(face_box); } } // Create the face overlap data object using the boxes and source shift return boost::make_shared<FaceOverlap>(dst_boxes, transformation); }
std::shared_ptr<hier::BoxOverlap> OuteredgeGeometry::doOverlap( const OuteredgeGeometry& dst_geometry, const OuteredgeGeometry& src_geometry, const hier::Box& src_mask, const hier::Box& fill_box, const bool overwrite_interior, const hier::Transformation& transformation, const hier::BoxContainer& dst_restrict_boxes) { const tbox::Dimension& dim(src_mask.getDim()); std::vector<hier::BoxContainer> dst_boxes(dim.getValue()); // Perform a quick-and-dirty intersection to see if the boxes might overlap const hier::Box src_box( hier::Box::grow(src_geometry.d_box, src_geometry.d_ghosts) * src_mask); hier::Box src_box_shifted(src_box); transformation.transform(src_box_shifted); const hier::Box dst_box( hier::Box::grow(dst_geometry.getBox(), dst_geometry.getGhosts())); // Compute the intersection (if any) for each of the edge directions const hier::IntVector one_vector(dim, 1); bool quick_boxes_intersect = (hier::Box::grow(src_box_shifted, one_vector)).intersects( hier::Box::grow(dst_box, one_vector)); if (quick_boxes_intersect) { for (tbox::Dimension::dir_t axis = 0; axis < dim.getValue(); ++axis) { const hier::Box dst_edge_box( EdgeGeometry::toEdgeBox(dst_box, axis)); const hier::Box src_edge_box( EdgeGeometry::toEdgeBox(src_box_shifted, axis)); bool boxes_intersect = dst_edge_box.intersects(src_edge_box); if (boxes_intersect) { const hier::Box fill_edge_box( EdgeGeometry::toEdgeBox(fill_box, axis)); for (tbox::Dimension::dir_t src_face_normal = 0; src_face_normal < dim.getValue(); ++src_face_normal) { if (src_face_normal != axis) { hier::Box outeredge_src_box_lo(toOuteredgeBox( src_box_shifted, axis, src_face_normal, 0)); hier::Box outeredge_src_box_up(toOuteredgeBox( src_box_shifted, axis, src_face_normal, 1)); for (tbox::Dimension::dir_t dst_face_normal = 0; dst_face_normal < dim.getValue(); ++dst_face_normal) { if (dst_face_normal != axis) { hier::Box outeredge_dst_box_lo(toOuteredgeBox(dst_box, axis, dst_face_normal, 0)); hier::Box outeredge_dst_box_up(toOuteredgeBox(dst_box, axis, dst_face_normal, 1)); outeredge_dst_box_lo = outeredge_dst_box_lo * fill_edge_box; outeredge_dst_box_up = outeredge_dst_box_up * fill_edge_box; hier::Box lo_lo_box( outeredge_src_box_lo * outeredge_dst_box_lo); if (!lo_lo_box.empty()) { dst_boxes[axis].pushBack(lo_lo_box); } hier::Box lo_up_box( outeredge_src_box_lo * outeredge_dst_box_up); if (!lo_up_box.empty()) { dst_boxes[axis].pushBack(lo_up_box); } hier::Box up_lo_box( outeredge_src_box_up * outeredge_dst_box_lo); if (!up_lo_box.empty()) { dst_boxes[axis].pushBack(up_lo_box); } hier::Box up_up_box( outeredge_src_box_up * outeredge_dst_box_up); if (!up_up_box.empty()) { dst_boxes[axis].pushBack(up_up_box); } } // dst data undefined when dst_face_normal == axis } // iterate over dst face normal directions } // src data undefined when src_face_normal == axis } // iterate over src face normal directions } // if source and destination edge boxes overlap in axis direction if (!overwrite_interior) { const hier::Box interior_edges( EdgeGeometry::toEdgeBox(dst_geometry.getBox(), axis)); dst_boxes[axis].removeIntersections(interior_edges); } if (!dst_restrict_boxes.empty() && !dst_boxes[axis].empty()) { hier::BoxContainer edge_restrict_boxes; for (hier::BoxContainer::const_iterator b = dst_restrict_boxes.begin(); b != dst_restrict_boxes.end(); ++b) { edge_restrict_boxes.pushBack(EdgeGeometry::toEdgeBox(*b, axis)); } dst_boxes[axis].intersectBoxes(edge_restrict_boxes); } } // iterate over axis directions } // if quick check passes // Create the edge overlap data object using the boxes and source shift return std::make_shared<EdgeOverlap>(dst_boxes, transformation); }
boost::shared_ptr<hier::BoxOverlap> OuterfaceGeometry::doOverlap( const OuterfaceGeometry& dst_geometry, const OuterfaceGeometry& src_geometry, const hier::Box& src_mask, const hier::Box& fill_box, const bool overwrite_interior, const hier::Transformation& transformation, const hier::BoxContainer& dst_restrict_boxes) { const tbox::Dimension& dim(src_mask.getDim()); std::vector<hier::BoxContainer> dst_boxes(dim.getValue()); // Perform a quick-and-dirty intersection to see if the boxes might overlap hier::Box src_box(src_geometry.d_box); src_box.grow(src_geometry.d_ghosts); src_box = src_box * src_mask; transformation.transform(src_box); hier::Box dst_ghost(dst_geometry.getBox()); dst_ghost.grow(dst_geometry.getGhosts()); // Compute the intersection (if any) for each of the face directions const hier::IntVector one_vector(dim, 1); const hier::Box quick_check( hier::Box::grow(src_box, one_vector) * hier::Box::grow(dst_ghost, one_vector)); if (!quick_check.empty()) { hier::Box mask_shift(src_mask); transformation.transform(mask_shift); for (tbox::Dimension::dir_t d = 0; d < dim.getValue(); ++d) { const hier::Box dst_face( FaceGeometry::toFaceBox(dst_geometry.getBox(), d)); const hier::Box src_face( FaceGeometry::toFaceBox(src_box, d)); const hier::Box fill_face( FaceGeometry::toFaceBox(fill_box, d)); const hier::Box together(dst_face * src_face * fill_face); if (!together.empty()) { const hier::Box msk_face( FaceGeometry::toFaceBox(mask_shift, d)); hier::Box low_dst_face(dst_face); low_dst_face.setUpper(0, low_dst_face.lower(0)); hier::Box hig_dst_face(dst_face); hig_dst_face.setLower(0, hig_dst_face.upper(0)); // Add lower face intersection (if any) to the box list hier::Box low_src_face(src_face); low_src_face.setUpper(0, low_src_face.lower(0)); hier::Box low_low_overlap(low_src_face * msk_face * low_dst_face); if (!low_low_overlap.empty()) { dst_boxes[d].pushBack(low_low_overlap); } hier::Box low_hig_overlap(low_src_face * msk_face * hig_dst_face); if (!low_hig_overlap.empty()) { dst_boxes[d].pushBack(low_hig_overlap); } // Add upper face intersection (if any) to the box list hier::Box hig_src_face(src_face); hig_src_face.setLower(0, hig_src_face.upper(0)); //-ghosts; hier::Box hig_low_overlap(hig_src_face * msk_face * low_dst_face); if (!hig_low_overlap.empty()) { dst_boxes[d].pushBack(hig_low_overlap); } hier::Box hig_hig_overlap(hig_src_face * msk_face * hig_dst_face); if (!hig_hig_overlap.empty()) { dst_boxes[d].pushBack(hig_hig_overlap); } // Take away the interior of over_write interior is not set if (!overwrite_interior) { dst_boxes[d].removeIntersections( FaceGeometry::toFaceBox(dst_geometry.getBox(), d)); } } // if (!together.empty()) if (!dst_restrict_boxes.empty() && !dst_boxes[d].empty()) { hier::BoxContainer face_restrict_boxes; for (hier::BoxContainer::const_iterator b = dst_restrict_boxes.begin(); b != dst_restrict_boxes.end(); ++b) { face_restrict_boxes.pushBack(FaceGeometry::toFaceBox(*b, d)); } dst_boxes[d].intersectBoxes(face_restrict_boxes); } dst_boxes[d].coalesce(); } // loop over dim } // if (!quick_check.empty()) // Create the face overlap data object using the boxes and source shift return boost::make_shared<FaceOverlap>(dst_boxes, transformation); }