| 1 |
// Copyright (C) 2016 Garth N. Wells |
| 2 |
// |
| 3 |
// This file is part of DOLFIN. |
| 4 |
// |
| 5 |
// DOLFIN is free software: you can redistribute it and/or modify |
| 6 |
// it under the terms of the GNU Lesser General Public License as published by |
| 7 |
// the Free Software Foundation, either version 3 of the License, or |
| 8 |
// (at your option) any later version. |
| 9 |
// |
| 10 |
// DOLFIN is distributed in the hope that it will be useful, |
| 11 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
// GNU Lesser General Public License for more details. |
| 14 |
// |
| 15 |
// You should have received a copy of the GNU Lesser General Public License |
| 16 |
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
// |
| 18 |
// Unit tests for MeshColoring |
| 19 |
|
| 20 |
#include <dolfin.h> |
| 21 |
#include <catch.hpp> |
| 22 |
|
| 23 |
using namespace dolfin; |
| 24 |
|
| 25 |
TEST_CASE("MeshColoring") |
| 26 |
{ |
| 27 |
|
| 28 |
SECTION("mesh coloring computation") |
| 29 |
{ |
| 30 |
// Create mesh |
| 31 |
auto mesh = std::make_shared<UnitCubeMesh>(24, 24, 24); |
| 32 |
|
| 33 |
// Compute vertex-based coloring |
| 34 |
mesh->color("vertex"); |
| 35 |
const MeshFunction<std::size_t> colors_vertex |
| 36 |
= MeshColoring::cell_colors(mesh, "vertex"); |
| 37 |
|
| 38 |
// Compute edge-based coloring |
| 39 |
mesh->color("edge"); |
| 40 |
const MeshFunction<std::size_t> colors_edge |
| 41 |
= MeshColoring::cell_colors(mesh, "edge"); |
| 42 |
|
| 43 |
// Compute facet-based coloring |
| 44 |
mesh->color("facet"); |
| 45 |
const MeshFunction<std::size_t> colors_facet |
| 46 |
= MeshColoring::cell_colors(mesh, "facet"); |
| 47 |
|
| 48 |
// Compute facet-based coloring with distance 2 |
| 49 |
std::vector<std::size_t> coloring_type |
| 50 |
= {{mesh->topology().dim(), |
| 51 |
mesh->topology().dim() - 1, |
| 52 |
mesh->topology().dim(), |
| 53 |
mesh->topology().dim() - 1, |
| 54 |
mesh->topology().dim()}}; |
| 55 |
mesh->color(coloring_type); |
| 56 |
const MeshFunction<std::size_t> colors_vertex_2 |
| 57 |
= MeshColoring::cell_colors(mesh, coloring_type); |
| 58 |
} |
| 59 |
} |