From acfa2f93f0ddf7460480ded1448be9652f4fa626 Mon Sep 17 00:00:00 2001 From: Wyatt Smith Date: Sat, 7 Jun 2025 10:34:19 -0600 Subject: [PATCH] added test for shape_grad adapted fe_interface_values_07.cc to check the jumps and averages of the shape function gradients across each face instead of their values --- tests/feinterface/fe_interface_values_17.cc | 116 ++++++++++++++++++ .../feinterface/fe_interface_values_17.output | 11 ++ 2 files changed, 127 insertions(+) create mode 100644 tests/feinterface/fe_interface_values_17.cc create mode 100644 tests/feinterface/fe_interface_values_17.output diff --git a/tests/feinterface/fe_interface_values_17.cc b/tests/feinterface/fe_interface_values_17.cc new file mode 100644 index 0000000000..6ce89d7050 --- /dev/null +++ b/tests/feinterface/fe_interface_values_17.cc @@ -0,0 +1,116 @@ +// ------------------------------------------------------------------------ +// +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (C) 2019 - 2023 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. +// +// ------------------------------------------------------------------------ + + +// evaluate jump_in_shape_gradients(), average_of_shape_gradients(), +// shape_grad() of FEInterfaceValues like fe_interface_values_02, but for a +// continuous element + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "../tests.h" + +#include "../test_grids.h" + + +template +void +test(unsigned int fe_degree) +{ + Triangulation tria; + TestGrids::hyper_line(tria, 2); + + DoFHandler dofh(tria); + FE_Q fe(fe_degree); + deallog << fe.get_name() << std::endl; + dofh.distribute_dofs(fe); + + MappingQ mapping(1); + UpdateFlags update_flags = update_values | update_gradients | + update_quadrature_points | update_JxW_values; + + FEInterfaceValues fiv(mapping, + fe, + QGauss(fe.degree + 1), + update_flags); + + + auto cell = dofh.begin(); + + for (const unsigned int f : GeometryInfo::face_indices()) + if (!cell->at_boundary(f)) + { + fiv.reinit(cell, + f, + numbers::invalid_unsigned_int, + cell->neighbor(f), + cell->neighbor_of_neighbor(f), + numbers::invalid_unsigned_int); + + const unsigned int n_dofs = fiv.n_current_interface_dofs(); + std::vector> cell_vector(n_dofs); + + const auto &q_points = fiv.get_quadrature_points(); + + std::fill(cell_vector.begin(), cell_vector.end(), 0); + for (unsigned int qpoint = 0; qpoint < q_points.size(); ++qpoint) + for (unsigned int i = 0; i < n_dofs; ++i) + cell_vector[i] += + fiv.shape_grad(true, i, qpoint) * fiv.get_JxW_values()[qpoint]; + deallog << "shape_grad(true): " << cell_vector << std::endl; + + std::fill(cell_vector.begin(), cell_vector.end(), 0); + for (unsigned int qpoint = 0; qpoint < q_points.size(); ++qpoint) + for (unsigned int i = 0; i < n_dofs; ++i) + cell_vector[i] += + fiv.shape_grad(false, i, qpoint) * fiv.get_JxW_values()[qpoint]; + deallog << "shape_grad(false): " << cell_vector << std::endl; + + + std::fill(cell_vector.begin(), cell_vector.end(), 0); + for (unsigned int qpoint = 0; qpoint < q_points.size(); ++qpoint) + for (unsigned int i = 0; i < n_dofs; ++i) + cell_vector[i] += fiv.jump_in_shape_gradients(i, qpoint) * + fiv.get_JxW_values()[qpoint]; + deallog << "jump_in_shape_gradients(): " << cell_vector << std::endl; + + std::fill(cell_vector.begin(), cell_vector.end(), 0); + for (unsigned int qpoint = 0; qpoint < q_points.size(); ++qpoint) + for (unsigned int i = 0; i < n_dofs; ++i) + cell_vector[i] += fiv.average_of_shape_gradients(i, qpoint) * + fiv.get_JxW_values()[qpoint]; + deallog << "average_of_shape_gradients(): " << cell_vector << std::endl; + } +} + + + +int +main() +{ + initlog(); + test<2>(1); + test<3>(1); +} diff --git a/tests/feinterface/fe_interface_values_17.output b/tests/feinterface/fe_interface_values_17.output new file mode 100644 index 0000000000..555fa311f3 --- /dev/null +++ b/tests/feinterface/fe_interface_values_17.output @@ -0,0 +1,11 @@ + +DEAL::FE_Q<2>(1) +DEAL::shape_grad(true): -0.500000 0.00000 0.500000 -1.00000 -0.500000 0.00000 0.500000 1.00000 0.00000 0.00000 0.00000 0.00000 +DEAL::shape_grad(false): 0.00000 0.00000 -0.500000 -1.00000 0.00000 0.00000 -0.500000 1.00000 0.500000 0.00000 0.500000 0.00000 +DEAL::jump_in_shape_gradients(): -0.500000 0.00000 1.00000 0.00000 -0.500000 0.00000 1.00000 0.00000 -0.500000 0.00000 -0.500000 0.00000 +DEAL::average_of_shape_gradients(): -0.250000 0.00000 0.00000 -1.00000 -0.250000 0.00000 0.00000 1.00000 0.250000 0.00000 0.250000 0.00000 +DEAL::FE_Q<3>(1) +DEAL::shape_grad(true): -0.250000 0.00000 0.00000 0.250000 -0.500000 -0.500000 -0.250000 0.00000 0.00000 0.250000 0.500000 -0.500000 -0.250000 0.00000 0.00000 0.250000 -0.500000 0.500000 -0.250000 0.00000 0.00000 0.250000 0.500000 0.500000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 +DEAL::shape_grad(false): 0.00000 0.00000 0.00000 -0.250000 -0.500000 -0.500000 0.00000 0.00000 0.00000 -0.250000 0.500000 -0.500000 0.00000 0.00000 0.00000 -0.250000 -0.500000 0.500000 0.00000 0.00000 0.00000 -0.250000 0.500000 0.500000 0.250000 0.00000 0.00000 0.250000 0.00000 0.00000 0.250000 0.00000 0.00000 0.250000 0.00000 0.00000 +DEAL::jump_in_shape_gradients(): -0.250000 0.00000 0.00000 0.500000 0.00000 0.00000 -0.250000 0.00000 0.00000 0.500000 0.00000 0.00000 -0.250000 0.00000 0.00000 0.500000 0.00000 0.00000 -0.250000 0.00000 0.00000 0.500000 0.00000 0.00000 -0.250000 0.00000 0.00000 -0.250000 0.00000 0.00000 -0.250000 0.00000 0.00000 -0.250000 0.00000 0.00000 +DEAL::average_of_shape_gradients(): -0.125000 0.00000 0.00000 0.00000 -0.500000 -0.500000 -0.125000 0.00000 0.00000 0.00000 0.500000 -0.500000 -0.125000 0.00000 0.00000 0.00000 -0.500000 0.500000 -0.125000 0.00000 0.00000 0.00000 0.500000 0.500000 0.125000 0.00000 0.00000 0.125000 0.00000 0.00000 0.125000 0.00000 0.00000 0.125000 0.00000 0.00000 -- 2.39.5