https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Functions
ActiveElementFractionTest.C File Reference

Go to the source code of this file.

Functions

 TEST (ActiveElementFractionTest, UnitSquare)
 

Function Documentation

◆ TEST()

TEST ( ActiveElementFractionTest  ,
UnitSquare   
)

Definition at line 22 of file ActiveElementFractionTest.C.

23{
24 Parallel::Communicator comm(MPI_COMM_SELF);
25 auto mesh = std::make_unique<libMesh::SerialMesh>(comm);
26
27 Node * n0 = mesh->add_point(Point(0.0, 0.0, 0.0), 0);
28 Node * n1 = mesh->add_point(Point(1.0, 0.0, 0.0), 1);
29 Node * n2 = mesh->add_point(Point(1.0, 1.0, 0.0), 2);
30 Node * n3 = mesh->add_point(Point(0.0, 1.0, 0.0), 3);
31
32 auto quad = new Quad4();
33 quad->set_node(0, n0);
34 quad->set_node(1, n1);
35 quad->set_node(2, n2);
36 quad->set_node(3, n3);
37 const Elem * elem = mesh->add_elem(quad);
38
39 mesh->prepare_for_use();
40
41 const auto all_active = [](const Point &) { return true; };
42 const auto none_active = [](const Point &) { return false; };
43 const auto left_half = [](const Point & p) { return p(0) < 0.5; };
44
45 // SECOND-order Gauss has 2 points per dimension, symmetric about the centre with none on it.
46 EXPECT_NEAR(SBMUtils::activeElementFraction(*elem, SECOND, all_active), 1.0, 1e-12);
47 EXPECT_NEAR(SBMUtils::activeElementFraction(*elem, SECOND, none_active), 0.0, 1e-12);
48 EXPECT_NEAR(SBMUtils::activeElementFraction(*elem, SECOND, left_half), 0.5, 1e-12);
49}
const Real p
MeshBase & mesh
Real activeElementFraction(const Elem &elem, Order qrule_order, const std::function< bool(const libMesh::Point &)> &is_active)
Compute the fraction of an element's quadrature-weighted measure satisfying a predicate.
Definition SBMUtils.C:26