From 00776d488fa99ea33845850512d5b22e9fadc77c Mon Sep 17 00:00:00 2001 From: bangerth Date: Mon, 5 May 2014 02:58:09 +0000 Subject: [PATCH] Add one test. git-svn-id: https://svn.dealii.org/trunk@32883 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/metis/metis_01a.cc | 165 +++++++++++++++++++++++++++++++++++ tests/metis/metis_01a.output | 15 ++++ 2 files changed, 180 insertions(+) create mode 100644 tests/metis/metis_01a.cc create mode 100644 tests/metis/metis_01a.output diff --git a/tests/metis/metis_01a.cc b/tests/metis/metis_01a.cc new file mode 100644 index 0000000000..ba2b3a8921 --- /dev/null +++ b/tests/metis/metis_01a.cc @@ -0,0 +1,165 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2004 - 2014 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. +// +// --------------------------------------------------------------------- + + + +// A test meant to identify why GridTools::partition_triangulation +// produces different output whether we're in 32- or 64-bit mode. it +// turns out that when we get METIS from PETSc and PETSc's downloaded +// version of METIS is the source of the METIS installation we use +// here, then PETSc configures METIS to use the same integer size as +// PETSc. However, then, METIS produces different output. +// +// We can not currently test for this, so the tests in this directory +// have different output depending on whether *we* (and consequently +// PETSc) use 32- or 64-bit indices, not on whether or not we use 32- +// or 64-bit METIS. + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +void partition (const SparsityPattern &sparsity_pattern, + const unsigned int n_partitions) +{ + // generate the data structures for + // METIS. Note that this is particularly + // simple, since METIS wants exactly our + // compressed row storage format. we only + // have to set up a few auxiliary arrays + idx_t + n = static_cast(sparsity_pattern.n_rows()), + ncon = 1, // number of balancing constraints (should be >0) + nparts = static_cast(n_partitions), // number of subdomains to create + dummy; // the numbers of edges cut by the + // resulting partition + + // use default options for METIS + idx_t options[METIS_NOPTIONS]; + METIS_SetDefaultOptions (options); + + // one more nuisance: we have to copy our + // own data to arrays that store signed + // integers :-( + std::vector int_rowstart(1); + int_rowstart.reserve(sparsity_pattern.n_rows()+1); + std::vector int_colnums; + int_colnums.reserve(sparsity_pattern.n_nonzero_elements()); + for (SparsityPattern::size_type row=0; rowcolumn()); + int_rowstart.push_back(int_colnums.size()); + } + + std::vector int_partition_indices (sparsity_pattern.n_rows()); + + // log the inputs to METIS + deallog << "METIS inputs:" << std::endl; + deallog << "IDXTYPEWIDTH=" << IDXTYPEWIDTH << std::endl; + deallog << n << ' ' << ncon << ' ' << nparts << std::endl; + for (unsigned int i=0; i +void test () +{ + Triangulation triangulation; + GridGenerator::hyper_cube (triangulation); + triangulation.refine_global (2); + + SparsityPattern cell_connectivity; + GridTools::get_face_connectivity_of_cells (triangulation, cell_connectivity); + + partition (cell_connectivity, 5); +} + + + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + test<1> (); + } + catch (std::exception &exc) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/metis/metis_01a.output b/tests/metis/metis_01a.output new file mode 100644 index 0000000000..0f64303f2f --- /dev/null +++ b/tests/metis/metis_01a.output @@ -0,0 +1,15 @@ + +DEAL::METIS inputs: +DEAL::IDXTYPEWIDTH=32 +DEAL::4 1 5 +DEAL::0 2 5 8 10 +DEAL::0 1 1 0 2 2 1 3 3 2 +DEAL::-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +DEAL::4 +DEAL::METIS outputs: +DEAL::3 +DEAL::0 0 +DEAL::1 1 +DEAL::2 3 +DEAL::3 4 +DEAL:: -- 2.39.5