]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Document a problem with FiniteElementBase::face_to_cell_index in a couple of differen...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Aug 2013 22:11:08 +0000 (22:11 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 8 Aug 2013 22:11:08 +0000 (22:11 +0000)
git-svn-id: https://svn.dealii.org/trunk@30260 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/doxygen/headers/glossary.h
deal.II/include/deal.II/fe/fe_base.h
deal.II/source/fe/fe_data.cc
tests/fe/face_to_cell_q1_2d.cc [new file with mode: 0644]
tests/fe/face_to_cell_q1_2d/cmp/generic [new file with mode: 0644]
tests/fe/face_to_cell_q2_2d.cc [new file with mode: 0644]
tests/fe/face_to_cell_q2_2d/cmp/generic [new file with mode: 0644]

index c9a106b56987ffdf3f8be3b40682f0376887b3a8..a4acb8b8c6ce7e928c106809f69a11ddcdb2e6f1 100644 (file)
  * is pointing the other direction. There are not very many places in
  * application programs where you need this information actually, but
  * a few places in the library make use of this. Note that in 2d, the
- * result is always @p true.
+ * result is always @p true. However, while every face in 2d is always
+ * in standard orientation, you can sometimes specify something to
+ * assume that this is not so; an example is the function
+ * DoFTools::make_periodicity_constraints().
  *
  * There are two other flags that describe the orientation of a face:
  * face_flip and face_rotation. Some documentation for these
index f7e0de1021eb3e81f392a7ded73d40d797304bbe..c317c45b323f473f0510370f91c310dd12a84832 100644 (file)
@@ -426,7 +426,25 @@ public:
    * @return The index of this degree of freedom within the set
    *   of degrees of freedom on the entire cell. The returned value
    *   will be between zero and dofs_per_cell.
-   */
+   *
+   * @note This function exists in this class because that is where it
+   * was first implemented. However, it can't really work in the most
+   * general case without knowing what element we have. The reason is that
+   * when a face is flipped or rotated, we also need to know whether we
+   * need to swap the degrees of freedom on this face, or whether they
+   * are immune from this. For this, consider the situation of a $Q_3$
+   * element in 2d. If face_flip is true, then we need to consider
+   * the two degrees of freedom on the edge in reverse order. On the other
+   * hand, if the element were a $Q_1^2$, then because the two degrees of
+   * freedom on this edge belong to different vector components, they
+   * should not be considered in reverse order. What all of this shows is
+   * that the function can't work if there are more than one degree of
+   * freedom per line or quad, and that in these cases the function will
+   * throw an exception pointing out that this functionality will need
+   * to be provided by a derived class that knows what degrees of freedom
+   * actually represent.
+   */
+  virtual
   unsigned int face_to_cell_index (const unsigned int face_dof_index,
                                    const unsigned int face,
                                    const bool face_orientation = true,
index e0873d9ba3f6a6de3210041acf74a7796c600d76..1a0f0b02b8ea0a998abdd754c965172031c93f42 100644 (file)
@@ -113,6 +113,15 @@ face_to_cell_index (const unsigned int face_index,
   Assert (face < GeometryInfo<dim>::faces_per_cell,
           ExcIndexRange(face, 0, GeometryInfo<dim>::faces_per_cell));
 
+  // see the function's documentation for an explanation of this
+  // assertion -- in essence, derived classes have to implement
+  // an overloaded version of this function
+  Assert ((this->dofs_per_line <= 1) && (this->dofs_per_quad <= 1),
+          ExcMessage ("The function in this base class can not handle this case. "
+                      "Rather, the derived class you are using must provide "
+                      "an overloaded version but apparently hasn't done so. See "
+                      "the documentation of this function for more information."));
+
   // DoF on a vertex
   if (face_index < this->first_face_line_index)
     {
diff --git a/tests/fe/face_to_cell_q1_2d.cc b/tests/fe/face_to_cell_q1_2d.cc
new file mode 100644 (file)
index 0000000..da4e1a7
--- /dev/null
@@ -0,0 +1,65 @@
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 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.
+//
+// ---------------------------------------------------------------------
+
+
+// it turns out that FE_Q::face_to_cell_index() had a bug for elements beyond
+// Q2 when using the face flip flag. this test is for the 2d case for the Q1
+// case
+
+#include "../tests.h"
+#include <iostream>
+#include <fstream>
+
+#include <deal.II/base/logstream.h>
+#include <deal.II/fe/fe_q.h>
+
+template<int dim>
+void test()
+{
+  FE_Q<dim> fe(1);
+  const unsigned int dofs_per_face = fe.dofs_per_face;
+
+  for (unsigned int face=0; face<4; ++face)
+    {
+      deallog << "Face=" << face << std::endl;
+
+      for (int flip=0; flip<2; ++flip)
+       {
+         deallog << "  flip=" << (flip == 0 ? "false" : "true")
+                 << std::endl
+                 << "    ";
+         for (unsigned int i = 0; i < dofs_per_face; ++i)
+           deallog << fe.face_to_cell_index(i, face,
+                                            true,
+                                            (flip == 0 ? false : true),
+                                            false) << " - ";
+         deallog << std::endl;
+       }
+    }
+}
+
+int main()
+{
+  std::ofstream logfile("face_to_cell_q1_2d/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test<2>();
+}
+
+
+
diff --git a/tests/fe/face_to_cell_q1_2d/cmp/generic b/tests/fe/face_to_cell_q1_2d/cmp/generic
new file mode 100644 (file)
index 0000000..338a958
--- /dev/null
@@ -0,0 +1,21 @@
+
+DEAL::Face=0
+DEAL::  flip=false
+DEAL::    0 - 2 - 
+DEAL::  flip=true
+DEAL::    2 - 0 - 
+DEAL::Face=1
+DEAL::  flip=false
+DEAL::    1 - 3 - 
+DEAL::  flip=true
+DEAL::    3 - 1 - 
+DEAL::Face=2
+DEAL::  flip=false
+DEAL::    0 - 1 - 
+DEAL::  flip=true
+DEAL::    1 - 0 - 
+DEAL::Face=3
+DEAL::  flip=false
+DEAL::    2 - 3 - 
+DEAL::  flip=true
+DEAL::    3 - 2 - 
diff --git a/tests/fe/face_to_cell_q2_2d.cc b/tests/fe/face_to_cell_q2_2d.cc
new file mode 100644 (file)
index 0000000..c261b33
--- /dev/null
@@ -0,0 +1,65 @@
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 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.
+//
+// ---------------------------------------------------------------------
+
+
+// it turns out that FE_Q::face_to_cell_index() had a bug for elements beyond
+// Q2 when using the face flip flag. this test is for the 2d case for the Q2
+// case
+
+#include "../tests.h"
+#include <iostream>
+#include <fstream>
+
+#include <deal.II/base/logstream.h>
+#include <deal.II/fe/fe_q.h>
+
+template<int dim>
+void test()
+{
+  FE_Q<dim> fe(2);
+  const unsigned int dofs_per_face = fe.dofs_per_face;
+
+  for (unsigned int face=0; face<4; ++face)
+    {
+      deallog << "Face=" << face << std::endl;
+
+      for (int flip=0; flip<2; ++flip)
+       {
+         deallog << "  flip=" << (flip == 0 ? "false" : "true")
+                 << std::endl
+                 << "    ";
+         for (unsigned int i = 0; i < dofs_per_face; ++i)
+           deallog << fe.face_to_cell_index(i, face,
+                                            true,
+                                            (flip == 0 ? false : true),
+                                            false) << " - ";
+         deallog << std::endl;
+       }
+    }
+}
+
+int main()
+{
+  std::ofstream logfile("face_to_cell_q2_2d/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test<2>();
+}
+
+
+
diff --git a/tests/fe/face_to_cell_q2_2d/cmp/generic b/tests/fe/face_to_cell_q2_2d/cmp/generic
new file mode 100644 (file)
index 0000000..3cf9017
--- /dev/null
@@ -0,0 +1,21 @@
+
+DEAL::Face=0
+DEAL::  flip=false
+DEAL::    0 - 2 - 4 - 
+DEAL::  flip=true
+DEAL::    2 - 0 - 4 - 
+DEAL::Face=1
+DEAL::  flip=false
+DEAL::    1 - 3 - 5 - 
+DEAL::  flip=true
+DEAL::    3 - 1 - 5 - 
+DEAL::Face=2
+DEAL::  flip=false
+DEAL::    0 - 1 - 6 - 
+DEAL::  flip=true
+DEAL::    1 - 0 - 6 - 
+DEAL::Face=3
+DEAL::  flip=false
+DEAL::    2 - 3 - 7 - 
+DEAL::  flip=true
+DEAL::    3 - 2 - 7 - 

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.