コード例 #1
0
void
CartesianNodeComplexLinearRefine::refine(
   hier::Patch& fine,
   const hier::Patch& coarse,
   const int dst_component,
   const int src_component,
   const hier::BoxOverlap& fine_overlap,
   const hier::IntVector& ratio) const
{
   const pdat::NodeOverlap* t_overlap =
      CPP_CAST<const pdat::NodeOverlap *>(&fine_overlap);

   TBOX_ASSERT(t_overlap != 0);

   const hier::BoxContainer& boxes = t_overlap->getDestinationBoxContainer();
   for (hier::BoxContainer::const_iterator b = boxes.begin();
        b != boxes.end(); ++b) {
      hier::Box fine_box(*b);
      fine_box.growUpper(hier::IntVector(ratio.getDim(), -1));
      refine(fine,
         coarse,
         dst_component,
         src_component,
         fine_box,
         ratio);
   }
}
コード例 #2
0
/*
 *************************************************************************
 *
 * computeFillBoxesAndNeighborhoodSets
 *
 *************************************************************************
 */
void
PatchLevelBorderFillPattern::computeFillBoxesAndNeighborhoodSets(
   boost::shared_ptr<hier::BoxLevel>& fill_box_level,
   boost::shared_ptr<hier::Connector>& dst_to_fill,
   const hier::BoxLevel& dst_box_level,
   const hier::IntVector& fill_ghost_width,
   bool data_on_patch_border)
{
   TBOX_ASSERT_OBJDIM_EQUALITY2(dst_box_level, fill_ghost_width);

   fill_box_level.reset(new hier::BoxLevel(
         dst_box_level.getRefinementRatio(),
         dst_box_level.getGridGeometry(),
         dst_box_level.getMPI()));

   dst_to_fill.reset(new hier::Connector(dst_box_level,
         *fill_box_level,
         fill_ghost_width));

   const hier::BoxContainer& dst_boxes = dst_box_level.getBoxes();

   const int dst_level_num = dst_box_level.getGridGeometry()->
      getEquivalentLevelNumber(dst_box_level.getRefinementRatio());

   hier::IntVector dst_to_dst_width(fill_ghost_width);
   if (data_on_patch_border) {
      dst_to_dst_width += hier::IntVector::getOne(fill_ghost_width.getDim());
   }

   const hier::Connector& dst_to_dst =
      dst_box_level.findConnector(dst_box_level,
         dst_to_dst_width,
         hier::CONNECTOR_IMPLICIT_CREATION_RULE,
         true);

   /*
    * To get the level border, grow each patch box and remove
    * the level from it.
    */
   hier::LocalId last_id = dst_box_level.getLastLocalId();
   for (hier::RealBoxConstIterator ni(dst_boxes.realBegin());
        ni != dst_boxes.realEnd(); ++ni) {
      const hier::Box& dst_box = *ni;
      hier::BoxContainer fill_boxes(
         hier::Box::grow(dst_box, fill_ghost_width));
      hier::Connector::ConstNeighborhoodIterator nabrs =
         dst_to_dst.find(dst_box.getBoxId());
      for (hier::Connector::ConstNeighborIterator na = dst_to_dst.begin(nabrs);
           na != dst_to_dst.end(nabrs); ++na) {
         if (dst_box.getBlockId() == na->getBlockId()) {
            fill_boxes.removeIntersections(*na);
         } else {
            boost::shared_ptr<const hier::BaseGridGeometry> grid_geometry(
               dst_box_level.getGridGeometry());

            const hier::BlockId& dst_block_id = dst_box.getBlockId();
            const hier::BlockId& nbr_block_id = na->getBlockId();

            TBOX_ASSERT(grid_geometry->areNeighbors(dst_block_id,
                  nbr_block_id));

            hier::Transformation::RotationIdentifier rotation =
               grid_geometry->getRotationIdentifier(dst_block_id,
                  nbr_block_id);
            hier::IntVector offset(
               grid_geometry->getOffset(dst_block_id, nbr_block_id, dst_level_num));

            hier::Transformation transformation(rotation, offset,
                                                nbr_block_id, dst_block_id);

            hier::Box nbr_box(*na);
            transformation.transform(nbr_box);

            fill_boxes.removeIntersections(nbr_box);
         }
      }

      if (!fill_boxes.empty()) {
         d_max_fill_boxes = tbox::MathUtilities<int>::Max(d_max_fill_boxes,
               fill_boxes.size());
         hier::Connector::NeighborhoodIterator base_box_itr =
            dst_to_fill->makeEmptyLocalNeighborhood(dst_box.getBoxId());
         for (hier::BoxContainer::iterator li = fill_boxes.begin();
              li != fill_boxes.end(); ++li) {
            hier::Box fill_box(*li,
                               ++last_id,
                               dst_box.getOwnerRank());
            TBOX_ASSERT(fill_box.getBlockId() == dst_box.getBlockId());
            fill_box_level->addBoxWithoutUpdate(fill_box);
            dst_to_fill->insertLocalNeighbor(fill_box, base_box_itr);
         }
      }
   }
   fill_box_level->finalize();
}
コード例 #3
0
ファイル: CommTester.C プロジェクト: LLNL/SAMRAI
void CommTester::registerVariable(
   const std::shared_ptr<hier::Variable> src_variable,
   const std::shared_ptr<hier::Variable> dst_variable,
   const hier::IntVector& src_ghosts,
   const hier::IntVector& dst_ghosts,
   const std::shared_ptr<hier::BaseGridGeometry> xfer_geom,
   const string& operator_name)
{
   TBOX_ASSERT_OBJDIM_EQUALITY2(src_ghosts, dst_ghosts);

   TBOX_ASSERT(src_variable);
   TBOX_ASSERT(dst_variable);
   TBOX_ASSERT(xfer_geom);
   TBOX_ASSERT(!operator_name.empty());

   const tbox::Dimension dim(src_ghosts.getDim());

   hier::VariableDatabase* variable_db = hier::VariableDatabase::getDatabase();

   int src_id = variable_db->registerVariableAndContext(src_variable,
         d_source,
         src_ghosts);

   int dst_id = variable_db->registerVariableAndContext(dst_variable,
         d_destination,
         dst_ghosts);

   TBOX_ASSERT(src_id != -1);
   TBOX_ASSERT(dst_id != -1);

   d_patch_data_components.setFlag(src_id);
   d_patch_data_components.setFlag(dst_id);

   if (d_do_refine) {
      std::shared_ptr<hier::RefineOperator> refine_operator(
         xfer_geom->lookupRefineOperator(src_variable, operator_name));

      hier::IntVector scratch_ghosts(hier::IntVector::max(src_ghosts,
                                        dst_ghosts));
      scratch_ghosts.max(hier::IntVector(scratch_ghosts.getDim(), 1));
      if (refine_operator) {
         scratch_ghosts.max(refine_operator->getStencilWidth(dim));
      }
      int scratch_id =
         variable_db->registerVariableAndContext(src_variable,
            d_refine_scratch,
            scratch_ghosts);
      TBOX_ASSERT(scratch_id != -1);

      d_patch_data_components.setFlag(scratch_id);

      d_refine_algorithm.registerRefine(dst_id,
         src_id,
         scratch_id,
         refine_operator);

      if (src_ghosts >= scratch_ghosts) {
         d_fill_source_algorithm.registerRefine(src_id,
            src_id,
            src_id,
            refine_operator);
      }
   } else if (d_do_coarsen) {
      std::shared_ptr<hier::CoarsenOperator> coarsen_operator(
         xfer_geom->lookupCoarsenOperator(src_variable, operator_name));
      d_coarsen_algorithm.registerCoarsen(dst_id,
         src_id,
         coarsen_operator);
   }

   registerVariableForReset(src_variable, dst_variable,
      src_ghosts, dst_ghosts, xfer_geom,
      operator_name);
}