当前位置: 首页>>代码示例>>C++>>正文


C++ Patch::getBox方法代码示例

本文整理汇总了C++中hier::Patch::getBox方法的典型用法代码示例。如果您正苦于以下问题:C++ Patch::getBox方法的具体用法?C++ Patch::getBox怎么用?C++ Patch::getBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hier::Patch的用法示例。


在下文中一共展示了Patch::getBox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setNodeInfo

/********************************************************************
 * 网格处理                                             *
 ********************************************************************/
 void MeshOpt::setNodeInfo(hier::Patch<NDIM>& patch)
{
    const hier::Index<NDIM> ifirst=patch.getBox().lower();
    const hier::Index<NDIM> ilast =patch.getBox().upper();

    int cols = ilast(0) - ifirst(0)+2;
    int rows = ilast(1) - ifirst(1)+2;

     int num_of_nodes = cols*rows;

    tbox::Array<bool> d_fixed_info(num_of_nodes,true);

    for(int row = 0; row < rows; row++)
    {
        for(int col = 0; col < cols; col++)
        {
            if(row == 0 || row == rows-1 || col == 0 || col == cols-1)
            {
                d_fixed_info[row*cols+col] = true;
            }
            else
                d_fixed_info[row*cols+col] = false;
        }
    }

    tbox::Pointer< pdat::NodeData<NDIM,bool> > fixed_info
            = patch.getPatchData(d_fixed_info_id);

    int count=-1;
    for(pdat::NodeIterator<NDIM> ic((*fixed_info).getBox()); ic; ic++)
    {
       (*fixed_info)(ic(),0) = d_fixed_info[++count];
    }
}
开发者ID:gotodo,项目名称:meshOptBasedjasmin,代码行数:37,代码来源:MeshOpt.C

示例2: tagCellsInInputBoxes

void PatchMultiblockTestStrategy::tagCellsInInputBoxes(
   hier::Patch& patch,
   int level_number,
   int tag_index)
{

   if (level_number < static_cast<int>(d_refine_level_boxes.size())) {

      std::shared_ptr<pdat::CellData<int> > tags(
         SAMRAI_SHARED_PTR_CAST<pdat::CellData<int>, hier::PatchData>(
            patch.getPatchData(tag_index)));
      TBOX_ASSERT(tags);
      tags->fillAll(0);

      const hier::Box pbox = patch.getBox();

      for (hier::BoxContainer::iterator k =
              d_refine_level_boxes[level_number].begin();
           k != d_refine_level_boxes[level_number].end(); ++k) {
         tags->fill(1, *k * pbox, 0);
      }

   }

}
开发者ID:LLNL,项目名称:SAMRAI,代码行数:25,代码来源:PatchMultiblockTestStrategy.C

示例3: postprocessRefine

void EdgeMultiblockTest::postprocessRefine(
   hier::Patch& fine,
   const hier::Patch& coarse,
   const std::shared_ptr<hier::VariableContext>& context,
   const hier::Box& fine_box,
   const hier::IntVector& ratio) const
{
   pdat::EdgeDoubleConstantRefine ref_op;

   hier::BoxContainer fine_box_list(fine_box);
   hier::BoxContainer empty_box_list;

   xfer::BoxGeometryVariableFillPattern fill_pattern;

   for (int i = 0; i < static_cast<int>(d_variables.size()); ++i) {

      int id = hier::VariableDatabase::getDatabase()->
         mapVariableAndContextToIndex(d_variables[i], context);

      std::shared_ptr<hier::PatchDataFactory> fine_pdf(
         fine.getPatchDescriptor()->getPatchDataFactory(id));

      std::shared_ptr<hier::BoxOverlap> fine_overlap(
         fill_pattern.computeFillBoxesOverlap(
            fine_box_list,
            empty_box_list,
            fine.getBox(),
            fine.getPatchData(id)->getGhostBox(),
            *fine_pdf));

      ref_op.refine(fine, coarse, id, id, *fine_overlap, ratio);
   }
}
开发者ID:LLNL,项目名称:SAMRAI,代码行数:33,代码来源:EdgeMultiblockTest.C

示例4: setGridData

void PoissonGaussianSolution::setGridData(
   hier::Patch& patch,
   pdat::CellData<double>& exact_data,
   pdat::CellData<double>& source_data)
{
   boost::shared_ptr<geom::CartesianPatchGeometry> patch_geom(
      BOOST_CAST<geom::CartesianPatchGeometry, hier::PatchGeometry>(
         patch.getPatchGeometry()));
   TBOX_ASSERT(patch_geom);

   const double* h = patch_geom->getDx();
   const double* xl = patch_geom->getXLower();
   const int* il = &patch.getBox().lower()[0];

   {
      /* Set cell-centered data. */
      double sl[SAMRAI::MAX_DIM_VAL]; // Like XLower, except for cell.
      int j;
      for (j = 0; j < d_dim.getValue(); ++j) {
         sl[j] = xl[j] + 0.5 * h[j];
      }
      pdat::CellData<double>::iterator iter(pdat::CellGeometry::begin(patch.getBox()));
      pdat::CellData<double>::iterator iterend(pdat::CellGeometry::end(patch.getBox()));
      if (d_dim == tbox::Dimension(2)) {
         double x, y;
         for ( ; iter != iterend; ++iter) {
            const pdat::CellIndex& index = *iter;
            x = sl[0] + (index[0] - il[0]) * h[0];
            y = sl[1] + (index[1] - il[1]) * h[1];
            exact_data(index) = exactFcn(x, y);
            source_data(index) = sourceFcn(x, y);
         }
      } else if (d_dim == tbox::Dimension(3)) {
         double x, y, z;
         for ( ; iter != iterend; ++iter) {
            const pdat::CellIndex& index = *iter;
            x = sl[0] + (index[0] - il[0]) * h[0];
            y = sl[1] + (index[1] - il[1]) * h[1];
            z = sl[2] + (index[2] - il[2]) * h[2];
            exact_data(index) = exactFcn(x, y, z);
            source_data(index) = sourceFcn(x, y, z);
         }
      }
   }
}       // End patch loop.
开发者ID:00liujj,项目名称:SAMRAI,代码行数:45,代码来源:PoissonGaussianSolution.C

示例5: pgeom

void
CommTester::putCoordinatesToDatabase(
   std::shared_ptr<tbox::Database>& coords_db,
   const hier::Patch& patch)
{

   std::shared_ptr<geom::CartesianPatchGeometry> pgeom(
      SAMRAI_SHARED_PTR_CAST<geom::CartesianPatchGeometry, hier::PatchGeometry>(
         patch.getPatchGeometry()));
/*
   if (pgeom) {
      pgeom->putBlueprintCoords(coords_db, patch.getBox());
   }
*/
   const tbox::Dimension& dim(patch.getDim());

   pdat::NodeData<double> coords(patch.getBox(), dim.getValue(),
                                 hier::IntVector::getZero(dim));

   const hier::Index& box_lo = patch.getBox().lower();
   const double* x_lo = pgeom->getXLower();
   const double* dx = pgeom->getDx();
   
   pdat::NodeIterator nend = pdat::NodeGeometry::end(patch.getBox());
   for (pdat::NodeIterator itr(pdat::NodeGeometry::begin(patch.getBox())); itr != nend; ++itr) {
      const pdat::NodeIndex& ni = *itr;
      for (int d = 0; d < dim.getValue(); ++d) {
         coords(ni, d) = x_lo[d] + (ni(d)-box_lo(d))*dx[d];
      }
   }

   coords_db->putString("type", "explicit");

   std::shared_ptr<tbox::Database> values_db = coords_db->putDatabase("values");

   int data_size = coords.getArrayData().getBox().size();

   values_db->putDoubleArray("x", coords.getPointer(0), data_size);
   if (dim.getValue() > 1) {
      values_db->putDoubleArray("y", coords.getPointer(1), data_size);
   }
   if (dim.getValue() > 2) {
      values_db->putDoubleArray("z", coords.getPointer(2), data_size);
   }
}
开发者ID:LLNL,项目名称:SAMRAI,代码行数:45,代码来源:CommTester.C

示例6: buildCartesianGridOnPatch

void MblkGeometry::buildCartesianGridOnPatch(
   const hier::Patch& patch,
   const int xyz_id,
   const int level_number,
   const int block_number)
{

   boost::shared_ptr<pdat::NodeData<double> > xyz(
      BOOST_CAST<pdat::NodeData<double>, hier::PatchData>(
         patch.getPatchData(xyz_id)));

   TBOX_ASSERT(xyz);

   pdat::NodeIterator niend(pdat::NodeGeometry::end(patch.getBox()));
   for (pdat::NodeIterator ni(pdat::NodeGeometry::begin(patch.getBox()));
        ni != niend; ++ni) {
      pdat::NodeIndex node = *ni;
      if (d_block_rotation[block_number] == 0) {

         (*xyz)(node, 0) =
            d_cart_xlo[block_number][0] + node(0) * d_dx[level_number][block_number][0];
         (*xyz)(node, 1) =
            d_cart_xlo[block_number][1] + node(1) * d_dx[level_number][block_number][1];
         if (d_dim == tbox::Dimension(3)) {
            (*xyz)(node, 2) =
               d_cart_xlo[block_number][2] + node(2) * d_dx[level_number][block_number][2];
         }
      }
      if (d_block_rotation[block_number] == 1) { // I sideways, J down

         (*xyz)(node, 0) =
            d_cart_xlo[block_number][0] - node(0) * d_dx[level_number][block_number][0];
         (*xyz)(node, 1) =
            d_cart_xlo[block_number][1] + node(1) * d_dx[level_number][block_number][1];
         if (d_dim == tbox::Dimension(3)) {
            (*xyz)(node, 2) =
               d_cart_xlo[block_number][2] + node(2) * d_dx[level_number][block_number][2];
         }
      }

   }

}
开发者ID:00liujj,项目名称:SAMRAI,代码行数:43,代码来源:MblkGeometry.C

示例7:

boost::shared_ptr<hier::PatchData>
CellDataFactory<TYPE>::allocate(
   const hier::Patch& patch) const
{
   TBOX_ASSERT_OBJDIM_EQUALITY2(*this, patch);

   return boost::make_shared<CellData<TYPE> >(
             patch.getBox(),
             d_depth,
             d_ghosts);
}
开发者ID:00liujj,项目名称:SAMRAI,代码行数:11,代码来源:CellDataFactory.C

示例8: tagOctantCells

/*
 *************************************************************************
 *
 * Tag cells for spherical octant problem
 *
 *************************************************************************
 */
void MblkGeometry::tagOctantCells(
   hier::Patch& patch,
   const int xyz_id,
   boost::shared_ptr<pdat::CellData<int> >& temp_tags,
   const double regrid_time,
   const int refine_tag_val)
{
   TBOX_ASSERT(d_geom_problem == "SPHERICAL_SHELL" &&
      d_sshell_type == "OCTANT");
   TBOX_ASSERT(temp_tags);

   boost::shared_ptr<pdat::NodeData<double> > xyz(
      BOOST_CAST<pdat::NodeData<double>, hier::PatchData>(
         patch.getPatchData(xyz_id)));
   TBOX_ASSERT(xyz);

   if (d_dim == tbox::Dimension(3)) {
      /*
       * Tag in X direction only
       */
      double xtag_loc_lo = d_sshell_rmin
         + (regrid_time * d_tag_velocity) - (0.5 * d_tag_width);
      double xtag_loc_hi = d_sshell_rmin
         + (regrid_time * d_tag_velocity) + (0.5 * d_tag_width);

      hier::Box pbox = patch.getBox();
      for (int k = pbox.lower(2); k <= pbox.upper(2) + 1; ++k) {
         for (int j = pbox.lower(1); j <= pbox.upper(1) + 1; ++j) {
            for (int i = pbox.lower(0); i <= pbox.upper(0) + 1; ++i) {
               hier::Index ic(i, j, k);
               pdat::NodeIndex node(ic, pdat::NodeIndex::LLL);
               hier::Index icm1(i - 1, j - 1, k - 1);
               pdat::CellIndex cell(icm1);

               double node_x_loc = (*xyz)(node, 0);

               if ((node_x_loc > xtag_loc_lo) &&
                   (node_x_loc < xtag_loc_hi)) {
                  (*temp_tags)(cell) = refine_tag_val;
               }
            }
         }
      }
   }

}
开发者ID:00liujj,项目名称:SAMRAI,代码行数:53,代码来源:MblkGeometry.C

示例9: verifyResults

/*
 *************************************************************************
 *
 * Verify results of communication operations.  This test must be
 * consistent with data initialization and boundary operations above.
 *
 *************************************************************************
 */
bool EdgeMultiblockTest::verifyResults(
   const hier::Patch& patch,
   const std::shared_ptr<hier::PatchHierarchy> hierarchy,
   const int level_number,
   const hier::BlockId& block_id)
{

   tbox::plog << "\nEntering EdgeMultiblockTest::verifyResults..." << endl;
   tbox::plog << "level_number = " << level_number << endl;
   tbox::plog << "Patch box = " << patch.getBox() << endl;

   hier::IntVector tgcw(d_dim, 0);
   for (int i = 0; i < static_cast<int>(d_variables.size()); ++i) {
      tgcw.max(patch.getPatchData(d_variables[i], getDataContext())->
         getGhostCellWidth());
   }
   hier::Box pbox = patch.getBox();

   std::shared_ptr<pdat::EdgeData<double> > solution(
      new pdat::EdgeData<double>(pbox, 1, tgcw));

   hier::Box tbox(pbox);
   tbox.grow(tgcw);

   std::shared_ptr<hier::BaseGridGeometry> grid_geom(
      hierarchy->getGridGeometry());

   hier::BoxContainer singularity(
      grid_geom->getSingularityBoxContainer(block_id));

   hier::IntVector ratio =
      hierarchy->getPatchLevel(level_number)->getRatioToLevelZero();

   singularity.refine(ratio);

   bool test_failed = false;

   for (int i = 0; i < static_cast<int>(d_variables.size()); ++i) {

      double correct = (double)block_id.getBlockValue();

      std::shared_ptr<pdat::EdgeData<double> > edge_data(
         SAMRAI_SHARED_PTR_CAST<pdat::EdgeData<double>, hier::PatchData>(
            patch.getPatchData(d_variables[i], getDataContext())));
      TBOX_ASSERT(edge_data);
      int depth = edge_data->getDepth();

      hier::Box interior_box(pbox);
      interior_box.grow(hier::IntVector(d_dim, -1));

      for (int axis = 0; axis < d_dim.getValue(); ++axis) {
         pdat::EdgeIterator ciend(pdat::EdgeGeometry::end(interior_box, axis));
         for (pdat::EdgeIterator ci(pdat::EdgeGeometry::begin(interior_box, axis));
              ci != ciend; ++ci) {
            for (int d = 0; d < depth; ++d) {
               double result = (*edge_data)(*ci, d);

               if (!tbox::MathUtilities<double>::equalEps(correct, result)) {
                  tbox::perr << "Test FAILED: ...."
                             << " : edge index = " << *ci << endl;
                  tbox::perr << "    Variable = " << d_variable_src_name[i]
                             << " : depth index = " << d << endl;
                  tbox::perr << "    result = " << result
                             << " : correct = " << correct << endl;
                  test_failed = true;
               }
            }
         }
      }

      hier::Box gbox = edge_data->getGhostBox();

      for (int axis = 0; axis < d_dim.getValue(); ++axis) {
         hier::Box patch_edge_box =
            pdat::EdgeGeometry::toEdgeBox(pbox, axis);

         hier::BoxContainer tested_neighbors;

         hier::BoxContainer sing_edge_boxlist;
         for (hier::BoxContainer::iterator si = singularity.begin();
              si != singularity.end(); ++si) {
            sing_edge_boxlist.pushFront(
               pdat::EdgeGeometry::toEdgeBox(*si, axis));
         }

         for (hier::BaseGridGeometry::ConstNeighborIterator ne(
                 grid_geom->begin(block_id));
              ne != grid_geom->end(block_id); ++ne) {

            const hier::BaseGridGeometry::Neighbor& nbr = *ne;
            if (nbr.isSingularity()) {
               continue;
//.........这里部分代码省略.........
开发者ID:LLNL,项目名称:SAMRAI,代码行数:101,代码来源:EdgeMultiblockTest.C

示例10: buildSShellGridOnPatch

void MblkGeometry::buildSShellGridOnPatch(
   const hier::Patch& patch,
   const hier::Box& domain,
   const int xyz_id,
   const int level_number,
   const int block_number)
{

   bool xyz_allocated = patch.checkAllocated(xyz_id);
   if (!xyz_allocated) {
      TBOX_ERROR("xyz data not allocated" << std::endl);
      //patch.allocatePatchData(xyz_id);
   }

   boost::shared_ptr<pdat::NodeData<double> > xyz(
      BOOST_CAST<pdat::NodeData<double>, hier::PatchData>(
         patch.getPatchData(xyz_id)));

   TBOX_ASSERT(xyz);

   if (d_dim == tbox::Dimension(3)) {

      const hier::Index ifirst = patch.getBox().lower();
      const hier::Index ilast = patch.getBox().upper();
      hier::IntVector nghost_cells = xyz->getGhostCellWidth();

      //int imin = ifirst(0);
      //int imax = ilast(0)  + 1;
      //int jmin = ifirst(1);
      //int jmax = ilast(1)  + 1;
      //int kmin = ifirst(2);
      //int kmax = ilast(2)  + 1;
      //int nx   = imax - imin + 1;
      //int ny   = jmax - jmin + 1;
      //int nxny = nx*ny;

      int nd_imin = ifirst(0) - nghost_cells(0);
      int nd_imax = ilast(0) + 1 + nghost_cells(0);
      int nd_jmin = ifirst(1) - nghost_cells(1);
      int nd_jmax = ilast(1) + 1 + nghost_cells(1);
      int nd_kmin = ifirst(2) - nghost_cells(2);
      int nd_kmax = ilast(2) + 1 + nghost_cells(2);
      int nd_nx = nd_imax - nd_imin + 1;
      int nd_ny = nd_jmax - nd_jmin + 1;
      int nd_nxny = nd_nx * nd_ny;

      double* x = xyz->getPointer(0);
      double* y = xyz->getPointer(1);
      double* z = xyz->getPointer(2);

      bool found = false;

      int nrad = (domain.upper(0) - domain.lower(0) + 1);
      int nth = (domain.upper(1) - domain.lower(1) + 1);
      int nphi = (domain.upper(2) - domain.lower(2) + 1);

      /*
       * If its a solid shell, its a single block and dx = dr, dth, dphi
       */
      if (d_sshell_type == "SOLID") {

         d_dx[level_number][block_number][0] = (d_sshell_rmax - d_sshell_rmin) / (double)nrad;
         d_dx[level_number][block_number][1] =
            2.0 * tbox::MathUtilities<double>::Abs(d_sangle_thmin)
            / (double)nth;
         d_dx[level_number][block_number][2] =
            2.0 * tbox::MathUtilities<double>::Abs(d_sangle_thmin)
            / (double)nphi;

         //
         // step in a radial direction in x and set y and z appropriately
         // for a solid angle we go -th to th and -phi to phi
         //
         for (int k = nd_kmin; k <= nd_kmax; ++k) {
            for (int j = nd_jmin; j <= nd_jmax; ++j) {

               double theta = d_sangle_thmin + j * d_dx[level_number][block_number][1]; // dx used for dth
               double phi = d_sangle_thmin + k * d_dx[level_number][block_number][2];

               double xface = cos(theta) * cos(phi);
               double yface = sin(theta) * cos(phi);
               double zface = sin(phi);

               for (int i = nd_imin; i <= nd_imax; ++i) {

                  int ind = POLY3(i,
                        j,
                        k,
                        nd_imin,
                        nd_jmin,
                        nd_kmin,
                        nd_nx,
                        nd_nxny);

                  double r = d_sshell_rmin + d_dx[level_number][block_number][0] * (i);

                  double xx = r * xface;
                  double yy = r * yface;
                  double zz = r * zface;

//.........这里部分代码省略.........
开发者ID:00liujj,项目名称:SAMRAI,代码行数:101,代码来源:MblkGeometry.C

示例11: buildWedgeGridOnPatch

void MblkGeometry::buildWedgeGridOnPatch(
   const hier::Patch& patch,
   const int xyz_id,
   const int level_number,
   const int block_number)
{

   boost::shared_ptr<pdat::NodeData<double> > xyz(
      BOOST_CAST<pdat::NodeData<double>, hier::PatchData>(
         patch.getPatchData(xyz_id)));

   TBOX_ASSERT(xyz);

   const hier::Index ifirst = patch.getBox().lower();
   const hier::Index ilast = patch.getBox().upper();
   hier::IntVector nghost_cells = xyz->getGhostCellWidth();

   int nd_imin = ifirst(0) - nghost_cells(0);
   int nd_imax = ilast(0) + 1 + nghost_cells(0);
   int nd_jmin = ifirst(1) - nghost_cells(1);
   int nd_jmax = ilast(1) + 1 + nghost_cells(1);
   int nd_nx = nd_imax - nd_imin + 1;
   int nd_ny = nd_jmax - nd_jmin + 1;
   //int nd_nz   = nd_kmax - nd_kmin + 1;
   int nd_nxny = nd_nx * nd_ny;
   //int nd_nel  = nd_nx*nd_ny*nd_nz;

   double dx[SAMRAI::MAX_DIM_VAL];
   dx[0] = d_dx[level_number][block_number][0];
   dx[1] = d_dx[level_number][block_number][1];

   double* x = xyz->getPointer(0);
   double* y = xyz->getPointer(1);

   int nd_kmin;
   int nd_kmax;
   dx[2] = d_dx[level_number][block_number][2];
   double* z = 0;
   if (d_dim == tbox::Dimension(3)) {
      nd_kmin = ifirst(2) - nghost_cells(2);
      nd_kmax = ilast(2) + 1 + nghost_cells(2);
      dx[2] = d_dx[level_number][block_number][2];
      z = xyz->getPointer(2);
   } else {
      nd_kmin = 0;
      nd_kmax = 0;
   }

   //
   // ----------- set the wedge nodal positions
   //

   for (int k = nd_kmin; k <= nd_kmax; ++k) {
      for (int j = nd_jmin; j <= nd_jmax; ++j) {
         for (int i = nd_imin; i <= nd_imax; ++i) {

            int ind = POLY3(i, j, k, nd_imin, nd_jmin, nd_kmin, nd_nx, nd_nxny);

            double r = d_wedge_rmin[block_number] + dx[0] * (i);
            double th = d_wedge_thmin + dx[1] * (j);

            double xx = r * cos(th);
            double yy = r * sin(th);

            x[ind] = xx;
            y[ind] = yy;

            if (d_dim == tbox::Dimension(3)) {
               double zz = d_wedge_zmin + dx[2] * (k);
               z[ind] = zz;
            }
         }
      }
   }
}
开发者ID:00liujj,项目名称:SAMRAI,代码行数:75,代码来源:MblkGeometry.C

示例12: setBcCoefs

void PoissonGaussianSolution::setBcCoefs(
   const boost::shared_ptr<pdat::ArrayData<double> >& acoef_data,
   const boost::shared_ptr<pdat::ArrayData<double> >& bcoef_data,
   const boost::shared_ptr<pdat::ArrayData<double> >& gcoef_data,
   const boost::shared_ptr<hier::Variable>& variable,
   const hier::Patch& patch,
   const hier::BoundaryBox& bdry_box,
   const double fill_time) const
{
   NULL_USE(variable);
   NULL_USE(fill_time);

   boost::shared_ptr<geom::CartesianPatchGeometry> patch_geom(
      BOOST_CAST<geom::CartesianPatchGeometry, hier::PatchGeometry>(
         patch.getPatchGeometry()));
   TBOX_ASSERT(patch_geom);
   /*
    * Set to an inhomogeneous Dirichlet boundary condition.
    */
   hier::Box patch_box(patch.getBox());

   const double* xlo = patch_geom->getXLower();
   const double* xup = patch_geom->getXUpper();
   const double* dx = patch_geom->getDx();

   if (bdry_box.getBoundaryType() != 1) {
      // Must be a face boundary.
      TBOX_ERROR("Bad boundary type in\n"
         << "PoissonGaussianSolution::setBcCoefs \n");
   }
   const hier::Box& box = bdry_box.getBox();
   hier::Index lower = box.lower();
   hier::Index upper = box.upper();

   if (d_dim == tbox::Dimension(2)) {
      double* a_array = acoef_data ? acoef_data->getPointer() : 0;
      double* b_array = bcoef_data ? bcoef_data->getPointer() : 0;
      double* g_array = gcoef_data ? gcoef_data->getPointer() : 0;
      int i, j, ibeg, iend, jbeg, jend;
      double x, y;
      switch (bdry_box.getLocationIndex()) {
         case 0:
            // min i edge
            jbeg = box.lower()[1];
            jend = box.upper()[1];
            x = xlo[0];
            for (j = jbeg; j <= jend; ++j) {
               y = xlo[1] + dx[1] * (j - patch_box.lower()[1] + 0.5);
               if (a_array) a_array[j - jbeg] = 1.0;
               if (b_array) b_array[j - jbeg] = 0.0;
               if (g_array) g_array[j - jbeg] = exactFcn(x, y);
            }
            break;
         case 1:
            // max i edge
            jbeg = box.lower()[1];
            jend = box.upper()[1];
            x = xup[0];
            for (j = jbeg; j <= jend; ++j) {
               y = xlo[1] + dx[1] * (j - patch_box.lower()[1] + 0.5);
               if (a_array) a_array[j - jbeg] = 1.0;
               if (b_array) b_array[j - jbeg] = 0.0;
               if (g_array) g_array[j - jbeg] = exactFcn(x, y);
            }
            break;
         case 2:
            // min j edge
            ibeg = box.lower()[0];
            iend = box.upper()[0];
            y = xlo[1];
            for (i = ibeg; i <= iend; ++i) {
               x = xlo[0] + dx[0] * (i - patch_box.lower()[0] + 0.5);
               if (a_array) a_array[i - ibeg] = 1.0;
               if (b_array) b_array[i - ibeg] = 0.0;
               if (g_array) g_array[i - ibeg] = exactFcn(x, y);
            }
            break;
         case 3:
            // max j edge
            ibeg = box.lower()[0];
            iend = box.upper()[0];
            y = xup[1];
            for (i = ibeg; i <= iend; ++i) {
               x = xlo[0] + dx[0] * (i - patch_box.lower()[0] + 0.5);
               if (a_array) a_array[i - ibeg] = 1.0;
               if (b_array) b_array[i - ibeg] = 0.0;
               if (g_array) g_array[i - ibeg] = exactFcn(x, y);
            }
            break;
         default:
            TBOX_ERROR("Invalid location index in\n"
            << "PoissonGaussianSolution::setBcCoefs");
      }
   }

   if (d_dim == tbox::Dimension(3)) {
      MDA_Access<double, 3, MDA_OrderColMajor<3> > a_array, b_array, g_array;
      if (acoef_data) a_array = pdat::ArrayDataAccess::access<3, double>(
               *acoef_data);
      if (bcoef_data) b_array = pdat::ArrayDataAccess::access<3, double>(
//.........这里部分代码省略.........
开发者ID:00liujj,项目名称:SAMRAI,代码行数:101,代码来源:PoissonGaussianSolution.C

示例13: fillSingularityBoundaryConditions

void EdgeMultiblockTest::fillSingularityBoundaryConditions(
   hier::Patch& patch,
   const hier::PatchLevel& encon_level,
   std::shared_ptr<const hier::Connector> dst_to_encon,
   const hier::Box& fill_box,
   const hier::BoundaryBox& bbox,
   const std::shared_ptr<hier::BaseGridGeometry>& grid_geometry)
{
   const tbox::Dimension& dim = fill_box.getDim();

   const hier::BoxId& dst_mb_id = patch.getBox().getBoxId();

   const hier::BlockId& patch_blk_id = patch.getBox().getBlockId();

   for (int i = 0; i < static_cast<int>(d_variables.size()); ++i) {

      std::shared_ptr<pdat::EdgeData<double> > edge_data(
         SAMRAI_SHARED_PTR_CAST<pdat::EdgeData<double>, hier::PatchData>(
            patch.getPatchData(d_variables[i], getDataContext())));
      TBOX_ASSERT(edge_data);

      hier::Box sing_fill_box(edge_data->getGhostBox() * fill_box);

      int depth = edge_data->getDepth();

      for (int axis = 0; axis < d_dim.getValue(); ++axis) {
         hier::Box pbox = pdat::EdgeGeometry::toEdgeBox(patch.getBox(), axis);

         hier::Index plower(pbox.lower());
         hier::Index pupper(pbox.upper());

         pdat::EdgeIterator niend(pdat::EdgeGeometry::end(sing_fill_box, axis));
         for (pdat::EdgeIterator ni(pdat::EdgeGeometry::begin(sing_fill_box, axis));
              ni != niend; ++ni) {
            bool use_index = true;
            for (tbox::Dimension::dir_t n = 0; n < d_dim.getValue(); ++n) {
               if (axis != n && bbox.getBox().numberCells(n) == 1) {
                  if ((*ni)(n) == plower(n) || (*ni)(n) == pupper(n)) {
                     use_index = false;
                     break;
                  }
               }
            }
            if (use_index) {
               for (int d = 0; d < depth; ++d) {
                  (*edge_data)(*ni, d) = 0.0;
               }
            }
         }
      }

      int num_encon_used = 0;

      if (grid_geometry->hasEnhancedConnectivity()) {

         hier::Connector::ConstNeighborhoodIterator ni =
            dst_to_encon->findLocal(dst_mb_id);

         if (ni != dst_to_encon->end()) {

            for (hier::Connector::ConstNeighborIterator ei = dst_to_encon->begin(ni);
                 ei != dst_to_encon->end(ni); ++ei) {

               const hier::BlockId& encon_blk_id = ei->getBlockId();
               std::shared_ptr<hier::Patch> encon_patch(
                  encon_level.getPatch(ei->getBoxId()));

               hier::Transformation::RotationIdentifier rotation =
                  hier::Transformation::NO_ROTATE;
               hier::IntVector offset(dim);

               hier::BaseGridGeometry::ConstNeighborIterator itr =
                  grid_geometry->find(patch_blk_id, encon_blk_id);
               if (itr != grid_geometry->end(patch_blk_id)) {
                  rotation = (*itr).getRotationIdentifier();
                  offset = (*itr).getShift(encon_level.getLevelNumber());
               }

               hier::Transformation transformation(rotation, offset,
                                                   encon_blk_id,
                                                   patch_blk_id);
               hier::Box encon_patch_box(encon_patch->getBox());
               transformation.transform(encon_patch_box);

               hier::Box encon_fill_box(encon_patch_box * sing_fill_box);
               if (!encon_fill_box.empty()) {

                  const hier::Transformation::RotationIdentifier back_rotate =
                     hier::Transformation::getReverseRotationIdentifier(
                        rotation, dim);

                  hier::IntVector back_shift(dim);

                  hier::Transformation::calculateReverseShift(
                     back_shift, offset, rotation);

                  hier::Transformation back_trans(back_rotate, back_shift,
                                                  patch_blk_id,
                                                  encon_blk_id);

//.........这里部分代码省略.........
开发者ID:LLNL,项目名称:SAMRAI,代码行数:101,代码来源:EdgeMultiblockTest.C

示例14: setPhysicalBoundaryConditions

void EdgeMultiblockTest::setPhysicalBoundaryConditions(
   hier::Patch& patch,
   const double time,
   const hier::IntVector& gcw_to_fill) const
{
   NULL_USE(time);

   std::shared_ptr<hier::PatchGeometry> pgeom(patch.getPatchGeometry());

   const std::vector<hier::BoundaryBox>& node_bdry =
      pgeom->getCodimensionBoundaries(d_dim.getValue());
   const int num_node_bdry_boxes = static_cast<int>(node_bdry.size());

   std::vector<hier::BoundaryBox> empty_vector(0, hier::BoundaryBox(d_dim));
   const std::vector<hier::BoundaryBox>& edge_bdry =
      d_dim > tbox::Dimension(1) ?
      pgeom->getCodimensionBoundaries(d_dim.getValue() - 1) : empty_vector;
   const int num_edge_bdry_boxes = static_cast<int>(edge_bdry.size());

   const std::vector<hier::BoundaryBox>& face_bdry =
      d_dim == tbox::Dimension(3) ?
      pgeom->getCodimensionBoundaries(d_dim.getValue() - 2) : empty_vector;
   const int num_face_bdry_boxes = static_cast<int>(face_bdry.size());

   for (int i = 0; i < static_cast<int>(d_variables.size()); ++i) {

      std::shared_ptr<pdat::EdgeData<double> > edge_data(
         SAMRAI_SHARED_PTR_CAST<pdat::EdgeData<double>, hier::PatchData>(
            patch.getPatchData(d_variables[i], getDataContext())));
      TBOX_ASSERT(edge_data);

      /*
       * Set node boundary data.
       */
      for (int nb = 0; nb < num_node_bdry_boxes; ++nb) {

         hier::Box fill_box = pgeom->getBoundaryFillBox(node_bdry[nb],
               patch.getBox(),
               gcw_to_fill);

         for (int axis = 0; axis < d_dim.getValue(); ++axis) {
            hier::Box patch_edge_box =
               pdat::EdgeGeometry::toEdgeBox(patch.getBox(), axis);
            if (!node_bdry[nb].getIsMultiblockSingularity()) {
               pdat::EdgeIterator niend(pdat::EdgeGeometry::end(fill_box, axis));
               for (pdat::EdgeIterator ni(pdat::EdgeGeometry::begin(fill_box, axis));
                    ni != niend; ++ni) {
                  if (!patch_edge_box.contains(*ni)) {
                     for (int d = 0; d < edge_data->getDepth(); ++d) {
                        (*edge_data)(*ni, d) =
                           (double)(node_bdry[nb].getLocationIndex() + 100);
                     }
                  }
               }
            }
         }
      }

      if (d_dim > tbox::Dimension(1)) {
         /*
          * Set edge boundary data.
          */
         for (int eb = 0; eb < num_edge_bdry_boxes; ++eb) {

            hier::Box fill_box = pgeom->getBoundaryFillBox(edge_bdry[eb],
                  patch.getBox(),
                  gcw_to_fill);

            for (int axis = 0; axis < d_dim.getValue(); ++axis) {
               hier::Box patch_edge_box =
                  pdat::EdgeGeometry::toEdgeBox(patch.getBox(), axis);
               hier::Index plower(patch_edge_box.lower());
               hier::Index pupper(patch_edge_box.upper());

               if (!edge_bdry[eb].getIsMultiblockSingularity()) {
                  pdat::EdgeIterator niend(pdat::EdgeGeometry::end(fill_box, axis));
                  for (pdat::EdgeIterator ni(pdat::EdgeGeometry::begin(fill_box, axis));
                       ni != niend; ++ni) {
                     if (!patch_edge_box.contains(*ni)) {
                        bool use_index = true;
                        for (tbox::Dimension::dir_t n = 0; n < d_dim.getValue(); ++n) {
                           if (axis != n &&
                               edge_bdry[eb].getBox().numberCells(n) == 1) {
                              if ((*ni)(n) == plower(n) || (*ni)(n) ==
                                  pupper(n)) {
                                 use_index = false;
                                 break;
                              }
                           }
                        }

                        if (use_index) {
                           for (int d = 0; d < edge_data->getDepth(); ++d) {
                              (*edge_data)(*ni, d) =
                                 (double)(edge_bdry[eb].getLocationIndex()
                                          + 100);
                           }
                        }
                     }
                  }
//.........这里部分代码省略.........
开发者ID:LLNL,项目名称:SAMRAI,代码行数:101,代码来源:EdgeMultiblockTest.C

示例15: setPhysicalBoundaryConditions

void BoundaryDataTester::setPhysicalBoundaryConditions(
   hier::Patch& patch,
   const double fill_time,
   const hier::IntVector& ghost_width_to_fill)
{
   NULL_USE(fill_time);
   tbox::plog << "\n\nFilling boundary data on patch = " << patch.getBox()
              << endl;
   tbox::plog << "ghost_width_to_fill = " << ghost_width_to_fill << endl;

   for (int iv = 0; iv < static_cast<int>(d_variables.size()); ++iv) {

      std::shared_ptr<pdat::CellData<double> > cvdata(
         SAMRAI_SHARED_PTR_CAST<pdat::CellData<double>, hier::PatchData>(
            patch.getPatchData(d_variables[iv], d_variable_context)));
      TBOX_ASSERT(cvdata);

      tbox::plog << "\n   iv = " << iv << " : " << d_variable_name[iv] << endl;
      tbox::plog << "   depth = " << cvdata->getDepth() << endl;

      hier::IntVector fill_gcw(hier::IntVector::min(cvdata->getGhostCellWidth(),
                                  ghost_width_to_fill));

      if (d_dim == tbox::Dimension(3)) {
         appu::CartesianBoundaryUtilities3::
         fillFaceBoundaryData(d_variable_name[iv], cvdata,
            patch,
            fill_gcw,
            ((cvdata->getDepth() > 1) ?
             d_vector_bdry_face_conds :
             d_scalar_bdry_face_conds),
            d_variable_bc_values[iv]);
         appu::CartesianBoundaryUtilities3::
         fillEdgeBoundaryData(d_variable_name[iv], cvdata,
            patch,
            fill_gcw,
            ((cvdata->getDepth() > 1) ?
             d_vector_bdry_edge_conds :
             d_scalar_bdry_edge_conds),
            d_variable_bc_values[iv]);

         appu::CartesianBoundaryUtilities3::
         fillNodeBoundaryData(d_variable_name[iv], cvdata,
            patch,
            fill_gcw,
            ((cvdata->getDepth() > 1) ?
             d_vector_bdry_node_conds :
             d_scalar_bdry_node_conds),
            d_variable_bc_values[iv]);
      }

      if (d_dim == tbox::Dimension(2)) {
         appu::CartesianBoundaryUtilities2::
         fillEdgeBoundaryData(d_variable_name[iv], cvdata,
            patch,
            fill_gcw,
            ((cvdata->getDepth() > 1) ?
             d_vector_bdry_edge_conds :
             d_scalar_bdry_edge_conds),
            d_variable_bc_values[iv]);

         appu::CartesianBoundaryUtilities2::
         fillNodeBoundaryData(d_variable_name[iv], cvdata,
            patch,
            fill_gcw,
            ((cvdata->getDepth() > 1) ?
             d_vector_bdry_node_conds :
             d_scalar_bdry_node_conds),
            d_variable_bc_values[iv]);
      }

   }

   if (d_dim == tbox::Dimension(2)) {
      checkBoundaryData(Bdry::EDGE2D, patch, ghost_width_to_fill);
      checkBoundaryData(Bdry::NODE2D, patch, ghost_width_to_fill);
   }
   if (d_dim == tbox::Dimension(3)) {
      checkBoundaryData(Bdry::FACE3D, patch, ghost_width_to_fill);
      checkBoundaryData(Bdry::EDGE3D, patch, ghost_width_to_fill);
      checkBoundaryData(Bdry::NODE3D, patch, ghost_width_to_fill);
   }

}
开发者ID:LLNL,项目名称:SAMRAI,代码行数:84,代码来源:BoundaryDataTester.C


注:本文中的hier::Patch::getBox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。