]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Also provide ways to extract symmetric gradients and divergences.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 14 Dec 2008 02:24:20 +0000 (02:24 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 14 Dec 2008 02:24:20 +0000 (02:24 +0000)
git-svn-id: https://svn.dealii.org/trunk@17939 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/fe/fe_values.h
tests/deal.II/fe_values_view_17.cc [new file with mode: 0644]
tests/deal.II/fe_values_view_17/cmp/generic [new file with mode: 0644]
tests/deal.II/fe_values_view_18.cc [new file with mode: 0644]
tests/deal.II/fe_values_view_18/cmp/generic [new file with mode: 0644]
tests/deal.II/fe_values_view_18/fe_values_view_09/cmp/generic [new file with mode: 0644]
tests/deal.II/fe_values_view_19.cc [new file with mode: 0644]
tests/deal.II/fe_values_view_19/cmp/generic [new file with mode: 0644]
tests/deal.II/fe_values_view_20.cc [new file with mode: 0644]
tests/deal.II/fe_values_view_20/cmp/generic [new file with mode: 0644]
tests/deal.II/fe_values_view_20/fe_values_view_09/cmp/generic [new file with mode: 0644]

index a2e9d94ed61ee352a15e5eaa30cb525673cc1abb..3d0b08b5e6943f3ca6f9c09a91290e6d0e84fbe4 100644 (file)
@@ -575,6 +575,53 @@ namespace FEValuesViews
       void get_function_gradients (const InputVector& fe_function,
                                   std::vector<gradient_type>& values) const;
 
+                                      /**
+                                       * Return the symmetrized gradients of
+                                       * the selected vector components of
+                                       * the finite element function
+                                       * characterized by
+                                       * <tt>fe_function</tt> at the
+                                       * quadrature points of the cell, face
+                                       * or subface selected the last time
+                                       * the <tt>reinit</tt> function of the
+                                       * FEValues object was called, at the
+                                       * quadrature points.
+                                       *
+                                       * There is no equivalent function such
+                                       * as
+                                       * FEValuesBase::get_function_gradients
+                                       * in the FEValues classes but the
+                                       * information can be obtained from
+                                       * FEValuesBase::get_function_gradients,
+                                       * of course.
+                                       */
+      template <class InputVector>
+      void get_function_symmetric_gradients (const InputVector& fe_function,
+                                            std::vector<symmetric_gradient_type>& values) const;
+      
+                                      /**
+                                       * Return the divergence of the selected
+                                       * vector components of the finite
+                                       * element function characterized by
+                                       * <tt>fe_function</tt> at the
+                                       * quadrature points of the cell, face
+                                       * or subface selected the last time
+                                       * the <tt>reinit</tt> function of the
+                                       * FEValues object was called, at the
+                                       * quadrature points.
+                                       *
+                                       * There is no equivalent function such
+                                       * as
+                                       * FEValuesBase::get_function_gradients
+                                       * in the FEValues classes but the
+                                       * information can be obtained from
+                                       * FEValuesBase::get_function_gradients,
+                                       * of course.
+                                       */
+      template <class InputVector>
+      void get_function_divergences (const InputVector& fe_function,
+                                    std::vector<divergence_type>& values) const;
+      
                                       /**
                                        * Return the Hessians of the selected
                                        * vector components of the finite
@@ -3704,6 +3751,116 @@ namespace FEValuesViews
 
 
 
+  template <int dim, int spacedim>  
+  template <class InputVector>
+  inline
+  void
+  Vector<dim,spacedim>::
+  get_function_symmetric_gradients (const InputVector &fe_function, 
+                                   std::vector<symmetric_gradient_type> &values) const
+  {
+    typedef FEValuesBase<dim,spacedim> FVB;
+    Assert (fe_values.update_flags & update_gradients,
+           typename FVB::ExcAccessToUninitializedField());    
+    Assert (values.size() == fe_values.n_quadrature_points,
+           ExcDimensionMismatch(values.size(), fe_values.n_quadrature_points));
+    Assert (fe_values.present_cell.get() != 0,
+           ExcMessage ("FEValues object is not reinit'ed to any cell"));
+    Assert (fe_function.size() == fe_values.present_cell->n_dofs_for_dof_handler(),
+           ExcDimensionMismatch(fe_function.size(),
+                                fe_values.present_cell->n_dofs_for_dof_handler()));
+
+                                    // get function values of dofs
+                                    // on this cell
+    dealii::Vector<typename InputVector::value_type> dof_values (fe_values.dofs_per_cell);
+    fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values);
+
+    std::fill (values.begin(), values.end(), symmetric_gradient_type());
+  
+    for (unsigned int shape_function=0;
+        shape_function<fe_values.fe->dofs_per_cell; ++shape_function)
+      {
+       const int snc = shape_function_data[shape_function].single_nonzero_component;
+       
+       if (snc == -2)
+                                          // shape function is zero for the
+                                          // selected components
+         continue;
+       else if (snc != -1)
+         for (unsigned int q_point=0; q_point<fe_values.n_quadrature_points; ++q_point)
+           values[q_point]
+             += dof_values(shape_function) *
+             symmetrize_single_row (shape_function_data[shape_function].single_nonzero_component_index,
+                                    fe_values.shape_gradients[snc][q_point]);
+       else
+         for (unsigned int q_point=0; q_point<fe_values.n_quadrature_points; ++q_point)
+           {
+             gradient_type grad;
+             for (unsigned int d=0; d<dim; ++d)    
+               if (shape_function_data[shape_function].is_nonzero_shape_function_component[d])
+                 grad[d] = (dof_values(shape_function) *
+                            fe_values.shape_gradients[shape_function_data[shape_function].row_index[d]][q_point]);
+             values[q_point] += symmetrize(grad);
+           }
+      }
+  }
+
+
+
+  template <int dim, int spacedim>  
+  template <class InputVector>
+  inline
+  void
+  Vector<dim,spacedim>::
+  get_function_divergences (const InputVector &fe_function, 
+                           std::vector<divergence_type> &values) const
+  {
+    typedef FEValuesBase<dim,spacedim> FVB;
+    Assert (fe_values.update_flags & update_gradients,
+           typename FVB::ExcAccessToUninitializedField());    
+    Assert (values.size() == fe_values.n_quadrature_points,
+           ExcDimensionMismatch(values.size(), fe_values.n_quadrature_points));
+    Assert (fe_values.present_cell.get() != 0,
+           ExcMessage ("FEValues object is not reinit'ed to any cell"));
+    Assert (fe_function.size() == fe_values.present_cell->n_dofs_for_dof_handler(),
+           ExcDimensionMismatch(fe_function.size(),
+                                fe_values.present_cell->n_dofs_for_dof_handler()));
+
+                                    // get function values of dofs
+                                    // on this cell
+    dealii::Vector<typename InputVector::value_type> dof_values (fe_values.dofs_per_cell);
+    fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values);
+
+    std::fill (values.begin(), values.end(), divergence_type());
+  
+    for (unsigned int shape_function=0;
+        shape_function<fe_values.fe->dofs_per_cell; ++shape_function)
+      {
+       const int snc = shape_function_data[shape_function].single_nonzero_component;
+       
+       if (snc == -2)
+                                          // shape function is zero for the
+                                          // selected components
+         continue;
+       else if (snc != -1)
+         for (unsigned int q_point=0; q_point<fe_values.n_quadrature_points; ++q_point)
+           values[q_point]
+             += dof_values(shape_function) *
+             fe_values.shape_gradients[snc][q_point][shape_function_data[shape_function].single_nonzero_component_index];
+       else
+         for (unsigned int q_point=0; q_point<fe_values.n_quadrature_points; ++q_point)
+           {
+             for (unsigned int d=0; d<dim; ++d)    
+               if (shape_function_data[shape_function].is_nonzero_shape_function_component[d])
+                 values[q_point] +=
+                   dof_values(shape_function) *
+                   fe_values.shape_gradients[shape_function_data[shape_function].row_index[d]][q_point][d];
+           }
+      }
+  }
+  
+
+
   template <int dim, int spacedim>  
   template <class InputVector>
   inline
diff --git a/tests/deal.II/fe_values_view_17.cc b/tests/deal.II/fe_values_view_17.cc
new file mode 100644 (file)
index 0000000..2b9de74
--- /dev/null
@@ -0,0 +1,118 @@
+//----------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2007, 2008 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------------------------------------------------
+
+
+// test the FEValues views and extractor classes. this test is for
+// get_function_symmetric_gradients for vector components and a primitive element
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <base/function.h>
+#include <base/quadrature_lib.h>
+#include <lac/vector.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_boundary_lib.h>
+#include <dofs/dof_handler.h>
+#include <fe/fe_q.h>
+#include <fe/fe_dgq.h>
+#include <fe/fe_system.h>
+#include <fe/fe_values.h>
+#include <fe/mapping_q1.h>
+
+#include <fstream>
+
+
+
+template<int dim>
+void test (const Triangulation<dim>& tr,
+          const FiniteElement<dim>& fe)
+{
+  deallog << "FE=" << fe.get_name()
+         << std::endl;
+
+  DoFHandler<dim> dof(tr);
+  dof.distribute_dofs(fe);
+
+  Vector<double> fe_function(dof.n_dofs());
+  for (unsigned int i=0; i<dof.n_dofs(); ++i)
+    fe_function(i) = i+1;
+  
+  const QGauss<dim> quadrature(2);
+  FEValues<dim> fe_values (fe, quadrature,
+                          update_values | update_gradients | update_hessians);
+  fe_values.reinit (dof.begin_active());
+
+  std::vector<SymmetricTensor<2,dim> > selected_vector_values (quadrature.n_quadrature_points);
+  std::vector<std::vector<Tensor<1,dim> > >
+    vector_values (quadrature.n_quadrature_points,
+                  std::vector<Tensor<1,dim> >(fe.n_components()));
+
+  fe_values.get_function_gradients (fe_function, vector_values);
+  
+  for (unsigned int c=0; c<fe.n_components(); ++c)
+                                    // use a vector extractor if there
+                                    // are sufficiently many components
+                                    // left after the current component
+                                    // 'c'
+    if (c+dim <= fe.n_components())
+      {
+       FEValuesExtractors::Vector vector_components (c);
+       fe_values[vector_components].get_function_symmetric_gradients (fe_function,
+                                                                      selected_vector_values);
+       deallog << "component=" << c << std::endl;
+      
+       for (unsigned int q=0; q<fe_values.n_quadrature_points; ++q)
+         {
+           deallog << selected_vector_values[q] << std::endl;
+
+           Tensor<2,dim> grad;
+           for (unsigned int d=0; d<dim; ++d)
+             grad[d] = vector_values[q][c+d];
+           
+           Assert ((selected_vector_values[q] - symmetrize(grad)).norm()
+                   <= 1e-12 * selected_vector_values[q].norm(),
+                   ExcInternalError());
+         }
+      }
+}
+
+
+
+template<int dim>
+void test_hyper_sphere()
+{
+  Triangulation<dim> tr;
+  GridGenerator::hyper_ball(tr);
+
+  static const HyperBallBoundary<dim> boundary;
+  tr.set_boundary (0, boundary);
+
+  FESystem<dim> fe (FE_Q<dim>(1), 1,
+                   FE_Q<dim>(2), 2,
+                   FE_DGQ<dim>(3), dim);
+  test(tr, fe);
+}
+
+
+int main()
+{
+  std::ofstream logfile ("fe_values_view_17/output");
+  deallog << std::setprecision (3);
+
+  deallog.attach(logfile);
+  deallog.depth_console (0);
+  deallog.threshold_double(1.e-10);
+
+  test_hyper_sphere<2>();
+  test_hyper_sphere<3>();
+}
diff --git a/tests/deal.II/fe_values_view_17/cmp/generic b/tests/deal.II/fe_values_view_17/cmp/generic
new file mode 100644 (file)
index 0000000..c56c9de
--- /dev/null
@@ -0,0 +1,59 @@
+
+DEAL::FE=FESystem<2>[FE_Q<2>(1)-FE_Q<2>(2)^2-FE_DGQ<2>(3)^2]
+DEAL::component=0
+DEAL::2.42 16.5 16.5 23.3
+DEAL::2.42 -0.114 -0.114 22.2
+DEAL::3.94 18.8 18.8 -33.3
+DEAL::3.94 -1.23 -1.23 -26.5
+DEAL::component=1
+DEAL::19.9 21.6 21.6 23.3
+DEAL::-16.1 3.06 3.06 22.2
+DEAL::25.4 -3.97 -3.97 -33.3
+DEAL::-19.2 -22.9 -22.9 -26.5
+DEAL::component=2
+DEAL::19.9 12.8 12.8 27.6
+DEAL::-16.1 12.3 12.3 30.4
+DEAL::25.4 -14.7 -14.7 26.7
+DEAL::-19.2 -11.3 -11.3 31.2
+DEAL::component=3
+DEAL::2.42 15.0 15.0 27.6
+DEAL::2.42 16.4 16.4 30.4
+DEAL::3.94 15.3 15.3 26.7
+DEAL::3.94 17.6 17.6 31.2
+DEAL::FE=FESystem<3>[FE_Q<3>(1)-FE_Q<3>(2)^2-FE_DGQ<3>(3)^3]
+DEAL::component=0
+DEAL::7.10 58.9 66.0 58.9 79.8 85.0 66.0 85.0 90.2
+DEAL::7.10 -39.7 -32.6 -39.7 78.8 84.0 -32.6 84.0 89.2
+DEAL::7.10 54.7 61.8 54.7 -66.2 11.0 61.8 11.0 88.1
+DEAL::7.10 -35.5 -28.4 -35.5 -65.1 11.0 -28.4 11.0 87.1
+DEAL::7.10 50.4 57.5 50.4 63.0 0.0566 57.5 0.0566 -62.9
+DEAL::7.10 -31.3 -24.2 -31.3 61.9 0.0566 -24.2 0.0566 -61.8
+DEAL::7.10 46.2 53.3 46.2 -49.3 -55.1 53.3 -55.1 -60.8
+DEAL::7.10 -27.0 -20.0 -27.0 -48.3 -54.0 -20.0 -54.0 -59.7
+DEAL::component=1
+DEAL::104. 91.7 48.7 91.7 79.8 59.3 48.7 59.3 114.
+DEAL::-93.5 -7.38 48.1 -7.38 78.8 58.8 48.1 58.8 114.
+DEAL::95.1 14.5 47.6 14.5 -66.2 58.3 47.6 58.3 114.
+DEAL::-85.1 -75.1 47.1 -75.1 -65.1 57.7 47.1 57.7 114.
+DEAL::86.7 74.8 -27.9 74.8 63.0 -17.2 -27.9 -17.2 114.
+DEAL::-76.7 -7.38 -27.4 -7.38 61.9 -16.7 -27.4 -16.7 114.
+DEAL::78.3 14.5 -26.8 14.5 -49.3 -16.2 -26.8 -16.2 114.
+DEAL::-68.3 -58.3 -26.3 -58.3 -48.3 -15.7 -26.3 -15.7 114.
+DEAL::component=2
+DEAL::104. 43.5 48.7 43.5 28.4 71.0 48.7 71.0 114.
+DEAL::-93.5 42.9 48.1 42.9 28.4 71.0 48.1 71.0 114.
+DEAL::95.1 -29.5 47.6 -29.5 28.4 71.0 47.6 71.0 114.
+DEAL::-85.1 -29.0 47.1 -29.0 28.4 71.0 47.1 71.0 114.
+DEAL::86.7 35.0 -27.9 35.0 28.4 71.0 -27.9 71.0 114.
+DEAL::-76.7 34.5 -27.4 34.5 28.4 71.0 -27.4 71.0 114.
+DEAL::78.3 -21.1 -26.8 -21.1 28.4 71.0 -26.8 71.0 114.
+DEAL::-68.3 -20.6 -26.3 -20.6 28.4 71.0 -26.3 71.0 114.
+DEAL::component=3
+DEAL::7.10 17.7 60.3 17.7 28.4 71.0 60.3 71.0 114.
+DEAL::7.10 17.7 60.3 17.7 28.4 71.0 60.3 71.0 114.
+DEAL::7.10 17.7 60.3 17.7 28.4 71.0 60.3 71.0 114.
+DEAL::7.10 17.7 60.3 17.7 28.4 71.0 60.3 71.0 114.
+DEAL::7.10 17.7 60.3 17.7 28.4 71.0 60.3 71.0 114.
+DEAL::7.10 17.7 60.3 17.7 28.4 71.0 60.3 71.0 114.
+DEAL::7.10 17.7 60.3 17.7 28.4 71.0 60.3 71.0 114.
+DEAL::7.10 17.7 60.3 17.7 28.4 71.0 60.3 71.0 114.
diff --git a/tests/deal.II/fe_values_view_18.cc b/tests/deal.II/fe_values_view_18.cc
new file mode 100644 (file)
index 0000000..66319cc
--- /dev/null
@@ -0,0 +1,120 @@
+//----------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2007, 2008 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------------------------------------------------
+
+
+// test the FEValues views and extractor classes. this test is for
+// get_function_symmetric_gradients for vector components and a non-primitive element
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <base/function.h>
+#include <base/quadrature_lib.h>
+#include <lac/vector.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_boundary_lib.h>
+#include <dofs/dof_handler.h>
+#include <fe/fe_q.h>
+#include <fe/fe_dgq.h>
+#include <fe/fe_nedelec.h>
+#include <fe/fe_raviart_thomas.h>
+#include <fe/fe_system.h>
+#include <fe/fe_values.h>
+#include <fe/mapping_q1.h>
+
+#include <fstream>
+
+
+
+template<int dim>
+void test (const Triangulation<dim>& tr,
+          const FiniteElement<dim>& fe)
+{
+  deallog << "FE=" << fe.get_name()
+         << std::endl;
+
+  DoFHandler<dim> dof(tr);
+  dof.distribute_dofs(fe);
+
+  Vector<double> fe_function(dof.n_dofs());
+  for (unsigned int i=0; i<dof.n_dofs(); ++i)
+    fe_function(i) = i+1;
+  
+  const QGauss<dim> quadrature(2);
+  FEValues<dim> fe_values (fe, quadrature,
+                          update_values | update_gradients | update_hessians);
+  fe_values.reinit (dof.begin_active());
+
+  std::vector<SymmetricTensor<2,dim> > selected_vector_values (quadrature.n_quadrature_points);
+  std::vector<std::vector<Tensor<1,dim> > >
+    vector_values (quadrature.n_quadrature_points,
+                  std::vector<Tensor<1,dim> >(fe.n_components()));
+
+  fe_values.get_function_gradients (fe_function, vector_values);
+  
+  for (unsigned int c=0; c<fe.n_components(); ++c)
+                                    // use a vector extractor if there
+                                    // are sufficiently many components
+                                    // left after the current component
+                                    // 'c'
+    if (c+dim <= fe.n_components())
+      {
+       FEValuesExtractors::Vector vector_components (c);
+       fe_values[vector_components].get_function_symmetric_gradients (fe_function,
+                                                                      selected_vector_values);
+       deallog << "component=" << c << std::endl;
+      
+       for (unsigned int q=0; q<fe_values.n_quadrature_points; ++q)
+         {
+           deallog << selected_vector_values[q] << std::endl;
+
+           Tensor<2,dim> grad;
+           for (unsigned int d=0; d<dim; ++d)
+             grad[d] = vector_values[q][c+d];
+           
+           Assert ((selected_vector_values[q] - symmetrize(grad)).norm()
+                   <= 1e-12 * selected_vector_values[q].norm(),
+                   ExcInternalError());
+         }
+      }
+}
+
+
+
+template<int dim>
+void test_hyper_sphere()
+{
+  Triangulation<dim> tr;
+  GridGenerator::hyper_ball(tr);
+
+  static const HyperBallBoundary<dim> boundary;
+  tr.set_boundary (0, boundary);
+
+  FESystem<dim> fe (FE_Q<dim>(1), 1,
+                   FE_RaviartThomas<dim>(1), 1,
+                   FE_Nedelec<dim>(1), 1);
+  test(tr, fe);
+}
+
+
+int main()
+{
+  std::ofstream logfile ("fe_values_view_18/output");
+  deallog << std::setprecision (3);
+
+  deallog.attach(logfile);
+  deallog.depth_console (0);
+  deallog.threshold_double(1.e-10);
+
+  test_hyper_sphere<2>();
+  test_hyper_sphere<3>();
+}
diff --git a/tests/deal.II/fe_values_view_18/cmp/generic b/tests/deal.II/fe_values_view_18/cmp/generic
new file mode 100644 (file)
index 0000000..b45f806
--- /dev/null
@@ -0,0 +1,68 @@
+
+DEAL::FE=FESystem<2>[FE_Q<2>(1)-FE_RaviartThomas<2>(1)-FE_Nedelec<2>(1)]
+DEAL::component=0
+DEAL::0.807 11.3 11.3 352.
+DEAL::0.807 -6.44 -6.44 337.
+DEAL::1.31 169. 169. 180.
+DEAL::1.31 -145. -145. 296.
+DEAL::component=1
+DEAL::18.2 197. 197. -31.7
+DEAL::-18.2 190. 190. 118.
+DEAL::333. 153. 153. -61.1
+DEAL::-295. 210. 210. -40.8
+DEAL::component=2
+DEAL::43.2 -15.8 -15.8 5.84
+DEAL::43.2 58.8 58.8 5.84
+DEAL::125. -30.5 -30.5 9.52
+DEAL::125. -20.4 -20.4 9.52
+DEAL::component=3
+DEAL::2.58e-16 5.84 5.84 -6.75
+DEAL::2.58e-16 5.84 5.84 6.75
+DEAL::3.58e-16 9.52 9.52 -11.0
+DEAL::3.58e-16 9.52 9.52 11.0
+DEAL::FE=FESystem<3>[FE_Q<3>(1)-FE_RaviartThomas<3>(1)-FE_Nedelec<3>(1)]
+DEAL::component=0
+DEAL::2.37 2.37 -133. 2.37 -275. -68.8 -133. -68.8 -138.
+DEAL::2.37 2.37 -133. 2.37 -275. -298. -133. -298. 4.80e+03
+DEAL::2.37 -181. -133. -181. -275. 2.36e+03 -133. 2.36e+03 -138.
+DEAL::2.37 186. -133. 186. -275. 2.69e+03 -133. 2.69e+03 5.02e+03
+DEAL::2.37 -89.4 2.34e+03 -89.4 4.57e+03 -115. 2.34e+03 -115. -138.
+DEAL::2.37 94.1 2.34e+03 94.1 4.79e+03 1.69e+03 2.34e+03 1.69e+03 4.80e+03
+DEAL::2.37 2.40e+03 2.44e+03 2.40e+03 4.57e+03 2.40e+03 2.44e+03 2.40e+03 -138.
+DEAL::2.37 -2.19e+03 2.44e+03 -2.19e+03 4.79e+03 916. 2.44e+03 916. 5.02e+03
+DEAL::component=1
+DEAL::8.18e-13 -275. -206. -275. 1.30e-12 -138. -206. -138. 1.36e-12
+DEAL::-5.71e-13 -275. -206. -275. -459. 4.85e+03 -206. 4.85e+03 -367.
+DEAL::-367. -275. 4.73e+03 -275. -1.40e-12 -138. 4.73e+03 -138. -184.
+DEAL::367. -275. 4.84e+03 -275. 459. 4.96e+03 4.84e+03 4.96e+03 2.23e+03
+DEAL::-184. 4.62e+03 -206. 4.62e+03 -91.8 -138. -206. -138. -3.64e-12
+DEAL::184. 4.73e+03 -206. 4.73e+03 3.52e+03 4.96e+03 -206. 4.96e+03 367.
+DEAL::4.80e+03 4.73e+03 4.84e+03 4.73e+03 91.8 -138. 4.84e+03 -138. 184.
+DEAL::-4.38e+03 4.83e+03 4.95e+03 4.83e+03 -3.09e+03 5.06e+03 4.95e+03 5.06e+03 -1.81e+03
+DEAL::component=2
+DEAL::-275. -138. -68.8 -138. -138. 2.80 -68.8 2.80 22.4
+DEAL::-275. -367. 2.40e+03 -367. 4.90e+03 -181. 2.40e+03 -181. 22.4
+DEAL::-275. 2.38e+03 -68.8 2.38e+03 -138. -89.0 -68.8 -89.0 22.4
+DEAL::-275. 2.61e+03 2.51e+03 2.61e+03 4.90e+03 1.12e+03 2.51e+03 1.12e+03 22.4
+DEAL::4.67e+03 -184. -68.8 -184. -138. 2.80 -68.8 2.80 22.4
+DEAL::4.67e+03 1.62e+03 2.40e+03 1.62e+03 5.11e+03 186. 2.40e+03 186. 22.4
+DEAL::4.88e+03 2.53e+03 -68.8 2.53e+03 -138. 94.6 -68.8 94.6 22.4
+DEAL::4.88e+03 939. 2.51e+03 939. 5.11e+03 -901. 2.51e+03 -901. 22.4
+DEAL::component=3
+DEAL::-275. -68.8 2.80 -68.8 5.60 11.2 2.80 11.2 22.4
+DEAL::-275. 2.45e+03 -181. 2.45e+03 5.60 11.2 -181. 11.2 22.4
+DEAL::4.76e+03 -68.8 -89.0 -68.8 5.60 11.2 -89.0 11.2 22.4
+DEAL::4.76e+03 2.45e+03 1.12e+03 2.45e+03 5.60 11.2 1.12e+03 11.2 22.4
+DEAL::-275. -68.8 2.80 -68.8 5.60 11.2 2.80 11.2 22.4
+DEAL::-275. 2.55e+03 186. 2.55e+03 5.60 11.2 186. 11.2 22.4
+DEAL::4.97e+03 -68.8 94.6 -68.8 5.60 11.2 94.6 11.2 22.4
+DEAL::4.97e+03 2.55e+03 -901. 2.55e+03 5.60 11.2 -901. 11.2 22.4
+DEAL::component=4
+DEAL::-7.70e-16 5.60 14.0 5.60 5.78e-16 16.8 14.0 16.8 -1.38e-15
+DEAL::-7.70e-16 5.60 14.0 5.60 -1.39e-15 16.8 14.0 16.8 1.96e-16
+DEAL::-6.69e-16 5.60 14.0 5.60 5.78e-16 16.8 14.0 16.8 1.23e-17
+DEAL::-6.69e-16 5.60 14.0 5.60 -1.39e-15 16.8 14.0 16.8 1.50e-15
+DEAL::1.58e-16 5.60 14.0 5.60 -6.60e-16 16.8 14.0 16.8 -1.38e-15
+DEAL::1.58e-16 5.60 14.0 5.60 3.53e-16 16.8 14.0 16.8 1.96e-16
+DEAL::9.52e-16 5.60 14.0 5.60 -6.60e-16 16.8 14.0 16.8 1.23e-17
+DEAL::9.52e-16 5.60 14.0 5.60 3.53e-16 16.8 14.0 16.8 1.50e-15
diff --git a/tests/deal.II/fe_values_view_18/fe_values_view_09/cmp/generic b/tests/deal.II/fe_values_view_18/fe_values_view_09/cmp/generic
new file mode 100644 (file)
index 0000000..977609c
--- /dev/null
@@ -0,0 +1,91 @@
+
+DEAL::FE=FESystem<2>[FE_Q<2>(1)-FE_RaviartThomas<2>(1)-FE_Nedelec<2>(1)]
+DEAL::component=0
+DEAL::0.807 4.36
+DEAL::0.807 5.29
+DEAL::1.31 4.07
+DEAL::1.31 5.59
+DEAL::component=1
+DEAL::18.2 352.
+DEAL::-18.2 337.
+DEAL::333. 180.
+DEAL::-295. 296.
+DEAL::component=2
+DEAL::43.2 -31.7
+DEAL::43.2 118.
+DEAL::125. -61.1
+DEAL::125. -40.8
+DEAL::component=3
+DEAL::2.58e-16 5.84
+DEAL::2.58e-16 5.84
+DEAL::3.58e-16 9.52
+DEAL::3.58e-16 9.52
+DEAL::component=4
+DEAL::5.84 -6.75
+DEAL::5.84 6.75
+DEAL::9.52 -11.0
+DEAL::9.52 11.0
+DEAL::FE=FESystem<3>[FE_Q<3>(1)-FE_RaviartThomas<3>(1)-FE_Nedelec<3>(1)]
+DEAL::component=0
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::component=1
+DEAL::8.18e-13 -275. -138.
+DEAL::-5.71e-13 -275. -138.
+DEAL::-367. -275. 4.71e+03
+DEAL::367. -275. 4.92e+03
+DEAL::-184. 4.57e+03 -138.
+DEAL::184. 4.79e+03 -138.
+DEAL::4.80e+03 4.57e+03 4.71e+03
+DEAL::-4.38e+03 4.79e+03 4.92e+03
+DEAL::component=2
+DEAL::-275. 1.30e-12 -138.
+DEAL::-275. -459. 4.80e+03
+DEAL::-275. -1.40e-12 -138.
+DEAL::-275. 459. 5.02e+03
+DEAL::4.67e+03 -91.8 -138.
+DEAL::4.67e+03 3.52e+03 4.80e+03
+DEAL::4.88e+03 91.8 -138.
+DEAL::4.88e+03 -3.09e+03 5.02e+03
+DEAL::component=3
+DEAL::-275. -138. 1.36e-12
+DEAL::-275. 4.90e+03 -367.
+DEAL::4.76e+03 -138. -184.
+DEAL::4.76e+03 4.90e+03 2.23e+03
+DEAL::-275. -138. -3.64e-12
+DEAL::-275. 5.11e+03 367.
+DEAL::4.97e+03 -138. 184.
+DEAL::4.97e+03 5.11e+03 -1.81e+03
+DEAL::component=4
+DEAL::-7.70e-16 5.60 22.4
+DEAL::-7.70e-16 5.60 22.4
+DEAL::-6.69e-16 5.60 22.4
+DEAL::-6.69e-16 5.60 22.4
+DEAL::1.58e-16 5.60 22.4
+DEAL::1.58e-16 5.60 22.4
+DEAL::9.52e-16 5.60 22.4
+DEAL::9.52e-16 5.60 22.4
+DEAL::component=5
+DEAL::5.60 5.78e-16 22.4
+DEAL::5.60 -1.39e-15 22.4
+DEAL::5.60 5.78e-16 22.4
+DEAL::5.60 -1.39e-15 22.4
+DEAL::5.60 -6.60e-16 22.4
+DEAL::5.60 3.53e-16 22.4
+DEAL::5.60 -6.60e-16 22.4
+DEAL::5.60 3.53e-16 22.4
+DEAL::component=6
+DEAL::5.60 11.2 -1.38e-15
+DEAL::5.60 11.2 1.96e-16
+DEAL::5.60 11.2 1.23e-17
+DEAL::5.60 11.2 1.50e-15
+DEAL::5.60 11.2 -1.38e-15
+DEAL::5.60 11.2 1.96e-16
+DEAL::5.60 11.2 1.23e-17
+DEAL::5.60 11.2 1.50e-15
diff --git a/tests/deal.II/fe_values_view_19.cc b/tests/deal.II/fe_values_view_19.cc
new file mode 100644 (file)
index 0000000..f8d054a
--- /dev/null
@@ -0,0 +1,118 @@
+//----------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2007, 2008 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------------------------------------------------
+
+
+// test the FEValues views and extractor classes. this test is for
+// get_function_divergences for vector components and a primitive element
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <base/function.h>
+#include <base/quadrature_lib.h>
+#include <lac/vector.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_boundary_lib.h>
+#include <dofs/dof_handler.h>
+#include <fe/fe_q.h>
+#include <fe/fe_dgq.h>
+#include <fe/fe_system.h>
+#include <fe/fe_values.h>
+#include <fe/mapping_q1.h>
+
+#include <fstream>
+
+
+
+template<int dim>
+void test (const Triangulation<dim>& tr,
+          const FiniteElement<dim>& fe)
+{
+  deallog << "FE=" << fe.get_name()
+         << std::endl;
+
+  DoFHandler<dim> dof(tr);
+  dof.distribute_dofs(fe);
+
+  Vector<double> fe_function(dof.n_dofs());
+  for (unsigned int i=0; i<dof.n_dofs(); ++i)
+    fe_function(i) = i+1;
+  
+  const QGauss<dim> quadrature(2);
+  FEValues<dim> fe_values (fe, quadrature,
+                          update_values | update_gradients | update_hessians);
+  fe_values.reinit (dof.begin_active());
+
+  std::vector<double> selected_vector_values (quadrature.n_quadrature_points);
+  std::vector<std::vector<Tensor<1,dim> > >
+    vector_values (quadrature.n_quadrature_points,
+                  std::vector<Tensor<1,dim> >(fe.n_components()));
+
+  fe_values.get_function_gradients (fe_function, vector_values);
+  
+  for (unsigned int c=0; c<fe.n_components(); ++c)
+                                    // use a vector extractor if there
+                                    // are sufficiently many components
+                                    // left after the current component
+                                    // 'c'
+    if (c+dim <= fe.n_components())
+      {
+       FEValuesExtractors::Vector vector_components (c);
+       fe_values[vector_components].get_function_divergences (fe_function,
+                                                              selected_vector_values);
+       deallog << "component=" << c << std::endl;
+      
+       for (unsigned int q=0; q<fe_values.n_quadrature_points; ++q)
+         {
+           deallog << selected_vector_values[q] << std::endl;
+
+           Tensor<2,dim> grad;
+           for (unsigned int d=0; d<dim; ++d)
+             grad[d] = vector_values[q][c+d];
+           
+           Assert (std::fabs(selected_vector_values[q] - trace(grad))
+                   <= 1e-12 * std::fabs(selected_vector_values[q]),
+                   ExcInternalError());
+         }
+      }
+}
+
+
+
+template<int dim>
+void test_hyper_sphere()
+{
+  Triangulation<dim> tr;
+  GridGenerator::hyper_ball(tr);
+
+  static const HyperBallBoundary<dim> boundary;
+  tr.set_boundary (0, boundary);
+
+  FESystem<dim> fe (FE_Q<dim>(1), 1,
+                   FE_Q<dim>(2), 2,
+                   FE_DGQ<dim>(3), dim);
+  test(tr, fe);
+}
+
+
+int main()
+{
+  std::ofstream logfile ("fe_values_view_19/output");
+  deallog << std::setprecision (3);
+
+  deallog.attach(logfile);
+  deallog.depth_console (0);
+  deallog.threshold_double(1.e-10);
+
+  test_hyper_sphere<2>();
+  test_hyper_sphere<3>();
+}
diff --git a/tests/deal.II/fe_values_view_19/cmp/generic b/tests/deal.II/fe_values_view_19/cmp/generic
new file mode 100644 (file)
index 0000000..7a96858
--- /dev/null
@@ -0,0 +1,59 @@
+
+DEAL::FE=FESystem<2>[FE_Q<2>(1)-FE_Q<2>(2)^2-FE_DGQ<2>(3)^2]
+DEAL::component=0
+DEAL::25.7
+DEAL::24.6
+DEAL::-29.4
+DEAL::-22.6
+DEAL::component=1
+DEAL::43.1
+DEAL::6.12
+DEAL::-7.93
+DEAL::-45.8
+DEAL::component=2
+DEAL::47.4
+DEAL::14.3
+DEAL::52.1
+DEAL::12.0
+DEAL::component=3
+DEAL::30.0
+DEAL::32.8
+DEAL::30.6
+DEAL::35.2
+DEAL::FE=FESystem<3>[FE_Q<3>(1)-FE_Q<3>(2)^2-FE_DGQ<3>(3)^3]
+DEAL::component=0
+DEAL::177.
+DEAL::175.
+DEAL::29.1
+DEAL::29.1
+DEAL::7.21
+DEAL::7.21
+DEAL::-103.
+DEAL::-101.
+DEAL::component=1
+DEAL::297.
+DEAL::98.8
+DEAL::143.
+DEAL::-36.7
+DEAL::263.
+DEAL::98.8
+DEAL::143.
+DEAL::-3.00
+DEAL::component=2
+DEAL::245.
+DEAL::48.4
+DEAL::237.
+DEAL::56.8
+DEAL::229.
+DEAL::65.3
+DEAL::220.
+DEAL::73.7
+DEAL::component=3
+DEAL::149.
+DEAL::149.
+DEAL::149.
+DEAL::149.
+DEAL::149.
+DEAL::149.
+DEAL::149.
+DEAL::149.
diff --git a/tests/deal.II/fe_values_view_20.cc b/tests/deal.II/fe_values_view_20.cc
new file mode 100644 (file)
index 0000000..1be1f3e
--- /dev/null
@@ -0,0 +1,122 @@
+//----------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2007, 2008 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------------------------------------------------
+
+
+// test the FEValues views and extractor classes. this test is for
+// get_function_divergences for vector components and a non-primitive element
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <base/function.h>
+#include <base/quadrature_lib.h>
+#include <lac/vector.h>
+#include <grid/grid_generator.h>
+#include <grid/tria_boundary_lib.h>
+#include <dofs/dof_handler.h>
+#include <fe/fe_q.h>
+#include <fe/fe_dgq.h>
+#include <fe/fe_nedelec.h>
+#include <fe/fe_raviart_thomas.h>
+#include <fe/fe_system.h>
+#include <fe/fe_values.h>
+#include <fe/mapping_q1.h>
+
+#include <fstream>
+
+
+
+template<int dim>
+void test (const Triangulation<dim>& tr,
+          const FiniteElement<dim>& fe)
+{
+  deallog << "FE=" << fe.get_name()
+         << std::endl;
+
+  DoFHandler<dim> dof(tr);
+  dof.distribute_dofs(fe);
+
+  Vector<double> fe_function(dof.n_dofs());
+  for (unsigned int i=0; i<dof.n_dofs(); ++i)
+    fe_function(i) = i+1;
+  
+  const QGauss<dim> quadrature(2);
+  FEValues<dim> fe_values (fe, quadrature,
+                          update_values | update_gradients | update_hessians);
+  fe_values.reinit (dof.begin_active());
+
+  std::vector<double> selected_vector_values (quadrature.n_quadrature_points);
+  std::vector<std::vector<Tensor<1,dim> > >
+    vector_values (quadrature.n_quadrature_points,
+                  std::vector<Tensor<1,dim> >(fe.n_components()));
+
+  fe_values.get_function_gradients (fe_function, vector_values);
+  
+  for (unsigned int c=0; c<fe.n_components(); ++c)
+                                    // use a vector extractor if there
+                                    // are sufficiently many components
+                                    // left after the current component
+                                    // 'c'
+    if (c+dim <= fe.n_components())
+      {
+       FEValuesExtractors::Vector vector_components (c);
+       fe_values[vector_components].get_function_divergences (fe_function,
+                                                              selected_vector_values);
+       deallog << "component=" << c << std::endl;
+      
+       for (unsigned int q=0; q<fe_values.n_quadrature_points; ++q)
+         {
+           deallog << selected_vector_values[q] << std::endl;
+
+           Tensor<2,dim> grad;
+           for (unsigned int d=0; d<dim; ++d)
+             grad[d] = vector_values[q][c+d];
+           
+           Assert ((std::fabs(selected_vector_values[q] - trace(grad))
+                    <= 1e-12 * std::fabs(selected_vector_values[q]))
+                   ||
+                   (std::fabs(selected_vector_values[q]) <= 1e-10),
+                   ExcInternalError());
+         }
+      }
+}
+
+
+
+template<int dim>
+void test_hyper_sphere()
+{
+  Triangulation<dim> tr;
+  GridGenerator::hyper_ball(tr);
+
+  static const HyperBallBoundary<dim> boundary;
+  tr.set_boundary (0, boundary);
+
+  FESystem<dim> fe (FE_Q<dim>(1), 1,
+                   FE_RaviartThomas<dim>(1), 1,
+                   FE_Nedelec<dim>(1), 1);
+  test(tr, fe);
+}
+
+
+int main()
+{
+  std::ofstream logfile ("fe_values_view_20/output");
+  deallog << std::setprecision (3);
+
+  deallog.attach(logfile);
+  deallog.depth_console (0);
+  deallog.threshold_double(1.e-10);
+
+  test_hyper_sphere<2>();
+  test_hyper_sphere<3>();
+}
diff --git a/tests/deal.II/fe_values_view_20/cmp/generic b/tests/deal.II/fe_values_view_20/cmp/generic
new file mode 100644 (file)
index 0000000..1807e53
--- /dev/null
@@ -0,0 +1,68 @@
+
+DEAL::FE=FESystem<2>[FE_Q<2>(1)-FE_RaviartThomas<2>(1)-FE_Nedelec<2>(1)]
+DEAL::component=0
+DEAL::353.
+DEAL::338.
+DEAL::182.
+DEAL::297.
+DEAL::component=1
+DEAL::-13.5
+DEAL::99.4
+DEAL::272.
+DEAL::-336.
+DEAL::component=2
+DEAL::49.0
+DEAL::49.0
+DEAL::134.
+DEAL::134.
+DEAL::component=3
+DEAL::-6.75
+DEAL::6.75
+DEAL::-11.0
+DEAL::11.0
+DEAL::FE=FESystem<3>[FE_Q<3>(1)-FE_RaviartThomas<3>(1)-FE_Nedelec<3>(1)]
+DEAL::component=0
+DEAL::-411.
+DEAL::4.53e+03
+DEAL::-411.
+DEAL::4.74e+03
+DEAL::4.44e+03
+DEAL::9.59e+03
+DEAL::4.44e+03
+DEAL::9.80e+03
+DEAL::component=1
+DEAL::0
+DEAL::-826.
+DEAL::-551.
+DEAL::3.06e+03
+DEAL::-275.
+DEAL::4.07e+03
+DEAL::5.08e+03
+DEAL::-9.27e+03
+DEAL::component=2
+DEAL::-391.
+DEAL::4.64e+03
+DEAL::-391.
+DEAL::4.64e+03
+DEAL::4.55e+03
+DEAL::9.80e+03
+DEAL::4.76e+03
+DEAL::1.00e+04
+DEAL::component=3
+DEAL::-247.
+DEAL::-247.
+DEAL::4.79e+03
+DEAL::4.79e+03
+DEAL::-247.
+DEAL::-247.
+DEAL::5.00e+03
+DEAL::5.00e+03
+DEAL::component=4
+DEAL::0
+DEAL::0
+DEAL::0
+DEAL::0
+DEAL::0
+DEAL::0
+DEAL::0
+DEAL::0
diff --git a/tests/deal.II/fe_values_view_20/fe_values_view_09/cmp/generic b/tests/deal.II/fe_values_view_20/fe_values_view_09/cmp/generic
new file mode 100644 (file)
index 0000000..977609c
--- /dev/null
@@ -0,0 +1,91 @@
+
+DEAL::FE=FESystem<2>[FE_Q<2>(1)-FE_RaviartThomas<2>(1)-FE_Nedelec<2>(1)]
+DEAL::component=0
+DEAL::0.807 4.36
+DEAL::0.807 5.29
+DEAL::1.31 4.07
+DEAL::1.31 5.59
+DEAL::component=1
+DEAL::18.2 352.
+DEAL::-18.2 337.
+DEAL::333. 180.
+DEAL::-295. 296.
+DEAL::component=2
+DEAL::43.2 -31.7
+DEAL::43.2 118.
+DEAL::125. -61.1
+DEAL::125. -40.8
+DEAL::component=3
+DEAL::2.58e-16 5.84
+DEAL::2.58e-16 5.84
+DEAL::3.58e-16 9.52
+DEAL::3.58e-16 9.52
+DEAL::component=4
+DEAL::5.84 -6.75
+DEAL::5.84 6.75
+DEAL::9.52 -11.0
+DEAL::9.52 11.0
+DEAL::FE=FESystem<3>[FE_Q<3>(1)-FE_RaviartThomas<3>(1)-FE_Nedelec<3>(1)]
+DEAL::component=0
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::2.37 4.73 9.46
+DEAL::component=1
+DEAL::8.18e-13 -275. -138.
+DEAL::-5.71e-13 -275. -138.
+DEAL::-367. -275. 4.71e+03
+DEAL::367. -275. 4.92e+03
+DEAL::-184. 4.57e+03 -138.
+DEAL::184. 4.79e+03 -138.
+DEAL::4.80e+03 4.57e+03 4.71e+03
+DEAL::-4.38e+03 4.79e+03 4.92e+03
+DEAL::component=2
+DEAL::-275. 1.30e-12 -138.
+DEAL::-275. -459. 4.80e+03
+DEAL::-275. -1.40e-12 -138.
+DEAL::-275. 459. 5.02e+03
+DEAL::4.67e+03 -91.8 -138.
+DEAL::4.67e+03 3.52e+03 4.80e+03
+DEAL::4.88e+03 91.8 -138.
+DEAL::4.88e+03 -3.09e+03 5.02e+03
+DEAL::component=3
+DEAL::-275. -138. 1.36e-12
+DEAL::-275. 4.90e+03 -367.
+DEAL::4.76e+03 -138. -184.
+DEAL::4.76e+03 4.90e+03 2.23e+03
+DEAL::-275. -138. -3.64e-12
+DEAL::-275. 5.11e+03 367.
+DEAL::4.97e+03 -138. 184.
+DEAL::4.97e+03 5.11e+03 -1.81e+03
+DEAL::component=4
+DEAL::-7.70e-16 5.60 22.4
+DEAL::-7.70e-16 5.60 22.4
+DEAL::-6.69e-16 5.60 22.4
+DEAL::-6.69e-16 5.60 22.4
+DEAL::1.58e-16 5.60 22.4
+DEAL::1.58e-16 5.60 22.4
+DEAL::9.52e-16 5.60 22.4
+DEAL::9.52e-16 5.60 22.4
+DEAL::component=5
+DEAL::5.60 5.78e-16 22.4
+DEAL::5.60 -1.39e-15 22.4
+DEAL::5.60 5.78e-16 22.4
+DEAL::5.60 -1.39e-15 22.4
+DEAL::5.60 -6.60e-16 22.4
+DEAL::5.60 3.53e-16 22.4
+DEAL::5.60 -6.60e-16 22.4
+DEAL::5.60 3.53e-16 22.4
+DEAL::component=6
+DEAL::5.60 11.2 -1.38e-15
+DEAL::5.60 11.2 1.96e-16
+DEAL::5.60 11.2 1.23e-17
+DEAL::5.60 11.2 1.50e-15
+DEAL::5.60 11.2 -1.38e-15
+DEAL::5.60 11.2 1.96e-16
+DEAL::5.60 11.2 1.23e-17
+DEAL::5.60 11.2 1.50e-15

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.