From 65d38c5274ab53851f306cade7102f1b458276f3 Mon Sep 17 00:00:00 2001 From: Markus Buerg Date: Thu, 26 Aug 2010 15:14:14 +0000 Subject: [PATCH] Tests for the parent relation. git-svn-id: https://svn.dealii.org/trunk@21726 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 6 + tests/bits/refine_and_coarsen_1d/cmp/generic | 5 +- tests/bits/refine_and_coarsen_for_parents.cc | 126 +++++++++++++++++++ 3 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 tests/bits/refine_and_coarsen_for_parents.cc diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 6cf8dfa9fb..f5b3bb9703 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -44,6 +44,12 @@ through DoFHandler::get_tria() and DoFHandler::get_fe(), respectively.

General

    +
  1. +

    New: Tests for the parent relations. +
    + (Markus Buerg 2010/08/26) +

    +
  2. Fixed: When using Trilinos and deal.II both with static libraries, a linker error would occur whenever a program linked both the 2d and diff --git a/tests/bits/refine_and_coarsen_1d/cmp/generic b/tests/bits/refine_and_coarsen_1d/cmp/generic index f3ec0fd883..292df5f812 100644 --- a/tests/bits/refine_and_coarsen_1d/cmp/generic +++ b/tests/bits/refine_and_coarsen_1d/cmp/generic @@ -1,3 +1,4 @@ -DEAL::5 -DEAL::5 5 +DEAL::OK for 1d +DEAL::OK for 2d +DEAL::OK for 3d diff --git a/tests/bits/refine_and_coarsen_for_parents.cc b/tests/bits/refine_and_coarsen_for_parents.cc new file mode 100644 index 0000000000..2e5859bfbd --- /dev/null +++ b/tests/bits/refine_and_coarsen_for_parents.cc @@ -0,0 +1,126 @@ +//---------------------------- refine_and_coarsen_3d.cc --------------------------- +// $Id: refine_and_coarsen_3d.cc 15183 2007-09-10 01:10:03Z bangerth $ +// Version: $Name$ +// +// Copyright (C) 2010 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. +// +//---------------------------- refine_and_coarsen_for_parents.cc --------------------------- + + +// check that, if we take an locally refined mesh, refine it globally once, +// then coarsen it globally again, the parent relation holds + +#include "../tests.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + + +void do_refine (Triangulation<1> &tria) +{ + const int dim = 1; + + tria.refine_global (2); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement (); +} + + +void do_refine (Triangulation<2> &tria) +{ + const int dim = 2; + + tria.refine_global (2); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement (); + tria.begin_active ()->set_refine_flag (RefinementPossibilities::cut_x); + tria.execute_coarsening_and_refinement (); + tria.begin_active ()->set_refine_flag (RefinementPossibilities::cut_y); + tria.execute_coarsening_and_refinement (); +} + + +void do_refine (Triangulation<3> &tria) +{ + const int dim = 3; + + tria.refine_global (2); + tria.begin_active()->set_refine_flag(); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_x); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_y); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_z); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_xy); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_xz); + tria.execute_coarsening_and_refinement (); + tria.begin_active()->set_refine_flag(RefinementPossibilities::cut_yz); + tria.execute_coarsening_and_refinement (); +} + + +template +void check () +{ + Triangulation tria; + GridGenerator::hyper_cube (tria); + do_refine (tria); + // refine the mesh globally and + // verify that the parent relation + // holds + tria.refine_global (1); + + for (typename Triangulation::cell_iterator cell = tria.begin(); + cell != tria.end (); ++cell) + for (unsigned int child = 0; child < cell->n_children (); ++child) + Assert (cell->child (child)->parent () == cell, + ExcInternalError ()); + + // coarsen the mesh globally and + // verify that the parent relation + // holds + for (typename Triangulation::active_cell_iterator cell = tria.begin_active (); + cell != tria.end (); ++cell) + cell->set_coarsen_flag (); + + tria.execute_coarsening_and_refinement (); + + for (typename Triangulation::cell_iterator cell = tria.begin (); + cell != tria.end(); ++cell) + for (unsigned int child = 0; child < cell->n_children (); ++child) + Assert (cell->child (child)->parent () == cell, + ExcInternalError()); + + deallog << "OK for " << dim << "d" << std::endl; +} + + +int main () +{ + std::ofstream logfile("refine_and_coarsen_for_parents/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + check<1> (); + check<2> (); + check<3> (); +} + + + -- 2.39.5