From b3f059325604bef21ae2bd556d42cc17b0cac661 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 30 Oct 2012 13:50:38 +0000 Subject: [PATCH] New test. git-svn-id: https://svn.dealii.org/trunk@27238 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/hp/crash_21.cc | 168 ++++++++++++++++++++++++++++++++++ tests/hp/crash_21/cmp/generic | 32 +++++++ 2 files changed, 200 insertions(+) create mode 100644 tests/hp/crash_21.cc create mode 100644 tests/hp/crash_21/cmp/generic diff --git a/tests/hp/crash_21.cc b/tests/hp/crash_21.cc new file mode 100644 index 0000000000..8adf599b17 --- /dev/null +++ b/tests/hp/crash_21.cc @@ -0,0 +1,168 @@ +//---------------------------- crash_21.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// 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. +// +//---------------------------- crash_21.cc --------------------------- + + +// a problem uncovered by Baerbel Janssen in that +// DoFTools::make_flux_sparsity_pattern aborted in 1d with adaptively refined +// meshes and hp DoFHandlers. this actually uncovered all sorts of other +// problems that led to a long sequence of assertions triggered everytime one +// of them was fixed. this test cumulatively makes sure everything is ok + +// while there, also test the same code in 2d (3d appears to take too long) + + +#include "../tests.h" +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +namespace Step +{ + using namespace dealii; + + template + class Problem : public Subscriptor + { + public: + Problem (); + ~Problem (); + + void refine_mesh (); + void setup_system (); + + private: + Triangulation triangulation; + + hp::DoFHandler dof_handler; + hp::FECollection fe_collection; + hp::QCollection quadrature_collection; + hp::QCollection face_quadrature_collection; + + ConstraintMatrix constraints; + + SparsityPattern sparsity_pattern; + SparseMatrix system_matrix; + }; + + + + template + Problem::Problem () + : + dof_handler (triangulation) + { + GridGenerator::hyper_cube(triangulation); + for (unsigned int degree=1; degree<=7; ++degree) + { + fe_collection.push_back (FE_DGQ(degree)); + quadrature_collection.push_back (QGauss(degree+1)); + face_quadrature_collection.push_back (QGauss(degree+1)); + } + } + + + template + Problem::~Problem () + { + dof_handler.clear (); + } + + template + void Problem::setup_system () + { + dof_handler.distribute_dofs (fe_collection); + + constraints.clear (); + constraints.close (); + + + CompressedSetSparsityPattern csp (dof_handler.n_dofs(), + dof_handler.n_dofs()); + DoFTools::make_flux_sparsity_pattern (dof_handler, csp, constraints, false); + sparsity_pattern.copy_from (csp); + system_matrix.reinit (sparsity_pattern); + + deallog << " Number of active cells: " + << triangulation.n_active_cells() + << std::endl + << " Number of degrees of freedom: " + << dof_handler.n_dofs() + << std::endl + << " Number of constraints : " + << constraints.n_constraints() + << std::endl; + deallog << "nnz=" << sparsity_pattern.n_nonzero_elements() << std::endl; + } + + + template + void Problem::refine_mesh () + { + dof_handler.begin_active()->set_refine_flag(); + triangulation.execute_coarsening_and_refinement (); + } +} + + +template +void test () +{ + using namespace dealii; + using namespace Step; + + Problem problem; + + for (unsigned int cycle=0; cycle<3; ++cycle) + { + deallog << "Cycle " << cycle << ':' << std::endl; + problem.setup_system(); + problem.refine_mesh(); + } +} + + +int main () +{ + std::ofstream logfile("crash_21/output"); + logfile.precision(2); + + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1> (); + test<2> (); + + deallog << "OK" << std::endl; +} diff --git a/tests/hp/crash_21/cmp/generic b/tests/hp/crash_21/cmp/generic new file mode 100644 index 0000000000..a1b95b40cb --- /dev/null +++ b/tests/hp/crash_21/cmp/generic @@ -0,0 +1,32 @@ + +DEAL::Cycle 0: +DEAL:: Number of active cells: 1 +DEAL:: Number of degrees of freedom: 2 +DEAL:: Number of constraints : 0 +DEAL::nnz=4 +DEAL::Cycle 1: +DEAL:: Number of active cells: 2 +DEAL:: Number of degrees of freedom: 4 +DEAL:: Number of constraints : 0 +DEAL::nnz=16 +DEAL::Cycle 2: +DEAL:: Number of active cells: 3 +DEAL:: Number of degrees of freedom: 6 +DEAL:: Number of constraints : 0 +DEAL::nnz=24 +DEAL::Cycle 0: +DEAL:: Number of active cells: 1 +DEAL:: Number of degrees of freedom: 4 +DEAL:: Number of constraints : 0 +DEAL::nnz=16 +DEAL::Cycle 1: +DEAL:: Number of active cells: 4 +DEAL:: Number of degrees of freedom: 16 +DEAL:: Number of constraints : 0 +DEAL::nnz=192 +DEAL::Cycle 2: +DEAL:: Number of active cells: 7 +DEAL:: Number of degrees of freedom: 28 +DEAL:: Number of constraints : 0 +DEAL::nnz=432 +DEAL::OK -- 2.39.5