From 5b21338ec5958c0fe113e2b9dc5bb3339cb23743 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Wed, 20 Jul 2016 02:08:18 +0200 Subject: [PATCH] Test for MGConstrainedDofs --- tests/multigrid/constrained_dofs_03.cc | 115 +++++++++++++++++++++ tests/multigrid/constrained_dofs_03.output | 41 ++++++++ 2 files changed, 156 insertions(+) create mode 100644 tests/multigrid/constrained_dofs_03.cc create mode 100644 tests/multigrid/constrained_dofs_03.output diff --git a/tests/multigrid/constrained_dofs_03.cc b/tests/multigrid/constrained_dofs_03.cc new file mode 100644 index 0000000000..6f55029b96 --- /dev/null +++ b/tests/multigrid/constrained_dofs_03.cc @@ -0,0 +1,115 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2006 - 2016 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 mg constrained dofs for primitive and non-primitive FiniteElements + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +using namespace std; + +template +void check_fe(FiniteElement &fe, ComponentMask &component_mask) +{ + deallog << fe.get_name() << std::endl; + + Triangulation tr; + GridGenerator::hyper_cube(tr); + tr.refine_global(1); + + DoFHandler dofh(tr); + dofh.distribute_dofs(fe); + dofh.distribute_mg_dofs(fe); + + MGConstrainedDoFs mg_constrained_dofs; + std::vector boundary_indicators(1,0); + mg_constrained_dofs.initialize(dofh); + mg_constrained_dofs.set_zero_boundary_dofs(dofh, boundary_indicators, component_mask); + + const unsigned int n_levels = tr.n_global_levels(); + for (unsigned int level = 0; level < n_levels; ++level) + { + deallog << "Level " << level << ":" << std::endl; + IndexSet boundary_indices = mg_constrained_dofs.get_boundary_indices (level); + boundary_indices.print(deallog); + } +} + +template +void check() +{ + //All primitive + { + FE_Q q1(2); + FE_Q q2(1); + FESystem s1(q1, dim, q2,1); + + //All selected + ComponentMask component_mask1(dim+1, true); + //Partially selecetd + ComponentMask component_mask2(dim+1, true); + component_mask2.set(dim, false); + + check_fe(s1, component_mask1); + check_fe(s1, component_mask2); + } + + //Non-primitive + { + FE_RaviartThomas q1(1); + FE_DGQ q2(1); + FESystem s1(q1, 1, q2,1); + + //All selected + ComponentMask component_mask1(dim+1, true); + //Partially selecetd + ComponentMask component_mask2(dim+1, true); + component_mask2.set(dim, false); + + check_fe(s1, component_mask1); + check_fe(s1, component_mask2); + } +} + +int main(int argc, char *argv[]) +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + + check<2> (); + check<3> (); +} diff --git a/tests/multigrid/constrained_dofs_03.output b/tests/multigrid/constrained_dofs_03.output new file mode 100644 index 0000000000..892c0ee597 --- /dev/null +++ b/tests/multigrid/constrained_dofs_03.output @@ -0,0 +1,41 @@ + +DEAL::FESystem<2>[FE_Q<2>(2)^2-FE_Q<2>(1)] +DEAL::Level 0: +DEAL::{[0,19]} +DEAL::Level 1: +DEAL::{[0,8], [12,13], [16,17], [22,31], [36,43], [46,47], [50,56]} +DEAL::FESystem<2>[FE_Q<2>(2)^2-FE_Q<2>(1)] +DEAL::Level 0: +DEAL::{[0,1], [3,4], [6,7], [9,10], [12,19]} +DEAL::Level 1: +DEAL::{[0,1], [3,4], [6,7], [12,13], [16,17], [22,23], [25,26], [28,31], [36,37], [39,40], [42,43], [46,47], [50,51], [53,56]} +DEAL::FESystem<2>[FE_RaviartThomas<2>(1)-FE_DGQ<2>(1)] +DEAL::Level 0: +DEAL::{[0,7]} +DEAL::Level 1: +DEAL::{[0,1], [4,5], [16,19], [30,31], [34,35], [44,47]} +DEAL::FESystem<2>[FE_RaviartThomas<2>(1)-FE_DGQ<2>(1)] +DEAL::Level 0: +DEAL::{[0,7]} +DEAL::Level 1: +DEAL::{[0,1], [4,5], [16,19], [30,31], [34,35], [44,47]} +DEAL::FESystem<3>[FE_Q<3>(2)^3-FE_Q<3>(1)] +DEAL::Level 0: +DEAL::{[0,85]} +DEAL::Level 1: +DEAL::{[0,27], [32,46], [50,52], [56,64], [68,70], [74,76], [80,82], [89,119], [123,134], [138,140], [147,174], [178,189], [193,198], [205,236], [243,279], [283,285], [289,291], [295,297], [301,329], [333,335], [339,364], [368,373], [377,398]} +DEAL::FESystem<3>[FE_Q<3>(2)^3-FE_Q<3>(1)] +DEAL::Level 0: +DEAL::{[0,2], [4,6], [8,10], [12,14], [16,18], [20,22], [24,26], [28,30], [32,85]} +DEAL::Level 1: +DEAL::{[0,2], [4,6], [8,10], [12,14], [16,18], [20,22], [24,26], [32,46], [50,52], [56,64], [68,70], [74,76], [80,82], [89,91], [93,95], [97,99], [101,103], [105,119], [123,134], [138,140], [147,149], [151,153], [155,157], [159,161], [163,174], [178,189], [193,198], [205,207], [209,211], [213,236], [243,245], [247,249], [251,253], [255,257], [259,279], [283,285], [289,291], [295,297], [301,303], [305,307], [309,329], [333,335], [339,341], [343,345], [347,364], [368,373], [377,379], [381,398]} +DEAL::FESystem<3>[FE_RaviartThomas<3>(1)-FE_DGQ<3>(1)] +DEAL::Level 0: +DEAL::{[0,23]} +DEAL::Level 1: +DEAL::{[0,3], [8,11], [16,19], [44,51], [56,59], [84,87], [92,99], [124,135], [160,163], [168,171], [176,179], [200,207], [212,215], [236,239], [244,251], [272,283]} +DEAL::FESystem<3>[FE_RaviartThomas<3>(1)-FE_DGQ<3>(1)] +DEAL::Level 0: +DEAL::{[0,23]} +DEAL::Level 1: +DEAL::{[0,3], [8,11], [16,19], [44,51], [56,59], [84,87], [92,99], [124,135], [160,163], [168,171], [176,179], [200,207], [212,215], [236,239], [244,251], [272,283]} -- 2.39.5