From 8d0ffbe24271e5215da3c7ce844574a9a22dc775 Mon Sep 17 00:00:00 2001 From: kanschat Date: Thu, 9 Aug 2012 14:42:03 +0000 Subject: [PATCH] first version of diergence tests git-svn-id: https://svn.dealii.org/trunk@25810 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/integrators/divergence_01.cc | 269 ++++++++++++++++++++ tests/integrators/divergence_01/cmp/generic | 193 ++++++++++++++ 2 files changed, 462 insertions(+) create mode 100644 tests/integrators/divergence_01.cc create mode 100644 tests/integrators/divergence_01/cmp/generic diff --git a/tests/integrators/divergence_01.cc b/tests/integrators/divergence_01.cc new file mode 100644 index 0000000000..1fcca9b56d --- /dev/null +++ b/tests/integrators/divergence_01.cc @@ -0,0 +1,269 @@ +//-------------------------------------------------------------------- +// $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 +#include +#include + +using namespace LocalIntegrators::Divergence; + +template +void test_cell(const FEValuesBase& fev, const FEValuesBase& fes) +{ + AssertDimension(fev.get_fe().n_components(), dim); + AssertDimension(fes.get_fe().n_components(), 1); + + const unsigned int nv = fev.dofs_per_cell; + const unsigned int ns = fes.dofs_per_cell; + + FullMatrix Md(ns,nv); + cell_matrix(Md,fev,fes); + Md.print(deallog,8); + + deallog << "gradient_matrix" << std::endl; + FullMatrix Mg(nv,ns); + gradient_matrix(Mg,fes,fev); + Mg.print(deallog,8); + + + // Vector u(n), v(n), w(n); + // std::vector > > + // ugrad(d,std::vector >(fev.n_quadrature_points)); + + // std::vector indices(n); + // for (unsigned int i=0;i +void test_boundary(const FEValuesBase& fev, const FEValuesBase& fes) +{ + AssertDimension(fev.get_fe().n_components(), dim); + AssertDimension(fes.get_fe().n_components(), 1); + + const unsigned int nv = fev.dofs_per_cell; + const unsigned int ns = fes.dofs_per_cell; + + FullMatrix M(ns,nv); + u_dot_n_matrix(M, fev, fes); + M.print(deallog,8); + + Vector u(nv), v(ns), w(ns); + std::vector > + uval (dim,std::vector(fev.n_quadrature_points)); + + std::vector indices(nv); + for (unsigned int i=0;i +void test_face(const FEValuesBase& fev1, + const FEValuesBase& fev2, + const FEValuesBase& fes1, + const FEValuesBase& fes2) +{ + AssertDimension(fev1.get_fe().n_components(), dim); + AssertDimension(fes1.get_fe().n_components(), 1); + AssertDimension(fev2.get_fe().n_components(), dim); + AssertDimension(fes2.get_fe().n_components(), 1); + + const unsigned int nv1 = fev1.dofs_per_cell; + const unsigned int nv2 = fev1.dofs_per_cell; + const unsigned int ns1 = fes1.dofs_per_cell; + const unsigned int ns2 = fes1.dofs_per_cell; + + FullMatrix M11(ns1,nv1); + FullMatrix M12(ns1,nv2); + FullMatrix M21(ns2,nv1); + FullMatrix M22(ns2,nv2); + + u_dot_n_matrix(M11, M12, M21, M22, fev1, fev2, fes1, fes2); + 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); + + // Vector u1(n1), v1(n1), w1(n1); + // Vector u2(n2), v2(n2), w2(n2); + // std::vector > + // u1val (d,std::vector(fev1.n_quadrature_points)), + // u2val (d,std::vector(fev2.n_quadrature_points)); + // std::vector > > + // u1grad(d,std::vector >(fev1.n_quadrature_points)), + // u2grad(d,std::vector >(fev2.n_quadrature_points)); + + // std::vector indices1(n1), indices2(n2); + // for (unsigned int i=0;i +void +test_fe(Triangulation& tr, FiniteElement& fv, FiniteElement& fs) +{ + deallog << fv.get_name() << " x " << fs.get_name() << std::endl << "cell matrix" << std::endl; + QGauss quadrature(fv.tensor_degree()+1); + FEValues fev(fv, quadrature, update_values | update_gradients); + FEValues fes(fs, quadrature, update_values | update_gradients); + + typename Triangulation::cell_iterator cell1 = tr.begin(1); + fev.reinit(cell1); + fes.reinit(cell1); + test_cell(fev, fes); + + QGauss face_quadrature(fv.tensor_degree()+1); + FEFaceValues fev1(fv, face_quadrature, update_values | update_gradients | update_normal_vectors); + FEFaceValues fes1(fs, 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; + fev1.reinit(cell1, i); + fes1.reinit(cell1, i); + test_boundary(fev1, fes1); + } + + FEFaceValues fev2(fv, face_quadrature, update_values | update_gradients); + FEFaceValues fes2(fs, face_quadrature, update_values | update_gradients); + typename Triangulation::cell_iterator cell2 = cell1->neighbor(1); + + deallog << "face_matrix " << 0 << std::endl; + cell1 = tr.begin(1); + fev1.reinit(cell1, 1); + fev2.reinit(cell2, 0); + fes1.reinit(cell1, 1); + fes2.reinit(cell2, 0); + test_face(fev1, fev2, fes1, fes2); +} + + +template +void +test(Triangulation& tr) +{ + FE_DGQ q1(1); + FE_Nedelec n1(1); + FE_RaviartThomas r1(1); + FESystem s1(q1,dim); + + test_fe(tr, r1, q1); + test_fe(tr, n1, q1); + test_fe(tr, s1, q1); + +} + + +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/divergence_01/cmp/generic b/tests/integrators/divergence_01/cmp/generic new file mode 100644 index 0000000000..002d89412b --- /dev/null +++ b/tests/integrators/divergence_01/cmp/generic @@ -0,0 +1,193 @@ + +DEAL::Triangulation hypercube 2D refinement 1 steps 4 active cells 5 total cells +DEAL::FE_RaviartThomas<2>(1) x FE_DGQ<2>(1) +DEAL::cell matrix +DEAL::-0.50 0.29 0 0 -0.50 0.29 0 0 0.50 0.50 -0.29 -0.29 +DEAL::0 0 0.50 -0.29 -0.50 -0.29 0 0 -0.50 0.50 0.29 0.29 +DEAL::-0.50 -0.29 0 0 0 0 0.50 -0.29 0.50 -0.50 0.29 0.29 +DEAL::0 0 0.50 0.29 0 0 0.50 0.29 -0.50 -0.50 -0.29 -0.29 +DEAL::gradient_matrix +DEAL::0 0 0 0 +DEAL::0 0 0 0 +DEAL::0 0 0 0 +DEAL::0 0 0 0 +DEAL::0 0 0 0 +DEAL::0 0 0 0 +DEAL::0 0 0 0 +DEAL::0 0 0 0 +DEAL::-0.50 0.50 -0.50 0.50 +DEAL::-0.50 -0.50 0.50 0.50 +DEAL::0.29 -0.29 -0.29 0.29 +DEAL::0.29 -0.29 -0.29 0.29 +DEAL:: +DEAL::boundary_matrix 0 +DEAL::-0.50 0.29 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::-0.50 -0.29 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::Residuals u dot n 0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::boundary_matrix 1 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0.50 -0.29 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0.50 0.29 0 0 0 0 0 0 0 0 +DEAL::Residuals u dot n 0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::boundary_matrix 2 +DEAL::0 0 0 0 -0.50 0.29 0 0 0 0 0 0 +DEAL::0 0 0 0 -0.50 -0.29 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::Residuals u dot n 0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::boundary_matrix 3 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0.50 -0.29 0 0 0 0 +DEAL::0 0 0 0 0 0 0.50 0.29 0 0 0 0 +DEAL::Residuals u dot n 0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::face_matrix 0 +DEAL::M11 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0.25 -0.14 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0.25 0.14 0 0 0 0 0 0 0 0 +DEAL::M22 +DEAL::-0.25 0.14 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::-0.25 -0.14 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::M12 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::-0.25 0.14 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::-0.25 -0.14 0 0 0 0 0 0 0 0 0 0 +DEAL::M21 +DEAL::0 0 0.25 -0.14 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0.25 0.14 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::FE_Nedelec<2>(1) x FE_DGQ<2>(1) +DEAL::cell matrix +DEAL::0 0.58 0 0.29 0 0.58 0 0.29 0 -0.25 0 -0.25 +DEAL::0 0.29 0 0.58 0 0.58 0 0.29 0 -0.25 0 -0.25 +DEAL::0 0.58 0 0.29 0 0.29 0 0.58 0 -0.25 0 -0.25 +DEAL::0 0.29 0 0.58 0 0.29 0 0.58 0 -0.25 0 -0.25 +DEAL::gradient_matrix +DEAL::-0.33 -0.17 0.33 0.17 +DEAL::0 0 0 0 +DEAL::-0.17 -0.33 0.17 0.33 +DEAL::0 0 0 0 +DEAL::-0.33 0.33 -0.17 0.17 +DEAL::0 0 0 0 +DEAL::-0.17 0.17 -0.33 0.33 +DEAL::0 0 0 0 +DEAL::0.14 -0.14 0.14 -0.14 +DEAL::0 0 0 0 +DEAL::0.14 0.14 -0.14 -0.14 +DEAL::0 0 0 0 +DEAL:: +DEAL::boundary_matrix 0 +DEAL::0 0 0 0 -0.33 0.58 -0.17 0.29 0.14 -0.25 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 -0.17 0.29 -0.33 0.58 0.14 -0.25 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::Residuals u dot n 0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::boundary_matrix 1 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0.33 0.58 0.17 0.29 -0.14 -0.25 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0.17 0.29 0.33 0.58 -0.14 -0.25 0 0 +DEAL::Residuals u dot n 0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::boundary_matrix 2 +DEAL::-0.33 0.58 -0.17 0.29 0 0 0 0 0 0 0.14 -0.25 +DEAL::-0.17 0.29 -0.33 0.58 0 0 0 0 0 0 0.14 -0.25 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::Residuals u dot n 0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::boundary_matrix 3 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0.33 0.58 0.17 0.29 0 0 0 0 0 0 -0.14 -0.25 +DEAL::0.17 0.29 0.33 0.58 0 0 0 0 0 0 -0.14 -0.25 +DEAL::Residuals u dot n 0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::face_matrix 0 +DEAL::M11 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0.17 0.29 0.083 0.14 -0.072 -0.12 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0.083 0.14 0.17 0.29 -0.072 -0.12 0 0 +DEAL::M22 +DEAL::0 0 0 0 -0.17 0.29 -0.083 0.14 0.072 -0.12 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 -0.083 0.14 -0.17 0.29 0.072 -0.12 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::M12 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 -0.17 0.29 -0.083 0.14 0.072 -0.12 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 -0.083 0.14 -0.17 0.29 0.072 -0.12 0 0 +DEAL::M21 +DEAL::0 0 0 0 0.17 0.29 0.083 0.14 -0.072 -0.12 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0.083 0.14 0.17 0.29 -0.072 -0.12 0 0 +DEAL::0 0 0 0 0 0 0 0 0 0 0 0 +DEAL::FESystem<2>[FE_DGQ<2>(1)^2] x FE_DGQ<2>(1) +DEAL::cell matrix +DEAL::-0.17 0.17 -0.083 0.083 -0.17 -0.083 0.17 0.083 +DEAL::-0.17 0.17 -0.083 0.083 -0.083 -0.17 0.083 0.17 +DEAL::-0.083 0.083 -0.17 0.17 -0.17 -0.083 0.17 0.083 +DEAL::-0.083 0.083 -0.17 0.17 -0.083 -0.17 0.083 0.17 +DEAL::gradient_matrix +DEAL::-0.17 0.17 -0.083 0.083 +DEAL::-0.17 0.17 -0.083 0.083 +DEAL::-0.083 0.083 -0.17 0.17 +DEAL::-0.083 0.083 -0.17 0.17 +DEAL::-0.17 -0.083 0.17 0.083 +DEAL::-0.083 -0.17 0.083 0.17 +DEAL::-0.17 -0.083 0.17 0.083 +DEAL::-0.083 -0.17 0.083 0.17 +DEAL:: +DEAL::boundary_matrix 0 +DEAL::-0.33 0 -0.17 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 +DEAL::-0.17 0 -0.33 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 +DEAL::Residuals u dot n 0 0 0 0 0 0 0 0 +DEAL::boundary_matrix 1 +DEAL::0 0 0 0 0 0 0 0 +DEAL::0 0.33 0 0.17 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 +DEAL::0 0.17 0 0.33 0 0 0 0 +DEAL::Residuals u dot n 0 0 0 0 0 0 0 0 +DEAL::boundary_matrix 2 +DEAL::0 0 0 0 -0.33 -0.17 0 0 +DEAL::0 0 0 0 -0.17 -0.33 0 0 +DEAL::0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 +DEAL::Residuals u dot n 0 0 0 0 0 0 0 0 +DEAL::boundary_matrix 3 +DEAL::0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0.33 0.17 +DEAL::0 0 0 0 0 0 0.17 0.33 +DEAL::Residuals u dot n 0 0 0 0 0 0 0 0 +DEAL::face_matrix 0 +DEAL::M11 +DEAL::0 0 0 0 0 0 0 0 +DEAL::0 0.17 0 0.083 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 +DEAL::0 0.083 0 0.17 0 0 0 0 +DEAL::M22 +DEAL::-0.17 0 -0.083 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 +DEAL::-0.083 0 -0.17 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 +DEAL::M12 +DEAL::0 0 0 0 0 0 0 0 +DEAL::-0.17 0 -0.083 0 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 +DEAL::-0.083 0 -0.17 0 0 0 0 0 +DEAL::M21 +DEAL::0 0.17 0 0.083 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 +DEAL::0 0.083 0 0.17 0 0 0 0 +DEAL::0 0 0 0 0 0 0 0 -- 2.39.5