1 /* ---------------------------------------------------------------------
2 *
3 * Copyright (C) 2013 - 2018 by the deal.II authors
4 *
5 * This file is part of the deal.II library.
6 *
7 * The deal.II library is free software; you can use it, redistribute
8 * it, and/or modify it under the terms of the GNU Lesser General
9 * Public License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 * The full text of the license can be found in the file LICENSE.md at
12 * the top level directory of deal.II.
13 *
14 * ---------------------------------------------------------------------
15 */
16
17 #include <deal.II/distributed/shared_tria.h>
18
19 #include <deal.II/dofs/dof_accessor.h>
20 #include <deal.II/dofs/dof_handler.h>
21 #include <deal.II/dofs/dof_tools.h>
22
23 #include <deal.II/fe/fe_q.h>
24
25 #include <deal.II/grid/grid_generator.h>
26 #include <deal.II/grid/tria.h>
27 #include <deal.II/grid/tria_accessor.h>
28 #include <deal.II/grid/tria_iterator.h>
29
30 #include <iostream>
31
32 using namespace dealii;
33
34 static const unsigned int dim = 2;
35
36 int
main(int argc,char ** argv)37 main(int argc, char **argv)
38 {
39 try
40 {
41 Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
42 {
43 parallel::shared::Triangulation<dim> triangulation(
44 MPI_COMM_WORLD,
45 ::Triangulation<dim>::none,
46 false,
47 parallel::shared::Triangulation<dim>::partition_metis);
48 FE_Q<dim> fe(1);
49 DoFHandler<dim> dof_handler(triangulation);
50
51 GridGenerator::hyper_cube(triangulation, -1, 1);
52 triangulation.refine_global(2);
53 dof_handler.distribute_dofs(fe);
54 IndexSet locally_owned_dofs = dof_handler.locally_owned_dofs();
55 deallog << locally_owned_dofs.n_elements() << std::endl;
56 dof_handler.clear();
57 deallog << "OK" << std::endl;
58 }
59 }
60
61 catch (std::exception &exc)
62 {
63 std::cerr << std::endl
64 << std::endl
65 << "----------------------------------------------------"
66 << std::endl;
67 std::cerr << "Exception on processing: " << std::endl
68 << exc.what() << std::endl
69 << "Aborting!" << std::endl
70 << "----------------------------------------------------"
71 << std::endl;
72
73 return 1;
74 }
75 catch (...)
76 {
77 std::cerr << std::endl
78 << std::endl
79 << "----------------------------------------------------"
80 << std::endl;
81 std::cerr << "Unknown exception!" << std::endl
82 << "Aborting!" << std::endl
83 << "----------------------------------------------------"
84 << std::endl;
85 return 1;
86 }
87
88 return 0;
89 }
90