本文整理汇总了C++中MeshBase::elem方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshBase::elem方法的具体用法?C++ MeshBase::elem怎么用?C++ MeshBase::elem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshBase
的用法示例。
在下文中一共展示了MeshBase::elem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void MeshTools::Subdivision::add_boundary_ghosts(MeshBase & mesh)
{
static const Real tol = 1e-5;
// add the mirrored ghost elements (without using iterators, because the mesh is modified in the course)
std::vector<Tri3Subdivision *> ghost_elems;
std::vector<Node *> ghost_nodes;
const unsigned int n_elem = mesh.n_elem();
for (unsigned int eid = 0; eid < n_elem; ++eid)
{
Elem * elem = mesh.elem(eid);
libmesh_assert_equal_to(elem->type(), TRI3SUBDIVISION);
// If the triangle happens to be in a corner (two boundary
// edges), we perform a counter-clockwise loop by mirroring the
// previous triangle until we come back to the original
// triangle. This prevents degenerated triangles in the mesh
// corners and guarantees that the node in the middle of the
// loop is of valence=6.
for (unsigned int i = 0; i < elem->n_sides(); ++i)
{
libmesh_assert_not_equal_to(elem->neighbor(i), elem);
if (elem->neighbor(i) == libmesh_nullptr &&
elem->neighbor(next[i]) == libmesh_nullptr)
{
Elem * nelem = elem;
unsigned int k = i;
for (unsigned int l=0;l<4;l++)
{
// this is the vertex to be mirrored
Point point = nelem->point(k) + nelem->point(next[k]) - nelem->point(prev[k]);
// Check if the proposed vertex doesn't coincide
// with one of the existing vertices. This is
// necessary because for some triangulations, it can
// happen that two mirrored ghost vertices coincide,
// which would then lead to a zero size ghost
// element below.
Node * node = libmesh_nullptr;
for (unsigned int j = 0; j < ghost_nodes.size(); ++j)
{
if ((*ghost_nodes[j] - point).size() < tol * (elem->point(k) - point).size())
{
node = ghost_nodes[j];
break;
}
}
// add the new vertex only if no other is nearby
if (node == libmesh_nullptr)
{
node = mesh.add_point(point);
ghost_nodes.push_back(node);
}
Tri3Subdivision * newelem = new Tri3Subdivision();
// add the first new ghost element to the list just as in the non-corner case
if (l == 0)
ghost_elems.push_back(newelem);
newelem->set_node(0) = nelem->get_node(next[k]);
newelem->set_node(1) = nelem->get_node(k);
newelem->set_node(2) = node;
newelem->set_neighbor(0, nelem);
newelem->set_ghost(true);
if (l>0)
newelem->set_neighbor(2, libmesh_nullptr);
nelem->set_neighbor(k, newelem);
mesh.add_elem(newelem);
mesh.get_boundary_info().add_node(nelem->get_node(k), 1);
mesh.get_boundary_info().add_node(nelem->get_node(next[k]), 1);
mesh.get_boundary_info().add_node(nelem->get_node(prev[k]), 1);
mesh.get_boundary_info().add_node(node, 1);
nelem = newelem;
k = 2 ;
}
Tri3Subdivision * newelem = new Tri3Subdivision();
newelem->set_node(0) = elem->get_node(next[i]);
newelem->set_node(1) = nelem->get_node(2);
newelem->set_node(2) = elem->get_node(prev[i]);
newelem->set_neighbor(0, nelem);
nelem->set_neighbor(2, newelem);
newelem->set_ghost(true);
newelem->set_neighbor(2, elem);
elem->set_neighbor(next[i],newelem);
mesh.add_elem(newelem);
break;
}
}
for (unsigned int i = 0; i < elem->n_sides(); ++i)
{
//.........这里部分代码省略.........