本文整理汇总了C++中STK_Interface::getElementBlockNames方法的典型用法代码示例。如果您正苦于以下问题:C++ STK_Interface::getElementBlockNames方法的具体用法?C++ STK_Interface::getElementBlockNames怎么用?C++ STK_Interface::getElementBlockNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类STK_Interface
的用法示例。
在下文中一共展示了STK_Interface::getElementBlockNames方法的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());
}
}
示例2: coords
void
CustomMeshFactory::buildElements(STK_Interface &mesh) const
{
mesh.beginModification();
const int dim = mesh.getDimension();
// build the nodes
std::vector<double> coords(dim,0.0);
for (int i=0;i<NumNodesPerProc_;++i) {
for (int k=0;k<dim;++k)
coords[k] = Coords_[i*dim+k];
mesh.addNode(Nodes_[i], coords);
}
// build the elements
std::vector<std::string> block_ids;
mesh.getElementBlockNames(block_ids);
for (int i=0;i<NumElementsPerProc_;++i) {
// get block by its name
std::stringstream block_id;
block_id << "eblock-" << BlockIDs_[i];
stk_classic::mesh::Part *block = mesh.getElementBlockPart(block_id.str());
// construct element and its nodal connectivity
stk_classic::mesh::EntityId elt = i + OffsetToGlobalElementIDs_;
std::vector<stk_classic::mesh::EntityId> elt2nodes(8);
for (int k=0;k<8;++k)
elt2nodes[k] = Element2Nodes_[i*8+k];
RCP<ElementDescriptor> ed = rcp(new ElementDescriptor(elt,elt2nodes));
mesh.addElement(ed,block);
}
mesh.endModification();
}