From ef8634ce69b712f1fc3374d41a9222e044322e3e Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 20 Aug 2024 17:25:05 -0600 Subject: [PATCH] Add test. --- tests/fe/has_support_points_01.cc | 192 ++++++++++++++++++ tests/fe/has_support_points_01.output | 281 ++++++++++++++++++++++++++ 2 files changed, 473 insertions(+) create mode 100644 tests/fe/has_support_points_01.cc create mode 100644 tests/fe/has_support_points_01.output diff --git a/tests/fe/has_support_points_01.cc b/tests/fe/has_support_points_01.cc new file mode 100644 index 0000000000..34d1fd0f95 --- /dev/null +++ b/tests/fe/has_support_points_01.cc @@ -0,0 +1,192 @@ +// ------------------------------------------------------------------------ +// +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (C) 2001 - 2021 by the deal.II authors +// +// This file is part of the deal.II library. +// +// Part of the source code is dual licensed under Apache-2.0 WITH +// LLVM-exception OR LGPL-2.1-or-later. Detailed license information +// governing the source code and code contributions can be found in +// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. +// +// ------------------------------------------------------------------------ + + +// Test FiniteElement::has_support_points() for various elements, +// including FE_Nothing. + + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "../tests.h" + + +template +void +test_2d_3d(std::vector *> &finite_elements) +{ + // Vector DG elements + finite_elements.push_back(new FE_DGRaviartThomas(0)); + finite_elements.push_back(new FE_DGRaviartThomas(1)); + finite_elements.push_back(new FE_DGBDM(1)); + finite_elements.push_back(new FE_DGBDM(2)); + finite_elements.push_back(new FE_DGNedelec(0)); + finite_elements.push_back(new FE_DGNedelec(1)); + + // Hdiv elements + FE_RaviartThomas *rt0 = new FE_RaviartThomas(0); + finite_elements.push_back(rt0); + + FE_RaviartThomas *rt1 = new FE_RaviartThomas(1); + finite_elements.push_back(rt1); + + finite_elements.push_back(new FE_RaviartThomas(2)); + finite_elements.push_back(new FESystem(*rt1, 1, FE_DGQ(1), 1)); + + finite_elements.push_back(new FE_BDM(1)); + finite_elements.push_back(new FE_BDM(2)); + + // Hcurl elements + FE_Nedelec *ned0 = new FE_Nedelec(0); + finite_elements.push_back(ned0); + FE_Nedelec *ned1 = new FE_Nedelec(1); + finite_elements.push_back(ned1); +} + + + +void +test_2d_3d(std::vector *> &finite_elements) +{} + + + +template +void +test_finite_elements() +{ + std::vector *> finite_elements; + finite_elements.push_back(new FE_Nothing()); + finite_elements.push_back(new FE_Q(1)); + finite_elements.push_back(new FE_Q(2)); + finite_elements.push_back(new FE_Q(4)); + finite_elements.push_back(new FE_Q_Hierarchical(1)); + finite_elements.push_back(new FE_Q_Hierarchical(2)); + finite_elements.push_back(new FE_Q_Hierarchical(4)); + finite_elements.push_back(new FE_DGQ(1)); + finite_elements.push_back(new FE_DGQ(2)); + finite_elements.push_back( + new FE_DGQArbitraryNodes(QIterated<1>(QTrapezoid<1>(), 4))); + finite_elements.push_back(new FE_DGQ(4)); + finite_elements.push_back(new FE_DGQArbitraryNodes(QGauss<1>(3))); + finite_elements.push_back(new FE_DGQLegendre(1)); + finite_elements.push_back(new FE_DGQLegendre(2)); + finite_elements.push_back(new FE_DGQHermite(3)); + finite_elements.push_back(new FE_DGP(1)); + finite_elements.push_back(new FE_DGP(2)); + finite_elements.push_back(new FESystem(FE_Q(2), 2)); + finite_elements.push_back( + new FESystem(FE_Q(1), 2, FE_Q(2), 1)); + finite_elements.push_back( + new FESystem(FE_Q(1), 2, FE_Q(2), 1, FE_Nothing(), 2)); + + // Face Q elements + finite_elements.push_back(new FE_FaceQ(0)); + finite_elements.push_back(new FE_FaceQ(1)); + finite_elements.push_back(new FE_FaceQ(3)); + // Face P elements + finite_elements.push_back(new FE_FaceP(0)); + finite_elements.push_back(new FE_FaceP(1)); + finite_elements.push_back(new FE_FaceP(3)); + + + // Check vector elements in 2d and higher only + test_2d_3d(finite_elements); + + if (dim == 2) + { + finite_elements.push_back(new FE_DGBDM(1)); + finite_elements.push_back(new FE_DGBDM(2)); + } + if (dim > 1) + { + FE_RaviartThomasNodal *rt0 = new FE_RaviartThomasNodal(0); + FE_RaviartThomasNodal *rt1 = new FE_RaviartThomasNodal(1); + finite_elements.push_back(rt0); + finite_elements.push_back(rt1); + finite_elements.push_back(new FESystem(*rt1, 1, FE_DGQ(1), 1)); + finite_elements.push_back( + new FESystem(*rt1, 1, FE_DGQ(1), 1, FE_Nothing(), 1)); + } + + + finite_elements.push_back(new FESystem(FE_Q(3), 2)); + finite_elements.push_back( + new FESystem(FE_Q(1), 2, FE_Q(3), 1)); + finite_elements.push_back(new FESystem(FE_Q(4), 2)); + + // have systems of systems, and + // construct hierarchies of + // subsequently weirder elements by + // taking each of them in turn as + // basis of others + finite_elements.push_back( + new FESystem(FESystem(FE_Q(1), 2), 2)); + finite_elements.push_back(new FESystem( + FESystem(FE_Q(1), 2), 1, FESystem(FE_DGQ(1), 2), 1)); + finite_elements.push_back( + new FESystem(FESystem(FE_Q(1), 1, FE_Q(2), 1), + 1, + FESystem(FE_Q(2), 2), + 1, + FESystem(FE_DGQ(2), 2), + 1)); + finite_elements.push_back( + new FESystem(*finite_elements[finite_elements.size() - 3], + 2, + *finite_elements[finite_elements.size() - 2], + 1, + *finite_elements[finite_elements.size() - 1], + 2)); + + deallog << std::endl << "dim=" << dim << std::endl; + for (unsigned int n = 0; n < finite_elements.size(); ++n) + { + FiniteElement *fe_data = finite_elements[n]; + deallog << " " << fe_data->get_name() << std::endl; + deallog << " has_support_points=" + << (fe_data->has_support_points() ? "true" : "false") + << std::endl; + } + + // delete all FiniteElement objects + for (unsigned int i = 0; i < finite_elements.size(); ++i) + delete finite_elements[i]; +} + +int +main() +{ + initlog(); + + test_finite_elements<1>(); + test_finite_elements<2>(); + test_finite_elements<3>(); +} diff --git a/tests/fe/has_support_points_01.output b/tests/fe/has_support_points_01.output new file mode 100644 index 0000000000..ffea1435dc --- /dev/null +++ b/tests/fe/has_support_points_01.output @@ -0,0 +1,281 @@ + +DEAL:: +DEAL::dim=1 +DEAL:: FE_Nothing<1>() +DEAL:: has_support_points=true +DEAL:: FE_Q<1>(1) +DEAL:: has_support_points=true +DEAL:: FE_Q<1>(2) +DEAL:: has_support_points=true +DEAL:: FE_Q<1>(4) +DEAL:: has_support_points=true +DEAL:: FE_Q_Hierarchical<1>(1) +DEAL:: has_support_points=false +DEAL:: FE_Q_Hierarchical<1>(2) +DEAL:: has_support_points=false +DEAL:: FE_Q_Hierarchical<1>(4) +DEAL:: has_support_points=false +DEAL:: FE_DGQ<1>(1) +DEAL:: has_support_points=true +DEAL:: FE_DGQ<1>(2) +DEAL:: has_support_points=true +DEAL:: FE_DGQArbitraryNodes<1>(QIterated(QTrapezoid(),4)) +DEAL:: has_support_points=true +DEAL:: FE_DGQ<1>(4) +DEAL:: has_support_points=true +DEAL:: FE_DGQArbitraryNodes<1>(QGauss(3)) +DEAL:: has_support_points=true +DEAL:: FE_DGQLegendre<1>(1) +DEAL:: has_support_points=false +DEAL:: FE_DGQLegendre<1>(2) +DEAL:: has_support_points=false +DEAL:: FE_DGQHermite<1>(3) +DEAL:: has_support_points=false +DEAL:: FE_DGP<1>(1) +DEAL:: has_support_points=false +DEAL:: FE_DGP<1>(2) +DEAL:: has_support_points=false +DEAL:: FESystem<1>[FE_Q<1>(2)^2] +DEAL:: has_support_points=true +DEAL:: FESystem<1>[FE_Q<1>(1)^2-FE_Q<1>(2)] +DEAL:: has_support_points=true +DEAL:: FESystem<1>[FE_Q<1>(1)^2-FE_Q<1>(2)-FE_Nothing<1>()^2] +DEAL:: has_support_points=true +DEAL:: FE_FaceQ<1>(0) +DEAL:: has_support_points=true +DEAL:: FE_FaceQ<1>(1) +DEAL:: has_support_points=true +DEAL:: FE_FaceQ<1>(3) +DEAL:: has_support_points=true +DEAL:: FE_FaceP<1>(0) +DEAL:: has_support_points=true +DEAL:: FE_FaceP<1>(1) +DEAL:: has_support_points=true +DEAL:: FE_FaceP<1>(3) +DEAL:: has_support_points=true +DEAL:: FESystem<1>[FE_Q<1>(3)^2] +DEAL:: has_support_points=true +DEAL:: FESystem<1>[FE_Q<1>(1)^2-FE_Q<1>(3)] +DEAL:: has_support_points=true +DEAL:: FESystem<1>[FE_Q<1>(4)^2] +DEAL:: has_support_points=true +DEAL:: FESystem<1>[FESystem<1>[FE_Q<1>(1)^2]^2] +DEAL:: has_support_points=true +DEAL:: FESystem<1>[FESystem<1>[FE_Q<1>(1)^2]-FESystem<1>[FE_DGQ<1>(1)^2]] +DEAL:: has_support_points=true +DEAL:: FESystem<1>[FESystem<1>[FE_Q<1>(1)-FE_Q<1>(2)]-FESystem<1>[FE_Q<1>(2)^2]-FESystem<1>[FE_DGQ<1>(2)^2]] +DEAL:: has_support_points=true +DEAL:: FESystem<1>[FESystem<1>[FESystem<1>[FE_Q<1>(1)^2]^2]^2-FESystem<1>[FESystem<1>[FE_Q<1>(1)^2]-FESystem<1>[FE_DGQ<1>(1)^2]]-FESystem<1>[FESystem<1>[FE_Q<1>(1)-FE_Q<1>(2)]-FESystem<1>[FE_Q<1>(2)^2]-FESystem<1>[FE_DGQ<1>(2)^2]]^2] +DEAL:: has_support_points=true +DEAL:: +DEAL::dim=2 +DEAL:: FE_Nothing<2>() +DEAL:: has_support_points=true +DEAL:: FE_Q<2>(1) +DEAL:: has_support_points=true +DEAL:: FE_Q<2>(2) +DEAL:: has_support_points=true +DEAL:: FE_Q<2>(4) +DEAL:: has_support_points=true +DEAL:: FE_Q_Hierarchical<2>(1) +DEAL:: has_support_points=false +DEAL:: FE_Q_Hierarchical<2>(2) +DEAL:: has_support_points=false +DEAL:: FE_Q_Hierarchical<2>(4) +DEAL:: has_support_points=false +DEAL:: FE_DGQ<2>(1) +DEAL:: has_support_points=true +DEAL:: FE_DGQ<2>(2) +DEAL:: has_support_points=true +DEAL:: FE_DGQArbitraryNodes<2>(QIterated(QTrapezoid(),4)) +DEAL:: has_support_points=true +DEAL:: FE_DGQ<2>(4) +DEAL:: has_support_points=true +DEAL:: FE_DGQArbitraryNodes<2>(QGauss(3)) +DEAL:: has_support_points=true +DEAL:: FE_DGQLegendre<2>(1) +DEAL:: has_support_points=false +DEAL:: FE_DGQLegendre<2>(2) +DEAL:: has_support_points=false +DEAL:: FE_DGQHermite<2>(3) +DEAL:: has_support_points=false +DEAL:: FE_DGP<2>(1) +DEAL:: has_support_points=false +DEAL:: FE_DGP<2>(2) +DEAL:: has_support_points=false +DEAL:: FESystem<2>[FE_Q<2>(2)^2] +DEAL:: has_support_points=true +DEAL:: FESystem<2>[FE_Q<2>(1)^2-FE_Q<2>(2)] +DEAL:: has_support_points=true +DEAL:: FESystem<2>[FE_Q<2>(1)^2-FE_Q<2>(2)-FE_Nothing<2>()^2] +DEAL:: has_support_points=true +DEAL:: FE_FaceQ<2>(0) +DEAL:: has_support_points=true +DEAL:: FE_FaceQ<2>(1) +DEAL:: has_support_points=true +DEAL:: FE_FaceQ<2>(3) +DEAL:: has_support_points=true +DEAL:: FE_FaceP<2>(0) +DEAL:: has_support_points=false +DEAL:: FE_FaceP<2>(1) +DEAL:: has_support_points=false +DEAL:: FE_FaceP<2>(3) +DEAL:: has_support_points=false +DEAL:: FE_DGRaviartThomas<2>(0) +DEAL:: has_support_points=false +DEAL:: FE_DGRaviartThomas<2>(1) +DEAL:: has_support_points=false +DEAL:: FE_DGBDM<2>(1) +DEAL:: has_support_points=false +DEAL:: FE_DGBDM<2>(2) +DEAL:: has_support_points=false +DEAL:: FE_DGNedelec<2>(0) +DEAL:: has_support_points=false +DEAL:: FE_DGNedelec<2>(1) +DEAL:: has_support_points=false +DEAL:: FE_RaviartThomas<2>(0) +DEAL:: has_support_points=false +DEAL:: FE_RaviartThomas<2>(1) +DEAL:: has_support_points=false +DEAL:: FE_RaviartThomas<2>(2) +DEAL:: has_support_points=false +DEAL:: FESystem<2>[FE_RaviartThomas<2>(1)-FE_DGQ<2>(1)] +DEAL:: has_support_points=false +DEAL:: FE_BDM<2>(1) +DEAL:: has_support_points=false +DEAL:: FE_BDM<2>(2) +DEAL:: has_support_points=false +DEAL:: FE_Nedelec<2>(0) +DEAL:: has_support_points=false +DEAL:: FE_Nedelec<2>(1) +DEAL:: has_support_points=false +DEAL:: FE_DGBDM<2>(1) +DEAL:: has_support_points=false +DEAL:: FE_DGBDM<2>(2) +DEAL:: has_support_points=false +DEAL:: FE_RaviartThomasNodal<2>(0) +DEAL:: has_support_points=false +DEAL:: FE_RaviartThomasNodal<2>(1) +DEAL:: has_support_points=false +DEAL:: FESystem<2>[FE_RaviartThomasNodal<2>(1)-FE_DGQ<2>(1)] +DEAL:: has_support_points=false +DEAL:: FESystem<2>[FE_RaviartThomasNodal<2>(1)-FE_DGQ<2>(1)-FE_Nothing<2>()] +DEAL:: has_support_points=false +DEAL:: FESystem<2>[FE_Q<2>(3)^2] +DEAL:: has_support_points=true +DEAL:: FESystem<2>[FE_Q<2>(1)^2-FE_Q<2>(3)] +DEAL:: has_support_points=true +DEAL:: FESystem<2>[FE_Q<2>(4)^2] +DEAL:: has_support_points=true +DEAL:: FESystem<2>[FESystem<2>[FE_Q<2>(1)^2]^2] +DEAL:: has_support_points=true +DEAL:: FESystem<2>[FESystem<2>[FE_Q<2>(1)^2]-FESystem<2>[FE_DGQ<2>(1)^2]] +DEAL:: has_support_points=true +DEAL:: FESystem<2>[FESystem<2>[FE_Q<2>(1)-FE_Q<2>(2)]-FESystem<2>[FE_Q<2>(2)^2]-FESystem<2>[FE_DGQ<2>(2)^2]] +DEAL:: has_support_points=true +DEAL:: FESystem<2>[FESystem<2>[FESystem<2>[FE_Q<2>(1)^2]^2]^2-FESystem<2>[FESystem<2>[FE_Q<2>(1)^2]-FESystem<2>[FE_DGQ<2>(1)^2]]-FESystem<2>[FESystem<2>[FE_Q<2>(1)-FE_Q<2>(2)]-FESystem<2>[FE_Q<2>(2)^2]-FESystem<2>[FE_DGQ<2>(2)^2]]^2] +DEAL:: has_support_points=true +DEAL:: +DEAL::dim=3 +DEAL:: FE_Nothing<3>() +DEAL:: has_support_points=true +DEAL:: FE_Q<3>(1) +DEAL:: has_support_points=true +DEAL:: FE_Q<3>(2) +DEAL:: has_support_points=true +DEAL:: FE_Q<3>(4) +DEAL:: has_support_points=true +DEAL:: FE_Q_Hierarchical<3>(1) +DEAL:: has_support_points=false +DEAL:: FE_Q_Hierarchical<3>(2) +DEAL:: has_support_points=false +DEAL:: FE_Q_Hierarchical<3>(4) +DEAL:: has_support_points=false +DEAL:: FE_DGQ<3>(1) +DEAL:: has_support_points=true +DEAL:: FE_DGQ<3>(2) +DEAL:: has_support_points=true +DEAL:: FE_DGQArbitraryNodes<3>(QIterated(QTrapezoid(),4)) +DEAL:: has_support_points=true +DEAL:: FE_DGQ<3>(4) +DEAL:: has_support_points=true +DEAL:: FE_DGQArbitraryNodes<3>(QGauss(3)) +DEAL:: has_support_points=true +DEAL:: FE_DGQLegendre<3>(1) +DEAL:: has_support_points=false +DEAL:: FE_DGQLegendre<3>(2) +DEAL:: has_support_points=false +DEAL:: FE_DGQHermite<3>(3) +DEAL:: has_support_points=false +DEAL:: FE_DGP<3>(1) +DEAL:: has_support_points=false +DEAL:: FE_DGP<3>(2) +DEAL:: has_support_points=false +DEAL:: FESystem<3>[FE_Q<3>(2)^2] +DEAL:: has_support_points=true +DEAL:: FESystem<3>[FE_Q<3>(1)^2-FE_Q<3>(2)] +DEAL:: has_support_points=true +DEAL:: FESystem<3>[FE_Q<3>(1)^2-FE_Q<3>(2)-FE_Nothing<3>()^2] +DEAL:: has_support_points=true +DEAL:: FE_FaceQ<3>(0) +DEAL:: has_support_points=true +DEAL:: FE_FaceQ<3>(1) +DEAL:: has_support_points=true +DEAL:: FE_FaceQ<3>(3) +DEAL:: has_support_points=true +DEAL:: FE_FaceP<3>(0) +DEAL:: has_support_points=false +DEAL:: FE_FaceP<3>(1) +DEAL:: has_support_points=false +DEAL:: FE_FaceP<3>(3) +DEAL:: has_support_points=false +DEAL:: FE_DGRaviartThomas<3>(0) +DEAL:: has_support_points=false +DEAL:: FE_DGRaviartThomas<3>(1) +DEAL:: has_support_points=false +DEAL:: FE_DGBDM<3>(1) +DEAL:: has_support_points=false +DEAL:: FE_DGBDM<3>(2) +DEAL:: has_support_points=false +DEAL:: FE_DGNedelec<3>(0) +DEAL:: has_support_points=false +DEAL:: FE_DGNedelec<3>(1) +DEAL:: has_support_points=false +DEAL:: FE_RaviartThomas<3>(0) +DEAL:: has_support_points=false +DEAL:: FE_RaviartThomas<3>(1) +DEAL:: has_support_points=false +DEAL:: FE_RaviartThomas<3>(2) +DEAL:: has_support_points=false +DEAL:: FESystem<3>[FE_RaviartThomas<3>(1)-FE_DGQ<3>(1)] +DEAL:: has_support_points=false +DEAL:: FE_BDM<3>(1) +DEAL:: has_support_points=false +DEAL:: FE_BDM<3>(2) +DEAL:: has_support_points=false +DEAL:: FE_Nedelec<3>(0) +DEAL:: has_support_points=false +DEAL:: FE_Nedelec<3>(1) +DEAL:: has_support_points=false +DEAL:: FE_RaviartThomasNodal<3>(0) +DEAL:: has_support_points=false +DEAL:: FE_RaviartThomasNodal<3>(1) +DEAL:: has_support_points=false +DEAL:: FESystem<3>[FE_RaviartThomasNodal<3>(1)-FE_DGQ<3>(1)] +DEAL:: has_support_points=false +DEAL:: FESystem<3>[FE_RaviartThomasNodal<3>(1)-FE_DGQ<3>(1)-FE_Nothing<3>()] +DEAL:: has_support_points=false +DEAL:: FESystem<3>[FE_Q<3>(3)^2] +DEAL:: has_support_points=true +DEAL:: FESystem<3>[FE_Q<3>(1)^2-FE_Q<3>(3)] +DEAL:: has_support_points=true +DEAL:: FESystem<3>[FE_Q<3>(4)^2] +DEAL:: has_support_points=true +DEAL:: FESystem<3>[FESystem<3>[FE_Q<3>(1)^2]^2] +DEAL:: has_support_points=true +DEAL:: FESystem<3>[FESystem<3>[FE_Q<3>(1)^2]-FESystem<3>[FE_DGQ<3>(1)^2]] +DEAL:: has_support_points=true +DEAL:: FESystem<3>[FESystem<3>[FE_Q<3>(1)-FE_Q<3>(2)]-FESystem<3>[FE_Q<3>(2)^2]-FESystem<3>[FE_DGQ<3>(2)^2]] +DEAL:: has_support_points=true +DEAL:: FESystem<3>[FESystem<3>[FESystem<3>[FE_Q<3>(1)^2]^2]^2-FESystem<3>[FESystem<3>[FE_Q<3>(1)^2]-FESystem<3>[FE_DGQ<3>(1)^2]]-FESystem<3>[FESystem<3>[FE_Q<3>(1)-FE_Q<3>(2)]-FESystem<3>[FE_Q<3>(2)^2]-FESystem<3>[FE_DGQ<3>(2)^2]]^2] +DEAL:: has_support_points=true -- 2.39.5