From a30246f561c99b3b3cb9eddd4afb2a9ab1569f2f Mon Sep 17 00:00:00 2001 From: Jonathan Robey Date: Sat, 10 Sep 2016 16:35:06 -0700 Subject: [PATCH] Add test for no mapping data FEValues ues --- tests/Testing/Temporary/CTestCostData.txt | 1 + tests/Testing/Temporary/LastTest.log | 3 + tests/fe/fe_values_no_mapping.cc | 148 +++++++++++++++++++++ tests/fe/fe_values_no_mapping.debug.output | 5 + 4 files changed, 157 insertions(+) create mode 100644 tests/Testing/Temporary/CTestCostData.txt create mode 100644 tests/Testing/Temporary/LastTest.log create mode 100644 tests/fe/fe_values_no_mapping.cc create mode 100644 tests/fe/fe_values_no_mapping.debug.output diff --git a/tests/Testing/Temporary/CTestCostData.txt b/tests/Testing/Temporary/CTestCostData.txt new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/tests/Testing/Temporary/CTestCostData.txt @@ -0,0 +1 @@ +--- diff --git a/tests/Testing/Temporary/LastTest.log b/tests/Testing/Temporary/LastTest.log new file mode 100644 index 0000000000..4d9b174492 --- /dev/null +++ b/tests/Testing/Temporary/LastTest.log @@ -0,0 +1,3 @@ +Start testing: Sep 11 08:44 PDT +---------------------------------------------------------- +End testing: Sep 11 08:44 PDT diff --git a/tests/fe/fe_values_no_mapping.cc b/tests/fe/fe_values_no_mapping.cc new file mode 100644 index 0000000000..a710f45127 --- /dev/null +++ b/tests/fe/fe_values_no_mapping.cc @@ -0,0 +1,148 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2016 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + +// Check for matching values on cartesian mesh with UpdateFlags +// update_values and update_values|update_jacobian + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + + +template +class F : public Function +{ +public: + F (const unsigned int q) : q(q) {} + + virtual double value (const Point &p, + const unsigned int) const + { + double v=0; + for (unsigned int d=0; d +void test() +{ + Triangulation tria; + GridGenerator::hyper_cube (tria); + tria.refine_global(1); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement(); + + const unsigned int q_test = 2; + + MappingCartesian mapping; + FE_Q elem(q_test); + // choose a point that is not right in the middle of the cell so that the + // Jacobian contains many nonzero entries + Point quad_p; + for (int d=0; d quad(quad_p); + + Point f_quad_p; + for (int d=0; d f_quad(f_quad_p); + + + { + DoFHandler dof_handler(tria); + dof_handler.distribute_dofs(elem); + + Vector interpolant (dof_handler.n_dofs()); + VectorTools::interpolate (dof_handler, + F (q_test), + interpolant); + + const UpdateFlags no_m(update_values); + const UpdateFlags w_m(update_values|update_jacobians); + std::vector values(quad.size()); + std::vector values_m(quad.size()); + FEValues fe_val (mapping, elem, quad, no_m); + FEValues fe_val_m (mapping, elem, quad, w_m); + FEFaceValues fe_f_val (mapping, elem, f_quad, no_m); + FEFaceValues fe_f_val_m (mapping, elem, f_quad, w_m); + FESubfaceValues fe_subf_val (mapping, elem, f_quad, no_m); + FESubfaceValues fe_subf_val_m (mapping, elem, f_quad, w_m); + + deallog << dim << " Checking no mapping FEValues behavior: " << std::endl; + typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(), endc = dof_handler.end(); + for ( ; cell != endc; ++cell) + { + fe_val.reinit (cell); + fe_val_m.reinit (cell); + + fe_val.get_function_values(interpolant, values); + fe_val_m.get_function_values(interpolant, values_m); + Assert(values[0]==values_m[0], ExcInternalError()) + + for (unsigned int f=0; f::faces_per_cell; ++f) + { + fe_f_val.reinit (cell, f); + fe_f_val_m.reinit (cell, f); + + fe_f_val.get_function_values(interpolant, values); + fe_f_val_m.get_function_values(interpolant, values_m); + Assert(values[0]==values_m[0], ExcInternalError()) + + // Also check the Jacobian with FESubfaceValues + if (cell->at_boundary(f) == false && + cell->neighbor(f)->level() < cell->level()) + { + fe_subf_val.reinit(cell->neighbor(f), cell->neighbor_face_no(f), + cell->neighbor_of_coarser_neighbor(f).second); + fe_subf_val_m.reinit(cell->neighbor(f), cell->neighbor_face_no(f), + cell->neighbor_of_coarser_neighbor(f).second); + + fe_subf_val.get_function_values(interpolant, values); + fe_subf_val_m.get_function_values(interpolant, values_m); + Assert(values[0]==values_m[0], ExcInternalError()) + } + } + } + deallog << "OK" << std::endl; + } +} + + +int +main() +{ + std::ofstream logfile ("output"); + deallog << std::setprecision(8) << std::fixed; + deallog.attach(logfile); + deallog.threshold_double(1.e-10); + + test<2>(); + test<3>(); + + return 0; +} diff --git a/tests/fe/fe_values_no_mapping.debug.output b/tests/fe/fe_values_no_mapping.debug.output new file mode 100644 index 0000000000..48a93c3f53 --- /dev/null +++ b/tests/fe/fe_values_no_mapping.debug.output @@ -0,0 +1,5 @@ + +DEAL::2 Checking no mapping FEValues behavior: +DEAL::OK +DEAL::3 Checking no mapping FEValues behavior: +DEAL::OK -- 2.39.5