本文整理汇总了C++中Facet::num_entities方法的典型用法代码示例。如果您正苦于以下问题:C++ Facet::num_entities方法的具体用法?C++ Facet::num_entities怎么用?C++ Facet::num_entities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facet
的用法示例。
在下文中一共展示了Facet::num_entities方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reorder
//-----------------------------------------------------------------------------
void BoundaryComputation::reorder(std::vector<std::size_t>& vertices,
const Facet& facet)
{
// Get mesh
const Mesh& mesh = facet.mesh();
// Get the vertex opposite to the facet (the one we remove)
std::size_t vertex = 0;
const Cell cell(mesh, facet.entities(mesh.topology().dim())[0]);
for (std::size_t i = 0; i < cell.num_entities(0); i++)
{
bool not_in_facet = true;
vertex = cell.entities(0)[i];
for (std::size_t j = 0; j < facet.num_entities(0); j++)
{
if (vertex == facet.entities(0)[j])
{
not_in_facet = false;
break;
}
}
if (not_in_facet)
break;
}
const Point p = mesh.geometry().point(vertex);
// Check orientation
switch (mesh.type().cell_type())
{
case CellType::interval:
// Do nothing
break;
case CellType::triangle:
{
dolfin_assert(facet.num_entities(0) == 2);
const Point p0 = mesh.geometry().point(facet.entities(0)[0]);
const Point p1 = mesh.geometry().point(facet.entities(0)[1]);
const Point v = p1 - p0;
const Point n(v.y(), -v.x());
if (n.dot(p0 - p) < 0.0)
{
const std::size_t tmp = vertices[0];
vertices[0] = vertices[1];
vertices[1] = tmp;
}
}
break;
case CellType::tetrahedron:
{
dolfin_assert(facet.num_entities(0) == 3);
const Point p0 = mesh.geometry().point(facet.entities(0)[0]);
const Point p1 = mesh.geometry().point(facet.entities(0)[1]);
const Point p2 = mesh.geometry().point(facet.entities(0)[2]);
const Point v1 = p1 - p0;
const Point v2 = p2 - p0;
const Point n = v1.cross(v2);
if (n.dot(p0 - p) < 0.0)
{
const std::size_t tmp = vertices[0];
vertices[0] = vertices[1];
vertices[1] = tmp;
}
}
break;
default:
{
dolfin_error("BoundaryComputation.cpp",
"reorder cell for extraction of mesh boundary",
"Unknown cell type (%d)",
mesh.type().cell_type());
}
}
}