From: Wolfgang Bangerth Date: Fri, 14 Apr 2006 20:41:09 +0000 (+0000) Subject: GridTools::have_same_coarse_mesh, GridTools::get_finest_common_cells X-Git-Tag: v8.0.0~11896 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2261345dd75f9988fff6d69dba1244e4aa4cb5c4;p=dealii.git GridTools::have_same_coarse_mesh, GridTools::get_finest_common_cells git-svn-id: https://svn.dealii.org/trunk@12835 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/grid_tools.h b/deal.II/deal.II/include/grid/grid_tools.h index e4af48ae8a..8c7d54aa73 100644 --- a/deal.II/deal.II/include/grid/grid_tools.h +++ b/deal.II/deal.II/include/grid/grid_tools.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -19,6 +19,7 @@ #include #include +#include @@ -199,7 +200,7 @@ class GridTools * type of the first parameter * may be either * Triangulation, - * DoFHandler, or + * DoFHandler, hp::DoFHandler, or * MGDoFHandler, i.e. we * can find the cell around a * point for iterators into each @@ -349,6 +350,108 @@ class GridTools count_cells_with_subdomain_association (const Triangulation &triangulation, const unsigned int subdomain); + /** + * Given two mesh containers + * (i.e. objects of type + * Triangulation, DoFHandler, + * hp::DoFHandler, or + * MGDoFHandler) that are based + * on the same coarse mesh, this + * function figures out a set of + * cells that are matched between + * the two meshes and where at + * most one of the meshes is more + * refined on this cell. In other + * words, it finds the smallest + * cells that are common to both + * meshes, and that together + * completely cover the domain. + * + * This function is useful, for + * example, in time-dependent or + * nonlinear application, where + * one has to integrate a + * solution defined on one mesh + * (e.g., the one from the + * previous time step or + * nonlinear iteration) against + * the shape functions of another + * mesh (the next time step, the + * next nonlinear iteration). If, + * for example, the new mesh is + * finer, then one has to obtain + * the solution on the coarse + * mesh (mesh_1) and interpolate + * it to the children of the + * corresponding cell of + * mesh_2. Conversely, if the new + * mesh is coarser, one has to + * express the coarse cell shape + * function by a linear + * combination of fine cell shape + * functions. In either case, one + * needs to loop over the finest + * cells that are common to both + * triangulations. This function + * returns a list of pairs of + * matching iterators to cells in + * the two meshes that can be + * used to this end. + * + * Note that the list of these + * iterators is not necessarily + * order, and does also not + * necessarily coincide with the + * order in which cells are + * traversed in one, or both, of + * the meshes given as arguments. + */ + template + static + std::list > + get_finest_common_cells (const Container &mesh_1, + const Container &mesh_2); + + /** + * Return true if the two + * triangulations are based on + * the same coarse mesh. This is + * determined by checking whether + * they have the same number of + * cells on the coarsest level, + * and then checking that they + * have the same vertices. + * + * The two meshes may have + * different refinement histories + * beyond the coarse mesh. + */ + template + static + bool + have_same_coarse_mesh (const Triangulation &mesh_1, + const Triangulation &mesh_2); + + /** + * The same function as above, + * but working on arguments of + * type DoFHandler, + * hp::DoFHandler, or + * MGDoFHandler. This function is + * provided to allow calling + * have_same_coarse_mesh for all + * types of containers + * representing triangulations or + * the classes built on + * triangulations. + */ + template + static + bool + have_same_coarse_mesh (const Container &mesh_1, + const Container &mesh_2); + /** * Exception */ diff --git a/deal.II/deal.II/source/grid/grid_tools.cc b/deal.II/deal.II/source/grid/grid_tools.cc index 74d586dab3..0241820e18 100644 --- a/deal.II/deal.II/source/grid/grid_tools.cc +++ b/deal.II/deal.II/source/grid/grid_tools.cc @@ -28,6 +28,7 @@ #include + #if deal_II_dimension != 1 template @@ -568,6 +569,141 @@ count_cells_with_subdomain_association (const Triangulation &triangulation, +template +std::list > +GridTools::get_finest_common_cells (const Container &mesh_1, + const Container &mesh_2) +{ + Assert (have_same_coarse_mesh (mesh_1, mesh_2), + ExcMessage ("The two containers must be represent triangulations that " + "have the same coarse meshes")); + + const unsigned int dim = Container::dimension; + + // the algorithm goes as follows: + // first, we fill a list with pairs + // of iterators common to the two + // meshes on the coarsest + // level. then we traverse the + // list; each time, we find a pair + // of iterators for which both + // correspond to non-active cells, + // we delete this item and push the + // pairs of iterators to their + // children to the back. if these + // again both correspond to + // non-active cells, we will get to + // the later on for further + // consideration + typedef + std::list > + CellList; + + CellList cell_list; + + // first push the coarse level cells + typename Container::cell_iterator + cell_1 = mesh_1.begin(0), + cell_2 = mesh_2.begin(0); + for (; cell_1 != mesh_1.end(0); ++cell_1, ++cell_2) + cell_list.push_back (std::make_pair (cell_1, cell_2)); + + // then traverse list as described + // above + typename CellList::iterator cell_pair = cell_list.begin(); + while (cell_pair != cell_list.end()) + { + // if both cells in this pair + // have children, then erase + // this element and push their + // children instead + if (cell_pair->first->has_children() + && + cell_pair->second->has_children()) + { + for (unsigned int c=0; c::children_per_cell; ++c) + cell_list.push_back (std::make_pair (cell_pair->first->child(c), + cell_pair->second->child(c))); + + // erasing an iterator + // keeps other iterators + // valid, so already + // advance the present + // iterator by one and then + // delete the element we've + // visited before + const typename CellList::iterator previous_cell_pair = cell_pair; + ++cell_pair; + + cell_list.erase (previous_cell_pair); + } + else + // both cells are active, do + // nothing + ++cell_pair; + } + + // just to make sure everything is + // ok, validate that all pairs have + // at least one active iterator + for (cell_pair = cell_list.begin(); cell_pair != cell_list.end(); ++cell_pair) + Assert (!cell_pair->first->has_children() + || + !cell_pair->second->has_children(), + ExcInternalError()); + + return cell_list; +} + + + +template +bool +GridTools::have_same_coarse_mesh (const Triangulation &mesh_1, + const Triangulation &mesh_2) +{ + // make sure the two meshes have + // the same number of coarse cells + if (mesh_1.n_cells (0) != mesh_2.n_cells (0)) + return false; + + // if so, also make sure they have + // the same vertices on the cells + // of the coarse mesh + typename Triangulation::cell_iterator + cell_1 = mesh_1.begin(0), + cell_2 = mesh_2.begin(0), + endc = mesh_1.end(0); + for (; cell_1!=endc; ++cell_1, ++cell_2) + for (unsigned int v=0; v::vertices_per_cell; ++v) + if (cell_1->vertex(v) != cell_2->vertex(v)) + return false; + + // if we've gotten through all + // this, then the meshes really + // seem to have a common coarse + // mesh + return true; +} + + + +template +bool +GridTools::have_same_coarse_mesh (const Container &mesh_1, + const Container &mesh_2) +{ + return have_same_coarse_mesh (mesh_1.get_tria(), + mesh_2.get_tria()); +} + + + + +// explicit instantiations + #if deal_II_dimension != 1 template double @@ -624,3 +760,52 @@ GridTools:: count_cells_with_subdomain_association (const Triangulation &, const unsigned int ); + +template +std::list::cell_iterator, + Triangulation::cell_iterator> > +GridTools:: +get_finest_common_cells (const Triangulation &mesh_1, + const Triangulation &mesh_2); + +template +std::list::cell_iterator, + DoFHandler::cell_iterator> > +GridTools:: +get_finest_common_cells (const DoFHandler &mesh_1, + const DoFHandler &mesh_2); + +template +std::list::cell_iterator, + hp::DoFHandler::cell_iterator> > +GridTools:: +get_finest_common_cells (const hp::DoFHandler &mesh_1, + const hp::DoFHandler &mesh_2); + +template +std::list::cell_iterator, + MGDoFHandler::cell_iterator> > +GridTools:: +get_finest_common_cells (const MGDoFHandler &mesh_1, + const MGDoFHandler &mesh_2); + + +template +bool +GridTools::have_same_coarse_mesh (const Triangulation &mesh_1, + const Triangulation &mesh_2); + +template +bool +GridTools::have_same_coarse_mesh (const DoFHandler &mesh_1, + const DoFHandler &mesh_2); + +template +bool +GridTools::have_same_coarse_mesh (const hp::DoFHandler &mesh_1, + const hp::DoFHandler &mesh_2); + +template +bool +GridTools::have_same_coarse_mesh (const MGDoFHandler &mesh_1, + const MGDoFHandler &mesh_2); diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index d9596da230..d6750f954d 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -583,6 +583,25 @@ inconvenience this causes.

deal.II

    +
  1. + New: The function GridTools::get_finest_common_cells can be + used to find those cells that are shared by two triangulations that are + based on the same coarse mesh. This is useful, for example, when having + to integrate the solution on one mesh against the shape functions on + another mesh, a situation that frequently happens in time-dependent but + also in nonlinear problems. +
    + (WB 2006/04/14) +

    + +
  2. + New: The function GridTools::have_same_coarse_mesh figures + out whether two triangulations, two DoFHandlers, etc, are built on the + same coarse mesh. +
    + (WB 2006/04/14) +

    +
  3. New: Since calling cell->get_dof_indices is a fairly frequent operation (called about 7 times per cell in diff --git a/tests/deal.II/Makefile b/tests/deal.II/Makefile index 43adf696a1..475530d998 100644 --- a/tests/deal.II/Makefile +++ b/tests/deal.II/Makefile @@ -51,7 +51,9 @@ tests_x = block_matrices \ face_orientations_3d \ mg_dof_handler \ subcelldata \ - interpolate_boundary_values_* + interpolate_boundary_values_* \ + have_same_coarse_mesh_* \ + get_finest_common_cells_* # from above list of regular expressions, generate the real set of # tests diff --git a/tests/deal.II/get_finest_common_cells_01.cc b/tests/deal.II/get_finest_common_cells_01.cc new file mode 100644 index 0000000000..21c04e1b86 --- /dev/null +++ b/tests/deal.II/get_finest_common_cells_01.cc @@ -0,0 +1,76 @@ +//---------------------------- get_finest_common_cells_01.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006 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. +// +//---------------------------- get_finest_common_cells_01.cc --------------------------- +// check GridTools::get_finest_common_cells for Triangulation arguments + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +#include + + +template +void test() +{ + // create 2 triangulations with the + // same coarse grid, and refine + // them differently + Triangulation tria[2]; + + GridGenerator::hyper_cube (tria[0]); + GridGenerator::hyper_cube (tria[1]); + + tria[0].refine_global (2); + tria[1].refine_global (2); + + tria[0].begin_active()->set_refine_flag(); + tria[0].execute_coarsening_and_refinement (); + + tria[1].last_active()->set_refine_flag(); + tria[1].execute_coarsening_and_refinement (); + + tria[1].last_active()->set_refine_flag(); + tria[1].execute_coarsening_and_refinement (); + + typedef + std::list::cell_iterator, + typename Triangulation::cell_iterator> > + CellList; + + const CellList cell_list + = GridTools::get_finest_common_cells (tria[0], tria[1]); + for (typename CellList::const_iterator cell_pair = cell_list.begin(); + cell_pair != cell_list.end(); ++cell_pair) + deallog << cell_pair->first << ' ' << cell_pair->second + << std::endl; +} + + +int main() +{ + std::ofstream logfile ("get_finest_common_cells_01/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/deal.II/get_finest_common_cells_01/cmp/generic b/tests/deal.II/get_finest_common_cells_01/cmp/generic new file mode 100644 index 0000000000..5a9740bcc0 --- /dev/null +++ b/tests/deal.II/get_finest_common_cells_01/cmp/generic @@ -0,0 +1,85 @@ + +DEAL::2.0 2.0 +DEAL::2.1 2.1 +DEAL::2.2 2.2 +DEAL::2.3 2.3 +DEAL::2.0 2.0 +DEAL::2.1 2.1 +DEAL::2.2 2.2 +DEAL::2.3 2.3 +DEAL::2.4 2.4 +DEAL::2.5 2.5 +DEAL::2.6 2.6 +DEAL::2.7 2.7 +DEAL::2.8 2.8 +DEAL::2.9 2.9 +DEAL::2.10 2.10 +DEAL::2.11 2.11 +DEAL::2.12 2.12 +DEAL::2.13 2.13 +DEAL::2.14 2.14 +DEAL::2.15 2.15 +DEAL::2.0 2.0 +DEAL::2.1 2.1 +DEAL::2.2 2.2 +DEAL::2.3 2.3 +DEAL::2.4 2.4 +DEAL::2.5 2.5 +DEAL::2.6 2.6 +DEAL::2.7 2.7 +DEAL::2.8 2.8 +DEAL::2.9 2.9 +DEAL::2.10 2.10 +DEAL::2.11 2.11 +DEAL::2.12 2.12 +DEAL::2.13 2.13 +DEAL::2.14 2.14 +DEAL::2.15 2.15 +DEAL::2.16 2.16 +DEAL::2.17 2.17 +DEAL::2.18 2.18 +DEAL::2.19 2.19 +DEAL::2.20 2.20 +DEAL::2.21 2.21 +DEAL::2.22 2.22 +DEAL::2.23 2.23 +DEAL::2.24 2.24 +DEAL::2.25 2.25 +DEAL::2.26 2.26 +DEAL::2.27 2.27 +DEAL::2.28 2.28 +DEAL::2.29 2.29 +DEAL::2.30 2.30 +DEAL::2.31 2.31 +DEAL::2.32 2.32 +DEAL::2.33 2.33 +DEAL::2.34 2.34 +DEAL::2.35 2.35 +DEAL::2.36 2.36 +DEAL::2.37 2.37 +DEAL::2.38 2.38 +DEAL::2.39 2.39 +DEAL::2.40 2.40 +DEAL::2.41 2.41 +DEAL::2.42 2.42 +DEAL::2.43 2.43 +DEAL::2.44 2.44 +DEAL::2.45 2.45 +DEAL::2.46 2.46 +DEAL::2.47 2.47 +DEAL::2.48 2.48 +DEAL::2.49 2.49 +DEAL::2.50 2.50 +DEAL::2.51 2.51 +DEAL::2.52 2.52 +DEAL::2.53 2.53 +DEAL::2.54 2.54 +DEAL::2.55 2.55 +DEAL::2.56 2.56 +DEAL::2.57 2.57 +DEAL::2.58 2.58 +DEAL::2.59 2.59 +DEAL::2.60 2.60 +DEAL::2.61 2.61 +DEAL::2.62 2.62 +DEAL::2.63 2.63 diff --git a/tests/deal.II/get_finest_common_cells_02.cc b/tests/deal.II/get_finest_common_cells_02.cc new file mode 100644 index 0000000000..2b812154aa --- /dev/null +++ b/tests/deal.II/get_finest_common_cells_02.cc @@ -0,0 +1,79 @@ +//---------------------------- get_finest_common_cells_02.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006 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. +// +//---------------------------- get_finest_common_cells_02.cc --------------------------- +// check GridTools::get_finest_common_cells for DoFHandler arguments + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +#include + + +template +void test() +{ + // create 2 triangulations with the + // same coarse grid, and refine + // them differently + Triangulation tria[2]; + + GridGenerator::hyper_cube (tria[0]); + GridGenerator::hyper_cube (tria[1]); + + tria[0].refine_global (2); + tria[1].refine_global (2); + + tria[0].begin_active()->set_refine_flag(); + tria[0].execute_coarsening_and_refinement (); + + tria[1].last_active()->set_refine_flag(); + tria[1].execute_coarsening_and_refinement (); + + tria[1].last_active()->set_refine_flag(); + tria[1].execute_coarsening_and_refinement (); + + DoFHandler dh0 (tria[0]); + DoFHandler dh1 (tria[1]); + + typedef + std::list::cell_iterator, + typename DoFHandler::cell_iterator> > + CellList; + + const CellList cell_list + = GridTools::get_finest_common_cells (dh0, dh1); + for (typename CellList::const_iterator cell_pair = cell_list.begin(); + cell_pair != cell_list.end(); ++cell_pair) + deallog << cell_pair->first << ' ' << cell_pair->second + << std::endl; +} + + +int main() +{ + std::ofstream logfile ("get_finest_common_cells_02/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/deal.II/get_finest_common_cells_02/cmp/generic b/tests/deal.II/get_finest_common_cells_02/cmp/generic new file mode 100644 index 0000000000..5a9740bcc0 --- /dev/null +++ b/tests/deal.II/get_finest_common_cells_02/cmp/generic @@ -0,0 +1,85 @@ + +DEAL::2.0 2.0 +DEAL::2.1 2.1 +DEAL::2.2 2.2 +DEAL::2.3 2.3 +DEAL::2.0 2.0 +DEAL::2.1 2.1 +DEAL::2.2 2.2 +DEAL::2.3 2.3 +DEAL::2.4 2.4 +DEAL::2.5 2.5 +DEAL::2.6 2.6 +DEAL::2.7 2.7 +DEAL::2.8 2.8 +DEAL::2.9 2.9 +DEAL::2.10 2.10 +DEAL::2.11 2.11 +DEAL::2.12 2.12 +DEAL::2.13 2.13 +DEAL::2.14 2.14 +DEAL::2.15 2.15 +DEAL::2.0 2.0 +DEAL::2.1 2.1 +DEAL::2.2 2.2 +DEAL::2.3 2.3 +DEAL::2.4 2.4 +DEAL::2.5 2.5 +DEAL::2.6 2.6 +DEAL::2.7 2.7 +DEAL::2.8 2.8 +DEAL::2.9 2.9 +DEAL::2.10 2.10 +DEAL::2.11 2.11 +DEAL::2.12 2.12 +DEAL::2.13 2.13 +DEAL::2.14 2.14 +DEAL::2.15 2.15 +DEAL::2.16 2.16 +DEAL::2.17 2.17 +DEAL::2.18 2.18 +DEAL::2.19 2.19 +DEAL::2.20 2.20 +DEAL::2.21 2.21 +DEAL::2.22 2.22 +DEAL::2.23 2.23 +DEAL::2.24 2.24 +DEAL::2.25 2.25 +DEAL::2.26 2.26 +DEAL::2.27 2.27 +DEAL::2.28 2.28 +DEAL::2.29 2.29 +DEAL::2.30 2.30 +DEAL::2.31 2.31 +DEAL::2.32 2.32 +DEAL::2.33 2.33 +DEAL::2.34 2.34 +DEAL::2.35 2.35 +DEAL::2.36 2.36 +DEAL::2.37 2.37 +DEAL::2.38 2.38 +DEAL::2.39 2.39 +DEAL::2.40 2.40 +DEAL::2.41 2.41 +DEAL::2.42 2.42 +DEAL::2.43 2.43 +DEAL::2.44 2.44 +DEAL::2.45 2.45 +DEAL::2.46 2.46 +DEAL::2.47 2.47 +DEAL::2.48 2.48 +DEAL::2.49 2.49 +DEAL::2.50 2.50 +DEAL::2.51 2.51 +DEAL::2.52 2.52 +DEAL::2.53 2.53 +DEAL::2.54 2.54 +DEAL::2.55 2.55 +DEAL::2.56 2.56 +DEAL::2.57 2.57 +DEAL::2.58 2.58 +DEAL::2.59 2.59 +DEAL::2.60 2.60 +DEAL::2.61 2.61 +DEAL::2.62 2.62 +DEAL::2.63 2.63 diff --git a/tests/deal.II/get_finest_common_cells_03.cc b/tests/deal.II/get_finest_common_cells_03.cc new file mode 100644 index 0000000000..f1c984e52e --- /dev/null +++ b/tests/deal.II/get_finest_common_cells_03.cc @@ -0,0 +1,79 @@ +//---------------------------- get_finest_common_cells_03.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006 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. +// +//---------------------------- get_finest_common_cells_03.cc --------------------------- +// check GridTools::get_finest_common_cells for hp::DoFHandler arguments + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +#include + + +template +void test() +{ + // create 2 triangulations with the + // same coarse grid, and refine + // them differently + Triangulation tria[2]; + + GridGenerator::hyper_cube (tria[0]); + GridGenerator::hyper_cube (tria[1]); + + tria[0].refine_global (2); + tria[1].refine_global (2); + + tria[0].begin_active()->set_refine_flag(); + tria[0].execute_coarsening_and_refinement (); + + tria[1].last_active()->set_refine_flag(); + tria[1].execute_coarsening_and_refinement (); + + tria[1].last_active()->set_refine_flag(); + tria[1].execute_coarsening_and_refinement (); + + hp::DoFHandler dh0 (tria[0]); + hp::DoFHandler dh1 (tria[1]); + + typedef + std::list::cell_iterator, + typename hp::DoFHandler::cell_iterator> > + CellList; + + const CellList cell_list + = GridTools::get_finest_common_cells (dh0, dh1); + for (typename CellList::const_iterator cell_pair = cell_list.begin(); + cell_pair != cell_list.end(); ++cell_pair) + deallog << cell_pair->first << ' ' << cell_pair->second + << std::endl; +} + + +int main() +{ + std::ofstream logfile ("get_finest_common_cells_03/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/deal.II/get_finest_common_cells_03/cmp/generic b/tests/deal.II/get_finest_common_cells_03/cmp/generic new file mode 100644 index 0000000000..5a9740bcc0 --- /dev/null +++ b/tests/deal.II/get_finest_common_cells_03/cmp/generic @@ -0,0 +1,85 @@ + +DEAL::2.0 2.0 +DEAL::2.1 2.1 +DEAL::2.2 2.2 +DEAL::2.3 2.3 +DEAL::2.0 2.0 +DEAL::2.1 2.1 +DEAL::2.2 2.2 +DEAL::2.3 2.3 +DEAL::2.4 2.4 +DEAL::2.5 2.5 +DEAL::2.6 2.6 +DEAL::2.7 2.7 +DEAL::2.8 2.8 +DEAL::2.9 2.9 +DEAL::2.10 2.10 +DEAL::2.11 2.11 +DEAL::2.12 2.12 +DEAL::2.13 2.13 +DEAL::2.14 2.14 +DEAL::2.15 2.15 +DEAL::2.0 2.0 +DEAL::2.1 2.1 +DEAL::2.2 2.2 +DEAL::2.3 2.3 +DEAL::2.4 2.4 +DEAL::2.5 2.5 +DEAL::2.6 2.6 +DEAL::2.7 2.7 +DEAL::2.8 2.8 +DEAL::2.9 2.9 +DEAL::2.10 2.10 +DEAL::2.11 2.11 +DEAL::2.12 2.12 +DEAL::2.13 2.13 +DEAL::2.14 2.14 +DEAL::2.15 2.15 +DEAL::2.16 2.16 +DEAL::2.17 2.17 +DEAL::2.18 2.18 +DEAL::2.19 2.19 +DEAL::2.20 2.20 +DEAL::2.21 2.21 +DEAL::2.22 2.22 +DEAL::2.23 2.23 +DEAL::2.24 2.24 +DEAL::2.25 2.25 +DEAL::2.26 2.26 +DEAL::2.27 2.27 +DEAL::2.28 2.28 +DEAL::2.29 2.29 +DEAL::2.30 2.30 +DEAL::2.31 2.31 +DEAL::2.32 2.32 +DEAL::2.33 2.33 +DEAL::2.34 2.34 +DEAL::2.35 2.35 +DEAL::2.36 2.36 +DEAL::2.37 2.37 +DEAL::2.38 2.38 +DEAL::2.39 2.39 +DEAL::2.40 2.40 +DEAL::2.41 2.41 +DEAL::2.42 2.42 +DEAL::2.43 2.43 +DEAL::2.44 2.44 +DEAL::2.45 2.45 +DEAL::2.46 2.46 +DEAL::2.47 2.47 +DEAL::2.48 2.48 +DEAL::2.49 2.49 +DEAL::2.50 2.50 +DEAL::2.51 2.51 +DEAL::2.52 2.52 +DEAL::2.53 2.53 +DEAL::2.54 2.54 +DEAL::2.55 2.55 +DEAL::2.56 2.56 +DEAL::2.57 2.57 +DEAL::2.58 2.58 +DEAL::2.59 2.59 +DEAL::2.60 2.60 +DEAL::2.61 2.61 +DEAL::2.62 2.62 +DEAL::2.63 2.63 diff --git a/tests/deal.II/get_finest_common_cells_04.cc b/tests/deal.II/get_finest_common_cells_04.cc new file mode 100644 index 0000000000..37bf99fac6 --- /dev/null +++ b/tests/deal.II/get_finest_common_cells_04.cc @@ -0,0 +1,79 @@ +//---------------------------- get_finest_common_cells_04.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006 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. +// +//---------------------------- get_finest_common_cells_04.cc --------------------------- +// check GridTools::get_finest_common_cells for MGDoFHandler arguments + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +#include + + +template +void test() +{ + // create 2 triangulations with the + // same coarse grid, and refine + // them differently + Triangulation tria[2]; + + GridGenerator::hyper_cube (tria[0]); + GridGenerator::hyper_cube (tria[1]); + + tria[0].refine_global (2); + tria[1].refine_global (2); + + tria[0].begin_active()->set_refine_flag(); + tria[0].execute_coarsening_and_refinement (); + + tria[1].last_active()->set_refine_flag(); + tria[1].execute_coarsening_and_refinement (); + + tria[1].last_active()->set_refine_flag(); + tria[1].execute_coarsening_and_refinement (); + + MGDoFHandler dh0 (tria[0]); + MGDoFHandler dh1 (tria[1]); + + typedef + std::list::cell_iterator, + typename MGDoFHandler::cell_iterator> > + CellList; + + const CellList cell_list + = GridTools::get_finest_common_cells (dh0, dh1); + for (typename CellList::const_iterator cell_pair = cell_list.begin(); + cell_pair != cell_list.end(); ++cell_pair) + deallog << cell_pair->first << ' ' << cell_pair->second + << std::endl; +} + + +int main() +{ + std::ofstream logfile ("get_finest_common_cells_04/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/deal.II/get_finest_common_cells_04/cmp/generic b/tests/deal.II/get_finest_common_cells_04/cmp/generic new file mode 100644 index 0000000000..5a9740bcc0 --- /dev/null +++ b/tests/deal.II/get_finest_common_cells_04/cmp/generic @@ -0,0 +1,85 @@ + +DEAL::2.0 2.0 +DEAL::2.1 2.1 +DEAL::2.2 2.2 +DEAL::2.3 2.3 +DEAL::2.0 2.0 +DEAL::2.1 2.1 +DEAL::2.2 2.2 +DEAL::2.3 2.3 +DEAL::2.4 2.4 +DEAL::2.5 2.5 +DEAL::2.6 2.6 +DEAL::2.7 2.7 +DEAL::2.8 2.8 +DEAL::2.9 2.9 +DEAL::2.10 2.10 +DEAL::2.11 2.11 +DEAL::2.12 2.12 +DEAL::2.13 2.13 +DEAL::2.14 2.14 +DEAL::2.15 2.15 +DEAL::2.0 2.0 +DEAL::2.1 2.1 +DEAL::2.2 2.2 +DEAL::2.3 2.3 +DEAL::2.4 2.4 +DEAL::2.5 2.5 +DEAL::2.6 2.6 +DEAL::2.7 2.7 +DEAL::2.8 2.8 +DEAL::2.9 2.9 +DEAL::2.10 2.10 +DEAL::2.11 2.11 +DEAL::2.12 2.12 +DEAL::2.13 2.13 +DEAL::2.14 2.14 +DEAL::2.15 2.15 +DEAL::2.16 2.16 +DEAL::2.17 2.17 +DEAL::2.18 2.18 +DEAL::2.19 2.19 +DEAL::2.20 2.20 +DEAL::2.21 2.21 +DEAL::2.22 2.22 +DEAL::2.23 2.23 +DEAL::2.24 2.24 +DEAL::2.25 2.25 +DEAL::2.26 2.26 +DEAL::2.27 2.27 +DEAL::2.28 2.28 +DEAL::2.29 2.29 +DEAL::2.30 2.30 +DEAL::2.31 2.31 +DEAL::2.32 2.32 +DEAL::2.33 2.33 +DEAL::2.34 2.34 +DEAL::2.35 2.35 +DEAL::2.36 2.36 +DEAL::2.37 2.37 +DEAL::2.38 2.38 +DEAL::2.39 2.39 +DEAL::2.40 2.40 +DEAL::2.41 2.41 +DEAL::2.42 2.42 +DEAL::2.43 2.43 +DEAL::2.44 2.44 +DEAL::2.45 2.45 +DEAL::2.46 2.46 +DEAL::2.47 2.47 +DEAL::2.48 2.48 +DEAL::2.49 2.49 +DEAL::2.50 2.50 +DEAL::2.51 2.51 +DEAL::2.52 2.52 +DEAL::2.53 2.53 +DEAL::2.54 2.54 +DEAL::2.55 2.55 +DEAL::2.56 2.56 +DEAL::2.57 2.57 +DEAL::2.58 2.58 +DEAL::2.59 2.59 +DEAL::2.60 2.60 +DEAL::2.61 2.61 +DEAL::2.62 2.62 +DEAL::2.63 2.63 diff --git a/tests/deal.II/have_same_coarse_mesh_01.cc b/tests/deal.II/have_same_coarse_mesh_01.cc new file mode 100644 index 0000000000..a4d763ae62 --- /dev/null +++ b/tests/deal.II/have_same_coarse_mesh_01.cc @@ -0,0 +1,80 @@ +//---------------------------- have_same_coarse_mesh_01.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006 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. +// +//---------------------------- have_same_coarse_mesh_01.cc --------------------------- +// check GridTools::have_same_coarse_mesh for triangulations + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include + +#include + + +template +void test() +{ + // create 3 triangulations + Triangulation tria[3]; + + GridGenerator::hyper_cube (tria[0]); + tria[0].refine_global (1); + + GridGenerator::hyper_cube (tria[1]); + GridTools::scale (2, tria[1]); + tria[1].refine_global (2); + + if (dim != 1) + GridGenerator::hyper_ball (tria[2]); + else + { + GridGenerator::hyper_cube (tria[2]); + GridTools::shift (Point(2.), tria[2]); + } + + tria[2].refine_global (3); + + for (unsigned int i=0; i<3; ++i) + for (unsigned int j=0; j<3; ++j) + { + Assert (GridTools::have_same_coarse_mesh (tria[i], tria[j]) + == + (i == j), + ExcInternalError()); + + deallog << "meshes " << i << " and " << j << ": " + << (GridTools::have_same_coarse_mesh (tria[i], tria[j]) + ? + "true" + : + "false") + << std::endl; + } +} + + +int main() +{ + std::ofstream logfile ("have_same_coarse_mesh_01/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/deal.II/have_same_coarse_mesh_01/cmp/generic b/tests/deal.II/have_same_coarse_mesh_01/cmp/generic new file mode 100644 index 0000000000..df35d31fe5 --- /dev/null +++ b/tests/deal.II/have_same_coarse_mesh_01/cmp/generic @@ -0,0 +1,28 @@ + +DEAL::meshes 0 and 0: true +DEAL::meshes 0 and 1: false +DEAL::meshes 0 and 2: false +DEAL::meshes 1 and 0: false +DEAL::meshes 1 and 1: true +DEAL::meshes 1 and 2: false +DEAL::meshes 2 and 0: false +DEAL::meshes 2 and 1: false +DEAL::meshes 2 and 2: true +DEAL::meshes 0 and 0: true +DEAL::meshes 0 and 1: false +DEAL::meshes 0 and 2: false +DEAL::meshes 1 and 0: false +DEAL::meshes 1 and 1: true +DEAL::meshes 1 and 2: false +DEAL::meshes 2 and 0: false +DEAL::meshes 2 and 1: false +DEAL::meshes 2 and 2: true +DEAL::meshes 0 and 0: true +DEAL::meshes 0 and 1: false +DEAL::meshes 0 and 2: false +DEAL::meshes 1 and 0: false +DEAL::meshes 1 and 1: true +DEAL::meshes 1 and 2: false +DEAL::meshes 2 and 0: false +DEAL::meshes 2 and 1: false +DEAL::meshes 2 and 2: true diff --git a/tests/deal.II/have_same_coarse_mesh_02.cc b/tests/deal.II/have_same_coarse_mesh_02.cc new file mode 100644 index 0000000000..c29102aac5 --- /dev/null +++ b/tests/deal.II/have_same_coarse_mesh_02.cc @@ -0,0 +1,86 @@ +//---------------------------- have_same_coarse_mesh_02.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006 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. +// +//---------------------------- have_same_coarse_mesh_02.cc --------------------------- +// check GridTools::have_same_coarse_mesh for DoFHandler arguments + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include + +#include + + +template +void test() +{ + // create 3 triangulations + Triangulation tria[3]; + + GridGenerator::hyper_cube (tria[0]); + tria[0].refine_global (1); + + GridGenerator::hyper_cube (tria[1]); + GridTools::scale (2, tria[1]); + tria[1].refine_global (2); + + if (dim != 1) + GridGenerator::hyper_ball (tria[2]); + else + { + GridGenerator::hyper_cube (tria[2]); + GridTools::shift (Point(2.), tria[2]); + } + + tria[2].refine_global (3); + + DoFHandler dh0 (tria[0]); + DoFHandler dh1 (tria[1]); + DoFHandler dh2 (tria[2]); + + DoFHandler *dof_handler[3] = { &dh0, &dh1, &dh2 }; + + for (unsigned int i=0; i<3; ++i) + for (unsigned int j=0; j<3; ++j) + { + Assert (GridTools::have_same_coarse_mesh (*dof_handler[i], *dof_handler[j]) + == + (i == j), + ExcInternalError()); + + deallog << "meshes " << i << " and " << j << ": " + << (GridTools::have_same_coarse_mesh (*dof_handler[i], *dof_handler[j]) + ? + "true" + : + "false") + << std::endl; + } +} + + +int main() +{ + std::ofstream logfile ("have_same_coarse_mesh_02/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/deal.II/have_same_coarse_mesh_02/cmp/generic b/tests/deal.II/have_same_coarse_mesh_02/cmp/generic new file mode 100644 index 0000000000..df35d31fe5 --- /dev/null +++ b/tests/deal.II/have_same_coarse_mesh_02/cmp/generic @@ -0,0 +1,28 @@ + +DEAL::meshes 0 and 0: true +DEAL::meshes 0 and 1: false +DEAL::meshes 0 and 2: false +DEAL::meshes 1 and 0: false +DEAL::meshes 1 and 1: true +DEAL::meshes 1 and 2: false +DEAL::meshes 2 and 0: false +DEAL::meshes 2 and 1: false +DEAL::meshes 2 and 2: true +DEAL::meshes 0 and 0: true +DEAL::meshes 0 and 1: false +DEAL::meshes 0 and 2: false +DEAL::meshes 1 and 0: false +DEAL::meshes 1 and 1: true +DEAL::meshes 1 and 2: false +DEAL::meshes 2 and 0: false +DEAL::meshes 2 and 1: false +DEAL::meshes 2 and 2: true +DEAL::meshes 0 and 0: true +DEAL::meshes 0 and 1: false +DEAL::meshes 0 and 2: false +DEAL::meshes 1 and 0: false +DEAL::meshes 1 and 1: true +DEAL::meshes 1 and 2: false +DEAL::meshes 2 and 0: false +DEAL::meshes 2 and 1: false +DEAL::meshes 2 and 2: true diff --git a/tests/deal.II/have_same_coarse_mesh_03.cc b/tests/deal.II/have_same_coarse_mesh_03.cc new file mode 100644 index 0000000000..ca92005be4 --- /dev/null +++ b/tests/deal.II/have_same_coarse_mesh_03.cc @@ -0,0 +1,86 @@ +//---------------------------- have_same_coarse_mesh_03.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006 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. +// +//---------------------------- have_same_coarse_mesh_03.cc --------------------------- +// check GridTools::have_same_coarse_mesh for hp::DoFHandler arguments + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include + +#include + + +template +void test() +{ + // create 3 triangulations + Triangulation tria[3]; + + GridGenerator::hyper_cube (tria[0]); + tria[0].refine_global (1); + + GridGenerator::hyper_cube (tria[1]); + GridTools::scale (2, tria[1]); + tria[1].refine_global (2); + + if (dim != 1) + GridGenerator::hyper_ball (tria[2]); + else + { + GridGenerator::hyper_cube (tria[2]); + GridTools::shift (Point(2.), tria[2]); + } + + tria[2].refine_global (3); + + hp::DoFHandler dh0 (tria[0]); + hp::DoFHandler dh1 (tria[1]); + hp::DoFHandler dh2 (tria[2]); + + hp::DoFHandler *dof_handler[3] = { &dh0, &dh1, &dh2 }; + + for (unsigned int i=0; i<3; ++i) + for (unsigned int j=0; j<3; ++j) + { + Assert (GridTools::have_same_coarse_mesh (*dof_handler[i], *dof_handler[j]) + == + (i == j), + ExcInternalError()); + + deallog << "meshes " << i << " and " << j << ": " + << (GridTools::have_same_coarse_mesh (*dof_handler[i], *dof_handler[j]) + ? + "true" + : + "false") + << std::endl; + } +} + + +int main() +{ + std::ofstream logfile ("have_same_coarse_mesh_03/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/deal.II/have_same_coarse_mesh_03/cmp/generic b/tests/deal.II/have_same_coarse_mesh_03/cmp/generic new file mode 100644 index 0000000000..df35d31fe5 --- /dev/null +++ b/tests/deal.II/have_same_coarse_mesh_03/cmp/generic @@ -0,0 +1,28 @@ + +DEAL::meshes 0 and 0: true +DEAL::meshes 0 and 1: false +DEAL::meshes 0 and 2: false +DEAL::meshes 1 and 0: false +DEAL::meshes 1 and 1: true +DEAL::meshes 1 and 2: false +DEAL::meshes 2 and 0: false +DEAL::meshes 2 and 1: false +DEAL::meshes 2 and 2: true +DEAL::meshes 0 and 0: true +DEAL::meshes 0 and 1: false +DEAL::meshes 0 and 2: false +DEAL::meshes 1 and 0: false +DEAL::meshes 1 and 1: true +DEAL::meshes 1 and 2: false +DEAL::meshes 2 and 0: false +DEAL::meshes 2 and 1: false +DEAL::meshes 2 and 2: true +DEAL::meshes 0 and 0: true +DEAL::meshes 0 and 1: false +DEAL::meshes 0 and 2: false +DEAL::meshes 1 and 0: false +DEAL::meshes 1 and 1: true +DEAL::meshes 1 and 2: false +DEAL::meshes 2 and 0: false +DEAL::meshes 2 and 1: false +DEAL::meshes 2 and 2: true diff --git a/tests/deal.II/have_same_coarse_mesh_04.cc b/tests/deal.II/have_same_coarse_mesh_04.cc new file mode 100644 index 0000000000..28bed581f7 --- /dev/null +++ b/tests/deal.II/have_same_coarse_mesh_04.cc @@ -0,0 +1,86 @@ +//---------------------------- have_same_coarse_mesh_04.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006 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. +// +//---------------------------- have_same_coarse_mesh_04.cc --------------------------- +// check GridTools::have_same_coarse_mesh for MGDoFHandler arguments + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include + +#include + + +template +void test() +{ + // create 3 triangulations + Triangulation tria[3]; + + GridGenerator::hyper_cube (tria[0]); + tria[0].refine_global (1); + + GridGenerator::hyper_cube (tria[1]); + GridTools::scale (2, tria[1]); + tria[1].refine_global (2); + + if (dim != 1) + GridGenerator::hyper_ball (tria[2]); + else + { + GridGenerator::hyper_cube (tria[2]); + GridTools::shift (Point(2.), tria[2]); + } + + tria[2].refine_global (3); + + MGDoFHandler dh0 (tria[0]); + MGDoFHandler dh1 (tria[1]); + MGDoFHandler dh2 (tria[2]); + + MGDoFHandler *dof_handler[3] = { &dh0, &dh1, &dh2 }; + + for (unsigned int i=0; i<3; ++i) + for (unsigned int j=0; j<3; ++j) + { + Assert (GridTools::have_same_coarse_mesh (*dof_handler[i], *dof_handler[j]) + == + (i == j), + ExcInternalError()); + + deallog << "meshes " << i << " and " << j << ": " + << (GridTools::have_same_coarse_mesh (*dof_handler[i], *dof_handler[j]) + ? + "true" + : + "false") + << std::endl; + } +} + + +int main() +{ + std::ofstream logfile ("have_same_coarse_mesh_04/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test<1>(); + test<2>(); + test<3>(); +} + diff --git a/tests/deal.II/have_same_coarse_mesh_04/cmp/generic b/tests/deal.II/have_same_coarse_mesh_04/cmp/generic new file mode 100644 index 0000000000..df35d31fe5 --- /dev/null +++ b/tests/deal.II/have_same_coarse_mesh_04/cmp/generic @@ -0,0 +1,28 @@ + +DEAL::meshes 0 and 0: true +DEAL::meshes 0 and 1: false +DEAL::meshes 0 and 2: false +DEAL::meshes 1 and 0: false +DEAL::meshes 1 and 1: true +DEAL::meshes 1 and 2: false +DEAL::meshes 2 and 0: false +DEAL::meshes 2 and 1: false +DEAL::meshes 2 and 2: true +DEAL::meshes 0 and 0: true +DEAL::meshes 0 and 1: false +DEAL::meshes 0 and 2: false +DEAL::meshes 1 and 0: false +DEAL::meshes 1 and 1: true +DEAL::meshes 1 and 2: false +DEAL::meshes 2 and 0: false +DEAL::meshes 2 and 1: false +DEAL::meshes 2 and 2: true +DEAL::meshes 0 and 0: true +DEAL::meshes 0 and 1: false +DEAL::meshes 0 and 2: false +DEAL::meshes 1 and 0: false +DEAL::meshes 1 and 1: true +DEAL::meshes 1 and 2: false +DEAL::meshes 2 and 0: false +DEAL::meshes 2 and 1: false +DEAL::meshes 2 and 2: true