本文整理汇总了C++中MeshBase::active_local_element_ptr_range方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshBase::active_local_element_ptr_range方法的具体用法?C++ MeshBase::active_local_element_ptr_range怎么用?C++ MeshBase::active_local_element_ptr_range使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshBase
的用法示例。
在下文中一共展示了MeshBase::active_local_element_ptr_range方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: integrate_function
void integrate_function (const MeshBase & mesh)
{
#if defined(LIBMESH_HAVE_TRIANGLE) && defined(LIBMESH_HAVE_TETGEN)
std::vector<Real> vertex_distance;
QComposite<QGauss> qrule (mesh.mesh_dimension(), FIRST);
//QGauss qrule (mesh.mesh_dimension(), FIRST);
std::unique_ptr<FEBase> fe (FEBase::build (mesh.mesh_dimension(), FEType (FIRST, LAGRANGE)));
Real int_val=0.;
const std::vector<Point> & q_points = fe->get_xyz();
const std::vector<Real> & JxW = fe->get_JxW();
for (const auto & elem : mesh.active_local_element_ptr_range())
{
vertex_distance.clear();
for (unsigned int v=0; v<elem->n_vertices(); v++)
vertex_distance.push_back (distance(elem->point(v)));
qrule.init (*elem, vertex_distance);
fe->reinit (elem,
&(qrule.get_points()),
&(qrule.get_weights()));
// TODO: would it be valuable to have the composite quadrature rule sort
// from smallest to largest JxW value to help prevent
// ... large + small + large + large + small ...
// type truncation errors?
for (std::size_t qp=0; qp<q_points.size(); qp++)
int_val += JxW[qp] * integrand(q_points[qp]);
}
mesh.comm().sum (int_val);
libMesh::out << "\n***********************************\n"
<< " int_val = " << int_val << std::endl
<< " exact_val = " << 1*(2*2 - radius*radius*pi) + 10.*(radius*radius*pi)
<< "\n***********************************\n"
<< std::endl;
#else
libmesh_ignore(mesh);
#endif
}