From: Timo Heister Date: Tue, 30 Jun 2015 15:02:40 +0000 (-0400) Subject: add test X-Git-Tag: v8.4.0-rc2~277^2~34 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e057852a6d6b80e9f373c4140dd5e7cd85eb84d;p=dealii.git add test --- diff --git a/tests/multigrid/constrained_dofs_01.cc b/tests/multigrid/constrained_dofs_01.cc new file mode 100644 index 0000000000..96a99b9ced --- /dev/null +++ b/tests/multigrid/constrained_dofs_01.cc @@ -0,0 +1,184 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2006 - 2015 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 in parallel + +#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; + + std::string id_to_string(const CellId &id) + { + std::ostringstream ss; + ss << id; + return ss.str(); + } + +template +void setup_tria(parallel::distributed::Triangulation &tr) +{ + GridGenerator::hyper_cube(tr); + tr.refine_global(2); + + for (typename parallel::distributed::Triangulation::active_cell_iterator cell = tr.begin_active(); + cell != tr.end(); ++cell) + { + if (id_to_string(cell->id()) == "0_2:11") + cell->set_refine_flag(); + } + tr.execute_coarsening_and_refinement(); +} + + +template +void reorder(DoFHandler &dofh, FiniteElement &fe) +{ + parallel::distributed::Triangulation tr(MPI_COMM_SELF, + Triangulation::none, + parallel::distributed::Triangulation::construct_multigrid_hierarchy); + setup_tria(tr); + + DoFHandler dofhref(tr); + dofhref.distribute_dofs(fe); + dofhref.distribute_mg_dofs(fe); + + //std::map > dofmap; + std::map > mgdofmap; + + for (typename DoFHandler::level_cell_iterator cell = dofhref.begin(); + cell != dofhref.end(); ++cell) + { + if (!cell->is_locally_owned_on_level()) + continue; + + std::vector &d = mgdofmap[id_to_string(cell->id())]; + d.resize(fe.dofs_per_cell); + cell->get_mg_dof_indices(d); + } + + for (typename DoFHandler::level_cell_iterator cell = dofh.begin(); + cell != dofh.end(); ++cell) + { + if (cell->level_subdomain_id()==numbers::artificial_subdomain_id) + continue; + + std::vector &renumbered = mgdofmap[id_to_string(cell->id())]; + cell->set_mg_dof_indices(renumbered); + cell->update_cell_dof_indices_cache(); + } + + +} + +template +void check_fe(FiniteElement &fe) +{ + deallog << fe.get_name() << std::endl; + + parallel::distributed::Triangulation tr(MPI_COMM_WORLD, + Triangulation::none, + parallel::distributed::Triangulation::construct_multigrid_hierarchy); + setup_tria(tr); + + ZeroFunction zero; + typename FunctionMap::type fmap; + fmap.insert(std::make_pair(0, &zero)); + + DoFHandler dofh(tr); + dofh.distribute_dofs(fe); + dofh.distribute_mg_dofs(fe); + + { // reorder + unsigned int numprocs = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD); + if (numprocs > 1) + reorder(dofh, fe); + } + + + + MGConstrainedDoFs mg_constrained_dofs; + + typename FunctionMap::type dirichlet_boundary; + ZeroFunction homogeneous_dirichlet_bc (1); + dirichlet_boundary[0] = &homogeneous_dirichlet_bc; + mg_constrained_dofs.initialize(dofh, dirichlet_boundary); + + const unsigned int n_levels = tr.n_global_levels(); + for (unsigned int level = 0; level < n_levels; ++level) + { + deallog << "Level " << level << ":" << std::endl; + + IndexSet rei = mg_constrained_dofs.get_refinement_edge_indices (level); + deallog << "get_refinement_edge_indices:" << std::endl; + rei.print(deallog); + + IndexSet bi = mg_constrained_dofs.get_boundary_indices (level); + deallog << "get_boundary_indices:" << std::endl; + bi.print(deallog); + + IndexSet relevant; + DoFTools::extract_locally_relevant_mg_dofs (dofh, + relevant, level); + deallog << "relevant:" << std::endl; + relevant.print(deallog); + } +} + + +template +void check() +{ + FE_Q q1(1); + FE_Q q2(2); +// FE_DGQ dq1(1); + + FESystem s1(q1, 2, q2,1); + + check_fe(q1); + // check_fe(q2); + //check_fe(s1); +} + +int main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll log; + + check<2> (); + //check<3> (); +} diff --git a/tests/multigrid/constrained_dofs_01.mpirun=1.output b/tests/multigrid/constrained_dofs_01.mpirun=1.output new file mode 100644 index 0000000000..57a5d2ccb0 --- /dev/null +++ b/tests/multigrid/constrained_dofs_01.mpirun=1.output @@ -0,0 +1,30 @@ + +DEAL:0::FE_Q<2>(1) +DEAL:0::Level 0: +DEAL:0::get_refinement_edge_indices: +DEAL:0::{} +DEAL:0::get_boundary_indices: +DEAL:0::{[0,3]} +DEAL:0::relevant: +DEAL:0::{[0,3]} +DEAL:0::Level 1: +DEAL:0::get_refinement_edge_indices: +DEAL:0::{} +DEAL:0::get_boundary_indices: +DEAL:0::{[0,2], [4,8]} +DEAL:0::relevant: +DEAL:0::{[0,8]} +DEAL:0::Level 2: +DEAL:0::get_refinement_edge_indices: +DEAL:0::{} +DEAL:0::get_boundary_indices: +DEAL:0::{[0,2], 4, 6, 9, [11,12], [14,15], [18,20], [22,24]} +DEAL:0::relevant: +DEAL:0::{[0,24]} +DEAL:0::Level 3: +DEAL:0::get_refinement_edge_indices: +DEAL:0::{0, 2, [6,8]} +DEAL:0::get_boundary_indices: +DEAL:0::{[0,1], [4,5], 8} +DEAL:0::relevant: +DEAL:0::{[0,8]} diff --git a/tests/multigrid/constrained_dofs_01.mpirun=3.output b/tests/multigrid/constrained_dofs_01.mpirun=3.output new file mode 100644 index 0000000000..bd7ed88b8a --- /dev/null +++ b/tests/multigrid/constrained_dofs_01.mpirun=3.output @@ -0,0 +1,92 @@ + +DEAL:0::FE_Q<2>(1) +DEAL:0::Level 0: +DEAL:0::get_refinement_edge_indices: +DEAL:0::{} +DEAL:0::get_boundary_indices: +DEAL:0::{[0,3]} +DEAL:0::relevant: +DEAL:0::{[0,3]} +DEAL:0::Level 1: +DEAL:0::get_refinement_edge_indices: +DEAL:0::{} +DEAL:0::get_boundary_indices: +DEAL:0::{[0,2], [4,8]} +DEAL:0::relevant: +DEAL:0::{[0,8]} +DEAL:0::Level 2: +DEAL:0::get_refinement_edge_indices: +DEAL:0::{} +DEAL:0::get_boundary_indices: +DEAL:0::{[0,2], 4, 6, 9, [11,12], [14,15]} +DEAL:0::relevant: +DEAL:0::{[0,17], 21} +DEAL:0::Level 3: +DEAL:0::get_refinement_edge_indices: +DEAL:0::{} +DEAL:0::get_boundary_indices: +DEAL:0::{} +DEAL:0::relevant: +DEAL:0::{} + +DEAL:1::FE_Q<2>(1) +DEAL:1::Level 0: +DEAL:1::get_refinement_edge_indices: +DEAL:1::{} +DEAL:1::get_boundary_indices: +DEAL:1::{} +DEAL:1::relevant: +DEAL:1::{} +DEAL:1::Level 1: +DEAL:1::get_refinement_edge_indices: +DEAL:1::{} +DEAL:1::get_boundary_indices: +DEAL:1::{1, [4,5]} +DEAL:1::relevant: +DEAL:1::{1, [3,5]} +DEAL:1::Level 2: +DEAL:1::get_refinement_edge_indices: +DEAL:1::{} +DEAL:1::get_boundary_indices: +DEAL:1::{1, 4, 9, [11,12], 14, 22} +DEAL:1::relevant: +DEAL:1::{1, [3,5], [7,14], [16,17], [21,22]} +DEAL:1::Level 3: +DEAL:1::get_refinement_edge_indices: +DEAL:1::{0, 2, [6,8]} +DEAL:1::get_boundary_indices: +DEAL:1::{[0,1], [4,5], 8} +DEAL:1::relevant: +DEAL:1::{[0,8]} + + +DEAL:2::FE_Q<2>(1) +DEAL:2::Level 0: +DEAL:2::get_refinement_edge_indices: +DEAL:2::{} +DEAL:2::get_boundary_indices: +DEAL:2::{[0,3]} +DEAL:2::relevant: +DEAL:2::{[0,3]} +DEAL:2::Level 1: +DEAL:2::get_refinement_edge_indices: +DEAL:2::{} +DEAL:2::get_boundary_indices: +DEAL:2::{[0,2], [4,8]} +DEAL:2::relevant: +DEAL:2::{[0,8]} +DEAL:2::Level 2: +DEAL:2::get_refinement_edge_indices: +DEAL:2::{} +DEAL:2::get_boundary_indices: +DEAL:2::{2, 6, 12, [14,15], [18,20], [22,24]} +DEAL:2::relevant: +DEAL:2::{[2,3], [5,8], 10, [12,24]} +DEAL:2::Level 3: +DEAL:2::get_refinement_edge_indices: +DEAL:2::{} +DEAL:2::get_boundary_indices: +DEAL:2::{} +DEAL:2::relevant: +DEAL:2::{} +