--- /dev/null
+/* ---------------------------------------------------------------------
+ *
+ * Copyright (C) 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.
+ *
+ * ---------------------------------------------------------------------
+ */
+
+// Check that ScratchData returns the correct solution values, gradients, etc.
+// - Scalar valued FE
+// - hp variant
+
+#include <deal.II/base/function_lib.h>
+#include <deal.II/base/quadrature_lib.h>
+
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_values.h>
+#include <deal.II/fe/fe_values_extractors.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include <deal.II/hp/fe_collection.h>
+#include <deal.II/hp/q_collection.h>
+
+#include <deal.II/meshworker/scratch_data.h>
+
+#include <deal.II/numerics/vector_tools.h>
+
+#include "../tests.h"
+
+
+template <int dim,
+ int spacedim = dim,
+ typename NumberType = double,
+ typename ExtractorType>
+void
+run(const ExtractorType &extractor)
+{
+ LogStream::Prefix prefix("Dim " + Utilities::to_string(dim));
+ std::cout << "Dim: " << dim << std::endl;
+
+ hp::FECollection<dim, spacedim> fe(FE_Q<dim, spacedim>(1),
+ FE_Q<dim, spacedim>(3));
+ hp::QCollection<dim> qf_cell(QGauss<dim>(fe[0].degree + 1),
+ QGauss<dim>(fe[1].degree + 1));
+ hp::QCollection<dim - 1> qf_face(QGauss<dim - 1>(fe[0].degree + 1),
+ QGauss<dim - 1>(fe[1].degree + 1));
+
+ Triangulation<dim, spacedim> triangulation;
+ GridGenerator::hyper_cube(triangulation);
+
+ DoFHandler<dim, spacedim> dof_handler(triangulation);
+ dof_handler.begin_active()->set_active_fe_index(1);
+ dof_handler.distribute_dofs(fe);
+
+ Vector<double> solution(dof_handler.n_dofs());
+ VectorTools::interpolate(dof_handler,
+ Functions::CosineFunction<spacedim>(
+ fe.n_components()),
+ solution);
+
+ const UpdateFlags update_flags =
+ update_values | update_gradients | update_hessians | update_3rd_derivatives;
+ MeshWorker::ScratchData<dim, spacedim> scratch_data(fe,
+ qf_cell,
+ update_flags);
+
+ const auto cell = dof_handler.begin_active();
+ scratch_data.reinit(cell);
+ scratch_data.extract_local_dof_values("solution", solution);
+
+ deallog << "Value: " << scratch_data.get_values("solution", extractor)[0]
+ << std::endl;
+ deallog << "Gradient: "
+ << scratch_data.get_gradients("solution", extractor)[0] << std::endl;
+ deallog << "Hessian: " << scratch_data.get_hessians("solution", extractor)[0]
+ << std::endl;
+ deallog << "Laplacian: "
+ << scratch_data.get_laplacians("solution", extractor)[0] << std::endl;
+ deallog << "Third derivative: "
+ << scratch_data.get_third_derivatives("solution", extractor)[0]
+ << std::endl;
+
+ deallog << "OK" << std::endl;
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ initlog();
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+ FEValuesExtractors::Scalar extractor(0);
+
+ run<2>(extractor);
+ run<3>(extractor);
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+
+DEAL:Dim 2::Value: 0.991562
+DEAL:Dim 2::Gradient: -0.158724 -0.158724
+DEAL:Dim 2::Hessian: -2.76461 0.0254076 0.0254076 -2.76461
+DEAL:Dim 2::Laplacian: -5.52923
+DEAL:Dim 2::Third derivative: 2.62952 0.442544 0.442544 0.442544 0.442544 0.442544 0.442544 2.62952
+DEAL:Dim 2::OK
+DEAL:Dim 3::Value: 0.987370
+DEAL:Dim 3::Gradient: -0.158053 -0.158053 -0.158053
+DEAL:Dim 3::Hessian: -2.75292 0.0253002 0.0253002 0.0253002 -2.75292 0.0253002 0.0253002 0.0253002 -2.75292
+DEAL:Dim 3::Laplacian: -8.25877
+DEAL:Dim 3::Third derivative: 2.61841 0.440673 0.440673 0.440673 0.440673 -0.00404991 0.440673 -0.00404991 0.440673 0.440673 0.440673 -0.00404991 0.440673 2.61841 0.440673 -0.00404991 0.440673 0.440673 0.440673 -0.00404991 0.440673 -0.00404991 0.440673 0.440673 0.440673 0.440673 2.61841
+DEAL:Dim 3::OK
+DEAL::OK
--- /dev/null
+/* ---------------------------------------------------------------------
+ *
+ * Copyright (C) 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.
+ *
+ * ---------------------------------------------------------------------
+ */
+
+// Check that ScratchData returns the correct solution values, gradients, etc.
+// - Vector valued FE
+// - hp variant
+
+#include <deal.II/base/function_lib.h>
+#include <deal.II/base/quadrature_lib.h>
+
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/fe/fe_values.h>
+#include <deal.II/fe/fe_values_extractors.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include <deal.II/hp/fe_collection.h>
+#include <deal.II/hp/q_collection.h>
+
+#include <deal.II/meshworker/scratch_data.h>
+
+#include <deal.II/numerics/vector_tools.h>
+
+#include "../tests.h"
+
+
+template <int dim,
+ int spacedim = dim,
+ typename NumberType = double,
+ typename ExtractorType>
+void
+run(const ExtractorType &extractor)
+{
+ LogStream::Prefix prefix("Dim " + Utilities::to_string(dim));
+ std::cout << "Dim: " << dim << std::endl;
+
+ hp::FECollection<dim, spacedim> fe(
+ FESystem<dim, spacedim>(FE_Q<dim, spacedim>(1), dim),
+ FESystem<dim, spacedim>(FE_Q<dim, spacedim>(3), dim));
+ hp::QCollection<dim> qf_cell(QGauss<dim>(fe[0].degree + 1),
+ QGauss<dim>(fe[1].degree + 1));
+ hp::QCollection<dim - 1> qf_face(QGauss<dim - 1>(fe[0].degree + 1),
+ QGauss<dim - 1>(fe[1].degree + 1));
+
+ Triangulation<dim, spacedim> triangulation;
+ GridGenerator::hyper_cube(triangulation);
+
+ DoFHandler<dim, spacedim> dof_handler(triangulation);
+ dof_handler.begin_active()->set_active_fe_index(1);
+ dof_handler.distribute_dofs(fe);
+
+ Vector<double> solution(dof_handler.n_dofs());
+ VectorTools::interpolate(dof_handler,
+ Functions::CosineFunction<spacedim>(
+ fe.n_components()),
+ solution);
+
+ const UpdateFlags update_flags =
+ update_values | update_gradients | update_hessians | update_3rd_derivatives;
+ MeshWorker::ScratchData<dim, spacedim> scratch_data(fe,
+ qf_cell,
+ update_flags);
+
+ const auto cell = dof_handler.begin_active();
+ scratch_data.reinit(cell);
+ scratch_data.extract_local_dof_values("solution", solution);
+
+ deallog << "Value: " << scratch_data.get_values("solution", extractor)[0]
+ << std::endl;
+ deallog << "Gradient: "
+ << scratch_data.get_gradients("solution", extractor)[0] << std::endl;
+ deallog << "Symmetric gradient: "
+ << scratch_data.get_symmetric_gradients("solution", extractor)[0]
+ << std::endl;
+ deallog << "Divergence: "
+ << scratch_data.get_divergences("solution", extractor)[0]
+ << std::endl;
+ deallog << "Curl: " << scratch_data.get_curls("solution", extractor)[0]
+ << std::endl;
+ deallog << "Hessian: " << scratch_data.get_hessians("solution", extractor)[0]
+ << std::endl;
+ deallog << "Laplacian: "
+ << scratch_data.get_laplacians("solution", extractor)[0] << std::endl;
+ deallog << "Third derivative: "
+ << scratch_data.get_third_derivatives("solution", extractor)[0]
+ << std::endl;
+
+ deallog << "OK" << std::endl;
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ initlog();
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+ FEValuesExtractors::Vector extractor(0);
+
+ // Just run in 3d, so we can extract the curl
+ run<3>(extractor);
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+
+DEAL:Dim 3::Value: 0.987370 0.987370 0.987370
+DEAL:Dim 3::Gradient: -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053
+DEAL:Dim 3::Symmetric gradient: -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053
+DEAL:Dim 3::Divergence: -0.474158
+DEAL:Dim 3::Curl: 1.11890e-16 7.88432e-16 6.54858e-16
+DEAL:Dim 3::Hessian: -2.75292 0.0253002 0.0253002 0.0253002 -2.75292 0.0253002 0.0253002 0.0253002 -2.75292 -2.75292 0.0253002 0.0253002 0.0253002 -2.75292 0.0253002 0.0253002 0.0253002 -2.75292 -2.75292 0.0253002 0.0253002 0.0253002 -2.75292 0.0253002 0.0253002 0.0253002 -2.75292
+DEAL:Dim 3::Laplacian: -8.25877 -8.25877 -8.25877
+DEAL:Dim 3::Third derivative: 2.61841 0.440673 0.440673 0.440673 0.440673 -0.00404991 0.440673 -0.00404991 0.440673 0.440673 0.440673 -0.00404991 0.440673 2.61841 0.440673 -0.00404991 0.440673 0.440673 0.440673 -0.00404991 0.440673 -0.00404991 0.440673 0.440673 0.440673 0.440673 2.61841 2.61841 0.440673 0.440673 0.440673 0.440673 -0.00404991 0.440673 -0.00404991 0.440673 0.440673 0.440673 -0.00404991 0.440673 2.61841 0.440673 -0.00404991 0.440673 0.440673 0.440673 -0.00404991 0.440673 -0.00404991 0.440673 0.440673 0.440673 0.440673 2.61841 2.61841 0.440673 0.440673 0.440673 0.440673 -0.00404991 0.440673 -0.00404991 0.440673 0.440673 0.440673 -0.00404991 0.440673 2.61841 0.440673 -0.00404991 0.440673 0.440673 0.440673 -0.00404991 0.440673 -0.00404991 0.440673 0.440673 0.440673 0.440673 2.61841
+DEAL:Dim 3::OK
+DEAL::OK
--- /dev/null
+/* ---------------------------------------------------------------------
+ *
+ * Copyright (C) 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.
+ *
+ * ---------------------------------------------------------------------
+ */
+
+// Check that ScratchData returns the correct solution values, gradients, etc.
+// - Tensor valued FE
+// - hp variant
+
+#include <deal.II/base/function_lib.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/tensor.h>
+
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/fe/fe_values.h>
+#include <deal.II/fe/fe_values_extractors.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include <deal.II/hp/fe_collection.h>
+#include <deal.II/hp/q_collection.h>
+
+#include <deal.II/meshworker/scratch_data.h>
+
+#include <deal.II/numerics/vector_tools.h>
+
+#include "../tests.h"
+
+
+template <int dim,
+ int spacedim = dim,
+ typename NumberType = double,
+ typename ExtractorType>
+void
+run(const ExtractorType &extractor)
+{
+ LogStream::Prefix prefix("Dim " + Utilities::to_string(dim));
+ std::cout << "Dim: " << dim << std::endl;
+
+ hp::FECollection<dim, spacedim> fe(
+ FESystem<dim, spacedim>(FE_Q<dim, spacedim>(1),
+ Tensor<2, dim>::n_independent_components),
+ FESystem<dim, spacedim>(FE_Q<dim, spacedim>(3),
+ Tensor<2, dim>::n_independent_components));
+ hp::QCollection<dim> qf_cell(QGauss<dim>(fe[0].degree + 1),
+ QGauss<dim>(fe[1].degree + 1));
+ hp::QCollection<dim - 1> qf_face(QGauss<dim - 1>(fe[0].degree + 1),
+ QGauss<dim - 1>(fe[1].degree + 1));
+
+ Triangulation<dim, spacedim> triangulation;
+ GridGenerator::hyper_cube(triangulation);
+
+ DoFHandler<dim, spacedim> dof_handler(triangulation);
+ dof_handler.begin_active()->set_active_fe_index(1);
+ dof_handler.distribute_dofs(fe);
+
+ Vector<double> solution(dof_handler.n_dofs());
+ VectorTools::interpolate(dof_handler,
+ Functions::CosineFunction<spacedim>(
+ fe.n_components()),
+ solution);
+
+ const UpdateFlags update_flags = update_values | update_gradients;
+ MeshWorker::ScratchData<dim, spacedim> scratch_data(fe,
+ qf_cell,
+ update_flags);
+
+ const auto cell = dof_handler.begin_active();
+ scratch_data.reinit(cell);
+ scratch_data.extract_local_dof_values("solution", solution);
+
+ deallog << "Value: " << scratch_data.get_values("solution", extractor)[0]
+ << std::endl;
+ deallog << "Gradient: "
+ << scratch_data.get_gradients("solution", extractor)[0] << std::endl;
+ deallog << "Divergence: "
+ << scratch_data.get_divergences("solution", extractor)[0]
+ << std::endl;
+
+ deallog << "OK" << std::endl;
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ initlog();
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+ FEValuesExtractors::Tensor<2> extractor(0);
+
+ run<2>(extractor);
+ run<3>(extractor);
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+
+DEAL:Dim 2::Value: 0.991562 0.991562 0.991562 0.991562
+DEAL:Dim 2::Gradient: -0.158724 -0.158724 -0.158724 -0.158724 -0.158724 -0.158724 -0.158724 -0.158724
+DEAL:Dim 2::Divergence: -0.317447 -0.317447
+DEAL:Dim 2::OK
+DEAL:Dim 3::Value: 0.987370 0.987370 0.987370 0.987370 0.987370 0.987370 0.987370 0.987370 0.987370
+DEAL:Dim 3::Gradient: -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053 -0.158053
+DEAL:Dim 3::Divergence: -0.474158 -0.474158 -0.474158
+DEAL:Dim 3::OK
+DEAL::OK
--- /dev/null
+/* ---------------------------------------------------------------------
+ *
+ * Copyright (C) 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.
+ *
+ * ---------------------------------------------------------------------
+ */
+
+// Check that ScratchData returns the correct solution values, gradients, etc.
+// - Symmetric tensor valued FE
+// - hp variant
+
+#include <deal.II/base/function_lib.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/symmetric_tensor.h>
+
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/fe/fe_values.h>
+#include <deal.II/fe/fe_values_extractors.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include <deal.II/hp/fe_collection.h>
+#include <deal.II/hp/q_collection.h>
+
+#include <deal.II/meshworker/scratch_data.h>
+
+#include <deal.II/numerics/vector_tools.h>
+
+#include "../tests.h"
+
+
+template <int dim,
+ int spacedim = dim,
+ typename NumberType = double,
+ typename ExtractorType>
+void
+run(const ExtractorType &extractor)
+{
+ LogStream::Prefix prefix("Dim " + Utilities::to_string(dim));
+ std::cout << "Dim: " << dim << std::endl;
+
+ hp::FECollection<dim, spacedim> fe(
+ FESystem<dim, spacedim>(FE_Q<dim, spacedim>(1),
+ SymmetricTensor<2, dim>::n_independent_components),
+ FESystem<dim, spacedim>(FE_Q<dim, spacedim>(3),
+ SymmetricTensor<2, dim>::n_independent_components));
+ hp::QCollection<dim> qf_cell(QGauss<dim>(fe[0].degree + 1),
+ QGauss<dim>(fe[1].degree + 1));
+ hp::QCollection<dim - 1> qf_face(QGauss<dim - 1>(fe[0].degree + 1),
+ QGauss<dim - 1>(fe[1].degree + 1));
+
+
+ Triangulation<dim, spacedim> triangulation;
+ GridGenerator::hyper_cube(triangulation);
+
+ DoFHandler<dim, spacedim> dof_handler(triangulation);
+ dof_handler.begin_active()->set_active_fe_index(1);
+ dof_handler.distribute_dofs(fe);
+
+ Vector<double> solution(dof_handler.n_dofs());
+ VectorTools::interpolate(dof_handler,
+ Functions::CosineFunction<spacedim>(
+ fe.n_components()),
+ solution);
+
+ const UpdateFlags update_flags = update_values | update_gradients;
+ MeshWorker::ScratchData<dim, spacedim> scratch_data(fe,
+ qf_cell,
+ update_flags);
+
+ const auto cell = dof_handler.begin_active();
+ scratch_data.reinit(cell);
+ scratch_data.extract_local_dof_values("solution", solution);
+
+ deallog << "Value: " << scratch_data.get_values("solution", extractor)[0]
+ << std::endl;
+ deallog << "Divergence: "
+ << scratch_data.get_divergences("solution", extractor)[0]
+ << std::endl;
+
+ deallog << "OK" << std::endl;
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ initlog();
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+ FEValuesExtractors::SymmetricTensor<2> extractor(0);
+
+ run<2>(extractor);
+ run<3>(extractor);
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+
+DEAL:Dim 2::Value: 0.991562 0.991562 0.991562 0.991562
+DEAL:Dim 2::Divergence: -0.317447 -0.317447
+DEAL:Dim 2::OK
+DEAL:Dim 3::Value: 0.987370 0.987370 0.987370 0.987370 0.987370 0.987370 0.987370 0.987370 0.987370
+DEAL:Dim 3::Divergence: -0.474158 -0.474158 -0.474158
+DEAL:Dim 3::OK
+DEAL::OK