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)
{
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:11")
+ if (cell->id().to_string() == "0_2:11")
cell->set_refine_flag();
}
tr.execute_coarsening_and_refinement();
if (!cell->is_locally_owned_on_level())
continue;
- std::vector<types::global_dof_index> &d = mgdofmap[id_to_string(cell->id())];
+ std::vector<types::global_dof_index> &d = mgdofmap[cell->id().to_string()];
d.resize(fe.dofs_per_cell);
cell->get_mg_dof_indices(d);
}
if (cell->level_subdomain_id()==numbers::artificial_subdomain_id)
continue;
- std::vector<types::global_dof_index> &renumbered = mgdofmap[id_to_string(cell->id())];
+ std::vector<types::global_dof_index> &renumbered = mgdofmap[cell->id().to_string()];
cell->set_mg_dof_indices(renumbered);
cell->update_cell_dof_indices_cache();
}
// ---------------------------------------------------------------------
-// check mg transfer in parallel
-
-// This is currently broken, because we are not correctly communicating
-// MGTransfer::copy_indices
+// check mg transfer in parallel, especially communication of copy_indices
#include "../tests.h"
#include <deal.II/base/logstream.h>
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)
{
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")
+ if (cell->id().to_string() == "0_2:03"
+ || cell->id().to_string() == "0_2:00"
+ || cell->id().to_string() == "0_2:01"
+ || cell->id().to_string() == "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")
+ if (cell->id().to_string() == "0_3:032"
+ || cell->id().to_string() == "0_3:000")
cell->set_refine_flag();
}
tr.execute_coarsening_and_refinement();
--- /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=0
+DEAL:0::cell=0_1:2 level_subdomain_id=0
+DEAL:0::cell=0_1:3 level_subdomain_id=0
+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=0
+DEAL:0::cell=0_2:11 level_subdomain_id=0
+DEAL:0::cell=0_2:12 level_subdomain_id=0
+DEAL:0::cell=0_2:13 level_subdomain_id=0
+DEAL:0::cell=0_2:20 level_subdomain_id=0
+DEAL:0::cell=0_2:21 level_subdomain_id=0
+DEAL:0::cell=0_2:22 level_subdomain_id=0
+DEAL:0::cell=0_2:23 level_subdomain_id=0
+DEAL:0::cell=0_2:30 level_subdomain_id=0
+DEAL:0::cell=0_2:31 level_subdomain_id=0
+DEAL:0::cell=0_2:32 level_subdomain_id=0
+DEAL:0::cell=0_2:33 level_subdomain_id=0
+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=0
+DEAL:0::cell=0_3:120 level_subdomain_id=0
+DEAL:0::cell=0_3:121 level_subdomain_id=0
+DEAL:0::cell=0_3:122 level_subdomain_id=0
+DEAL:0::cell=0_3:123 level_subdomain_id=0
+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=0
+DEAL:0::cell=0_3:201 level_subdomain_id=0
+DEAL:0::cell=0_3:202 level_subdomain_id=0
+DEAL:0::cell=0_3:203 level_subdomain_id=0
+DEAL:0::cell=0_3:210 level_subdomain_id=0
+DEAL:0::cell=0_3:211 level_subdomain_id=0
+DEAL:0::cell=0_3:212 level_subdomain_id=0
+DEAL:0::cell=0_3:213 level_subdomain_id=0
+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
+DEAL:0::ok
--- /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
+
+#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;
+
+template <int dim>
+void setup_tria(parallel::distributed::Triangulation<dim> &tr)
+{
+ GridGenerator::hyper_cube(tr);
+ tr.refine_global(1);
+
+ for (typename parallel::distributed::Triangulation<dim>::active_cell_iterator cell = tr.begin_active();
+ cell != tr.end(); ++cell)
+ {
+ if (cell->id().to_string() != "0_1:3")
+ 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 (cell->id().to_string() == "0_2:00"
+ || cell->id().to_string() == "0_2:01"
+ || cell->id().to_string() == "0_2:02")
+ 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);
+
+ }
+
+
+ ZeroFunction<dim> zero;
+ typename FunctionMap<dim>::type fmap;
+ fmap.insert(std::make_pair(0, &zero));
+
+ DoFHandler<dim> dofh(tr);
+ dofh.distribute_dofs(fe);
+ dofh.distribute_mg_dofs(fe);
+ typedef TrilinosWrappers::MPI::Vector vector_t;
+ {
+
+
+
+ }
+ MGTransferPrebuilt<vector_t> transfer;
+ 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;//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);
+ deallog << v[index] << " ";
+ }
+ }
+ //v.print(deallog.get_file_stream());
+ 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=0
+DEAL:0::cell=0_1:2 level_subdomain_id=0
+DEAL:0::cell=0_1:3 level_subdomain_id=0
+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=0
+DEAL:0::cell=0_2:11 level_subdomain_id=0
+DEAL:0::cell=0_2:12 level_subdomain_id=0
+DEAL:0::cell=0_2:13 level_subdomain_id=0
+DEAL:0::cell=0_2:20 level_subdomain_id=0
+DEAL:0::cell=0_2:21 level_subdomain_id=0
+DEAL:0::cell=0_2:22 level_subdomain_id=0
+DEAL:0::cell=0_2:23 level_subdomain_id=0
+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: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
+copy_indices[1] 0 3
+copy_indices[1] 1 5
+copy_indices[1] 2 7
+copy_indices[1] 3 8
+copy_indices[2] 0 8
+copy_indices[2] 1 14
+copy_indices[2] 2 20
+copy_indices[2] 4 3
+copy_indices[2] 5 5
+copy_indices[2] 6 7
+copy_indices[2] 7 4
+copy_indices[2] 8 9
+copy_indices[2] 9 10
+copy_indices[2] 10 11
+copy_indices[2] 11 12
+copy_indices[2] 12 13
+copy_indices[2] 13 6
+copy_indices[2] 14 15
+copy_indices[2] 15 16
+copy_indices[2] 16 17
+copy_indices[2] 17 18
+copy_indices[2] 18 19
+copy_indices[3] 4 8
+copy_indices[3] 5 14
+copy_indices[3] 6 20
+copy_indices[3] 7 11
+copy_indices[3] 13 18
+copy_indices[3] 19 0
+copy_indices[3] 20 1
+copy_indices[3] 21 2
+copy_indices[3] 22 3
+copy_indices[3] 23 4
+copy_indices[3] 24 5
+copy_indices[3] 25 6
+copy_indices[3] 26 7
+copy_indices[3] 27 9
+copy_indices[3] 28 10
+copy_indices[3] 29 12
+copy_indices[3] 30 13
+copy_indices[3] 31 15
+copy_indices[3] 32 16
+copy_indices[3] 33 17
+copy_indices[3] 34 19
+DEAL:0::1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 ok
--- /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=1
+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_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: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
+copy_indices[2] 8 3
+copy_indices[2] 11 4
+copy_indices[2] 14 5
+copy_indices[2] 18 6
+copy_indices[2] 20 7
+copy_indices[3] 0 0
+copy_indices[3] 1 1
+copy_indices[3] 2 2
+copy_indices[3] 3 3
+copy_indices[3] 4 4
+copy_indices[3] 5 5
+copy_indices[3] 6 6
+copy_indices[3] 7 7
+copy_indices[3] 8 8
+copy_indices[3] 9 9
+copy_indices[3] 10 10
+copy_indices[3] 11 11
+copy_indices[3] 12 12
+copy_indices[3] 13 13
+copy_indices[3] 14 14
+copy_indices[3] 15 15
+copy_indices[3] 16 16
+copy_indices[3] 17 17
+copy_indices[3] 18 18
+copy_indices[3] 19 19
+copy_indices[3] 20 20
+copy_ifrom [1] 21 3
+DEAL:0::1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 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=0
+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=1
+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_3:000 level_subdomain_id=4294967294
+DEAL:1::cell=0_3:001 level_subdomain_id=4294967294
+DEAL:1::cell=0_3:002 level_subdomain_id=4294967294
+DEAL:1::cell=0_3:003 level_subdomain_id=4294967294
+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=4294967294
+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=4294967294
+DEAL:1::cell=0_3:023 level_subdomain_id=4294967294
+copy_indices[1] 22 5
+copy_indices[1] 23 7
+copy_indices[1] 24 8
+copy_indices[2] 21 8
+copy_indices[2] 22 14
+copy_indices[2] 23 20
+copy_indices[2] 25 9
+copy_indices[2] 26 10
+copy_indices[2] 27 11
+copy_indices[2] 28 12
+copy_indices[2] 29 13
+copy_indices[2] 30 15
+copy_indices[2] 31 16
+copy_indices[2] 32 17
+copy_indices[2] 33 18
+copy_indices[2] 34 19
+copy_ito [1] 21 3
+DEAL:1::1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 ok
+