]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fixed Jacobian for FlatManifold.
authorLuca Heltai <luca.heltai@sissa.it>
Thu, 3 Mar 2016 19:54:17 +0000 (20:54 +0100)
committerLuca Heltai <luca.heltai@sissa.it>
Wed, 6 Apr 2016 11:00:14 +0000 (13:00 +0200)
tests/fe/mapping_manifold_03.cc
tests/fe/mapping_manifold_04.cc [new file with mode: 0644]
tests/fe/mapping_manifold_04.output [new file with mode: 0644]

index b37b4e7d48d96a46c2f2d42f7383d736d01fce51..8d91e0703ad4f7d0d5a23ae900bfa9ba8d5ebcc7 100644 (file)
@@ -13,9 +13,8 @@
 //
 // ---------------------------------------------------------------------
 
-
-// Check that the quadrature points obtained through transform_unit_to_real
-// are the same of those given by FEValues
+// Check that the Jacobian obtained through MappingManifold and
+// MappingQ1 are the same on a FlatManifold, on trivial meshes
 
 
 #include "../tests.h"
diff --git a/tests/fe/mapping_manifold_04.cc b/tests/fe/mapping_manifold_04.cc
new file mode 100644 (file)
index 0000000..adfd3d9
--- /dev/null
@@ -0,0 +1,112 @@
+// ---------------------------------------------------------------------
+//
+// 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 that the Jacobian obtained through MappingManifold and
+// MappingQ1 are the same on a FlatManifold, with non-trivial cells
+
+
+#include "../tests.h"
+
+#include <deal.II/base/utilities.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/manifold_lib.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/fe/mapping_q_generic.h>
+#include <deal.II/fe/mapping_manifold.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_values.h>
+
+template<int dim, int spacedim>
+void test()
+{
+  deallog << "dim=" << dim << ", spacedim=" << spacedim << std::endl;
+
+  Triangulation<dim, spacedim>   triangulation;
+
+  Point<spacedim> center;
+  for (unsigned int i=0; i<spacedim; ++i)
+    center[i] = 5+i;
+
+  const double inner_radius = 0.5,
+               outer_radius = 1.0;
+  GridGenerator::hyper_shell (triangulation,
+                              center, inner_radius, outer_radius);
+
+  const QGauss<spacedim> quad(3);
+
+  FE_Q<dim,spacedim> fe(1);
+
+  DoFHandler<dim,spacedim> dof(triangulation);
+  dof.distribute_dofs(fe);
+
+  MappingManifold<dim,spacedim> mapping_manifold;
+  MappingQGeneric<dim,spacedim> mapping_q(1);
+
+  FEValues<dim,spacedim> fe_values_mapping (mapping_manifold,
+                                            fe, quad,
+                                            update_jacobians);
+
+  FEValues<dim,spacedim> fe_values_q (mapping_q,
+                                      fe, quad,
+                                      update_jacobians);
+
+  typename Triangulation<dim,spacedim>::active_cell_iterator cell= triangulation.begin_active();
+
+  fe_values_mapping.reinit(cell);
+  fe_values_q.reinit(cell);
+  std::vector<DerivativeForm<1,dim,spacedim> > jac_from_mapping_manifold = fe_values_mapping.get_jacobians();
+
+  std::vector<DerivativeForm<1,dim,spacedim> > jac_from_mapping_q = fe_values_q.get_jacobians();
+
+  AssertThrow(jac_from_mapping_q.size() == jac_from_mapping_manifold.size(), ExcInternalError());
+
+  for (unsigned int q=0; q<jac_from_mapping_q.size(); ++q)
+    {
+      double dist = 0;
+      for (unsigned int d=0; d<spacedim; ++d)
+        dist += (jac_from_mapping_manifold[q][d] - jac_from_mapping_q[q][d]).norm();
+      if (dist > 1e-10)
+        {
+          deallog << "Jacobian from mapping manifold at point "<< q << std::endl;
+          for (unsigned int d=0; d<spacedim; ++d)
+            deallog << jac_from_mapping_manifold[q][d] << std::endl;
+
+          deallog << "Jacobian from mapping q at point "<< q << std::endl;
+          for (unsigned int d=0; d<spacedim; ++d)
+            deallog << jac_from_mapping_q[q][d] << std::endl;
+        }
+    }
+
+  deallog << "OK" << std::endl;
+}
+
+
+int
+main()
+{
+  std::ofstream logfile ("output");
+  deallog.attach(logfile);
+  deallog.threshold_double(1.e-10);
+
+  test<2,2>();
+  test<3,3>();
+
+  return 0;
+}
+
+
+
diff --git a/tests/fe/mapping_manifold_04.output b/tests/fe/mapping_manifold_04.output
new file mode 100644 (file)
index 0000000..2aae953
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::dim=2, spacedim=2
+DEAL::OK
+DEAL::dim=3, spacedim=3
+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.