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


C++ STK_Interface::elementLocalId方法代码示例

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


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

示例1: buildLocalIds

void buildLocalIds(const STK_Interface & mesh,
                   std::map<std::string,Teuchos::RCP<std::vector<std::size_t> > > & localIds)
{
   // defines ordering of blocks
   std::vector<std::string> blockIds;
   mesh.getElementBlockNames(blockIds);

   std::vector<std::string>::const_iterator idItr;
   for(idItr=blockIds.begin();idItr!=blockIds.end();++idItr) {
      std::string blockId = *idItr;

      localIds[blockId] = Teuchos::rcp(new std::vector<std::size_t>);
      std::vector<std::size_t> & localBlockIds = *localIds[blockId];

      // grab elements on this block
      std::vector<stk::mesh::Entity*> blockElmts;
      mesh.getMyElements(blockId,blockElmts);

      std::vector<stk::mesh::Entity*>::const_iterator itr;
      for(itr=blockElmts.begin();itr!=blockElmts.end();++itr)
         localBlockIds.push_back(mesh.elementLocalId(*itr));

      std::sort(localBlockIds.begin(),localBlockIds.end());
   }
}
开发者ID:gitter-badger,项目名称:quinoa,代码行数:25,代码来源:tSTK_IO.cpp

示例2: charge_density

  void
  CustomMeshFactory::fillSolutionFieldData(STK_Interface &mesh) const
  {
    for (int blk=0;blk<NumBlocks_;++blk) {

      std::stringstream block_id;
      block_id << "eblock-" << blk;
      
      // elements in this processor for this block
      std::vector<stk_classic::mesh::Entity*> elements;    
      mesh.getMyElements(block_id.str(), elements);

      // size of elements in the current block
      std::size_t n_elements = elements.size();
      
      // build local element index
      std::vector<std::size_t> local_ids;
      for (std::vector<stk_classic::mesh::Entity*>::const_iterator
             itr=elements.begin();itr!=elements.end();++itr) 
        local_ids.push_back(mesh.elementLocalId(*itr));

      // re-index solution fields in the same order of local_ids
      std::vector<double> charge_density_by_local_ids, electric_potential_by_local_ids;
      for (std::vector<stk_classic::mesh::Entity*>::const_iterator
             itr=elements.begin();itr!=elements.end();++itr) {
        int q = (*itr)->identifier() - OffsetToGlobalElementIDs_;
        for (int k=0;k<8;++k) {
          int loc = q*8 + k;
          charge_density_by_local_ids.push_back(ChargeDensity_[loc]);
          electric_potential_by_local_ids.push_back(ElectricPotential_[loc]);
        }
      }

      // wrap the buffer with a proper container
      FieldContainer charge_density(n_elements, 8, &charge_density_by_local_ids[0]),
        electric_potential(n_elements, 8, &electric_potential_by_local_ids[0]);

      // write out to stk mesh
      mesh.setSolutionFieldData("CHARGE_DENSITY",
                                block_id.str(),
                                local_ids,
                                charge_density, 1.0);
      
      mesh.setSolutionFieldData("ELECTRIC_POTENTIAL",
                                block_id.str(),
                                local_ids,
                                electric_potential, 1.0);
    }
  }
开发者ID:Russell-Jones-OxPhys,项目名称:Trilinos,代码行数:49,代码来源:Panzer_STK_CustomMeshFactory.cpp


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