From 0e36837ddfc4b6fd48814f9d24f491435754eae9 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 5 Aug 2014 22:14:06 -0500 Subject: [PATCH] Patch by Alexander Grayver: Fix face interpolation between FE_Nedelec elements. This patch fixes a bug in the FE_Nedelec::get_face_interpolation_matrix related to the wrong indexing of the DoFs located on element faces. This patch ensures that the code produces an interpolation matrix with full column rank meaning that all DoFs of the FE with lower order are constrained. --- doc/news/changes.h | 7 + source/fe/fe_nedelec.cc | 29 +- tests/deal.II/nedelec_crash_hp.cc | 119 ++++ tests/deal.II/nedelec_crash_hp.output | 568 ++++++++++++++++++ tests/deal.II/nedelec_face_interpolation.cc | 109 ++++ .../deal.II/nedelec_face_interpolation.output | 5 + 6 files changed, 823 insertions(+), 14 deletions(-) create mode 100644 tests/deal.II/nedelec_crash_hp.cc create mode 100644 tests/deal.II/nedelec_crash_hp.output create mode 100644 tests/deal.II/nedelec_face_interpolation.cc create mode 100644 tests/deal.II/nedelec_face_interpolation.output diff --git a/doc/news/changes.h b/doc/news/changes.h index f53f3a2dde..f067f74953 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -190,6 +190,13 @@ inconvenience this causes.

Specific improvements

    +
  1. Fixed: The FE_Nedelec element computed face interpolation matrices + wrongly for elements of order p>1. This also led to trouble computing + hanging node constraints in the context of hp adaptivity. This is now fixed. +
    + (Alexander Grayver, 2014/08/05) +
  2. +
  3. New: The function GridTools::get_patch_around_cell() extracts the set of cells that surround a single cell. The new functions DoFTools::count_dofs_on_patch() and DoFTools::get_dofs_on_patch() diff --git a/source/fe/fe_nedelec.cc b/source/fe/fe_nedelec.cc index 40c14953f4..9fd9e9f7fd 100644 --- a/source/fe/fe_nedelec.cc +++ b/source/fe/fe_nedelec.cc @@ -2496,26 +2496,27 @@ const // indices of the degrees of // freedom. if (dim == 3) - for (unsigned int i = 0; i degree; ++i) + { + const unsigned int p = source_fe.degree; + const unsigned int q = this->degree; + + for (unsigned int i = 0; i ::lines_per_face; ++j) - interpolation_matrix (j * source_fe.degree + i, - j * this->degree + i) = 1.0; + interpolation_matrix (j * p + i, + j * q + i) = 1.0; - for (unsigned int j = 0; j < this->degree-1; ++j) + for (unsigned int j = 0; j < q-1; ++j) { - interpolation_matrix - ((i + GeometryInfo::lines_per_face) * (source_fe.degree - 1) - + j + GeometryInfo::lines_per_face, - (i + GeometryInfo::lines_per_face) * (this->degree-1) + j - + GeometryInfo::lines_per_face) - = 1.0; - interpolation_matrix - (i + (j + GeometryInfo::lines_per_face) * source_fe.degree, - i + (j + GeometryInfo::lines_per_face) * this->degree) - = 1.0; + interpolation_matrix (GeometryInfo::lines_per_face * p + i * (p - 1) + j, + GeometryInfo::lines_per_face * q + i * (q - 1) + j) + = 1.0; + interpolation_matrix (GeometryInfo::lines_per_face * p + i + (j + p - 1) * p, + GeometryInfo::lines_per_face * q + i + (j + q - 1) * q) + = 1.0; } } + } } diff --git a/tests/deal.II/nedelec_crash_hp.cc b/tests/deal.II/nedelec_crash_hp.cc new file mode 100644 index 0000000000..e58a02db4f --- /dev/null +++ b/tests/deal.II/nedelec_crash_hp.cc @@ -0,0 +1,119 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2014 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. +// +// --------------------------------------------------------------------- + + +// Test by Alexander Grayver: The FE_Nedelec did not correctly compute face +// interpolation matrices from lower to higher order elements. This +// consequently led to a situation where +// DoFTools::make_hanging_node_constraints got into trouble because it could +// not find a master DoF for one particular slave DoF. + + +char logname[] = "output"; + + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + + +template +void test () +{ + // create a mesh like this (viewed + // from top, if in 3d): + // *---*---* + // | 0 | 1 | + // *---*---* + Triangulation triangulation; + std::vector subdivisions (dim, 1); + subdivisions[0] = 2; + GridGenerator::subdivided_hyper_rectangle (triangulation, subdivisions, + Point(), + (dim == 3 ? + Point(2,1,1) : + Point(2,1))); + (++triangulation.begin_active())->set_refine_flag (); + triangulation.execute_coarsening_and_refinement (); + + hp::FECollection fe; + fe.push_back (FE_Nedelec(1)); + fe.push_back (FE_Nedelec(2)); + + hp::DoFHandler dof_handler(triangulation); + + for (unsigned int i=0; i::active_cell_iterator + cell = dof_handler.begin_active(); + cell->set_active_fe_index (i); + ++cell; + + for (; cell != dof_handler.end(); ++cell) + cell->set_active_fe_index (j); + + dof_handler.distribute_dofs (fe); + + ConstraintMatrix constraints; + DoFTools::make_hanging_node_constraints (dof_handler, + constraints); + constraints.close (); + + constraints.print (deallog.get_file_stream()); + } +} + + + +int main () +{ + std::ofstream logfile(logname); + logfile.precision (7); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + + test<2> (); + test<3> (); +} diff --git a/tests/deal.II/nedelec_crash_hp.output b/tests/deal.II/nedelec_crash_hp.output new file mode 100644 index 0000000000..d20fa9a22c --- /dev/null +++ b/tests/deal.II/nedelec_crash_hp.output @@ -0,0 +1,568 @@ + +DEAL::Testing FE_Nedelec<2>(1) vs. FE_Nedelec<2>(1) + 12 2: 0.5000000 + 12 3: -0.4330127 + 13 3: 0.2500000 + 34 2: 0.5000000 + 34 3: 0.4330127 + 35 3: 0.2500000 +DEAL::Testing FE_Nedelec<2>(1) vs. FE_Nedelec<2>(2) + 12 2: 0.5000000 + 12 3: -0.4330127 + 13 3: 0.2500000 + 14 = 0 + 57 2: 0.5000000 + 57 3: 0.4330127 + 58 3: 0.2500000 + 59 = 0 +DEAL::Testing FE_Nedelec<2>(2) vs. FE_Nedelec<2>(1) + 5 = 0 + 24 3: 0.5000000 + 24 4: -0.4330127 + 25 4: 0.2500000 + 46 3: 0.5000000 + 46 4: 0.4330127 + 47 4: 0.2500000 +DEAL::Testing FE_Nedelec<2>(2) vs. FE_Nedelec<2>(2) + 24 3: 0.5000000 + 24 4: -0.4330127 + 25 4: 0.2500000 + 25 5: -0.4841229 + 26 5: 0.1250000 + 69 3: 0.5000000 + 69 4: 0.4330127 + 70 4: 0.2500000 + 70 5: 0.4841229 + 71 5: 0.1250000 +DEAL::Testing FE_Nedelec<3>(1) vs. FE_Nedelec<3>(1) + 54 2: 0.5000000 + 54 3: -0.4330127 + 55 3: 0.2500000 + 62 2: 0.2500000 + 62 3: -0.2165064 + 62 10: 0.2500000 + 62 11: -0.2165064 + 62 28: -0.2165064 + 62 29: 0.1875000 + 63 3: 0.1250000 + 63 11: 0.1250000 + 63 29: -0.1082532 + 70 18: 0.5000000 + 70 19: -0.4330127 + 71 19: 0.2500000 + 74 18: 0.2500000 + 74 19: -0.2165064 + 74 22: 0.2500000 + 74 23: -0.2165064 + 74 30: -0.2165064 + 74 31: 0.1875000 + 75 19: 0.1250000 + 75 23: 0.1250000 + 75 31: -0.1082532 + 78 28: 0.1250000 + 78 29: -0.1082532 + 79 29: 0.06250000 + 80 30: 0.1250000 + 80 31: -0.1082532 + 81 31: 0.06250000 + 150 2: 0.5000000 + 150 3: 0.4330127 + 151 3: 0.2500000 + 156 2: 0.2500000 + 156 3: 0.2165064 + 156 10: 0.2500000 + 156 11: 0.2165064 + 156 28: -0.2165064 + 156 29: -0.1875000 + 157 3: 0.1250000 + 157 11: 0.1250000 + 157 29: -0.1082532 + 162 22: 0.5000000 + 162 23: -0.4330127 + 163 23: 0.2500000 + 166 28: 0.1250000 + 166 29: 0.1082532 + 167 29: 0.06250000 + 168 30: 0.1250000 + 168 31: -0.1082532 + 169 31: 0.06250000 + 224 10: 0.5000000 + 224 11: -0.4330127 + 225 11: 0.2500000 + 232 18: 0.5000000 + 232 19: 0.4330127 + 233 19: 0.2500000 + 236 18: 0.2500000 + 236 19: 0.2165064 + 236 22: 0.2500000 + 236 23: 0.2165064 + 236 30: -0.2165064 + 236 31: -0.1875000 + 237 19: 0.1250000 + 237 23: 0.1250000 + 237 31: -0.1082532 + 240 28: 0.1250000 + 240 29: -0.1082532 + 241 29: 0.06250000 + 242 30: 0.1250000 + 242 31: 0.1082532 + 243 31: 0.06250000 + 298 10: 0.5000000 + 298 11: 0.4330127 + 299 11: 0.2500000 + 304 22: 0.5000000 + 304 23: 0.4330127 + 305 23: 0.2500000 + 308 28: 0.1250000 + 308 29: 0.1082532 + 309 29: 0.06250000 + 310 30: 0.1250000 + 310 31: 0.1082532 + 311 31: 0.06250000 +DEAL::Testing FE_Nedelec<3>(1) vs. FE_Nedelec<3>(2) + 54 2: 0.5000000 + 54 3: -0.4330127 + 55 3: 0.2500000 + 56 = 0 + 66 2: 0.2500000 + 66 3: -0.2165064 + 66 10: 0.2500000 + 66 11: -0.2165064 + 66 28: -0.2165064 + 66 29: 0.1875000 + 67 3: 0.1250000 + 67 11: 0.1250000 + 67 29: -0.1082532 + 68 = 0 + 78 18: 0.5000000 + 78 19: -0.4330127 + 79 19: 0.2500000 + 80 = 0 + 84 18: 0.2500000 + 84 19: -0.2165064 + 84 22: 0.2500000 + 84 23: -0.2165064 + 84 30: -0.2165064 + 84 31: 0.1875000 + 85 19: 0.1250000 + 85 23: 0.1250000 + 85 31: -0.1082532 + 86 = 0 + 90 28: 0.1250000 + 90 29: -0.1082532 + 91 = 0 + 92 29: 0.06250000 + 93 = 0 + 94 = 0 + 95 = 0 + 96 30: 0.1250000 + 96 31: -0.1082532 + 97 31: 0.06250000 + 98 = 0 + 99 = 0 + 100 = 0 + 101 = 0 + 318 2: 0.5000000 + 318 3: 0.4330127 + 319 3: 0.2500000 + 320 = 0 + 327 2: 0.2500000 + 327 3: 0.2165064 + 327 10: 0.2500000 + 327 11: 0.2165064 + 327 28: -0.2165064 + 327 29: -0.1875000 + 328 3: 0.1250000 + 328 11: 0.1250000 + 328 29: -0.1082532 + 329 = 0 + 336 22: 0.5000000 + 336 23: -0.4330127 + 337 23: 0.2500000 + 338 = 0 + 342 28: 0.1250000 + 342 29: 0.1082532 + 343 = 0 + 344 29: 0.06250000 + 345 = 0 + 346 = 0 + 347 = 0 + 348 30: 0.1250000 + 348 31: -0.1082532 + 349 31: 0.06250000 + 350 = 0 + 351 = 0 + 352 = 0 + 353 = 0 + 537 10: 0.5000000 + 537 11: -0.4330127 + 538 11: 0.2500000 + 539 = 0 + 549 18: 0.5000000 + 549 19: 0.4330127 + 550 19: 0.2500000 + 551 = 0 + 555 18: 0.2500000 + 555 19: 0.2165064 + 555 22: 0.2500000 + 555 23: 0.2165064 + 555 30: -0.2165064 + 555 31: -0.1875000 + 556 19: 0.1250000 + 556 23: 0.1250000 + 556 31: -0.1082532 + 557 = 0 + 561 28: 0.1250000 + 561 29: -0.1082532 + 562 = 0 + 563 29: 0.06250000 + 564 = 0 + 565 = 0 + 566 = 0 + 567 30: 0.1250000 + 567 31: 0.1082532 + 568 31: 0.06250000 + 569 = 0 + 570 = 0 + 571 = 0 + 572 = 0 + 756 10: 0.5000000 + 756 11: 0.4330127 + 757 11: 0.2500000 + 758 = 0 + 765 22: 0.5000000 + 765 23: 0.4330127 + 766 23: 0.2500000 + 767 = 0 + 771 28: 0.1250000 + 771 29: 0.1082532 + 772 = 0 + 773 29: 0.06250000 + 774 = 0 + 775 = 0 + 776 = 0 + 777 30: 0.1250000 + 777 31: 0.1082532 + 778 31: 0.06250000 + 779 = 0 + 780 = 0 + 781 = 0 + 782 = 0 +DEAL::Testing FE_Nedelec<3>(2) vs. FE_Nedelec<3>(1) + 5 = 0 + 17 = 0 + 29 = 0 + 35 = 0 + 49 = 0 + 51 = 0 + 52 = 0 + 53 = 0 + 56 = 0 + 57 = 0 + 58 = 0 + 59 = 0 + 144 3: 0.5000000 + 144 4: -0.4330127 + 145 4: 0.2500000 + 152 3: 0.2500000 + 152 4: -0.2165064 + 152 15: 0.2500000 + 152 16: -0.2165064 + 152 48: -0.2165064 + 152 50: 0.1875000 + 153 4: 0.1250000 + 153 16: 0.1250000 + 153 50: -0.1082532 + 160 27: 0.5000000 + 160 28: -0.4330127 + 161 28: 0.2500000 + 164 27: 0.2500000 + 164 28: -0.2165064 + 164 33: 0.2500000 + 164 34: -0.2165064 + 164 54: -0.2165064 + 164 55: 0.1875000 + 165 28: 0.1250000 + 165 34: 0.1250000 + 165 55: -0.1082532 + 168 48: 0.1250000 + 168 50: -0.1082532 + 169 50: 0.06250000 + 170 54: 0.1250000 + 170 55: -0.1082532 + 171 55: 0.06250000 + 240 3: 0.5000000 + 240 4: 0.4330127 + 241 4: 0.2500000 + 246 3: 0.2500000 + 246 4: 0.2165064 + 246 15: 0.2500000 + 246 16: 0.2165064 + 246 48: -0.2165064 + 246 50: -0.1875000 + 247 4: 0.1250000 + 247 16: 0.1250000 + 247 50: -0.1082532 + 252 33: 0.5000000 + 252 34: -0.4330127 + 253 34: 0.2500000 + 256 48: 0.1250000 + 256 50: 0.1082532 + 257 50: 0.06250000 + 258 54: 0.1250000 + 258 55: -0.1082532 + 259 55: 0.06250000 + 314 15: 0.5000000 + 314 16: -0.4330127 + 315 16: 0.2500000 + 322 27: 0.5000000 + 322 28: 0.4330127 + 323 28: 0.2500000 + 326 27: 0.2500000 + 326 28: 0.2165064 + 326 33: 0.2500000 + 326 34: 0.2165064 + 326 54: -0.2165064 + 326 55: -0.1875000 + 327 28: 0.1250000 + 327 34: 0.1250000 + 327 55: -0.1082532 + 330 48: 0.1250000 + 330 50: -0.1082532 + 331 50: 0.06250000 + 332 54: 0.1250000 + 332 55: 0.1082532 + 333 55: 0.06250000 + 388 15: 0.5000000 + 388 16: 0.4330127 + 389 16: 0.2500000 + 394 33: 0.5000000 + 394 34: 0.4330127 + 395 34: 0.2500000 + 398 48: 0.1250000 + 398 50: 0.1082532 + 399 50: 0.06250000 + 400 54: 0.1250000 + 400 55: 0.1082532 + 401 55: 0.06250000 +DEAL::Testing FE_Nedelec<3>(2) vs. FE_Nedelec<3>(2) + 144 3: 0.5000000 + 144 4: -0.4330127 + 145 4: 0.2500000 + 145 5: -0.4841229 + 146 5: 0.1250000 + 156 3: 0.2500000 + 156 4: -0.2165064 + 156 15: 0.2500000 + 156 16: -0.2165064 + 156 48: -0.2165064 + 156 50: 0.1875000 + 157 4: 0.1250000 + 157 5: -0.2420615 + 157 16: 0.1250000 + 157 17: -0.2420615 + 157 50: -0.1082532 + 157 52: 0.2096314 + 158 5: 0.06250000 + 158 17: 0.06250000 + 158 52: -0.05412659 + 168 27: 0.5000000 + 168 28: -0.4330127 + 169 28: 0.2500000 + 169 29: -0.4841229 + 170 29: 0.1250000 + 174 27: 0.2500000 + 174 28: -0.2165064 + 174 33: 0.2500000 + 174 34: -0.2165064 + 174 54: -0.2165064 + 174 55: 0.1875000 + 175 28: 0.1250000 + 175 29: -0.2420615 + 175 34: 0.1250000 + 175 35: -0.2420615 + 175 55: -0.1082532 + 175 56: 0.2096314 + 176 29: 0.06250000 + 176 35: 0.06250000 + 176 56: -0.05412659 + 180 48: 0.1250000 + 180 49: -0.2420615 + 180 50: -0.1082532 + 180 51: 0.2096314 + 181 49: 0.06250000 + 181 51: -0.05412659 + 182 50: 0.06250000 + 182 51: -0.1210307 + 182 52: -0.1210307 + 182 53: 0.2343750 + 183 51: 0.03125000 + 183 53: -0.06051536 + 184 52: 0.03125000 + 184 53: -0.06051536 + 185 53: 0.01562500 + 186 54: 0.1250000 + 186 55: -0.1082532 + 186 57: -0.2420615 + 186 58: 0.2096314 + 187 55: 0.06250000 + 187 56: -0.1210307 + 187 58: -0.1210307 + 187 59: 0.2343750 + 188 56: 0.03125000 + 188 59: -0.06051536 + 189 57: 0.06250000 + 189 58: -0.05412659 + 190 58: 0.03125000 + 190 59: -0.06051536 + 191 59: 0.01562500 + 408 3: 0.5000000 + 408 4: 0.4330127 + 409 4: 0.2500000 + 409 5: 0.4841229 + 410 5: 0.1250000 + 417 3: 0.2500000 + 417 4: 0.2165064 + 417 15: 0.2500000 + 417 16: 0.2165064 + 417 48: -0.2165064 + 417 50: -0.1875000 + 418 4: 0.1250000 + 418 5: 0.2420615 + 418 16: 0.1250000 + 418 17: 0.2420615 + 418 50: -0.1082532 + 418 52: -0.2096314 + 419 5: 0.06250000 + 419 17: 0.06250000 + 419 52: -0.05412659 + 426 33: 0.5000000 + 426 34: -0.4330127 + 427 34: 0.2500000 + 427 35: -0.4841229 + 428 35: 0.1250000 + 432 48: 0.1250000 + 432 49: -0.2420615 + 432 50: 0.1082532 + 432 51: -0.2096314 + 433 49: 0.06250000 + 433 51: 0.05412659 + 434 50: 0.06250000 + 434 51: -0.1210307 + 434 52: 0.1210307 + 434 53: -0.2343750 + 435 51: 0.03125000 + 435 53: 0.06051536 + 436 52: 0.03125000 + 436 53: -0.06051536 + 437 53: 0.01562500 + 438 54: 0.1250000 + 438 55: -0.1082532 + 438 57: 0.2420615 + 438 58: -0.2096314 + 439 55: 0.06250000 + 439 56: -0.1210307 + 439 58: 0.1210307 + 439 59: -0.2343750 + 440 56: 0.03125000 + 440 59: 0.06051536 + 441 57: 0.06250000 + 441 58: -0.05412659 + 442 58: 0.03125000 + 442 59: -0.06051536 + 443 59: 0.01562500 + 627 15: 0.5000000 + 627 16: -0.4330127 + 628 16: 0.2500000 + 628 17: -0.4841229 + 629 17: 0.1250000 + 639 27: 0.5000000 + 639 28: 0.4330127 + 640 28: 0.2500000 + 640 29: 0.4841229 + 641 29: 0.1250000 + 645 27: 0.2500000 + 645 28: 0.2165064 + 645 33: 0.2500000 + 645 34: 0.2165064 + 645 54: -0.2165064 + 645 55: -0.1875000 + 646 28: 0.1250000 + 646 29: 0.2420615 + 646 34: 0.1250000 + 646 35: 0.2420615 + 646 55: -0.1082532 + 646 56: -0.2096314 + 647 29: 0.06250000 + 647 35: 0.06250000 + 647 56: -0.05412659 + 651 48: 0.1250000 + 651 49: 0.2420615 + 651 50: -0.1082532 + 651 51: -0.2096314 + 652 49: 0.06250000 + 652 51: -0.05412659 + 653 50: 0.06250000 + 653 51: 0.1210307 + 653 52: -0.1210307 + 653 53: -0.2343750 + 654 51: 0.03125000 + 654 53: -0.06051536 + 655 52: 0.03125000 + 655 53: 0.06051536 + 656 53: 0.01562500 + 657 54: 0.1250000 + 657 55: 0.1082532 + 657 57: -0.2420615 + 657 58: -0.2096314 + 658 55: 0.06250000 + 658 56: 0.1210307 + 658 58: -0.1210307 + 658 59: -0.2343750 + 659 56: 0.03125000 + 659 59: -0.06051536 + 660 57: 0.06250000 + 660 58: 0.05412659 + 661 58: 0.03125000 + 661 59: 0.06051536 + 662 59: 0.01562500 + 846 15: 0.5000000 + 846 16: 0.4330127 + 847 16: 0.2500000 + 847 17: 0.4841229 + 848 17: 0.1250000 + 855 33: 0.5000000 + 855 34: 0.4330127 + 856 34: 0.2500000 + 856 35: 0.4841229 + 857 35: 0.1250000 + 861 48: 0.1250000 + 861 49: 0.2420615 + 861 50: 0.1082532 + 861 51: 0.2096314 + 862 49: 0.06250000 + 862 51: 0.05412659 + 863 50: 0.06250000 + 863 51: 0.1210307 + 863 52: 0.1210307 + 863 53: 0.2343750 + 864 51: 0.03125000 + 864 53: 0.06051536 + 865 52: 0.03125000 + 865 53: 0.06051536 + 866 53: 0.01562500 + 867 54: 0.1250000 + 867 55: 0.1082532 + 867 57: 0.2420615 + 867 58: 0.2096314 + 868 55: 0.06250000 + 868 56: 0.1210307 + 868 58: 0.1210307 + 868 59: 0.2343750 + 869 56: 0.03125000 + 869 59: 0.06051536 + 870 57: 0.06250000 + 870 58: 0.05412659 + 871 58: 0.03125000 + 871 59: 0.06051536 + 872 59: 0.01562500 diff --git a/tests/deal.II/nedelec_face_interpolation.cc b/tests/deal.II/nedelec_face_interpolation.cc new file mode 100644 index 0000000000..51ce86f6ac --- /dev/null +++ b/tests/deal.II/nedelec_face_interpolation.cc @@ -0,0 +1,109 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2014 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. +// +// --------------------------------------------------------------------- + + +// Test by Alexander Grayver: The FE_Nedelec did not correctly compute face +// interpolation matrices from lower to higher order elements. In particular, +// the matrix sometimes did not have full column rank, meaning that a nonzero +// function on the lower-p side would be interpolated to zero on the higher-p +// side. + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace dealii; + +template +void test (unsigned p1, unsigned p2) +{ + // create a mesh like this (viewed + // from top, if in 3d): + // *----*----* + // | p1 | p2 | + // *----*----* + Triangulation triangulation; + std::vector subdivisions (dim, 1); + subdivisions[0] = 2; + GridGenerator::subdivided_hyper_rectangle (triangulation, subdivisions, + Point(), + (dim == 3 ? + Point(2,1,1) : + Point(2,1))); + (++triangulation.begin_active())->set_refine_flag (); + triangulation.execute_coarsening_and_refinement (); + + hp::FECollection fe; + fe.push_back (FE_Nedelec(p1)); + fe.push_back (FE_Nedelec(p2)); + + deallog << "Testing " << fe[0].get_name() + << " vs. " << fe[1].get_name() + << std::endl; + + FullMatrix face_int_matrix(fe[1].dofs_per_face, + fe[0].dofs_per_face); + + fe[0].get_face_interpolation_matrix(fe[1], face_int_matrix); + + bool is_zero_column = true; + for (unsigned int i=0; i 1e-10) + { + is_zero_column = false; + break; + } + } + + if(is_zero_column) + { + deallog << "Column " << i + << " has no non-zero elements." + << std::endl; + } + } + + if(!is_zero_column) + deallog << "OK" << std::endl; + else + deallog << "Failed" << std::endl; +} + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + + test<3>(0, 1); + test<3>(1, 2); + //test<3>(2, 3); + //test<3>(3, 4); + return 0; +} + diff --git a/tests/deal.II/nedelec_face_interpolation.output b/tests/deal.II/nedelec_face_interpolation.output new file mode 100644 index 0000000000..8c07ee95d5 --- /dev/null +++ b/tests/deal.II/nedelec_face_interpolation.output @@ -0,0 +1,5 @@ + +DEAL::Testing FE_Nedelec<3>(0) vs. FE_Nedelec<3>(1) +DEAL::OK +DEAL::Testing FE_Nedelec<3>(1) vs. FE_Nedelec<3>(2) +DEAL::OK -- 2.39.5