From: bangerth Date: Thu, 7 Nov 2013 19:41:41 +0000 (+0000) Subject: Add another test. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79c46739a7c0ac019dd3939c663083c9085cb885;p=dealii-svn.git Add another test. git-svn-id: https://svn.dealii.org/trunk@31573 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/base/graph_coloring_02a.cc b/tests/base/graph_coloring_02a.cc new file mode 100644 index 0000000000..274aa39979 --- /dev/null +++ b/tests/base/graph_coloring_02a.cc @@ -0,0 +1,121 @@ +// --------------------------------------------------------------------- +// $Id: graph_coloring_02.cc 30045 2013-07-18 19:18:00Z maier $ +// +// Copyright (C) 2003 - 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// Like _02, but verify that the elements in each partition really do +// not conflict + + +#include "../tests.h" +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +template +std::vector get_conflict_indices_cfem( + typename DoFHandler::active_cell_iterator const &it) +{ + std::vector local_dof_indices(it->get_fe().dofs_per_cell); + it->get_dof_indices(local_dof_indices); + + return local_dof_indices; +} + +template +void check() +{ + // Create the Triangulation and the DoFHandler + Triangulation triangulation; + GridGenerator::hyper_cube(triangulation); + triangulation.refine_global(2); + FE_Q fe(2); + DoFHandler dof_handler(triangulation); + dof_handler.distribute_dofs(fe); + + // Create an adapted mesh + typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(); + for (; cellcenter()[0]==0.625) + && + ((dim < 2) || (cell->center()[1]==0.625)) + && + ((dim < 3) || (cell->center()[2]==0.625))) + cell->set_refine_flag(); + } + triangulation.execute_coarsening_and_refinement(); + dof_handler.distribute_dofs(fe); + + // Create the coloring + std::vector::active_cell_iterator> > coloring( + graph_coloring::make_graph_coloring(dof_handler.begin_active(),dof_handler.end(), + std_cxx1x::function (typename + DoFHandler::active_cell_iterator const &)> (&get_conflict_indices_cfem))); + + // verify that within each color, there is no conflict + for (unsigned int color=0; color + conflicts_i = get_conflict_indices_cfem (coloring[color][i]); + std::sort (conflicts_i.begin(), conflicts_i.end()); + + for (unsigned int j=i+1; j + conflicts_j = get_conflict_indices_cfem (coloring[color][j]); + std::sort (conflicts_j.begin(), conflicts_j.end()); + + // compute intersection of index sets + std::vector + intersection (std::max (conflicts_i.size(), conflicts_j.size())); + std::vector::iterator + p = std::set_intersection (conflicts_i.begin(), conflicts_i.end(), + conflicts_j.begin(), conflicts_j.end(), + intersection.begin()); + // verify that there is no intersection + Assert (p == intersection.begin(), + ExcInternalError()); + } + } + + deallog << "OK" << std::endl; +} + +int main() +{ + std::ofstream logfile("output"); + deallog< (); + check<2> (); + check<3> (); + + return 0; +} diff --git a/tests/base/graph_coloring_02a.output b/tests/base/graph_coloring_02a.output new file mode 100644 index 0000000000..fb71de2867 --- /dev/null +++ b/tests/base/graph_coloring_02a.output @@ -0,0 +1,4 @@ + +DEAL::OK +DEAL::OK +DEAL::OK