Skip to content

Commit 1f2ea31

Browse files
authored
Merge pull request #3398 from lindsayad/partition-of-unity
Add partition-of-unity testing
2 parents 2e65b53 + 66b52ee commit 1f2ea31

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

tests/fe/fe_test.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#define FETEST \
2424
CPPUNIT_TEST( testU ); \
25+
CPPUNIT_TEST( testPartitionOfUnity ); \
2526
CPPUNIT_TEST( testGradU ); \
2627
CPPUNIT_TEST( testGradUComp ); \
2728
CPPUNIT_TEST( testHessU ); \
@@ -564,6 +565,81 @@ class FETest : public FETestBase<order, family, elem_type, 1> {
564565
#endif // LIBMESH_ENABLE_EXCEPTIONS
565566
}
566567

568+
void testPartitionOfUnity()
569+
{
570+
if (!this->_elem)
571+
return;
572+
573+
this->_fe->reinit(this->_elem);
574+
575+
bool satisfies_partition_of_unity = true;
576+
for (const auto qp : make_range(this->_qrule->n_points()))
577+
{
578+
Real phi_sum = 0;
579+
for (std::size_t d = 0; d != this->_dof_indices.size(); ++d)
580+
phi_sum += this->_fe->get_phi()[d][qp];
581+
if (phi_sum < (1 - TOLERANCE) || phi_sum > (1 + TOLERANCE))
582+
{
583+
satisfies_partition_of_unity = false;
584+
break;
585+
}
586+
}
587+
588+
switch (this->_fe->get_family())
589+
{
590+
case MONOMIAL:
591+
{
592+
switch (this->_fe->get_order())
593+
{
594+
case CONSTANT:
595+
CPPUNIT_ASSERT(satisfies_partition_of_unity);
596+
break;
597+
598+
default:
599+
CPPUNIT_ASSERT(!satisfies_partition_of_unity);
600+
break;
601+
}
602+
break;
603+
}
604+
case SZABAB:
605+
case HIERARCHIC:
606+
case L2_HIERARCHIC:
607+
{
608+
switch (this->_fe->get_order())
609+
{
610+
case FIRST:
611+
CPPUNIT_ASSERT(satisfies_partition_of_unity);
612+
break;
613+
614+
default:
615+
CPPUNIT_ASSERT(!satisfies_partition_of_unity);
616+
break;
617+
}
618+
break;
619+
}
620+
621+
case XYZ:
622+
case CLOUGH:
623+
case HERMITE:
624+
{
625+
CPPUNIT_ASSERT(!satisfies_partition_of_unity);
626+
break;
627+
}
628+
629+
case LAGRANGE:
630+
case L2_LAGRANGE:
631+
case BERNSTEIN:
632+
case RATIONAL_BERNSTEIN:
633+
{
634+
CPPUNIT_ASSERT(satisfies_partition_of_unity);
635+
break;
636+
}
637+
638+
default:
639+
CPPUNIT_FAIL("Uncovered FEFamily");
640+
}
641+
}
642+
567643

568644
void testU()
569645
{

0 commit comments

Comments
 (0)