]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
start testing laplacian
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 6 Aug 2012 16:53:25 +0000 (16:53 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 6 Aug 2012 16:53:25 +0000 (16:53 +0000)
git-svn-id: https://svn.dealii.org/trunk@25753 0785d39b-7218-0410-832d-ea1e28bc413d

tests/integrators/laplacian_01.cc [new file with mode: 0644]
tests/integrators/laplacian_01/cmp/generic [new file with mode: 0644]

diff --git a/tests/integrators/laplacian_01.cc b/tests/integrators/laplacian_01.cc
new file mode 100644 (file)
index 0000000..4836a58
--- /dev/null
@@ -0,0 +1,152 @@
+//--------------------------------------------------------------------
+//    $Id: cochain_01.cc 25686 2012-07-04 14:18:43Z bangerth $
+//
+//    Copyright (C) 2012 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 functions in integrators/laplace.h
+// Output matrices and assert consistency of residuals
+
+#include "../tests.h"
+#include "../lib/test_grids.h"
+
+#include <deal.II/base/logstream.h>
+#include <deal.II/integrators/laplace.h>
+
+#include <deal.II/fe/fe_dgq.h>
+#include <deal.II/fe/fe_nedelec.h>
+
+using namespace LocalIntegrators::Laplace;
+
+template <int dim>
+void test_cell(const FEValuesBase<dim>& fev)
+{
+  const unsigned int n = fev.dofs_per_cell;
+  FullMatrix<double> M(n,n);
+//  Vector<double> u(n), v(n);
+  
+  cell_matrix(M,fev);
+  M.print(deallog,8);
+}
+
+
+template <int dim>
+void test_boundary(const FEValuesBase<dim>& fev)
+{
+  const unsigned int n = fev.dofs_per_cell;
+  FullMatrix<double> M(n,n);
+  Vector<double> u(n), v(n), w(n);
+  
+  nitsche_matrix(M, fev, 17);
+  M.print(deallog,8);
+
+  // deallog << "Residuals";
+  // for (unsigned int i=0;i<n;++i)
+  //   {
+  //     u = 0.;
+  //     u(i) = 1.;
+  //     M.vmult(v,u);
+  //     nitsche_residual(w, fev, 17);
+  //     w.add(-1., v);
+  //     deallog << ' ' << w.l2_norm();
+  //   }
+  // deallog << std::endl;
+}
+
+
+template <int dim>
+void test_face(const FEValuesBase<dim>& fev1,
+              const FEValuesBase<dim>& fev2)
+{
+  const unsigned int n1 = fev1.dofs_per_cell;
+  const unsigned int n2 = fev1.dofs_per_cell;
+  FullMatrix<double> M11(n1,n1);
+  FullMatrix<double> M12(n1,n2);
+  FullMatrix<double> M21(n2,n1);
+  FullMatrix<double> M22(n2,n2);
+//  Vector<double> u(n), v(n);
+  
+  ip_matrix(M11, M12, M21, M22, fev1, fev2, 17);
+  deallog << "M11" << std::endl;
+  M11.print(deallog,8);
+  deallog << "M22" << std::endl;
+  M22.print(deallog,8);
+  deallog << "M12" << std::endl;
+  M12.print(deallog,8);
+  deallog << "M21" << std::endl;
+  M21.print(deallog,8);
+}
+
+
+template <int dim>
+void
+test_fe(Triangulation<dim>& tr, FiniteElement<dim>& fe)
+{
+  deallog << fe.get_name() << std::endl << "cell matrix" << std::endl;
+  QGauss<dim> quadrature(fe.tensor_degree()+1);
+  FEValues<dim> fev(fe, quadrature, update_gradients);
+
+  typename Triangulation<dim>::cell_iterator cell1 = tr.begin(1);
+  fev.reinit(cell1);
+  test_cell(fev);
+  
+  QGauss<dim-1> face_quadrature(fe.tensor_degree()+1);
+  FEFaceValues<dim> fef1(fe, face_quadrature, update_values | update_gradients | update_normal_vectors);
+  for (unsigned int i=0;i<GeometryInfo<dim>::faces_per_cell;++i)
+    {
+      deallog << "boundary_matrix " << i << std::endl;
+      fef1.reinit(cell1, i);
+      test_boundary(fef1);
+    }
+
+  FEFaceValues<dim> fef2(fe, face_quadrature, update_values | update_gradients);
+  typename Triangulation<dim>::cell_iterator cell2 = cell1->neighbor(1);
+  
+  deallog << "face_matrix " << 0 << std::endl;
+  cell1 = tr.begin(1);
+  fef1.reinit(cell1, 1);
+  fef2.reinit(cell2, 0);
+  test_face(fef1, fef2);
+  
+  
+}
+
+
+template <int dim>
+void
+test(Triangulation<dim>& tr)
+{
+  FE_DGQ<dim> q1(1);
+  test_fe(tr, q1);
+
+//  FE_DGQ<dim> q2(2);
+//  test_fe(tr, q2);
+
+//  FE_Nedelec<dim> n1(1);  
+//  test_fe(tr, n1);  
+}
+
+
+int main()
+{
+  const std::string logname = JobIdentifier::base_name(__FILE__) + std::string("/output");
+  std::ofstream logfile(logname.c_str());
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+  
+  Triangulation<2> tr2;
+  TestGrids::hypercube(tr2, 1);
+  test(tr2);
+  
+//  Triangulation<3> tr3;
+//  TestGrids::hypercube(tr3, 1);
+//  test(tr3);
+  
+}
diff --git a/tests/integrators/laplacian_01/cmp/generic b/tests/integrators/laplacian_01/cmp/generic
new file mode 100644 (file)
index 0000000..476f291
--- /dev/null
@@ -0,0 +1,49 @@
+
+DEAL::Triangulation hypercube 2D refinement 1 steps 4 active cells 5 total cells 
+DEAL::FE_DGQ<2>(1)
+DEAL::cell matrix
+DEAL::0.67    -0.17   -0.17   -0.33   
+DEAL::-0.17   0.67    -0.33   -0.17   
+DEAL::-0.17   -0.33   0.67    -0.17   
+DEAL::-0.33   -0.17   -0.17   0.67    
+DEAL::boundary_matrix 0
+DEAL::11.     0.33    5.3     0.17    
+DEAL::0.33    0       0.17    0       
+DEAL::5.3     0.17    11.     0.33    
+DEAL::0.17    0       0.33    0       
+DEAL::boundary_matrix 1
+DEAL::0       0.33    0       0.17    
+DEAL::0.33    11.     0.17    5.3     
+DEAL::0       0.17    0       0.33    
+DEAL::0.17    5.3     0.33    11.     
+DEAL::boundary_matrix 2
+DEAL::11.     5.3     0.33    0.17    
+DEAL::5.3     11.     0.17    0.33    
+DEAL::0.33    0.17    0       0       
+DEAL::0.17    0.33    0       0       
+DEAL::boundary_matrix 3
+DEAL::0       0       0.33    0.17    
+DEAL::0       0       0.17    0.33    
+DEAL::0.33    0.17    11.     5.3     
+DEAL::0.17    0.33    5.3     11.     
+DEAL::face_matrix 0
+DEAL::M11
+DEAL::0       0.17    0       0.083   
+DEAL::0.17    5.3     0.083   2.7     
+DEAL::0       0.083   0       0.17    
+DEAL::0.083   2.7     0.17    5.3     
+DEAL::M22
+DEAL::5.3     0.17    2.7     0.083   
+DEAL::0.17    0       0.083   0       
+DEAL::2.7     0.083   5.3     0.17    
+DEAL::0.083   0       0.17    0       
+DEAL::M12
+DEAL::-0.17   0       -0.083  0       
+DEAL::-5.3    -0.17   -2.7    -0.083  
+DEAL::-0.083  0       -0.17   0       
+DEAL::-2.7    -0.083  -5.3    -0.17   
+DEAL::M21
+DEAL::-0.17   -5.3    -0.083  -2.7    
+DEAL::0       -0.17   0       -0.083  
+DEAL::-0.083  -2.7    -0.17   -5.3    
+DEAL::0       -0.083  0       -0.17   

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.