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


C++ DisjointBoxLayout::sameBoxes方法代码示例

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


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

示例1: setupGrids


//.........这里部分代码省略.........
          thresh /= 2.; 
        }
      
      // make tags
      curr_dom_box = a_domains[0].domainBox(); // used for hard wired refinement
      for (int ilev=0;ilev<new_level;ilev++)
        {
          const DisjointBoxLayout& dbl = a_grids[ilev];
          for (DataIterator dit = dbl.dataIterator(); dit.ok(); ++dit)
            {
              FArrayBox& exactFAB = (*a_exact[ilev])[dit];
              FArrayBox& phiFAB = (*a_phi[ilev])[dit];
              Box region = dbl[dit];
              for (BoxIterator bit(region); bit.ok(); ++bit)
                {
                  const IntVect& iv = bit();
                  if (s_amr_type_iserror)
                    {
                      Real error = fabs(phiFAB(iv,0)-exactFAB(iv,0));
                      if (error > thresh) a_tagVects[ilev] |= iv; // real AMR
                    }
                  else // grad
                    {
                      Real grad = 0., tt;
                      for (int dir=0; dir<SpaceDim; ++dir)
                        {
                          IntVect liv(iv), riv(iv); liv.shift(dir,-1); riv.shift(dir,1); 
                          tt = (exactFAB(riv,0)-exactFAB(liv,0))/(2.*dx);
                          grad += tt*tt;
                        }
                      grad = sqrt(grad);
                      if (grad > thresh) a_tagVects[ilev] |= iv; // real AMR
                    }
                }
            } // grid

          // hardwire refinement in fake place
          IntVect se = a_domains[ilev].domainBox().smallEnd();
          //se.shift(1,curr_dom_box.size(1)-1);
          a_tagVects[ilev] |= se; 

          curr_dom_box.refine(s_refRatio);
          dx /= s_refRatio;
          thresh *= s_error_thresh; 
        }
  
      // make old_grids, need to make all because coarse grids can change after refinement
      for (int ilev=0;ilev<new_level;ilev++)
        {
          const DisjointBoxLayout& dbl = a_grids[ilev];
          old_grids[ilev].resize(dbl.size());
          LayoutIterator lit = dbl.layoutIterator();
          int boxIndex = 0;
          for (lit.begin(); lit.ok(); ++lit, ++boxIndex) 
            {
              old_grids[ilev][boxIndex] = dbl[lit()];
            }
        }
      
      pout() << "setupGrids for level " << new_level+1 << "/" << a_nLevs << ". level domain " << a_domains[new_level].domainBox() << endl;

      // want to keep these
      Vector<IntVectSet> tagVects_copy(a_nLevs-1);
      for (int ilev=0;ilev<new_level;ilev++)
        {
          tagVects_copy[ilev] = a_tagVects[ilev];
        }
      Vector<Vector<Box> > new_grids;
      new_finest_level = refiner.regrid( new_grids, tagVects_copy, 
                                         0, new_level-1, 
                                         old_grids );

      if (new_finest_level == new_level-1) 
        {
          a_same = true;
        }
      else
        {
          // test to see if grids have changed, create new DBLs
          a_same = true;
          for (int ilev=1; ilev<=new_finest_level; ++ilev)
            {
              int numGridsNew = new_grids[ilev].size();
              Vector<int> procIDs(numGridsNew);
              LoadBalance(procIDs, new_grids[ilev]);
              const DisjointBoxLayout newDBL( new_grids[ilev], procIDs,
                                              a_domains[ilev] );
              const DisjointBoxLayout oldDBL = a_grids[ilev];
              a_same &= oldDBL.sameBoxes(newDBL);
              a_grids[ilev] = newDBL;
            }
        }
      if (a_same)
        {
          pout() << "setupGrids -- grids unchanged" << endl;
        }
    }

  PetscFunctionReturn(0);
}
开发者ID:rsnemmen,项目名称:Chombo,代码行数:101,代码来源:testPetscCompGrid.cpp


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