From fe006402cf3d60ded068cf88aaa72402263a72f3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 25 Apr 2023 13:33:02 -0600 Subject: [PATCH] Add a test. --- tests/feinterface/fe_interface_values_14.cc | 125 ++++++++++++++++++ .../feinterface/fe_interface_values_14.output | 7 + 2 files changed, 132 insertions(+) create mode 100644 tests/feinterface/fe_interface_values_14.cc create mode 100644 tests/feinterface/fe_interface_values_14.output diff --git a/tests/feinterface/fe_interface_values_14.cc b/tests/feinterface/fe_interface_values_14.cc new file mode 100644 index 0000000000..07c006afe7 --- /dev/null +++ b/tests/feinterface/fe_interface_values_14.cc @@ -0,0 +1,125 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2018 - 2021 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Set up a two cells with different elements, such that neither element +// dominates. Create an FEInterfaceValues object and call reinit on it. +// +// In this test case, there is only one quadrature and mapping, so +// that is the only reasonable choice. + +#include + +#include +#include +#include + +#include +#include + +#include "../tests.h" + +template +void +make_2_cells(Triangulation &tria); + +template <> +void +make_2_cells<2>(Triangulation<2> &tria) +{ + const unsigned int dim = 2; + std::vector repetitions = {2, 1}; + Point p1; + Point p2(2.0, 1.0); + + GridGenerator::subdivided_hyper_rectangle(tria, repetitions, p1, p2); +} + + +template +void +test() +{ + Triangulation tria; + make_2_cells(tria); + + const unsigned max_fe_degree = 2; + const FESystem fe_left(FE_Q(1), FE_Q(2)); + const FESystem fe_right(FE_Q(2), FE_Q(1)); + + hp::FECollection fe_collection; + fe_collection.push_back(fe_left); + fe_collection.push_back(fe_right); + + DoFHandler dofh(tria); + + const unsigned int face_index = 1; + + auto cell = dofh.begin(); + auto neighbor = cell->neighbor(face_index); + + cell->set_active_fe_index(0); + neighbor->set_active_fe_index(1); + + dofh.distribute_dofs(fe_collection); + + const QGauss quadrature(max_fe_degree + 1); + const hp::QCollection q_collection(quadrature); + + const MappingQ mapping(1); + const hp::MappingCollection mapping_collection(mapping); + + + deallog << "Adjacent finite elements: " << cell->get_fe().get_name() + << " and " << neighbor->get_fe().get_name() << std::endl; + + const UpdateFlags update_flags = update_values; + FEInterfaceValues fiv(mapping_collection, + fe_collection, + q_collection, + update_flags); + fiv.reinit(cell, + face_index, + /* subface_no */ numbers::invalid_unsigned_int, + neighbor, + cell->neighbor_of_neighbor(face_index), + /* subface_no_neighbor */ numbers::invalid_unsigned_int, + /* q_index */ numbers::invalid_unsigned_int, + /* mapping_index */ numbers::invalid_unsigned_int, + /* fe_index */ numbers::invalid_unsigned_int); + + deallog << "Chosen quadrature for the common face has " + << fiv.get_fe_face_values(0).get_quadrature().size() + << " quadrature points. These points are located at:" << std::endl; + for (const auto p : fiv.get_fe_face_values(0).get_quadrature().get_points()) + deallog << " " << p << std::endl; + + // Also check that we see the same quadrature formula from both + // sides: + Assert(fiv.get_fe_face_values(0).get_quadrature().get_points() == + fiv.get_fe_face_values(1).get_quadrature().get_points(), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int +main() +{ + initlog(); + test<2>(); +} diff --git a/tests/feinterface/fe_interface_values_14.output b/tests/feinterface/fe_interface_values_14.output new file mode 100644 index 0000000000..f3c0a20f22 --- /dev/null +++ b/tests/feinterface/fe_interface_values_14.output @@ -0,0 +1,7 @@ + +DEAL::Adjacent finite elements: FESystem<2>[FE_Q<2>(1)-FE_Q<2>(2)] and FESystem<2>[FE_Q<2>(2)-FE_Q<2>(1)] +DEAL::Chosen quadrature for the common face has 3 quadrature points. These points are located at: +DEAL:: 0.112702 +DEAL:: 0.500000 +DEAL:: 0.887298 +DEAL::OK -- 2.39.5