From: kanschat Date: Mon, 6 Aug 2012 16:53:25 +0000 (+0000) Subject: start testing laplacian X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27254ed2cf7d694b028e4869fdc0723910e075ff;p=dealii-svn.git start testing laplacian git-svn-id: https://svn.dealii.org/trunk@25753 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/integrators/laplacian_01.cc b/tests/integrators/laplacian_01.cc new file mode 100644 index 0000000000..4836a589d4 --- /dev/null +++ b/tests/integrators/laplacian_01.cc @@ -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 +#include + +#include +#include + +using namespace LocalIntegrators::Laplace; + +template +void test_cell(const FEValuesBase& fev) +{ + const unsigned int n = fev.dofs_per_cell; + FullMatrix M(n,n); +// Vector u(n), v(n); + + cell_matrix(M,fev); + M.print(deallog,8); +} + + +template +void test_boundary(const FEValuesBase& fev) +{ + const unsigned int n = fev.dofs_per_cell; + FullMatrix M(n,n); + Vector u(n), v(n), w(n); + + nitsche_matrix(M, fev, 17); + M.print(deallog,8); + + // deallog << "Residuals"; + // for (unsigned int i=0;i +void test_face(const FEValuesBase& fev1, + const FEValuesBase& fev2) +{ + const unsigned int n1 = fev1.dofs_per_cell; + const unsigned int n2 = fev1.dofs_per_cell; + FullMatrix M11(n1,n1); + FullMatrix M12(n1,n2); + FullMatrix M21(n2,n1); + FullMatrix M22(n2,n2); +// Vector 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 +void +test_fe(Triangulation& tr, FiniteElement& fe) +{ + deallog << fe.get_name() << std::endl << "cell matrix" << std::endl; + QGauss quadrature(fe.tensor_degree()+1); + FEValues fev(fe, quadrature, update_gradients); + + typename Triangulation::cell_iterator cell1 = tr.begin(1); + fev.reinit(cell1); + test_cell(fev); + + QGauss face_quadrature(fe.tensor_degree()+1); + FEFaceValues fef1(fe, face_quadrature, update_values | update_gradients | update_normal_vectors); + for (unsigned int i=0;i::faces_per_cell;++i) + { + deallog << "boundary_matrix " << i << std::endl; + fef1.reinit(cell1, i); + test_boundary(fef1); + } + + FEFaceValues fef2(fe, face_quadrature, update_values | update_gradients); + typename Triangulation::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 +void +test(Triangulation& tr) +{ + FE_DGQ q1(1); + test_fe(tr, q1); + +// FE_DGQ q2(2); +// test_fe(tr, q2); + +// FE_Nedelec 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 index 0000000000..476f291320 --- /dev/null +++ b/tests/integrators/laplacian_01/cmp/generic @@ -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