1 // Copyright (c) 2010-2021, Lawrence Livermore National Security, LLC. Produced 2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files 3 // LICENSE and NOTICE for details. LLNL-CODE-806117. 4 // 5 // This file is part of the MFEM library. For more information and source code 6 // availability visit https://mfem.org. 7 // 8 // MFEM is free software; you can redistribute it and/or modify it under the 9 // terms of the BSD-3 license. We welcome feedback and contributions, see file 10 // CONTRIBUTING.md for details. 11 12 #include "mfem.hpp" 13 using namespace mfem; 14 15 #include "unit_tests.hpp" 16 17 // You typically want to start by testing things one object at a time. 18 TEST_CASE("IntegrationRules of Different Types", "[IntegrationRules]") 19 { 20 // This code is automatically re-executed for all of the sections. 21 IntegrationRules gauss_intrules(0, Quadrature1D::GaussLegendre); 22 IntegrationRules lobatto_intrules(0, Quadrature1D::GaussLobatto); 23 IntegrationRules oes_intrules(0, Quadrature1D::OpenUniform); 24 IntegrationRules ces_intrules(0, Quadrature1D::ClosedUniform); 25 26 27 28 // The tests will be reported in these sections. 29 // Each REQUIRE counts as an assertion. 30 // true = pass, false = fail 31 SECTION("Expected Number of points for GaussLegendre exactness") 32 { 33 // polynomial degree we want to exactly integrate 34 int exact = 4; 35 // exact for 2*np - 1 36 int pts_needed = 3; 37 38 const IntegrationRule *ir; 39 ir = &gauss_intrules.Get(Geometry::SEGMENT, exact); 40 REQUIRE(ir->Size() == pts_needed); 41 } 42 SECTION("Expected Number of points for GaussLobatto exactness") 43 { 44 // polynomial degree we want to exactly integrate 45 int exact = 4; 46 // exact for 2*np - 3 47 int pts_needed = 4; 48 49 const IntegrationRule *ir; 50 ir = &lobatto_intrules.Get(Geometry::SEGMENT, exact); 51 REQUIRE(ir->Size() == pts_needed); 52 } 53 } 54