本文整理汇总了C++中MeshEntity::num_entities方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshEntity::num_entities方法的具体用法?C++ MeshEntity::num_entities怎么用?C++ MeshEntity::num_entities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshEntity
的用法示例。
在下文中一共展示了MeshEntity::num_entities方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
//.........这里部分代码省略.........
for (std::vector<std::size_t>::iterator it
= submesh_cell_parent_indices.begin();
it != submesh_cell_parent_indices.end(); ++it)
{
parent_cell_indices[current_cell++] = *it;
}
// Initialise present MeshDomain
const MeshDomains& parent_domains = mesh.domains();
this->domains().init(parent_domains.max_dim());
// Collect MeshValueCollections from parent mesh
for (std::size_t dim_t = 0; dim_t <= parent_domains.max_dim(); dim_t++)
{
// If parent mesh does not has a data for dim_t
if (parent_domains.num_marked(dim_t) == 0)
continue;
// Initialise connectivity
mesh.init(dim_t, D);
// FIXME: Can avoid building this map for cell and vertices
// Build map from submesh entity (parent vertex list) -> (submesh index)
mesh.init(dim_t);
std::map<std::vector<std::size_t>, std::size_t> entity_map;
for (MeshEntityIterator e(*this, dim_t); !e.end(); ++e)
{
// Build list of entity vertex indices and sort
std::vector<std::size_t> vertex_list;
for (VertexIterator v(*e); !v.end(); ++v)
vertex_list.push_back(parent_vertex_indices[v->index()]);
std::sort(vertex_list.begin(), vertex_list.end());
entity_map.insert(std::make_pair(vertex_list, e->index()));
}
// Get submesh marker map
std::map<std::size_t, std::size_t>& submesh_markers
= this->domains().markers(dim_t);
// Get values map from parent MeshValueCollection
const std::map<std::size_t, std::size_t>& parent_markers
= parent_domains.markers(dim_t);
// Iterate over all parents marker values
std::map<std::size_t, std::size_t>::const_iterator itt;
for (itt = parent_markers.begin(); itt != parent_markers.end(); itt++)
{
// Create parent entity
const MeshEntity parent_entity(mesh, dim_t, itt->first);
// FIXME: Need to check all attached cells
std::size_t parent_cell_index = std::numeric_limits<std::size_t>::max();
if (dim_t == D)
{
parent_cell_index = itt->first;
}
else
{
// Get first parent cell index attached to parent entity
for (std::size_t i = 0; i < parent_entity.num_entities(D); ++i)
{
if (sub_domains[parent_entity.entities(D)[i]] == sub_domain)
{
parent_cell_index = parent_entity.entities(D)[i];
break;
}
}
}
// Check if the cell is included in the submesh
if (sub_domains[parent_cell_index] == sub_domain)
{
// Map markers from parent mesh to submesh
if (dim_t == D)
{
// Get submesh cell index
const std::size_t submesh_cell_index
= parent_to_submesh_cell_indices[parent_cell_index];
submesh_markers[submesh_cell_index] = itt->second;
}
else
{
std::vector<std::size_t> parent_vertex_list;
for (VertexIterator v(parent_entity); !v.end(); ++v)
parent_vertex_list.push_back(v->index());
std::sort(parent_vertex_list.begin(), parent_vertex_list.end());
// Get submesh entity index
std::map<std::vector<std::size_t>, std::size_t>::const_iterator
submesh_it = entity_map.find(parent_vertex_list);
dolfin_assert(submesh_it != entity_map.end());
submesh_markers[submesh_it->second] = itt->second;
}
}
}
}
}