]> https://gitweb.dealii.org/ - dealii.git/commitdiff
added test for shape_grad 18550/head
authorWyatt Smith <wsmith97@tamu.edu>
Sat, 7 Jun 2025 16:34:19 +0000 (10:34 -0600)
committerWyatt Smith <wsmith97@tamu.edu>
Sat, 7 Jun 2025 16:40:49 +0000 (10:40 -0600)
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 [new file with mode: 0644]
tests/feinterface/fe_interface_values_17.output [new file with mode: 0644]

diff --git a/tests/feinterface/fe_interface_values_17.cc b/tests/feinterface/fe_interface_values_17.cc
new file mode 100644 (file)
index 0000000..6ce89d7
--- /dev/null
@@ -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 <deal.II/base/quadrature_lib.h>
+
+#include <deal.II/fe/fe_dgq.h>
+#include <deal.II/fe/fe_interface_values.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/mapping_q.h>
+
+#include <deal.II/grid/grid_refinement.h>
+#include <deal.II/grid/tria.h>
+
+#include <fstream>
+#include <iostream>
+
+#include "../tests.h"
+
+#include "../test_grids.h"
+
+
+template <int dim>
+void
+test(unsigned int fe_degree)
+{
+  Triangulation<dim> tria;
+  TestGrids::hyper_line(tria, 2);
+
+  DoFHandler<dim> dofh(tria);
+  FE_Q<dim>       fe(fe_degree);
+  deallog << fe.get_name() << std::endl;
+  dofh.distribute_dofs(fe);
+
+  MappingQ<dim> mapping(1);
+  UpdateFlags   update_flags = update_values | update_gradients |
+                             update_quadrature_points | update_JxW_values;
+
+  FEInterfaceValues<dim> fiv(mapping,
+                             fe,
+                             QGauss<dim - 1>(fe.degree + 1),
+                             update_flags);
+
+
+  auto cell = dofh.begin();
+
+  for (const unsigned int f : GeometryInfo<dim>::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<Tensor<1, dim>> 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 (file)
index 0000000..555fa31
--- /dev/null
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.