--- /dev/null
+// ---------------------------------------------------------------------
+//
+// 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 transfer in parallel
+
+// This is currently broken, because we are not correctly communicating
+// MGTransfer::copy_indices
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/function.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/block_vector.h>
+#include <deal.II/distributed/tria.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/dofs/function_map.h>
+#include <deal.II/fe/fe_dgq.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_raviart_thomas.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/multigrid/mg_tools.h>
+#include <deal.II/multigrid/mg_transfer.h>
+#include <deal.II/multigrid/mg_constrained_dofs.h>
+#include <deal.II/numerics/data_out.h>
+#include <deal.II/lac/trilinos_vector.h>
+
+#include <fstream>
+#include <iomanip>
+#include <iomanip>
+#include <algorithm>
+
+using namespace std;
+
+ std::string id_to_string(const CellId &id)
+ {
+ std::ostringstream ss;
+ ss << id;
+ return ss.str();
+ }
+
+template <int dim>
+void setup_tria(parallel::distributed::Triangulation<dim> &tr)
+{
+ GridGenerator::hyper_cube(tr);
+ tr.refine_global(2);
+
+ for (typename parallel::distributed::Triangulation<dim>::active_cell_iterator cell = tr.begin_active();
+ cell != tr.end(); ++cell)
+ {
+ if (id_to_string(cell->id()) == "0_2:03"
+ || id_to_string(cell->id()) == "0_2:00"
+ || id_to_string(cell->id()) == "0_2:01"
+ || id_to_string(cell->id()) == "0_2:12")
+ cell->set_refine_flag();
+ }
+ tr.execute_coarsening_and_refinement();
+ for (typename parallel::distributed::Triangulation<dim>::active_cell_iterator cell = tr.begin_active();
+ cell != tr.end(); ++cell)
+ {
+ if (id_to_string(cell->id()) == "0_3:032"
+ || id_to_string(cell->id()) == "0_3:000")
+ cell->set_refine_flag();
+ }
+ tr.execute_coarsening_and_refinement();
+
+
+ for (typename parallel::distributed::Triangulation<dim>::cell_iterator cell = tr.begin();
+ cell != tr.end(); ++cell)
+ {
+ deallog << "cell=" << cell->id()
+ << " level_subdomain_id=" << cell->level_subdomain_id()
+ << std::endl;
+ }
+}
+
+
+
+
+
+
+
+
+
+template <int dim>
+void check_fe(FiniteElement<dim> &fe)
+{
+ deallog << fe.get_name() << std::endl;
+
+ parallel::distributed::Triangulation<dim> tr(MPI_COMM_WORLD,
+ Triangulation<dim>::none,
+ parallel::distributed::Triangulation<dim>::construct_multigrid_hierarchy);
+ setup_tria(tr);
+
+ if (false)
+ {
+ DataOut<dim> data_out;
+ Vector<float> subdomain (tr.n_active_cells());
+ for (unsigned int i=0; i<subdomain.size(); ++i)
+ subdomain(i) = tr.locally_owned_subdomain();
+ data_out.attach_triangulation (tr);
+ data_out.add_data_vector (subdomain, "subdomain");
+ data_out.build_patches (0);
+ const std::string filename = ("solution." +
+ Utilities::int_to_string
+ (tr.locally_owned_subdomain(), 4) +
+ ".vtu");
+ std::ofstream output (filename.c_str());
+ data_out.write_vtu (output);
+ }
+
+ DoFHandler<dim> dofh(tr);
+ dofh.distribute_dofs(fe);
+ dofh.distribute_mg_dofs(fe);
+ typedef TrilinosWrappers::MPI::Vector vector_t;
+
+ MGConstrainedDoFs mg_constrained_dofs;
+ mg_constrained_dofs.initialize(dofh);
+
+ ConstraintMatrix hanging_node_constraints;
+ IndexSet locally_relevant_set;
+ DoFTools::extract_locally_relevant_dofs (dofh,
+ locally_relevant_set);
+ hanging_node_constraints.reinit (locally_relevant_set);
+ DoFTools::make_hanging_node_constraints (dofh, hanging_node_constraints);
+ hanging_node_constraints.close();
+
+ MGTransferPrebuilt<vector_t> transfer(hanging_node_constraints, mg_constrained_dofs);
+ transfer.build_matrices(dofh);
+ transfer.print_indices(deallog.get_file_stream());
+
+ MGLevelObject<vector_t> u(0, tr.n_global_levels()-1);
+ for (unsigned int level=u.min_level(); level<=u.max_level(); ++level)
+ {
+ u[level].reinit(dofh.locally_owned_mg_dofs(level), MPI_COMM_WORLD);
+ for (unsigned int i=0;i<dofh.locally_owned_mg_dofs(level).n_elements();++i)
+ {
+ unsigned int index = dofh.locally_owned_mg_dofs(level).nth_index_in_set(i);
+ u[level][index] = 1.0;//1000+level*100+index;
+ }
+ u[level].compress(VectorOperation::insert);
+ }
+
+ vector_t v;
+ v.reinit(dofh.locally_owned_dofs(), MPI_COMM_WORLD);
+ v = 0.;
+ transfer.copy_from_mg(dofh, v, u);
+
+ {
+ for (unsigned int i=0;i<dofh.locally_owned_dofs().n_elements();++i)
+ {
+ unsigned int index = dofh.locally_owned_dofs().nth_index_in_set(i);
+ if (abs(v[index] - 1.0)>1e-5)
+ deallog << "ERROR: index=" << index << " is equal to " << v[index] << std::endl;
+ }
+ }
+ deallog << "ok" << std::endl;
+}
+
+
+template <int dim>
+void check()
+{
+ FE_Q<dim> q1(1);
+ FE_Q<dim> q2(2);
+// FE_DGQ<dim> dq1(1);
+
+ FESystem<dim> 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> ();
+}
--- /dev/null
+
+DEAL:0::FE_Q<2>(1)
+DEAL:0::cell=0_0: level_subdomain_id=0
+DEAL:0::cell=0_1:0 level_subdomain_id=0
+DEAL:0::cell=0_1:1 level_subdomain_id=1
+DEAL:0::cell=0_1:2 level_subdomain_id=1
+DEAL:0::cell=0_1:3 level_subdomain_id=1
+DEAL:0::cell=0_2:00 level_subdomain_id=0
+DEAL:0::cell=0_2:01 level_subdomain_id=0
+DEAL:0::cell=0_2:02 level_subdomain_id=0
+DEAL:0::cell=0_2:03 level_subdomain_id=0
+DEAL:0::cell=0_2:10 level_subdomain_id=1
+DEAL:0::cell=0_2:11 level_subdomain_id=4294967294
+DEAL:0::cell=0_2:12 level_subdomain_id=1
+DEAL:0::cell=0_2:13 level_subdomain_id=4294967294
+DEAL:0::cell=0_2:20 level_subdomain_id=1
+DEAL:0::cell=0_2:21 level_subdomain_id=1
+DEAL:0::cell=0_2:22 level_subdomain_id=4294967294
+DEAL:0::cell=0_2:23 level_subdomain_id=4294967294
+DEAL:0::cell=0_2:30 level_subdomain_id=1
+DEAL:0::cell=0_2:31 level_subdomain_id=4294967294
+DEAL:0::cell=0_2:32 level_subdomain_id=4294967294
+DEAL:0::cell=0_2:33 level_subdomain_id=4294967294
+DEAL:0::cell=0_3:000 level_subdomain_id=0
+DEAL:0::cell=0_3:001 level_subdomain_id=0
+DEAL:0::cell=0_3:002 level_subdomain_id=0
+DEAL:0::cell=0_3:003 level_subdomain_id=0
+DEAL:0::cell=0_3:010 level_subdomain_id=0
+DEAL:0::cell=0_3:011 level_subdomain_id=0
+DEAL:0::cell=0_3:012 level_subdomain_id=0
+DEAL:0::cell=0_3:013 level_subdomain_id=0
+DEAL:0::cell=0_3:030 level_subdomain_id=0
+DEAL:0::cell=0_3:031 level_subdomain_id=0
+DEAL:0::cell=0_3:032 level_subdomain_id=0
+DEAL:0::cell=0_3:033 level_subdomain_id=1
+DEAL:0::cell=0_3:120 level_subdomain_id=1
+DEAL:0::cell=0_3:121 level_subdomain_id=4294967294
+DEAL:0::cell=0_3:122 level_subdomain_id=1
+DEAL:0::cell=0_3:123 level_subdomain_id=4294967294
+DEAL:0::cell=0_3:020 level_subdomain_id=0
+DEAL:0::cell=0_3:021 level_subdomain_id=0
+DEAL:0::cell=0_3:022 level_subdomain_id=0
+DEAL:0::cell=0_3:023 level_subdomain_id=0
+DEAL:0::cell=0_3:200 level_subdomain_id=1
+DEAL:0::cell=0_3:201 level_subdomain_id=1
+DEAL:0::cell=0_3:202 level_subdomain_id=4294967294
+DEAL:0::cell=0_3:203 level_subdomain_id=4294967294
+DEAL:0::cell=0_3:210 level_subdomain_id=1
+DEAL:0::cell=0_3:211 level_subdomain_id=1
+DEAL:0::cell=0_3:212 level_subdomain_id=4294967294
+DEAL:0::cell=0_3:213 level_subdomain_id=4294967294
+DEAL:0::cell=0_4:0000 level_subdomain_id=0
+DEAL:0::cell=0_4:0001 level_subdomain_id=0
+DEAL:0::cell=0_4:0002 level_subdomain_id=0
+DEAL:0::cell=0_4:0003 level_subdomain_id=0
+DEAL:0::cell=0_4:0320 level_subdomain_id=0
+DEAL:0::cell=0_4:0321 level_subdomain_id=0
+DEAL:0::cell=0_4:0322 level_subdomain_id=0
+DEAL:0::cell=0_4:0323 level_subdomain_id=0
+copy_indices[2] 10 4
+copy_indices[2] 13 5
+copy_indices[3] 0 1
+copy_indices[3] 1 4
+copy_indices[3] 2 3
+copy_indices[3] 3 5
+copy_indices[3] 4 2
+copy_indices[3] 5 6
+copy_indices[3] 6 7
+copy_indices[3] 7 8
+copy_indices[3] 8 9
+copy_indices[3] 9 10
+copy_indices[3] 12 13
+copy_indices[3] 14 15
+copy_indices[3] 15 16
+copy_indices[3] 16 17
+copy_indices[3] 17 20
+copy_indices[3] 18 21
+copy_indices[3] 19 22
+copy_indices[3] 20 23
+copy_indices[3] 21 18
+copy_indices[3] 33 19
+copy_indices[4] 22 0
+copy_indices[4] 23 1
+copy_indices[4] 24 2
+copy_indices[4] 25 3
+copy_indices[4] 30 12
+DEAL:0::ok
+
+DEAL:1::FE_Q<2>(1)
+DEAL:1::cell=0_0: level_subdomain_id=0
+DEAL:1::cell=0_1:0 level_subdomain_id=0
+DEAL:1::cell=0_1:1 level_subdomain_id=1
+DEAL:1::cell=0_1:2 level_subdomain_id=1
+DEAL:1::cell=0_1:3 level_subdomain_id=1
+DEAL:1::cell=0_2:00 level_subdomain_id=4294967294
+DEAL:1::cell=0_2:01 level_subdomain_id=0
+DEAL:1::cell=0_2:02 level_subdomain_id=0
+DEAL:1::cell=0_2:03 level_subdomain_id=0
+DEAL:1::cell=0_2:10 level_subdomain_id=1
+DEAL:1::cell=0_2:11 level_subdomain_id=1
+DEAL:1::cell=0_2:12 level_subdomain_id=1
+DEAL:1::cell=0_2:13 level_subdomain_id=1
+DEAL:1::cell=0_2:20 level_subdomain_id=1
+DEAL:1::cell=0_2:21 level_subdomain_id=1
+DEAL:1::cell=0_2:22 level_subdomain_id=1
+DEAL:1::cell=0_2:23 level_subdomain_id=1
+DEAL:1::cell=0_2:30 level_subdomain_id=1
+DEAL:1::cell=0_2:31 level_subdomain_id=1
+DEAL:1::cell=0_2:32 level_subdomain_id=1
+DEAL:1::cell=0_2:33 level_subdomain_id=1
+DEAL:1::cell=0_3:010 level_subdomain_id=4294967294
+DEAL:1::cell=0_3:011 level_subdomain_id=4294967294
+DEAL:1::cell=0_3:012 level_subdomain_id=4294967294
+DEAL:1::cell=0_3:013 level_subdomain_id=0
+DEAL:1::cell=0_3:030 level_subdomain_id=0
+DEAL:1::cell=0_3:031 level_subdomain_id=0
+DEAL:1::cell=0_3:032 level_subdomain_id=0
+DEAL:1::cell=0_3:033 level_subdomain_id=1
+DEAL:1::cell=0_3:120 level_subdomain_id=1
+DEAL:1::cell=0_3:121 level_subdomain_id=1
+DEAL:1::cell=0_3:122 level_subdomain_id=1
+DEAL:1::cell=0_3:123 level_subdomain_id=1
+DEAL:1::cell=0_3:020 level_subdomain_id=4294967294
+DEAL:1::cell=0_3:021 level_subdomain_id=4294967294
+DEAL:1::cell=0_3:022 level_subdomain_id=0
+DEAL:1::cell=0_3:023 level_subdomain_id=0
+DEAL:1::cell=0_3:200 level_subdomain_id=1
+DEAL:1::cell=0_3:201 level_subdomain_id=1
+DEAL:1::cell=0_3:202 level_subdomain_id=1
+DEAL:1::cell=0_3:203 level_subdomain_id=1
+DEAL:1::cell=0_3:210 level_subdomain_id=1
+DEAL:1::cell=0_3:211 level_subdomain_id=1
+DEAL:1::cell=0_3:212 level_subdomain_id=1
+DEAL:1::cell=0_3:213 level_subdomain_id=1
+DEAL:1::cell=0_4:0320 level_subdomain_id=4294967294
+DEAL:1::cell=0_4:0321 level_subdomain_id=4294967294
+DEAL:1::cell=0_4:0322 level_subdomain_id=4294967294
+DEAL:1::cell=0_4:0323 level_subdomain_id=4294967294
+copy_indices[2] 34 9
+copy_indices[2] 35 10
+copy_indices[2] 36 11
+copy_indices[2] 37 12
+copy_indices[2] 38 13
+copy_indices[2] 39 14
+copy_indices[2] 40 15
+copy_indices[2] 41 16
+copy_indices[2] 42 18
+copy_indices[2] 43 19
+copy_indices[2] 44 17
+copy_indices[2] 45 20
+copy_indices[2] 47 21
+copy_indices[2] 48 22
+copy_indices[2] 49 23
+copy_indices[2] 50 24
+copy_indices[3] 52 26
+copy_indices[3] 55 31
+copy_indices[3] 56 32
+copy_indices[3] 57 33
+copy_indices[3] 59 37
+copy_ito [2] 46 8
+DEAL:1::ok
+