]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix a testcase by Minh Do-Quang: FESystem got a bit confused with FE_Nothing elements.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 8 Jan 2014 22:54:05 +0000 (22:54 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 8 Jan 2014 22:54:05 +0000 (22:54 +0000)
git-svn-id: https://svn.dealii.org/trunk@32178 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/source/fe/fe_system.cc
tests/hp/solution_transfer_04.cc [new file with mode: 0644]
tests/hp/solution_transfer_04.output [new file with mode: 0644]

index 8b705acd64638047a5739a5365ef347914720c57..444e2a9d142539372f0581d77bced8415327ad56 100644 (file)
@@ -1,7 +1,7 @@
  // ---------------------------------------------------------------------
 // $Id$
 //
-// Copyright (C) 2013 by the deal.II authors
+// Copyright (C) 2013, 2014 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //
@@ -85,6 +85,13 @@ inconvenience this causes.
 
 <ol>
 
+  <li> Fixed: FESystem::get_interpolation_matrix, a function that is among
+  other places used by SolutionTransfer, had a bug that prevented it from
+  running correctly in some situations where one uses FE_Nothing.
+  <br>
+  (Minh Do-Quang, Wolfgang Bangerth, 2014/01/08)
+  </li>
+
   <li> Improved: When you call WorkStream::run with an empty function object
   for the copier, operations on individual cells are essentially all independent.
   In other words, you have a massively parallel collection of jobs. In this
index bf70ec76a66a4172825259726658b8a54a4dfe91..8683136e667d7a1234e99679f203581a622923a5 100644 (file)
@@ -1,7 +1,7 @@
 // ---------------------------------------------------------------------
 // $Id$
 //
-// Copyright (C) 1999 - 2013 by the deal.II authors
+// Copyright (C) 1999 - 2014 by the deal.II authors
 //
 // This file is part of the deal.II library.
 //
@@ -528,10 +528,18 @@ FESystem<dim,spacedim>::get_interpolation_matrix (
   const FiniteElement<dim,spacedim> &x_source_fe,
   FullMatrix<double>           &interpolation_matrix) const
 {
-  Assert (interpolation_matrix.m() == this->dofs_per_cell,
+  // check that the size of the matrices is correct. for historical
+  // reasons, if you call matrix.reinit(8,0), it sets the sizes
+  // to m==n==0 internally. this may happen when we use a FE_Nothing,
+  // so write the test in a more lenient way
+  Assert ((interpolation_matrix.m() == this->dofs_per_cell)
+         ||
+         (x_source_fe.dofs_per_cell == 0),
           ExcDimensionMismatch (interpolation_matrix.m(),
                                 this->dofs_per_cell));
-  Assert (interpolation_matrix.n() == x_source_fe.dofs_per_cell,
+  Assert ((interpolation_matrix.n() == x_source_fe.dofs_per_cell)
+         ||
+         (this->dofs_per_cell == 0),
           ExcDimensionMismatch (interpolation_matrix.m(),
                                 x_source_fe.dofs_per_cell));
 
diff --git a/tests/hp/solution_transfer_04.cc b/tests/hp/solution_transfer_04.cc
new file mode 100644 (file)
index 0000000..985f6c6
--- /dev/null
@@ -0,0 +1,104 @@
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2011 - 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// testcase by Minh Do-Quang: a case where SolutionTransfer got into trouble
+// in a couple of places when using FE_Nothing and FESystem.
+
+#include "../tests.h"
+#include <fstream>
+#include <sstream>
+#include <iostream>
+
+#include <deal.II/base/logstream.h>
+
+#include <deal.II/grid/tria.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/hp/dof_handler.h>
+#include <deal.II/grid/tria_iterator.h>
+
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_nothing.h>
+#include <deal.II/dofs/dof_tools.h>
+
+#include <deal.II/hp/fe_collection.h>
+
+#include <deal.II/numerics/solution_transfer.h>
+
+#include <deal.II/numerics/data_out.h>
+
+using namespace dealii;
+
+int main()
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  Triangulation<2> triangulation;
+  GridGenerator::hyper_cube (triangulation);
+  triangulation.refine_global (1);
+
+
+  hp::FECollection<2>     fe_collection;
+
+  fe_collection.push_back(FESystem<2>(FE_Q<2>(1), 1, FE_Q<2>(1), 1));
+  fe_collection.push_back(FESystem<2>(FE_Nothing<2>(), 1, FE_Nothing<2>(), 1));
+
+  hp::DoFHandler<2> dof_handler(triangulation);
+
+  // Assign FE to cells
+  hp::DoFHandler<2>::active_cell_iterator cell;
+  hp::DoFHandler<2>::active_cell_iterator endc = dof_handler.end();      
+
+
+  cell = dof_handler.begin_active();
+  cell->set_active_fe_index(1);
+  cell++;
+  cell->set_active_fe_index(1);
+  cell++;
+  cell->set_active_fe_index(0);
+  cell++;
+  cell->set_active_fe_index(0);
+
+
+  dof_handler.distribute_dofs (fe_collection);
+
+  // Init solution
+  Vector<double> solution(dof_handler.n_dofs());
+  solution = 1.0;
+
+
+  SolutionTransfer<2, Vector<double>, hp::DoFHandler<2> > solultion_trans(dof_handler);
+  solultion_trans.prepare_for_coarsening_and_refinement(solution);
+
+  triangulation.execute_coarsening_and_refinement ();
+  dof_handler.distribute_dofs (fe_collection);
+  
+  Vector<double> new_solution(dof_handler.n_dofs());
+  solultion_trans.interpolate(solution, new_solution);
+
+  // we are good if we made it to here
+  deallog << "OK" << std::endl;
+}
+
+
+
diff --git a/tests/hp/solution_transfer_04.output b/tests/hp/solution_transfer_04.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK

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.