From afd8aa15354a5f705e5376043b17fb6b1805ac81 Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Sun, 5 Jul 2015 11:42:29 +0200 Subject: [PATCH] add test for multiple subdomains and convert huge unsigned to negative values --- source/grid/grid_out.cc | 4 +- .../grid_out_vtk_01.cc} | 0 .../grid_out_vtk_01.output} | 0 tests/grid/grid_out_vtk_02.cc | 112 ++++++++++++++++++ tests/grid/grid_out_vtk_02.mpirun=3.output | 29 +++++ 5 files changed, 143 insertions(+), 2 deletions(-) rename tests/{deal.II/grid_out_06.cc => grid/grid_out_vtk_01.cc} (100%) rename tests/{deal.II/grid_out_06.output => grid/grid_out_vtk_01.output} (100%) create mode 100644 tests/grid/grid_out_vtk_02.cc create mode 100644 tests/grid/grid_out_vtk_02.mpirun=3.output diff --git a/source/grid/grid_out.cc b/source/grid/grid_out.cc index 73efbe4b41..d2898116d8 100644 --- a/source/grid/grid_out.cc +++ b/source/grid/grid_out.cc @@ -2442,10 +2442,10 @@ namespace patch.data(0, v) = cell->level(); patch.data(1, v) = cell->material_id(); if (!cell->has_children()) - patch.data(2, v) = cell->subdomain_id(); + patch.data(2, v) = static_cast(cell->subdomain_id()); else patch.data(2, v) = -1; - patch.data(3, v) = cell->level_subdomain_id(); + patch.data(3, v) = static_cast(cell->level_subdomain_id()); } patches.push_back (patch); } diff --git a/tests/deal.II/grid_out_06.cc b/tests/grid/grid_out_vtk_01.cc similarity index 100% rename from tests/deal.II/grid_out_06.cc rename to tests/grid/grid_out_vtk_01.cc diff --git a/tests/deal.II/grid_out_06.output b/tests/grid/grid_out_vtk_01.output similarity index 100% rename from tests/deal.II/grid_out_06.output rename to tests/grid/grid_out_vtk_01.output diff --git a/tests/grid/grid_out_vtk_02.cc b/tests/grid/grid_out_vtk_02.cc new file mode 100644 index 0000000000..a26b55fe23 --- /dev/null +++ b/tests/grid/grid_out_vtk_02.cc @@ -0,0 +1,112 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2009 - 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. +// +// --------------------------------------------------------------------- + + + +// check level_subdomain_id for distributed Triangulation + +#include "../tests.h" +#include "coarse_grid_common.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +template +void output(parallel::distributed::Triangulation &tr, std::ostream& stream) +{ + GridOut out; + out.write_vtk(tr, stream); +} + +template +void test() +{ + unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + + if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0) + deallog << "hyper_cube" << std::endl; + + parallel::distributed::Triangulation tr(MPI_COMM_WORLD, + Triangulation::none, + parallel::distributed::Triangulation::construct_multigrid_hierarchy); + + GridGenerator::hyper_cube(tr); + tr.refine_global(2); + DoFHandler dofh(tr); + + const std::string + filename = ("mesh" + Utilities::int_to_string(dim) + + "d." + + Utilities::int_to_string(tr.locally_owned_subdomain(), 4) + + ".vtk"); + std::ofstream stream(filename.c_str()); + output(tr, stream); + + //tr.begin_active()->set_level_subdomain_id(1+myid); + + for (unsigned int i=0; i<10; ++i) + { + + MPI_Barrier(MPI_COMM_WORLD); + if (myid==i) + { + deallog << "ID = " << i << std::endl; + for (unsigned int lvl=0; lvl::cell_iterator + cell = tr.begin(lvl), + endc = tr.end(lvl); + + for (; cell!=endc; ++cell) + if (cell->level_subdomain_id()!=4294967294) + deallog << cell->level_subdomain_id(); + else + deallog << "-"; + deallog << std::endl; + } + deallog << std::endl; + } + } + + if (myid==0) + deallog << "my levels: " << tr.n_levels() << "<= global levels:" << tr.n_global_levels() << std::endl; + + +} + + +int main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll log; + + deallog.push("2d"); + test<2>(); + deallog.pop(); +} diff --git a/tests/grid/grid_out_vtk_02.mpirun=3.output b/tests/grid/grid_out_vtk_02.mpirun=3.output new file mode 100644 index 0000000000..0504869876 --- /dev/null +++ b/tests/grid/grid_out_vtk_02.mpirun=3.output @@ -0,0 +1,29 @@ + +DEAL:0:2d::hyper_cube +DEAL:0:2d::ID = 0 +DEAL:0:2d::0 +DEAL:0:2d::0123 +DEAL:0:2d::00001-1-22--3--- +DEAL:0:2d:: +DEAL:0:2d::my levels: 3<= global levels:3 + +DEAL:1:2d::ID = 1 +DEAL:1:2d::0 +DEAL:1:2d::0123 +DEAL:1:2d::-0-01111-2--33-- +DEAL:1:2d:: + + +DEAL:2:2d::ID = 2 +DEAL:2:2d::0 +DEAL:2:2d::0123 +DEAL:2:2d::--00--1-22223-3- +DEAL:2:2d:: + + +DEAL:3:2d::ID = 3 +DEAL:3:2d::0 +DEAL:3:2d::0123 +DEAL:3:2d::---0--11-2-23333 +DEAL:3:2d:: + -- 2.39.5