From 91e8796250762b193c49f1623053c735f7bcfcf0 Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Sat, 17 Aug 2019 14:48:25 +0200 Subject: [PATCH] Add p:f:t --- doc/news/changes/major/20190726PeterMunch | 5 + doc/news/changes/minor/20190902PeterMunch | 5 + .../distributed/fully_distributed_tria.h | 394 +++++++++++ .../distributed/fully_distributed_tria_util.h | 74 ++ source/distributed/CMakeLists.txt | 4 + source/distributed/fully_distributed_tria.cc | 531 ++++++++++++++ .../fully_distributed_tria.inst.in | 33 + .../fully_distributed_tria_util.cc | 525 ++++++++++++++ .../fully_distributed_tria_util.inst.in | 36 + source/grid/grid_tools_dof_handlers.cc | 63 +- source/grid/tria.cc | 13 - tests/fullydistributed_grids/CMakeLists.txt | 4 + .../copy_distributed_tria_01.cc | 89 +++ ...ed_tria_01.with_p4est=true.mpirun=1.output | 15 + ...ed_tria_01.with_p4est=true.mpirun=7.output | 111 +++ .../copy_distributed_tria_02.cc | 93 +++ ...ed_tria_02.with_p4est=true.mpirun=1.output | 47 ++ ...ed_tria_02.with_p4est=true.mpirun=7.output | 335 +++++++++ .../copy_serial_tria_01.cc | 88 +++ .../copy_serial_tria_01.mpirun=1.output | 15 + .../copy_serial_tria_01.mpirun=7.output | 111 +++ .../copy_serial_tria_02.cc | 103 +++ .../copy_serial_tria_02.mpirun=1.output | 94 +++ .../copy_serial_tria_02.mpirun=7.output | 664 ++++++++++++++++++ .../copy_serial_tria_03.cc | 115 +++ .../copy_serial_tria_03.mpirun=1.output | 28 + .../copy_serial_tria_03.mpirun=7.output | 202 ++++++ .../copy_serial_tria_04.cc | 129 ++++ .../copy_serial_tria_04.mpirun=1.output | 22 + .../copy_serial_tria_04.mpirun=7.output | 160 +++++ .../copy_serial_tria_05.cc | 102 +++ .../copy_serial_tria_05.mpirun=9.output | 206 ++++++ tests/fullydistributed_grids/tests.h | 75 ++ 33 files changed, 4471 insertions(+), 20 deletions(-) create mode 100644 doc/news/changes/major/20190726PeterMunch create mode 100644 doc/news/changes/minor/20190902PeterMunch create mode 100644 include/deal.II/distributed/fully_distributed_tria.h create mode 100644 include/deal.II/distributed/fully_distributed_tria_util.h create mode 100644 source/distributed/fully_distributed_tria.cc create mode 100644 source/distributed/fully_distributed_tria.inst.in create mode 100644 source/distributed/fully_distributed_tria_util.cc create mode 100644 source/distributed/fully_distributed_tria_util.inst.in create mode 100644 tests/fullydistributed_grids/CMakeLists.txt create mode 100644 tests/fullydistributed_grids/copy_distributed_tria_01.cc create mode 100644 tests/fullydistributed_grids/copy_distributed_tria_01.with_p4est=true.mpirun=1.output create mode 100644 tests/fullydistributed_grids/copy_distributed_tria_01.with_p4est=true.mpirun=7.output create mode 100644 tests/fullydistributed_grids/copy_distributed_tria_02.cc create mode 100644 tests/fullydistributed_grids/copy_distributed_tria_02.with_p4est=true.mpirun=1.output create mode 100644 tests/fullydistributed_grids/copy_distributed_tria_02.with_p4est=true.mpirun=7.output create mode 100644 tests/fullydistributed_grids/copy_serial_tria_01.cc create mode 100644 tests/fullydistributed_grids/copy_serial_tria_01.mpirun=1.output create mode 100644 tests/fullydistributed_grids/copy_serial_tria_01.mpirun=7.output create mode 100644 tests/fullydistributed_grids/copy_serial_tria_02.cc create mode 100644 tests/fullydistributed_grids/copy_serial_tria_02.mpirun=1.output create mode 100644 tests/fullydistributed_grids/copy_serial_tria_02.mpirun=7.output create mode 100644 tests/fullydistributed_grids/copy_serial_tria_03.cc create mode 100644 tests/fullydistributed_grids/copy_serial_tria_03.mpirun=1.output create mode 100644 tests/fullydistributed_grids/copy_serial_tria_03.mpirun=7.output create mode 100644 tests/fullydistributed_grids/copy_serial_tria_04.cc create mode 100644 tests/fullydistributed_grids/copy_serial_tria_04.mpirun=1.output create mode 100644 tests/fullydistributed_grids/copy_serial_tria_04.mpirun=7.output create mode 100644 tests/fullydistributed_grids/copy_serial_tria_05.cc create mode 100644 tests/fullydistributed_grids/copy_serial_tria_05.mpirun=9.output create mode 100644 tests/fullydistributed_grids/tests.h diff --git a/doc/news/changes/major/20190726PeterMunch b/doc/news/changes/major/20190726PeterMunch new file mode 100644 index 0000000000..9a7f1cea5f --- /dev/null +++ b/doc/news/changes/major/20190726PeterMunch @@ -0,0 +1,5 @@ +New: Introduce a new distributed triangulation class parallel::fullydistributed::Triangulation. +It partitions the coarse-grid as well as works for hanging nodes, geometric multigrid, and +arbitrary dimensions. +
+(Peter Munch, 2019/07/26) diff --git a/doc/news/changes/minor/20190902PeterMunch b/doc/news/changes/minor/20190902PeterMunch new file mode 100644 index 0000000000..6a222575c2 --- /dev/null +++ b/doc/news/changes/minor/20190902PeterMunch @@ -0,0 +1,5 @@ +New: Add a function, which creates a parallel::fullydistributed::ConstructionData from a +serial and a distributed triangulation. This data structure can be used to initialize +parallel::fullydistributed::Triangulation. +
+(Peter Munch, 2019/09/02) diff --git a/include/deal.II/distributed/fully_distributed_tria.h b/include/deal.II/distributed/fully_distributed_tria.h new file mode 100644 index 0000000000..eef0b55d2d --- /dev/null +++ b/include/deal.II/distributed/fully_distributed_tria.h @@ -0,0 +1,394 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + +#ifndef dealii_fully_distributed_tria_h +#define dealii_fully_distributed_tria_h + + +#include + +#include + +#include + +#ifdef DEAL_II_WITH_MPI +# include +#endif + +DEAL_II_NAMESPACE_OPEN + +// Forward declarations +#ifndef DOXYGEN +// forward declaration of the data type for periodic face pairs +namespace GridTools +{ + template + struct PeriodicFacePair; +} +#endif + +namespace parallel +{ + /** + * A namespace for the fully distributed triangulation. + * + * @ingroup parallel + */ + namespace fullydistributed + { + /** + * Configuration flags for fully distributed Triangulations. + * Settings can be combined using bitwise OR. + * + * @author Peter Munch, 2019 + */ + enum Settings + { + /** + * Default settings, other options are disabled. + */ + default_setting = 0x0, + /** + * This flags needs to be set to use the geometric multigrid + * functionality. This option requires additional computation and + * communication. + */ + construct_multigrid_hierarchy = 0x1 + }; + + /** + * Information needed for each locally relevant cell, stored in + * ConstructionData and used during construction of a + * parallel::fullydistributed::Triangulation. This struct stores + * the cell id, the subdomain_id and the level_subdomain_id as well as + * information related to manifold_id and boundary_id. + * + * @author Peter Munch, 2019 + */ + template + struct CellData + { + /** + * Constructor. + */ + CellData() = default; + + /** + * Unique CellID of the cell. + */ + CellId::binary_type id; + + /** + * subdomain_id of the cell. + */ + types::subdomain_id subdomain_id; + + /** + * level_subdomain_id of the cell. + */ + types::subdomain_id level_subdomain_id; + + /** + * Manifold id of the cell. + */ + types::material_id manifold_id; + + /** + * Manifold id of all lines of the cell. + * + * @note Only used for 2D and 3D. + */ + std::array::lines_per_cell> + manifold_line_ids; + + /** + * Manifold id of all face quads of the cell. + * + * @note Only used for 3D. + */ + std::array::quads_per_cell> + manifold_quad_ids; + + /** + * List of face number and boundary id of all non-internal faces of the + * cell. + */ + std::vector> boundary_ids; + }; + + + + /** + * Data used to construct a fully distributed triangulation in + * parallel::fullydistributed::Triangulation::create_triangulation(). + * + * @author Peter Munch, 2019 + */ + template + struct ConstructionData + { + /** + * Cells of the locally-relevant coarse-grid triangulation. + */ + std::vector> coarse_cells; + + /** + * Vertices of the locally-relevant coarse-grid triangulation. + */ + std::vector> coarse_cell_vertices; + + /** + * List that for each locally-relevant coarse cell provides the + * corresponding global @ref GlossCoarseCellId. + */ + std::vector coarse_cell_index_to_coarse_cell_id; + + /** + * CellData for each locally relevant cell on each level. cell_infos[i] + * contains the CellData for each locally relevant cell on the ith + * level. + */ + std::vector>> cell_infos; + + /** + * The MPI communicator used to create this struct. It will be compared + * to the communicator inside of parallel::fullydistributed::Triangulation + * and an assert is thrown if they do not match. + * + * @note Please note this is necessary since the communicator inside of + * parallel::TriangulationBase is const and cannot be changed after the + * constructor has been called. + * + */ + MPI_Comm comm; + + /** + * @note settings See the description of the Settings enumerator. + */ + Settings settings; + }; + + + /** + * A distributed triangulation with a distributed coarse grid. + * + * The motivation for parallel::fullydistributed::Triangulation has its + * origins in the following observations about complex geometries and/or + * about given meshes created by an external mesh generator. We regard + * complex geometries as geometries that can be meshed only with a + * non-negligible number of coarse cells (>10,000): + * - storing the coarse-grid information on every process is too expensive + * from a memory point of view (as done by + * parallel::distributed::Triangulation). Normally, a process only needs a + * small section of the global triangulation, i.e., a small section of the + * coarse grid such that a partitioning of the coarse grid is indeed + * essential. The cells stored on each process consist of the + * @ref GlossLocallyOwnedCell "locally owned cells" and the + * @ref GlossGhostCell "ghost cells". + * - the distribution of the active cells - on the finest level - among all + * processes by simply partitioning a space-filling curve might not lead + * to an optimal result for triangulations that originate from large + * coarse grids: e.g. partitions that belong to the same process might + * be discontinuous, leading to increased communication (within a + * node and beyond). Graph-based partitioning algorithms might be a sound + * alternative to the space filling curve used by + * parallel::distributed::Triangulation. + * + * To be able to construct a fully partitioned triangulation that + * distributes the coarse grid and gives flexibility regarding partitioning, + * the following ingredients are required: + * - a locally relevant coarse-grid triangulation + * (vertices, cell definition; including a layer of ghost cells) + * - a mapping of the locally relevant coarse-grid triangulation into the + * global coarse-grid triangulation + * - information about which cell should be refined as well as information + * regarding the subdomain_id, the level_subdomain_id, manifold_id, + * and boundary_id of each cell. + * + * The ingredients listed above are bundled in the struct + * parallel::fullydistributed::ConstructionData. The user has to fill this + * data structure - in a pre-processing step - before actually creating the + * triangulation. Predefined functions to create ConstructionData + * can be found in the namespace dealii::fullydistributed::Utilities. + * + * Once the ConstructionData `construction_data` has been constructed, the + * triangulation `tria` can be created by calling + * `tria.create_triangulation(construction_data);`. + * + * @note This triangulation supports: 1D/2D/3D, hanging nodes, + * geometric multigrid, and periodicity. + * + * @note You can create a triangulation with hanging nodes and multigrid + * levels with create_triangulation(). However, once it has been + * created, it cannot be altered anymore, i.e. you cannot coarsen or + * refine afterwards. + * + * @note Currently only simple periodicity conditions (i.e. without offsets + * and rotation matrices - see also the documentation of + * GridTools::collect_periodic_faces()) are supported. + * + * @author Peter Munch, 2019 + */ + template + class Triangulation + : public parallel::DistributedTriangulationBase + { + public: + using cell_iterator = + typename dealii::Triangulation::cell_iterator; + + using active_cell_iterator = + typename dealii::Triangulation::active_cell_iterator; + + using CellStatus = + typename dealii::Triangulation::CellStatus; + + /** + * Constructor. + * + * @param mpi_communicator The MPI communicator to be used for the + * triangulation. + */ + explicit Triangulation(MPI_Comm mpi_communicator); + + /** + * Destructor. + */ + virtual ~Triangulation() = default; + + /** + * Create a triangulation from the provided ConstructionData. + * + * @note The namespace dealii::fullydistributed::Util contains functions + * to create ConstructionData. + * + * @note This is the function to be used instead of + * Triangulation::create_triangulation() for some of the other + * triangulations of deal.II. + * + * @param construction_data The data needed for this process. + */ + void + create_triangulation( + const ConstructionData &construction_data); + + /** + * @note This function is not implemented for this class and throws + * an assertion. Instead, use + * the other create_triangulation() function to create the + * triangulation. + */ + virtual void + create_triangulation(const std::vector> & vertices, + const std::vector> &cells, + const SubCellData &subcelldata) override; + + /** + * Coarsen and refine the mesh according to refinement and coarsening + * flags set. + * + * @note Not implemented yet. + */ + virtual void + execute_coarsening_and_refinement() override; + + /** + * Override the implementation of prepare_coarsening_and_refinement from + * the base class. + * + * @note Not implemented yet. + */ + virtual bool + prepare_coarsening_and_refinement() override; + + /** + * Return true if the triangulation has hanging nodes. + * + * @note Not implemented yet. + */ + virtual bool + has_hanging_nodes() const override; + + /** + * Return the local memory consumption in bytes. + */ + virtual std::size_t + memory_consumption() const override; + + /** + * This function determines the neighboring subdomains that are adjacent + * to each vertex. + */ + virtual std::map> + compute_vertices_with_ghost_neighbors() const override; + + virtual bool + is_multilevel_hierarchy_constructed() const override; + + virtual unsigned int + coarse_cell_id_to_coarse_cell_index( + const types::coarse_cell_id coarse_cell_id) const override; + + virtual types::coarse_cell_id + coarse_cell_index_to_coarse_cell_id( + const unsigned int coarse_cell_index) const override; + + private: + /** + * Override the function to update the number cache so we can fill data + * like @p level_ghost_owners. + */ + virtual void + update_number_cache() override; + + /** + * store the Settings. + */ + Settings settings; + + /** + * Sorted list of pairs of coarse-cell ids and their indices. + */ + std::vector> + coarse_cell_id_to_coarse_cell_index_vector; + + /** + * List of the coarse-cell id for each coarse cell (stored at + * cell->index()). + */ + std::vector + coarse_cell_index_to_coarse_cell_id_vector; + + /** + * Boolean indicating that the function create_triangulation() was called + * for internal usage. + */ + bool currently_processing_create_triangulation_for_internal_usage; + + /** + * Boolean indicating that the function + * prepare_coarsening_and_refinement() was called for internal usage. + */ + bool + currently_processing_prepare_coarsening_and_refinement_for_internal_usage; + }; + + } // namespace fullydistributed +} // namespace parallel + + +DEAL_II_NAMESPACE_CLOSE + +#endif diff --git a/include/deal.II/distributed/fully_distributed_tria_util.h b/include/deal.II/distributed/fully_distributed_tria_util.h new file mode 100644 index 0000000000..5fda80f342 --- /dev/null +++ b/include/deal.II/distributed/fully_distributed_tria_util.h @@ -0,0 +1,74 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + +#ifndef dealii_fully_distributed_tria_util_h +#define dealii_fully_distributed_tria_util_h + +#include + +DEAL_II_NAMESPACE_OPEN + +namespace parallel +{ + namespace fullydistributed + { + namespace Utilities + { + /** + * Construct parallel::fullydistributed::ConstructionData from a given + * partitioned triangulation `tria` and a specified process. + * The input triangulation can be either + * a serial triangulation of type dealii::Triangulation which has been + * colored (subdomain_id and/or level_subdomain_id has been set) or a + * distributed triangulation of type dealii::distributed::Triangulation, + * where the partitioning is adopted unaltered. + * + * @param tria Partitioned input triangulation. + * @param comm MPI_Communicator to be used. In the case + * of dealii::distributed::Triangulation, the communicators + * have to match. + * @param construct_multilevel_hierarchy Signal if the multigrid levels + * should be constructed. + * @param my_rank_in Construct ConstructionData for this rank (only + * working for serial triangulations). + * @return ConstructionData to be used to setup + * parallel::fullydistributed::Triangulation. + * + * @note Multilevel hierarchies are supported if it is enabled in + * parallel::fullydistributed::Triangulation. + * + * @note Hanging nodes in the input triangulation are supported. However, + * to be able to use this + * feature, the user has to enable multilevel hierarchy support in + * parallel::fullydistributed::Triangulation. + * + * @author Peter Munch, 2019 + */ + template + ConstructionData + create_construction_data_from_triangulation( + const dealii::Triangulation &tria, + const MPI_Comm comm, + const bool construct_multilevel_hierarchy = false, + const unsigned int my_rank_in = numbers::invalid_unsigned_int); + + } // namespace Utilities + } // namespace fullydistributed +} // namespace parallel + + +DEAL_II_NAMESPACE_CLOSE + +#endif diff --git a/source/distributed/CMakeLists.txt b/source/distributed/CMakeLists.txt index ce52071ba1..358bbe16f1 100644 --- a/source/distributed/CMakeLists.txt +++ b/source/distributed/CMakeLists.txt @@ -19,6 +19,8 @@ SET(_unity_include_src grid_refinement.cc cell_weights.cc cell_data_transfer.cc + fully_distributed_tria.cc + fully_distributed_tria_util.cc solution_transfer.cc tria.cc tria_base.cc @@ -42,6 +44,8 @@ SET(_inst grid_refinement.inst.in cell_weights.inst.in cell_data_transfer.inst.in + fully_distributed_tria.inst.in + fully_distributed_tria_util.inst.in solution_transfer.inst.in tria.inst.in shared_tria.inst.in diff --git a/source/distributed/fully_distributed_tria.cc b/source/distributed/fully_distributed_tria.cc new file mode 100644 index 0000000000..f4fe3720d4 --- /dev/null +++ b/source/distributed/fully_distributed_tria.cc @@ -0,0 +1,531 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +#include + +#include + +DEAL_II_NAMESPACE_OPEN + +// Forward declarations +namespace GridGenerator +{ + template + void + hyper_cube(Triangulation &tria, + const double left, + const double right, + const bool colorize); +} // namespace GridGenerator + +namespace parallel +{ + namespace fullydistributed + { + template + Triangulation::Triangulation(MPI_Comm mpi_communicator) + : parallel::DistributedTriangulationBase(mpi_communicator) + , settings(Settings::default_setting) + , currently_processing_create_triangulation_for_internal_usage(false) + , currently_processing_prepare_coarsening_and_refinement_for_internal_usage( + false) + {} + + + + template + void + Triangulation::create_triangulation( + const ConstructionData &construction_data) + { + // check if the communicator of this parallel triangulation has been used + // to construct the ConstructionData + Assert(construction_data.comm == this->mpi_communicator, + ExcMessage("MPI communicators do not match!")); + + // store internally the settings + settings = construction_data.settings; + + // set the smoothing properties + if (settings & construct_multigrid_hierarchy) + this->set_mesh_smoothing( + static_cast< + typename dealii::Triangulation::MeshSmoothing>( + dealii::Triangulation::none | + Triangulation::limit_level_difference_at_vertices)); + else + this->set_mesh_smoothing( + static_cast< + typename dealii::Triangulation::MeshSmoothing>( + dealii::Triangulation::none)); + + // clear internal data structures + this->coarse_cell_id_to_coarse_cell_index_vector.clear(); + this->coarse_cell_index_to_coarse_cell_id_vector.clear(); + + // check if no locally relevant coarse-grid cells have been provided + if (construction_data.coarse_cell_vertices.empty()) + { + // 1) create a dummy hypercube + currently_processing_create_triangulation_for_internal_usage = true; + GridGenerator::hyper_cube(*this, 0, 1, false); + currently_processing_create_triangulation_for_internal_usage = false; + + // 2) mark cell as artificial + auto cell = this->begin(); + cell->set_subdomain_id(dealii::numbers::artificial_subdomain_id); + cell->set_level_subdomain_id( + dealii::numbers::artificial_subdomain_id); + + // 3) set up dummy mapping between locally relevant coarse-grid cells + // and global cells + this->coarse_cell_id_to_coarse_cell_index_vector.emplace_back( + numbers::invalid_coarse_cell_id, 0); + this->coarse_cell_index_to_coarse_cell_id_vector.emplace_back( + numbers::invalid_coarse_cell_id); + } + else + { + // 1) store `coarse-cell index to coarse-cell id`-mapping + this->coarse_cell_index_to_coarse_cell_id_vector = + construction_data.coarse_cell_index_to_coarse_cell_id; + + // 2) set up `coarse-cell id to coarse-cell index`-mapping + std::map + coarse_cell_id_to_coarse_cell_index_vector; + for (unsigned int i = 0; + i < construction_data.coarse_cell_index_to_coarse_cell_id.size(); + ++i) + coarse_cell_id_to_coarse_cell_index_vector + [construction_data.coarse_cell_index_to_coarse_cell_id[i]] = i; + + for (auto i : coarse_cell_id_to_coarse_cell_index_vector) + this->coarse_cell_id_to_coarse_cell_index_vector.emplace_back(i); + + // 3) create coarse grid + dealii::parallel::Triangulation::create_triangulation( + construction_data.coarse_cell_vertices, + construction_data.coarse_cells, + SubCellData()); + + Assert(this->n_cells() == + this->coarse_cell_id_to_coarse_cell_index_vector.size(), + ExcInternalError()); + Assert(this->n_cells() == + this->coarse_cell_index_to_coarse_cell_id_vector.size(), + ExcInternalError()); + + // create a copy of cell_infos such that we can sort them + auto cell_infos = construction_data.cell_infos; + + // sort cell_infos on each level separately + for (auto &cell_info : cell_infos) + std::sort(cell_info.begin(), + cell_info.end(), + [&](CellData a, CellData b) { + const CellId a_id(a.id); + const CellId b_id(b.id); + + const auto a_coarse_cell_index = + this->coarse_cell_id_to_coarse_cell_index( + a_id.get_coarse_cell_id()); + const auto b_coarse_cell_index = + this->coarse_cell_id_to_coarse_cell_index( + b_id.get_coarse_cell_id()); + + // according to their coarse-cell index and if that is + // same according to their cell id (the result is that + // cells on each level are sorted according to their + // index on that level - what we need in the following + // operations) + if (a_coarse_cell_index != b_coarse_cell_index) + return a_coarse_cell_index < b_coarse_cell_index; + else + return a_id < b_id; + }); + + // 4) create all levels via a sequence of refinements + for (unsigned int level = 0; level < cell_infos.size(); ++level) + { + // a) set manifold ids here (because new vertices have to be + // positioned correctly during each refinement step) + { + auto cell = this->begin(level); + auto cell_info = cell_infos[level].begin(); + for (; cell_info != cell_infos[level].end(); ++cell_info) + { + while (cell_info->id != + cell->id().template to_binary()) + ++cell; + if (spacedim == 3) + for (unsigned int quad = 0; + quad < GeometryInfo::quads_per_cell; + ++quad) + cell->quad(quad)->set_manifold_id( + cell_info->manifold_quad_ids[quad]); + + if (spacedim >= 2) + for (unsigned int line = 0; + line < GeometryInfo::lines_per_cell; + ++line) + cell->line(line)->set_manifold_id( + cell_info->manifold_line_ids[line]); + + cell->set_manifold_id(cell_info->manifold_id); + } + } + + // b) perform refinement on all levels but on the finest + if (level + 1 != cell_infos.size()) + { + // find cells that should have children and mark them for + // refinement + auto coarse_cell = this->begin(level); + auto fine_cell_info = cell_infos[level + 1].begin(); + + // loop over all cells on the next level + for (; fine_cell_info != cell_infos[level + 1].end(); + ++fine_cell_info) + { + // find the parent of that cell + while (!coarse_cell->id().is_parent_of( + CellId(fine_cell_info->id))) + ++coarse_cell; + + // set parent for refinement + coarse_cell->set_refine_flag(); + } + + // execute refinement + currently_processing_prepare_coarsening_and_refinement_for_internal_usage = + true; + dealii::Triangulation:: + execute_coarsening_and_refinement(); + currently_processing_prepare_coarsening_and_refinement_for_internal_usage = + false; + } + } + + // 4a) set all cells artificial (and set the actual + // (level_)subdomain_ids in the next step) + for (auto cell = this->begin(); cell != this->end(); ++cell) + { + if (cell->active()) + cell->set_subdomain_id( + dealii::numbers::artificial_subdomain_id); + + cell->set_level_subdomain_id( + dealii::numbers::artificial_subdomain_id); + } + + // 4b) set actual (level_)subdomain_ids as well as boundary ids + for (unsigned int level = 0; level < cell_infos.size(); ++level) + { + auto cell = this->begin(level); + auto cell_info = cell_infos[level].begin(); + for (; cell_info != cell_infos[level].end(); ++cell_info) + { + // find cell that has the correct cell + while (cell_info->id != cell->id().template to_binary()) + ++cell; + + // subdomain id + if (cell->active()) + cell->set_subdomain_id(cell_info->subdomain_id); + + // level subdomain id + if (settings & construct_multigrid_hierarchy) + cell->set_level_subdomain_id(cell_info->level_subdomain_id); + + // boundary ids + for (auto pair : cell_info->boundary_ids) + { + Assert(cell->at_boundary(pair.first), + ExcMessage("Cell face is not on the boundary!")); + cell->face(pair.first)->set_boundary_id(pair.second); + } + } + } + } + + update_number_cache(); + } + + + + template + void + Triangulation::create_triangulation( + const std::vector> & vertices, + const std::vector> &cells, + const SubCellData & subcelldata) + { + AssertThrow( + currently_processing_create_triangulation_for_internal_usage, + ExcMessage( + "Use the other create_triangulation() function to create triangulations of type parallel::fullydistributed::Triangulation.!")); + + dealii::Triangulation::create_triangulation(vertices, + cells, + subcelldata); + } + + + + template + void + Triangulation::update_number_cache() + { + if (settings & construct_multigrid_hierarchy) + parallel::Triangulation::fill_level_ghost_owners(); + + parallel::Triangulation::update_number_cache(); + } + + + + template + void + Triangulation::execute_coarsening_and_refinement() + { + Assert(false, ExcNotImplemented()); + } + + + + template + bool + Triangulation::prepare_coarsening_and_refinement() + { + Assert( + currently_processing_prepare_coarsening_and_refinement_for_internal_usage, + ExcMessage("No coarsening and refinement is supported!")); + + return dealii::Triangulation:: + prepare_coarsening_and_refinement(); + } + + + + template + bool + Triangulation::has_hanging_nodes() const + { + Assert(false, ExcNotImplemented()); + return false; + } + + + + template + std::size_t + Triangulation::memory_consumption() const + { + const std::size_t mem = + this->dealii::parallel::TriangulationBase:: + memory_consumption() + + MemoryConsumption::memory_consumption( + coarse_cell_id_to_coarse_cell_index_vector) + + MemoryConsumption::memory_consumption( + coarse_cell_index_to_coarse_cell_id_vector); + return mem; + } + + + + template + std::map> + Triangulation::compute_vertices_with_ghost_neighbors() const + { + // 1) collect for each vertex on periodic faces all vertices it coincides + // with + std::map> + vertex_to_coinciding_vertices; + { + // 1a) collect nodes coinciding due to periodicity + std::map vertex_to_coinciding_vertex; + for (auto &cell : this->active_cell_iterators()) + if (cell->is_locally_owned() || cell->is_ghost()) + for (auto i = 0u; i < GeometryInfo::faces_per_cell; ++i) + if (cell->has_periodic_neighbor(i) && + cell->periodic_neighbor(i)->active()) + { + auto face_t = cell->face(i); + auto face_n = cell->periodic_neighbor(i)->face( + cell->periodic_neighbor_face_no(i)); + for (auto j = 0u; j < GeometryInfo::vertices_per_face; + ++j) + { + auto v_t = face_t->vertex_index(j); + auto v_n = face_n->vertex_index(j); + unsigned int temp = std::min(v_t, v_n); + { + auto it = vertex_to_coinciding_vertex.find(v_t); + if (it != vertex_to_coinciding_vertex.end()) + temp = std::min(temp, it->second); + } + { + auto it = vertex_to_coinciding_vertex.find(v_n); + if (it != vertex_to_coinciding_vertex.end()) + temp = std::min(temp, it->second); + } + vertex_to_coinciding_vertex[v_t] = temp; + vertex_to_coinciding_vertex[v_n] = temp; + } + } + + // 1b) compress map: let vertices point to the coinciding vertex with + // the smallest index + for (auto &p : vertex_to_coinciding_vertex) + { + if (p.first == p.second) + continue; + unsigned int temp = p.second; + while (temp != vertex_to_coinciding_vertex[temp]) + temp = vertex_to_coinciding_vertex[temp]; + p.second = temp; + } + +#ifdef DEBUG + // check if map is actually compressed + for (auto p : vertex_to_coinciding_vertex) + { + if (p.first == p.second) + continue; + auto pp = vertex_to_coinciding_vertex.find(p.second); + if (pp->first == pp->second) + continue; + AssertThrow(false, ExcMessage("Map has to be compressed!")); + } +#endif + + // 1c) create a map: smallest index of coinciding index -> all + // coinciding indices + std::map> + smallest_coinciding_vertex_to_coinciding_vertices; + for (auto p : vertex_to_coinciding_vertex) + smallest_coinciding_vertex_to_coinciding_vertices[p.second] = + std::set(); + + for (auto p : vertex_to_coinciding_vertex) + smallest_coinciding_vertex_to_coinciding_vertices[p.second].insert( + p.first); + + // 1d) create a map: vertex -> all coinciding indices + for (auto &s : smallest_coinciding_vertex_to_coinciding_vertices) + for (auto &ss : s.second) + vertex_to_coinciding_vertices[ss] = s.second; + } + + // 2) collect vertices belonging to local cells + std::vector vertex_of_own_cell(this->n_vertices(), false); + for (const auto &cell : this->active_cell_iterators()) + if (cell->is_locally_owned()) + for (auto v = 0u; v < GeometryInfo::vertices_per_cell; ++v) + vertex_of_own_cell[cell->vertex_index(v)] = true; + + // 3) for for each vertex belonging to a locally owned cell all ghost + // neighbors (including the periodic own) + std::map> result; + + // loop over all active ghost cells + for (const auto &cell : this->active_cell_iterators()) + if (cell->is_ghost()) + { + const auto owner = cell->subdomain_id(); + + // loop over all its vertices + for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; + ++v) + { + // set owner if vertex belongs to a local cell + if (vertex_of_own_cell[cell->vertex_index(v)]) + result[cell->vertex_index(v)].insert(owner); + + // mark also nodes coinciding due to periodicity + auto coinciding_vertices = + vertex_to_coinciding_vertices.find(cell->vertex_index(v)); + if (coinciding_vertices != vertex_to_coinciding_vertices.end()) + for (auto coinciding_vertex : coinciding_vertices->second) + if (vertex_of_own_cell[coinciding_vertex]) + result[coinciding_vertex].insert(owner); + } + } + + return result; + } + + + + template + bool + Triangulation::is_multilevel_hierarchy_constructed() const + { + return (settings & construct_multigrid_hierarchy); + } + + + + template + unsigned int + Triangulation::coarse_cell_id_to_coarse_cell_index( + const types::coarse_cell_id coarse_cell_id) const + { + const auto coarse_cell_index = + std::lower_bound(coarse_cell_id_to_coarse_cell_index_vector.begin(), + coarse_cell_id_to_coarse_cell_index_vector.end(), + coarse_cell_id, + [](const auto &pair, const auto &val) { + return pair.first < val; + }); + Assert(coarse_cell_index != + coarse_cell_id_to_coarse_cell_index_vector.cend(), + ExcMessage("Coarse cell index not found!")); + return coarse_cell_index->second; + } + + + + template + types::coarse_cell_id + Triangulation::coarse_cell_index_to_coarse_cell_id( + const unsigned int coarse_cell_index) const + { + Assert(coarse_cell_index < + coarse_cell_index_to_coarse_cell_id_vector.size(), + ExcIndexRange(coarse_cell_index, + 0, + coarse_cell_index_to_coarse_cell_id_vector.size())); + + const auto coarse_cell_id = + coarse_cell_index_to_coarse_cell_id_vector[coarse_cell_index]; + Assert(coarse_cell_id != numbers::invalid_coarse_cell_id, + ExcMessage("You are trying to access a dummy cell!")); + return coarse_cell_id; + } + + + + } // namespace fullydistributed +} // namespace parallel + + + +/*-------------- Explicit Instantiations -------------------------------*/ +#include "fully_distributed_tria.inst" + + +DEAL_II_NAMESPACE_CLOSE diff --git a/source/distributed/fully_distributed_tria.inst.in b/source/distributed/fully_distributed_tria.inst.in new file mode 100644 index 0000000000..b4438c3429 --- /dev/null +++ b/source/distributed/fully_distributed_tria.inst.in @@ -0,0 +1,33 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2010 - 2018 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + + +for (deal_II_dimension : DIMENSIONS) + { + namespace parallel + \{ + namespace fullydistributed + \{ + template class Triangulation; +#if deal_II_dimension < 3 + template class Triangulation; +#endif +#if deal_II_dimension < 2 + template class Triangulation; +#endif + \} + \} + } diff --git a/source/distributed/fully_distributed_tria_util.cc b/source/distributed/fully_distributed_tria_util.cc new file mode 100644 index 0000000000..a430ae6521 --- /dev/null +++ b/source/distributed/fully_distributed_tria_util.cc @@ -0,0 +1,525 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + +#include +#include + +#include +#include +#include + +#include +#include + +DEAL_II_NAMESPACE_OPEN + +namespace parallel +{ + namespace fullydistributed + { + namespace Utilities + { + namespace + { + /** + * Set the user_flag of a cell and of all its parent cells. + */ + template + void + set_user_flag_reverse(TriaIterator> cell) + { + cell->set_user_flag(); + if (cell->level() != 0) + set_user_flag_reverse(cell->parent()); + } + + + /** + * Convert the binary representation of a CellId to coarse-cell id as + * if the finest level were the coarsest level ("level coarse-grid id"). + */ + template + types::coarse_cell_id + convert_cell_id_binary_type_to_level_coarse_cell_id( + const typename CellId::binary_type &binary_representation) + { + // exploiting the structure of CellId::binary_type + // see also the documentation of CellId + + // actual coarse-grid id + const unsigned int coarse_cell_id = binary_representation[0]; + const unsigned int n_child_indices = binary_representation[1] >> 2; + + const unsigned int children_per_value = + sizeof(CellId::binary_type::value_type) * 8 / dim; + unsigned int child_level = 0; + unsigned int binary_entry = 2; + + // path to the get to the cell + std::vector cell_indices; + while (child_level < n_child_indices) + { + Assert(binary_entry < binary_representation.size(), + ExcInternalError()); + + for (unsigned int j = 0; j < children_per_value; ++j) + { + unsigned int cell_index = + (((binary_representation[binary_entry] >> (j * dim))) & + (GeometryInfo::max_children_per_cell - 1)); + cell_indices.push_back(cell_index); + ++child_level; + if (child_level == n_child_indices) + break; + } + ++binary_entry; + } + + // compute new coarse-grid id: c_{i+1} = c_{i}*2^dim + q; + types::coarse_cell_id level_coarse_cell_id = coarse_cell_id; + for (auto i : cell_indices) + level_coarse_cell_id = + level_coarse_cell_id * GeometryInfo::max_children_per_cell + + i; + + return level_coarse_cell_id; + } + } // namespace + + + template + ConstructionData + create_construction_data_from_triangulation( + const dealii::Triangulation &tria, + const MPI_Comm comm, + const bool construct_multilevel_hierarchy, + const unsigned int my_rank_in) + { + if (auto tria_pdt = dynamic_cast< + const parallel::distributed::Triangulation *>( + &tria)) + AssertThrow(comm == tria_pdt->get_communicator(), + ExcMessage("MPI communicators do not match.")); + + // First, figure out for what rank we are supposed to build the + // ConstructionData object + unsigned int my_rank = my_rank_in; + AssertThrow(my_rank == numbers::invalid_unsigned_int || + my_rank < dealii::Utilities::MPI::n_mpi_processes(comm), + ExcMessage( + "Rank has to be smaller than available processes.")); + + if (auto tria_pdt = dynamic_cast< + const parallel::distributed::Triangulation *>( + &tria)) + { + AssertThrow( + my_rank == numbers::invalid_unsigned_int || + my_rank == dealii::Utilities::MPI::this_mpi_process(comm), + ExcMessage( + "If parallel::distributed::Triangulation as source triangulation, my_rank has to equal global rank.")); + + my_rank = dealii::Utilities::MPI::this_mpi_process(comm); + } + else if (auto tria_serial = + dynamic_cast *>( + &tria)) + { + if (my_rank == numbers::invalid_unsigned_int) + my_rank = dealii::Utilities::MPI::this_mpi_process(comm); + } + else + { + AssertThrow(false, + ExcMessage( + "This type of triangulation is not supported!")); + } + + ConstructionData construction_data; + + // store the communicator + construction_data.comm = comm; + + // helper function, which collects all vertices belonging to a cell + // (also taking into account periodicity) + auto add_vertices_of_cell_to_vertices_owned_by_locally_owned_cells = + [](TriaIterator> &cell, + std::set &vertices_owned_by_locally_owned_cells) { + // add vertices belonging to a periodic neighbor + for (unsigned int f = 0; f < GeometryInfo::faces_per_cell; ++f) + if (cell->has_periodic_neighbor(f)) + { + auto face_t = cell->face(f); + auto face_n = cell->periodic_neighbor(f)->face( + cell->periodic_neighbor_face_no(f)); + for (unsigned int v = 0; + v < GeometryInfo::vertices_per_face; + ++v) + { + vertices_owned_by_locally_owned_cells.insert( + face_t->vertex_index(v)); + vertices_owned_by_locally_owned_cells.insert( + face_n->vertex_index(v)); + } + } + + // add local vertices + for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; + ++v) + vertices_owned_by_locally_owned_cells.insert( + cell->vertex_index(v)); + }; + + // check if multilevel hierarchy should be constructed + if (construct_multilevel_hierarchy == false) + { + AssertThrow( + tria.has_hanging_nodes() == false, + ExcMessage( + "Hanging nodes are only supported if multilevel hierarchy is constructed!")); + + construction_data.settings = + fullydistributed::Settings::default_setting; + + // 1) collect vertices of active locally owned cells + std::set vertices_owned_by_locally_owned_cells; + for (auto cell : tria.cell_iterators()) + if (cell->active() && cell->subdomain_id() == my_rank) + add_vertices_of_cell_to_vertices_owned_by_locally_owned_cells( + cell, vertices_owned_by_locally_owned_cells); + + // helper function to determine if cell is locally relevant + // (i.e. a cell which is connected to a vertex via a locally owned + // active cell) + auto is_locally_relevant = + [&](TriaIterator> &cell) { + for (unsigned int v = 0; + v < GeometryInfo::vertices_per_cell; + ++v) + if (vertices_owned_by_locally_owned_cells.find( + cell->vertex_index(v)) != + vertices_owned_by_locally_owned_cells.end()) + return true; + return false; + }; + + // 2) process all local and ghost cells: set up needed data + // structures and collect all locally relevant vertices + // for second sweep + std::map vertices_locally_relevant; + construction_data.cell_infos.resize(1); + + for (auto cell : tria.cell_iterators()) + if (cell->active() && is_locally_relevant(cell)) + { + // to be filled + CellData cell_info; + + // a) extract cell definition (with old numbering of + // vertices) + dealii::CellData cell_data; + cell_data.material_id = cell->material_id(); + cell_data.manifold_id = cell->manifold_id(); + for (unsigned int v = 0; + v < GeometryInfo::vertices_per_cell; + ++v) + cell_data.vertices[v] = cell->vertex_index(v); + construction_data.coarse_cells.push_back(cell_data); + + // b) save indices of each vertex of this cell + for (unsigned int v = 0; + v < GeometryInfo::vertices_per_cell; + ++v) + vertices_locally_relevant[cell->vertex_index(v)] = + numbers::invalid_unsigned_int; + + // c) save boundary_ids of each face of this cell + for (unsigned int f = 0; + f < GeometryInfo::faces_per_cell; + ++f) + { + types::boundary_id boundary_ind = + cell->face(f)->boundary_id(); + if (boundary_ind != numbers::internal_face_boundary_id) + cell_info.boundary_ids.emplace_back(f, boundary_ind); + } + + // d) compute a new coarse-cell id (by ignoring all parent + // level) + types::coarse_cell_id new_coarse_cell_id = + convert_cell_id_binary_type_to_level_coarse_cell_id( + cell->id().template to_binary()); + + // store the coarse cell id + cell_info.id = CellId(new_coarse_cell_id, 0, nullptr) + .template to_binary(); + + // save coarse_cell_index -> coarse_cell_id mapping + construction_data.coarse_cell_index_to_coarse_cell_id + .push_back(new_coarse_cell_id); + + // e) store manifold id of cell + cell_info.manifold_id = cell->manifold_id(); + + // ... of lines + if (dim >= 2) + for (unsigned int line = 0; + line < GeometryInfo::lines_per_cell; + ++line) + cell_info.manifold_line_ids[line] = + cell->line(line)->manifold_id(); + + // ... of quads + if (dim == 3) + for (unsigned int quad = 0; + quad < GeometryInfo::quads_per_cell; + ++quad) + cell_info.manifold_quad_ids[quad] = + cell->quad(quad)->manifold_id(); + + // f) store subdomain_id + cell_info.subdomain_id = cell->subdomain_id(); + + // g) store invalid level_subdomain_id (since multilevel + // hierarchy is not constructed) + cell_info.level_subdomain_id = numbers::invalid_subdomain_id; + + construction_data.cell_infos[0].emplace_back(cell_info); + } + + // 3) enumerate locally relevant vertices + unsigned int vertex_counter = 0; + for (auto &vertex : vertices_locally_relevant) + { + construction_data.coarse_cell_vertices.push_back( + tria.get_vertices()[vertex.first]); + vertex.second = vertex_counter++; + } + + // 4) correct vertices of cells (make them local) + for (auto &cell : construction_data.coarse_cells) + for (unsigned int v = 0; v < GeometryInfo::vertices_per_cell; + ++v) + cell.vertices[v] = vertices_locally_relevant[cell.vertices[v]]; + } + else + { + construction_data.settings = + fullydistributed::Settings::construct_multigrid_hierarchy; + + // 1) collect locally relevant cells (set user_flag) + std::vector old_user_flags; + tria.save_user_flags(old_user_flags); + + // 1a) clear user_flags + const_cast &>(tria) + .clear_user_flags(); + + // 1b) loop over levels (from fine to coarse) and mark on each level + // the locally relevant cells + for (unsigned int level = + tria.get_triangulation().n_global_levels() - 1; + level != numbers::invalid_unsigned_int; + level--) + { + // collect vertices connected to a (on any level) locally owned + // cell + std::set vertices_owned_by_locally_owned_cells; + for (auto cell : tria.cell_iterators_on_level(level)) + if (cell->level_subdomain_id() == my_rank || + (cell->active() && cell->subdomain_id() == my_rank)) + add_vertices_of_cell_to_vertices_owned_by_locally_owned_cells( + cell, vertices_owned_by_locally_owned_cells); + + // helper function to determine if cell is locally relevant + // (i.e. a cell which is connected to a vertex via a locally + // owned cell) + auto is_locally_relevant = + [&](TriaIterator> &cell) { + for (unsigned int v = 0; + v < GeometryInfo::vertices_per_cell; + ++v) + if (vertices_owned_by_locally_owned_cells.find( + cell->vertex_index(v)) != + vertices_owned_by_locally_owned_cells.end()) + return true; + return false; + }; + + // mark all locally relevant cells + for (auto cell : tria.cell_iterators_on_level(level)) + if (is_locally_relevant(cell)) + set_user_flag_reverse(cell); + } + + // 2) set_up coarse-grid triangulation + { + std::map vertices_locally_relevant; + + // a) loop over all cells + for (auto cell : tria.cell_iterators_on_level(0)) + { + if (!cell->user_flag_set()) + continue; + + // extract cell definition (with old numbering of vertices) + dealii::CellData cell_data; + cell_data.material_id = cell->material_id(); + cell_data.manifold_id = cell->manifold_id(); + for (unsigned int v = 0; + v < GeometryInfo::vertices_per_cell; + ++v) + cell_data.vertices[v] = cell->vertex_index(v); + construction_data.coarse_cells.push_back(cell_data); + + // save indices of each vertex of this cell + for (unsigned int v = 0; + v < GeometryInfo::vertices_per_cell; + ++v) + vertices_locally_relevant[cell->vertex_index(v)] = + numbers::invalid_unsigned_int; + + // save translation for corase grid: lid -> gid + construction_data.coarse_cell_index_to_coarse_cell_id + .push_back(cell->id().get_coarse_cell_id()); + } + + // b) enumerate locally relevant vertices + unsigned int vertex_counter = 0; + for (auto &vertex : vertices_locally_relevant) + { + construction_data.coarse_cell_vertices.push_back( + tria.get_vertices()[vertex.first]); + vertex.second = vertex_counter++; + } + + // c) correct vertices of cells (make them local) + for (auto &cell : construction_data.coarse_cells) + for (unsigned int v = 0; + v < GeometryInfo::vertices_per_cell; + ++v) + cell.vertices[v] = + vertices_locally_relevant[cell.vertices[v]]; + } + + + // 3) collect info of each cell + construction_data.cell_infos.resize( + tria.get_triangulation().n_global_levels()); + + for (unsigned int level = 0; + level < tria.get_triangulation().n_global_levels(); + ++level) + { + // collect local vertices on level + std::set vertices_owned_by_locally_owned_cells; + for (auto cell : tria.cell_iterators_on_level(level)) + if (cell->level_subdomain_id() == my_rank || + (cell->active() && cell->subdomain_id() == my_rank)) + add_vertices_of_cell_to_vertices_owned_by_locally_owned_cells( + cell, vertices_owned_by_locally_owned_cells); + + // helper function to determine if cell is locally relevant + auto is_locally_relevant = + [&](TriaIterator> &cell) { + for (unsigned int v = 0; + v < GeometryInfo::vertices_per_cell; + ++v) + if (vertices_owned_by_locally_owned_cells.find( + cell->vertex_index(v)) != + vertices_owned_by_locally_owned_cells.end()) + return true; + return false; + }; + + auto &level_cell_infos = construction_data.cell_infos[level]; + for (auto cell : tria.cell_iterators_on_level(level)) + { + // check if cell is locally relevant + if (!(cell->user_flag_set())) + continue; + + CellData cell_info; + + // save coarse-cell id + cell_info.id = cell->id().template to_binary(); + + // save boundary_ids of each face of this cell + for (unsigned int f = 0; + f < GeometryInfo::faces_per_cell; + ++f) + { + types::boundary_id boundary_ind = + cell->face(f)->boundary_id(); + if (boundary_ind != numbers::internal_face_boundary_id) + cell_info.boundary_ids.emplace_back(f, boundary_ind); + } + + // save manifold id + { + // ... of cell + cell_info.manifold_id = cell->manifold_id(); + + // ... of lines + if (dim >= 2) + for (unsigned int line = 0; + line < GeometryInfo::lines_per_cell; + ++line) + cell_info.manifold_line_ids[line] = + cell->line(line)->manifold_id(); + + // ... of quads + if (dim == 3) + for (unsigned int quad = 0; + quad < GeometryInfo::quads_per_cell; + ++quad) + cell_info.manifold_quad_ids[quad] = + cell->quad(quad)->manifold_id(); + } + + // subdomain and level subdomain id + cell_info.subdomain_id = numbers::artificial_subdomain_id; + cell_info.level_subdomain_id = + numbers::artificial_subdomain_id; + + if (is_locally_relevant(cell)) + { + cell_info.level_subdomain_id = + cell->level_subdomain_id(); + if (cell->active()) + cell_info.subdomain_id = cell->subdomain_id(); + } + + level_cell_infos.emplace_back(cell_info); + } + } + + const_cast &>(tria) + .load_user_flags(old_user_flags); + } + + return construction_data; + } + } // namespace Utilities + } // namespace fullydistributed +} // namespace parallel + + + +/*-------------- Explicit Instantiations -------------------------------*/ +#include "fully_distributed_tria_util.inst" + + +DEAL_II_NAMESPACE_CLOSE diff --git a/source/distributed/fully_distributed_tria_util.inst.in b/source/distributed/fully_distributed_tria_util.inst.in new file mode 100644 index 0000000000..0774776173 --- /dev/null +++ b/source/distributed/fully_distributed_tria_util.inst.in @@ -0,0 +1,36 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2010 - 2018 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + + +for (deal_II_dimension : DIMENSIONS) + { + namespace parallel + \{ + namespace fullydistributed + \{ + namespace Utilities + \{ + template ConstructionData + create_construction_data_from_triangulation( + const dealii::Triangulation + & tria, + const MPI_Comm comm, + const bool construct_multilevel_hierarchy = false, + const unsigned int my_rank_in = numbers::invalid_unsigned_int); + \} + \} + \} + } \ No newline at end of file diff --git a/source/grid/grid_tools_dof_handlers.cc b/source/grid/grid_tools_dof_handlers.cc index dc2e7ece41..8dfe5435d4 100644 --- a/source/grid/grid_tools_dof_handlers.cc +++ b/source/grid/grid_tools_dof_handlers.cc @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -2063,8 +2064,26 @@ namespace GridTools Assert(0 <= direction && direction < space_dim, ExcIndexRange(direction, 0, space_dim)); - Assert(pairs1.size() == pairs2.size(), - ExcMessage("Unmatched faces on periodic boundaries")); +#ifdef DEBUG + { + constexpr int dim = CellIterator::AccessorType::dimension; + constexpr int spacedim = CellIterator::AccessorType::space_dimension; + // For parallel::fullydistributed::Triangulation there might be unmatched + // faces on periodic boundaries on the coarse grid, which results that + // this assert is not fulfilled (not a bug!). See also the discussion in + // the method collect_periodic_faces. + if (!(((pairs1.size() > 0) && + (dynamic_cast *>( + &pairs1.begin()->first->get_triangulation()) != nullptr)) || + ((pairs2.size() > 0) && + (dynamic_cast< + const parallel::fullydistributed::Triangulation + *>(&pairs2.begin()->first->get_triangulation()) != nullptr)))) + Assert(pairs1.size() == pairs2.size(), + ExcMessage("Unmatched faces on periodic boundaries")); + } +#endif unsigned int n_matches = 0; @@ -2100,9 +2119,25 @@ namespace GridTools } } - // Assure that all faces are matched - AssertThrow(n_matches == pairs1.size() && pairs2.size() == 0, - ExcMessage("Unmatched faces on periodic boundaries")); + // Assure that all faces are matched if not + // parallel::fullydistributed::Triangulation is used. This is related to the + // fact that the faces might not be successfully matched on the coarse grid + // (not a bug!). See also the comment above and in the + // method collect_periodic_faces. + { + constexpr int dim = CellIterator::AccessorType::dimension; + constexpr int spacedim = CellIterator::AccessorType::space_dimension; + if (!(((pairs1.size() > 0) && + (dynamic_cast *>( + &pairs1.begin()->first->get_triangulation()) != nullptr)) || + ((pairs2.size() > 0) && + (dynamic_cast< + const parallel::fullydistributed::Triangulation + *>(&pairs2.begin()->first->get_triangulation()) != nullptr)))) + AssertThrow(n_matches == pairs1.size() && pairs2.size() == 0, + ExcMessage("Unmatched faces on periodic boundaries")); + } } @@ -2237,8 +2272,22 @@ namespace GridTools } } - Assert(pairs1.size() == pairs2.size(), - ExcMessage("Unmatched faces on periodic boundaries")); + // Assure that all faces are matched on the coare grid. This requirement + // can only fulfilled if a process owns the complete coarse grid. This is + // not the case for a parallel::fullydistributed::Triangulation, i.e. this + // requirement has not to be met neither (consider faces on the outside of a + // ghost cell that are periodic but for which the ghost neighbor doesn't + // exist). + if (!(((pairs1.size() > 0) && + (dynamic_cast< + const parallel::fullydistributed::Triangulation + *>(&pairs1.begin()->first->get_triangulation()) != nullptr)) || + ((pairs2.size() > 0) && + (dynamic_cast< + const parallel::fullydistributed::Triangulation + *>(&pairs2.begin()->first->get_triangulation()) != nullptr)))) + Assert(pairs1.size() == pairs2.size(), + ExcMessage("Unmatched faces on periodic boundaries")); Assert(pairs1.size() > 0, ExcMessage("No new periodic face pairs have been found. " diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 17efe915c0..88658c5494 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -1849,19 +1849,6 @@ namespace internal "of freedom at these vertices have the same " "value, using the AffineConstraints class.")); } - - // assert there are no more - // than two boundary - // nodes. note that if the - // space dimension is - // bigger than 1, then we - // can have fewer than 2 - // nodes (for example a - // ring of cells -- no end - // points at all) - AssertThrow(((spacedim == 1) && (boundary_nodes == 2)) || - (spacedim > 1), - ExcMessage("The Triangulation has too many end points")); } diff --git a/tests/fullydistributed_grids/CMakeLists.txt b/tests/fullydistributed_grids/CMakeLists.txt new file mode 100644 index 0000000000..d33eafa20b --- /dev/null +++ b/tests/fullydistributed_grids/CMakeLists.txt @@ -0,0 +1,4 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +INCLUDE(../setup_testsubproject.cmake) +PROJECT(testsuite CXX) +DEAL_II_PICKUP_TESTS() diff --git a/tests/fullydistributed_grids/copy_distributed_tria_01.cc b/tests/fullydistributed_grids/copy_distributed_tria_01.cc new file mode 100644 index 0000000000..213019fe57 --- /dev/null +++ b/tests/fullydistributed_grids/copy_distributed_tria_01.cc @@ -0,0 +1,89 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Create a distributed triangulation without multigrid levels and copy it. + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "./tests.h" + +using namespace dealii; + +template +void +test(int n_refinements, MPI_Comm comm) +{ + // create pdt + parallel::distributed::Triangulation tria_pdt( + comm, + dealii::Triangulation::none, + parallel::distributed::Triangulation::construct_multigrid_hierarchy); + GridGenerator::hyper_cube(tria_pdt); + tria_pdt.refine_global(n_refinements); + + // create instance of pft + parallel::fullydistributed::Triangulation tria_pft(comm); + + // extract relevant information form serial triangulation + auto construction_data = parallel::fullydistributed::Utilities:: + create_construction_data_from_triangulation(tria_pdt, comm); + + // actually create triangulation + tria_pft.create_triangulation(construction_data); + + // test triangulation + FE_Q fe(2); + DoFHandler dof_handler(tria_pft); + dof_handler.distribute_dofs(fe); + + // print statistics + print_statistics(tria_pft); + print_statistics(dof_handler); +} + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll all; + + const MPI_Comm comm = MPI_COMM_WORLD; + + { + deallog.push("2d"); + const int n_refinements = 8; + test<2>(n_refinements, comm); + deallog.pop(); + } + { + deallog.push("3d"); + const int n_refinements = 4; + test<3>(n_refinements, comm); + deallog.pop(); + } +} diff --git a/tests/fullydistributed_grids/copy_distributed_tria_01.with_p4est=true.mpirun=1.output b/tests/fullydistributed_grids/copy_distributed_tria_01.with_p4est=true.mpirun=1.output new file mode 100644 index 0000000000..a51a37a6a9 --- /dev/null +++ b/tests/fullydistributed_grids/copy_distributed_tria_01.with_p4est=true.mpirun=1.output @@ -0,0 +1,15 @@ + +DEAL:0:2d::n_levels: 1 +DEAL:0:2d::n_cells: 65536 +DEAL:0:2d::n_active_cells: 65536 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 263169 +DEAL:0:2d::n_locally_owned_dofs: 263169 +DEAL:0:2d:: +DEAL:0:3d::n_levels: 1 +DEAL:0:3d::n_cells: 4096 +DEAL:0:3d::n_active_cells: 4096 +DEAL:0:3d:: +DEAL:0:3d::n_dofs: 35937 +DEAL:0:3d::n_locally_owned_dofs: 35937 +DEAL:0:3d:: diff --git a/tests/fullydistributed_grids/copy_distributed_tria_01.with_p4est=true.mpirun=7.output b/tests/fullydistributed_grids/copy_distributed_tria_01.with_p4est=true.mpirun=7.output new file mode 100644 index 0000000000..199a43f37a --- /dev/null +++ b/tests/fullydistributed_grids/copy_distributed_tria_01.with_p4est=true.mpirun=7.output @@ -0,0 +1,111 @@ + +DEAL:0:2d::n_levels: 1 +DEAL:0:2d::n_cells: 9589 +DEAL:0:2d::n_active_cells: 9589 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 38809 +DEAL:0:2d::n_locally_owned_dofs: 38809 +DEAL:0:2d:: +DEAL:0:3d::n_levels: 1 +DEAL:0:3d::n_cells: 847 +DEAL:0:3d::n_active_cells: 847 +DEAL:0:3d:: +DEAL:0:3d::n_dofs: 8023 +DEAL:0:3d::n_locally_owned_dofs: 8023 +DEAL:0:3d:: + +DEAL:1:2d::n_levels: 1 +DEAL:1:2d::n_cells: 9876 +DEAL:1:2d::n_active_cells: 9876 +DEAL:1:2d:: +DEAL:1:2d::n_dofs: 40126 +DEAL:1:2d::n_locally_owned_dofs: 40126 +DEAL:1:2d:: +DEAL:1:3d::n_levels: 1 +DEAL:1:3d::n_cells: 971 +DEAL:1:3d::n_active_cells: 971 +DEAL:1:3d:: +DEAL:1:3d::n_dofs: 9305 +DEAL:1:3d::n_locally_owned_dofs: 9305 +DEAL:1:3d:: + + +DEAL:2:2d::n_levels: 1 +DEAL:2:2d::n_cells: 9749 +DEAL:2:2d::n_active_cells: 9749 +DEAL:2:2d:: +DEAL:2:2d::n_dofs: 39513 +DEAL:2:2d::n_locally_owned_dofs: 39513 +DEAL:2:2d:: +DEAL:2:3d::n_levels: 1 +DEAL:2:3d::n_cells: 933 +DEAL:2:3d::n_active_cells: 933 +DEAL:2:3d:: +DEAL:2:3d::n_dofs: 8893 +DEAL:2:3d::n_locally_owned_dofs: 8893 +DEAL:2:3d:: + + +DEAL:3:2d::n_levels: 1 +DEAL:3:2d::n_cells: 9876 +DEAL:3:2d::n_active_cells: 9876 +DEAL:3:2d:: +DEAL:3:2d::n_dofs: 40158 +DEAL:3:2d::n_locally_owned_dofs: 40158 +DEAL:3:2d:: +DEAL:3:3d::n_levels: 1 +DEAL:3:3d::n_cells: 1082 +DEAL:3:3d::n_active_cells: 1082 +DEAL:3:3d:: +DEAL:3:3d::n_dofs: 10425 +DEAL:3:3d::n_locally_owned_dofs: 10425 +DEAL:3:3d:: + + +DEAL:4:2d::n_levels: 1 +DEAL:4:2d::n_cells: 9749 +DEAL:4:2d::n_active_cells: 9749 +DEAL:4:2d:: +DEAL:4:2d::n_dofs: 39513 +DEAL:4:2d::n_locally_owned_dofs: 39513 +DEAL:4:2d:: +DEAL:4:3d::n_levels: 1 +DEAL:4:3d::n_cells: 933 +DEAL:4:3d::n_active_cells: 933 +DEAL:4:3d:: +DEAL:4:3d::n_dofs: 8893 +DEAL:4:3d::n_locally_owned_dofs: 8893 +DEAL:4:3d:: + + +DEAL:5:2d::n_levels: 1 +DEAL:5:2d::n_cells: 9876 +DEAL:5:2d::n_active_cells: 9876 +DEAL:5:2d:: +DEAL:5:2d::n_dofs: 40126 +DEAL:5:2d::n_locally_owned_dofs: 40126 +DEAL:5:2d:: +DEAL:5:3d::n_levels: 1 +DEAL:5:3d::n_cells: 971 +DEAL:5:3d::n_active_cells: 971 +DEAL:5:3d:: +DEAL:5:3d::n_dofs: 9305 +DEAL:5:3d::n_locally_owned_dofs: 9305 +DEAL:5:3d:: + + +DEAL:6:2d::n_levels: 1 +DEAL:6:2d::n_cells: 9589 +DEAL:6:2d::n_active_cells: 9589 +DEAL:6:2d:: +DEAL:6:2d::n_dofs: 38809 +DEAL:6:2d::n_locally_owned_dofs: 38809 +DEAL:6:2d:: +DEAL:6:3d::n_levels: 1 +DEAL:6:3d::n_cells: 847 +DEAL:6:3d::n_active_cells: 847 +DEAL:6:3d:: +DEAL:6:3d::n_dofs: 8023 +DEAL:6:3d::n_locally_owned_dofs: 8023 +DEAL:6:3d:: + diff --git a/tests/fullydistributed_grids/copy_distributed_tria_02.cc b/tests/fullydistributed_grids/copy_distributed_tria_02.cc new file mode 100644 index 0000000000..0cc9c3e05f --- /dev/null +++ b/tests/fullydistributed_grids/copy_distributed_tria_02.cc @@ -0,0 +1,93 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Create a distributed triangulation with multigrid levels and copy it. + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "./tests.h" + +using namespace dealii; + +template +void +test(int n_refinements, const int n_subdivisions, MPI_Comm comm) +{ + // create pdt + parallel::distributed::Triangulation tria_pdt( + comm, + dealii::Triangulation::none, + parallel::distributed::Triangulation::construct_multigrid_hierarchy); + GridGenerator::subdivided_hyper_cube(tria_pdt, n_subdivisions); + tria_pdt.refine_global(n_refinements); + + // create instance of pft + parallel::fullydistributed::Triangulation tria_pft(comm); + + // extract relevant information form pdt + auto construction_data = parallel::fullydistributed::Utilities:: + create_construction_data_from_triangulation(tria_pdt, comm, true); + + // actually create triangulation + tria_pft.create_triangulation(construction_data); + + // test triangulation + FE_Q fe(2); + DoFHandler dof_handler(tria_pft); + dof_handler.distribute_dofs(fe); + dof_handler.distribute_mg_dofs(); + + // print statistics + print_statistics(tria_pft, true); + print_statistics(dof_handler, true); +} + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll all; + + const int dim = 2; + const MPI_Comm comm = MPI_COMM_WORLD; + + { + deallog.push("2d"); + const int n_refinements = 3; + const int n_subdivisions = 5; + test<2>(n_refinements, n_subdivisions, comm); + deallog.pop(); + } + { + deallog.push("3d"); + const int n_refinements = 3; + const int n_subdivisions = 4; + test<3>(n_refinements, n_subdivisions, comm); + deallog.pop(); + } +} diff --git a/tests/fullydistributed_grids/copy_distributed_tria_02.with_p4est=true.mpirun=1.output b/tests/fullydistributed_grids/copy_distributed_tria_02.with_p4est=true.mpirun=1.output new file mode 100644 index 0000000000..11dd095624 --- /dev/null +++ b/tests/fullydistributed_grids/copy_distributed_tria_02.with_p4est=true.mpirun=1.output @@ -0,0 +1,47 @@ + +DEAL:0:2d::n_levels: 4 +DEAL:0:2d::n_cells: 2125 +DEAL:0:2d::n_active_cells: 1600 +DEAL:0:2d::n_cells on level=0: 25 +DEAL:0:2d::n_cells on level=1: 100 +DEAL:0:2d::n_cells on level=2: 400 +DEAL:0:2d::n_cells on level=3: 1600 +DEAL:0:2d::n_active_cells on level=0: 0 +DEAL:0:2d::n_active_cells on level=1: 0 +DEAL:0:2d::n_active_cells on level=2: 0 +DEAL:0:2d::n_active_cells on level=3: 1600 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 6561 +DEAL:0:2d::n_locally_owned_dofs: 6561 +DEAL:0:2d::n_dofs on level=0: 121 +DEAL:0:2d::n_dofs on level=1: 441 +DEAL:0:2d::n_dofs on level=2: 1681 +DEAL:0:2d::n_dofs on level=3: 6561 +DEAL:0:2d::n_locally_owned_mg_dofs on level=0: 121 +DEAL:0:2d::n_locally_owned_mg_dofs on level=1: 441 +DEAL:0:2d::n_locally_owned_mg_dofs on level=2: 1681 +DEAL:0:2d::n_locally_owned_mg_dofs on level=3: 6561 +DEAL:0:2d:: +DEAL:0:3d::n_levels: 4 +DEAL:0:3d::n_cells: 37440 +DEAL:0:3d::n_active_cells: 32768 +DEAL:0:3d::n_cells on level=0: 64 +DEAL:0:3d::n_cells on level=1: 512 +DEAL:0:3d::n_cells on level=2: 4096 +DEAL:0:3d::n_cells on level=3: 32768 +DEAL:0:3d::n_active_cells on level=0: 0 +DEAL:0:3d::n_active_cells on level=1: 0 +DEAL:0:3d::n_active_cells on level=2: 0 +DEAL:0:3d::n_active_cells on level=3: 32768 +DEAL:0:3d:: +DEAL:0:3d::n_dofs: 274625 +DEAL:0:3d::n_locally_owned_dofs: 274625 +DEAL:0:3d::n_dofs on level=0: 729 +DEAL:0:3d::n_dofs on level=1: 4913 +DEAL:0:3d::n_dofs on level=2: 35937 +DEAL:0:3d::n_dofs on level=3: 274625 +DEAL:0:3d::n_locally_owned_mg_dofs on level=0: 729 +DEAL:0:3d::n_locally_owned_mg_dofs on level=1: 4913 +DEAL:0:3d::n_locally_owned_mg_dofs on level=2: 35937 +DEAL:0:3d::n_locally_owned_mg_dofs on level=3: 274625 +DEAL:0:3d:: diff --git a/tests/fullydistributed_grids/copy_distributed_tria_02.with_p4est=true.mpirun=7.output b/tests/fullydistributed_grids/copy_distributed_tria_02.with_p4est=true.mpirun=7.output new file mode 100644 index 0000000000..add9d41f85 --- /dev/null +++ b/tests/fullydistributed_grids/copy_distributed_tria_02.with_p4est=true.mpirun=7.output @@ -0,0 +1,335 @@ + +DEAL:0:2d::n_levels: 4 +DEAL:0:2d::n_cells: 437 +DEAL:0:2d::n_active_cells: 330 +DEAL:0:2d::n_cells on level=0: 9 +DEAL:0:2d::n_cells on level=1: 36 +DEAL:0:2d::n_cells on level=2: 96 +DEAL:0:2d::n_cells on level=3: 296 +DEAL:0:2d::n_active_cells on level=0: 0 +DEAL:0:2d::n_active_cells on level=1: 12 +DEAL:0:2d::n_active_cells on level=2: 22 +DEAL:0:2d::n_active_cells on level=3: 296 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 1113 +DEAL:0:2d::n_locally_owned_dofs: 1113 +DEAL:0:2d::n_dofs on level=0: 49 +DEAL:0:2d::n_dofs on level=1: 169 +DEAL:0:2d::n_dofs on level=2: 425 +DEAL:0:2d::n_dofs on level=3: 1257 +DEAL:0:2d::n_locally_owned_mg_dofs on level=0: 49 +DEAL:0:2d::n_locally_owned_mg_dofs on level=1: 169 +DEAL:0:2d::n_locally_owned_mg_dofs on level=2: 425 +DEAL:0:2d::n_locally_owned_mg_dofs on level=3: 1257 +DEAL:0:2d:: +DEAL:0:3d::n_levels: 4 +DEAL:0:3d::n_cells: 8263 +DEAL:0:3d::n_active_cells: 7234 +DEAL:0:3d::n_cells on level=0: 31 +DEAL:0:3d::n_cells on level=1: 248 +DEAL:0:3d::n_cells on level=2: 1176 +DEAL:0:3d::n_cells on level=3: 6808 +DEAL:0:3d::n_active_cells on level=0: 0 +DEAL:0:3d::n_active_cells on level=1: 101 +DEAL:0:3d::n_active_cells on level=2: 325 +DEAL:0:3d::n_active_cells on level=3: 6808 +DEAL:0:3d:: +DEAL:0:3d::n_dofs: 49815 +DEAL:0:3d::n_locally_owned_dofs: 49815 +DEAL:0:3d::n_dofs on level=0: 393 +DEAL:0:3d::n_dofs on level=1: 2521 +DEAL:0:3d::n_dofs on level=2: 10937 +DEAL:0:3d::n_dofs on level=3: 59385 +DEAL:0:3d::n_locally_owned_mg_dofs on level=0: 393 +DEAL:0:3d::n_locally_owned_mg_dofs on level=1: 2521 +DEAL:0:3d::n_locally_owned_mg_dofs on level=2: 10937 +DEAL:0:3d::n_locally_owned_mg_dofs on level=3: 59385 +DEAL:0:3d:: + +DEAL:1:2d::n_levels: 4 +DEAL:1:2d::n_cells: 566 +DEAL:1:2d::n_active_cells: 428 +DEAL:1:2d::n_cells on level=0: 14 +DEAL:1:2d::n_cells on level=1: 56 +DEAL:1:2d::n_cells on level=2: 132 +DEAL:1:2d::n_cells on level=3: 364 +DEAL:1:2d::n_active_cells on level=0: 0 +DEAL:1:2d::n_active_cells on level=1: 23 +DEAL:1:2d::n_active_cells on level=2: 41 +DEAL:1:2d::n_active_cells on level=3: 364 +DEAL:1:2d:: +DEAL:1:2d::n_dofs: 1263 +DEAL:1:2d::n_locally_owned_dofs: 1263 +DEAL:1:2d::n_dofs on level=0: 73 +DEAL:1:2d::n_dofs on level=1: 257 +DEAL:1:2d::n_dofs on level=2: 581 +DEAL:1:2d::n_dofs on level=3: 1549 +DEAL:1:2d::n_locally_owned_mg_dofs on level=0: 73 +DEAL:1:2d::n_locally_owned_mg_dofs on level=1: 257 +DEAL:1:2d::n_locally_owned_mg_dofs on level=2: 581 +DEAL:1:2d::n_locally_owned_mg_dofs on level=3: 1549 +DEAL:1:2d:: +DEAL:1:3d::n_levels: 4 +DEAL:1:3d::n_cells: 9565 +DEAL:1:3d::n_active_cells: 8374 +DEAL:1:3d::n_cells on level=0: 37 +DEAL:1:3d::n_cells on level=1: 296 +DEAL:1:3d::n_cells on level=2: 1416 +DEAL:1:3d::n_cells on level=3: 7816 +DEAL:1:3d::n_active_cells on level=0: 0 +DEAL:1:3d::n_active_cells on level=1: 119 +DEAL:1:3d::n_active_cells on level=2: 439 +DEAL:1:3d::n_active_cells on level=3: 7816 +DEAL:1:3d:: +DEAL:1:3d::n_dofs: 54905 +DEAL:1:3d::n_locally_owned_dofs: 54905 +DEAL:1:3d::n_dofs on level=0: 463 +DEAL:1:3d::n_dofs on level=1: 2989 +DEAL:1:3d::n_dofs on level=2: 13189 +DEAL:1:3d::n_dofs on level=3: 68597 +DEAL:1:3d::n_locally_owned_mg_dofs on level=0: 463 +DEAL:1:3d::n_locally_owned_mg_dofs on level=1: 2989 +DEAL:1:3d::n_locally_owned_mg_dofs on level=2: 13189 +DEAL:1:3d::n_locally_owned_mg_dofs on level=3: 68597 +DEAL:1:3d:: + + +DEAL:2:2d::n_levels: 4 +DEAL:2:2d::n_cells: 657 +DEAL:2:2d::n_active_cells: 497 +DEAL:2:2d::n_cells on level=0: 17 +DEAL:2:2d::n_cells on level=1: 68 +DEAL:2:2d::n_cells on level=2: 160 +DEAL:2:2d::n_cells on level=3: 412 +DEAL:2:2d::n_active_cells on level=0: 0 +DEAL:2:2d::n_active_cells on level=1: 28 +DEAL:2:2d::n_active_cells on level=2: 57 +DEAL:2:2d::n_active_cells on level=3: 412 +DEAL:2:2d:: +DEAL:2:2d::n_dofs: 1368 +DEAL:2:2d::n_locally_owned_dofs: 1368 +DEAL:2:2d::n_dofs on level=0: 89 +DEAL:2:2d::n_dofs on level=1: 313 +DEAL:2:2d::n_dofs on level=2: 709 +DEAL:2:2d::n_dofs on level=3: 1774 +DEAL:2:2d::n_locally_owned_mg_dofs on level=0: 89 +DEAL:2:2d::n_locally_owned_mg_dofs on level=1: 313 +DEAL:2:2d::n_locally_owned_mg_dofs on level=2: 709 +DEAL:2:2d::n_locally_owned_mg_dofs on level=3: 1774 +DEAL:2:2d:: +DEAL:2:3d::n_levels: 4 +DEAL:2:3d::n_cells: 9081 +DEAL:2:3d::n_active_cells: 7950 +DEAL:2:3d::n_cells on level=0: 33 +DEAL:2:3d::n_cells on level=1: 264 +DEAL:2:3d::n_cells on level=2: 1304 +DEAL:2:3d::n_cells on level=3: 7480 +DEAL:2:3d::n_active_cells on level=0: 0 +DEAL:2:3d::n_active_cells on level=1: 101 +DEAL:2:3d::n_active_cells on level=2: 369 +DEAL:2:3d::n_active_cells on level=3: 7480 +DEAL:2:3d:: +DEAL:2:3d::n_dofs: 53645 +DEAL:2:3d::n_locally_owned_dofs: 53645 +DEAL:2:3d::n_dofs on level=0: 413 +DEAL:2:3d::n_dofs on level=1: 2665 +DEAL:2:3d::n_dofs on level=2: 12089 +DEAL:2:3d::n_dofs on level=3: 65433 +DEAL:2:3d::n_locally_owned_mg_dofs on level=0: 413 +DEAL:2:3d::n_locally_owned_mg_dofs on level=1: 2665 +DEAL:2:3d::n_locally_owned_mg_dofs on level=2: 12089 +DEAL:2:3d::n_locally_owned_mg_dofs on level=3: 65433 +DEAL:2:3d:: + + +DEAL:3:2d::n_levels: 4 +DEAL:3:2d::n_cells: 686 +DEAL:3:2d::n_active_cells: 519 +DEAL:3:2d::n_cells on level=0: 18 +DEAL:3:2d::n_cells on level=1: 72 +DEAL:3:2d::n_cells on level=2: 164 +DEAL:3:2d::n_cells on level=3: 432 +DEAL:3:2d::n_active_cells on level=0: 0 +DEAL:3:2d::n_active_cells on level=1: 31 +DEAL:3:2d::n_active_cells on level=2: 56 +DEAL:3:2d::n_active_cells on level=3: 432 +DEAL:3:2d:: +DEAL:3:2d::n_dofs: 1413 +DEAL:3:2d::n_locally_owned_dofs: 1413 +DEAL:3:2d::n_dofs on level=0: 91 +DEAL:3:2d::n_dofs on level=1: 325 +DEAL:3:2d::n_dofs on level=2: 717 +DEAL:3:2d::n_dofs on level=3: 1837 +DEAL:3:2d::n_locally_owned_mg_dofs on level=0: 91 +DEAL:3:2d::n_locally_owned_mg_dofs on level=1: 325 +DEAL:3:2d::n_locally_owned_mg_dofs on level=2: 717 +DEAL:3:2d::n_locally_owned_mg_dofs on level=3: 1837 +DEAL:3:2d:: +DEAL:3:3d::n_levels: 4 +DEAL:3:3d::n_cells: 10750 +DEAL:3:3d::n_active_cells: 9412 +DEAL:3:3d::n_cells on level=0: 46 +DEAL:3:3d::n_cells on level=1: 368 +DEAL:3:3d::n_cells on level=2: 1680 +DEAL:3:3d::n_cells on level=3: 8656 +DEAL:3:3d::n_active_cells on level=0: 0 +DEAL:3:3d::n_active_cells on level=1: 158 +DEAL:3:3d::n_active_cells on level=2: 598 +DEAL:3:3d::n_active_cells on level=3: 8656 +DEAL:3:3d:: +DEAL:3:3d::n_dofs: 58265 +DEAL:3:3d::n_locally_owned_dofs: 58265 +DEAL:3:3d::n_dofs on level=0: 561 +DEAL:3:3d::n_dofs on level=1: 3665 +DEAL:3:3d::n_dofs on level=2: 15617 +DEAL:3:3d::n_dofs on level=3: 76129 +DEAL:3:3d::n_locally_owned_mg_dofs on level=0: 561 +DEAL:3:3d::n_locally_owned_mg_dofs on level=1: 3665 +DEAL:3:3d::n_locally_owned_mg_dofs on level=2: 15617 +DEAL:3:3d::n_locally_owned_mg_dofs on level=3: 76129 +DEAL:3:3d:: + + +DEAL:4:2d::n_levels: 4 +DEAL:4:2d::n_cells: 623 +DEAL:4:2d::n_active_cells: 471 +DEAL:4:2d::n_cells on level=0: 15 +DEAL:4:2d::n_cells on level=1: 60 +DEAL:4:2d::n_cells on level=2: 152 +DEAL:4:2d::n_cells on level=3: 396 +DEAL:4:2d::n_active_cells on level=0: 0 +DEAL:4:2d::n_active_cells on level=1: 22 +DEAL:4:2d::n_active_cells on level=2: 53 +DEAL:4:2d::n_active_cells on level=3: 396 +DEAL:4:2d:: +DEAL:4:2d::n_dofs: 1338 +DEAL:4:2d::n_locally_owned_dofs: 1338 +DEAL:4:2d::n_dofs on level=0: 79 +DEAL:4:2d::n_dofs on level=1: 277 +DEAL:4:2d::n_dofs on level=2: 673 +DEAL:4:2d::n_dofs on level=3: 1706 +DEAL:4:2d::n_locally_owned_mg_dofs on level=0: 79 +DEAL:4:2d::n_locally_owned_mg_dofs on level=1: 277 +DEAL:4:2d::n_locally_owned_mg_dofs on level=2: 673 +DEAL:4:2d::n_locally_owned_mg_dofs on level=3: 1706 +DEAL:4:2d:: +DEAL:4:3d::n_levels: 4 +DEAL:4:3d::n_cells: 9081 +DEAL:4:3d::n_active_cells: 7950 +DEAL:4:3d::n_cells on level=0: 33 +DEAL:4:3d::n_cells on level=1: 264 +DEAL:4:3d::n_cells on level=2: 1304 +DEAL:4:3d::n_cells on level=3: 7480 +DEAL:4:3d::n_active_cells on level=0: 0 +DEAL:4:3d::n_active_cells on level=1: 101 +DEAL:4:3d::n_active_cells on level=2: 369 +DEAL:4:3d::n_active_cells on level=3: 7480 +DEAL:4:3d:: +DEAL:4:3d::n_dofs: 53645 +DEAL:4:3d::n_locally_owned_dofs: 53645 +DEAL:4:3d::n_dofs on level=0: 413 +DEAL:4:3d::n_dofs on level=1: 2665 +DEAL:4:3d::n_dofs on level=2: 12089 +DEAL:4:3d::n_dofs on level=3: 65433 +DEAL:4:3d::n_locally_owned_mg_dofs on level=0: 413 +DEAL:4:3d::n_locally_owned_mg_dofs on level=1: 2665 +DEAL:4:3d::n_locally_owned_mg_dofs on level=2: 12089 +DEAL:4:3d::n_locally_owned_mg_dofs on level=3: 65433 +DEAL:4:3d:: + + +DEAL:5:2d::n_levels: 4 +DEAL:5:2d::n_cells: 582 +DEAL:5:2d::n_active_cells: 440 +DEAL:5:2d::n_cells on level=0: 14 +DEAL:5:2d::n_cells on level=1: 56 +DEAL:5:2d::n_cells on level=2: 140 +DEAL:5:2d::n_cells on level=3: 372 +DEAL:5:2d::n_active_cells on level=0: 0 +DEAL:5:2d::n_active_cells on level=1: 21 +DEAL:5:2d::n_active_cells on level=2: 47 +DEAL:5:2d::n_active_cells on level=3: 372 +DEAL:5:2d:: +DEAL:5:2d::n_dofs: 1300 +DEAL:5:2d::n_locally_owned_dofs: 1300 +DEAL:5:2d::n_dofs on level=0: 75 +DEAL:5:2d::n_dofs on level=1: 261 +DEAL:5:2d::n_dofs on level=2: 634 +DEAL:5:2d::n_dofs on level=3: 1610 +DEAL:5:2d::n_locally_owned_mg_dofs on level=0: 75 +DEAL:5:2d::n_locally_owned_mg_dofs on level=1: 261 +DEAL:5:2d::n_locally_owned_mg_dofs on level=2: 634 +DEAL:5:2d::n_locally_owned_mg_dofs on level=3: 1610 +DEAL:5:2d:: +DEAL:5:3d::n_levels: 4 +DEAL:5:3d::n_cells: 9565 +DEAL:5:3d::n_active_cells: 8374 +DEAL:5:3d::n_cells on level=0: 37 +DEAL:5:3d::n_cells on level=1: 296 +DEAL:5:3d::n_cells on level=2: 1416 +DEAL:5:3d::n_cells on level=3: 7816 +DEAL:5:3d::n_active_cells on level=0: 0 +DEAL:5:3d::n_active_cells on level=1: 119 +DEAL:5:3d::n_active_cells on level=2: 439 +DEAL:5:3d::n_active_cells on level=3: 7816 +DEAL:5:3d:: +DEAL:5:3d::n_dofs: 54905 +DEAL:5:3d::n_locally_owned_dofs: 54905 +DEAL:5:3d::n_dofs on level=0: 463 +DEAL:5:3d::n_dofs on level=1: 2989 +DEAL:5:3d::n_dofs on level=2: 13189 +DEAL:5:3d::n_dofs on level=3: 68597 +DEAL:5:3d::n_locally_owned_mg_dofs on level=0: 463 +DEAL:5:3d::n_locally_owned_mg_dofs on level=1: 2989 +DEAL:5:3d::n_locally_owned_mg_dofs on level=2: 13189 +DEAL:5:3d::n_locally_owned_mg_dofs on level=3: 68597 +DEAL:5:3d:: + + +DEAL:6:2d::n_levels: 4 +DEAL:6:2d::n_cells: 461 +DEAL:6:2d::n_active_cells: 348 +DEAL:6:2d::n_cells on level=0: 9 +DEAL:6:2d::n_cells on level=1: 36 +DEAL:6:2d::n_cells on level=2: 104 +DEAL:6:2d::n_cells on level=3: 312 +DEAL:6:2d::n_active_cells on level=0: 0 +DEAL:6:2d::n_active_cells on level=1: 10 +DEAL:6:2d::n_active_cells on level=2: 26 +DEAL:6:2d::n_active_cells on level=3: 312 +DEAL:6:2d:: +DEAL:6:2d::n_dofs: 1161 +DEAL:6:2d::n_locally_owned_dofs: 1161 +DEAL:6:2d::n_dofs on level=0: 51 +DEAL:6:2d::n_dofs on level=1: 173 +DEAL:6:2d::n_dofs on level=2: 465 +DEAL:6:2d::n_dofs on level=3: 1337 +DEAL:6:2d::n_locally_owned_mg_dofs on level=0: 51 +DEAL:6:2d::n_locally_owned_mg_dofs on level=1: 173 +DEAL:6:2d::n_locally_owned_mg_dofs on level=2: 465 +DEAL:6:2d::n_locally_owned_mg_dofs on level=3: 1337 +DEAL:6:2d:: +DEAL:6:3d::n_levels: 4 +DEAL:6:3d::n_cells: 8263 +DEAL:6:3d::n_active_cells: 7234 +DEAL:6:3d::n_cells on level=0: 31 +DEAL:6:3d::n_cells on level=1: 248 +DEAL:6:3d::n_cells on level=2: 1176 +DEAL:6:3d::n_cells on level=3: 6808 +DEAL:6:3d::n_active_cells on level=0: 0 +DEAL:6:3d::n_active_cells on level=1: 101 +DEAL:6:3d::n_active_cells on level=2: 325 +DEAL:6:3d::n_active_cells on level=3: 6808 +DEAL:6:3d:: +DEAL:6:3d::n_dofs: 49815 +DEAL:6:3d::n_locally_owned_dofs: 49815 +DEAL:6:3d::n_dofs on level=0: 393 +DEAL:6:3d::n_dofs on level=1: 2521 +DEAL:6:3d::n_dofs on level=2: 10937 +DEAL:6:3d::n_dofs on level=3: 59385 +DEAL:6:3d::n_locally_owned_mg_dofs on level=0: 393 +DEAL:6:3d::n_locally_owned_mg_dofs on level=1: 2521 +DEAL:6:3d::n_locally_owned_mg_dofs on level=2: 10937 +DEAL:6:3d::n_locally_owned_mg_dofs on level=3: 59385 +DEAL:6:3d:: + diff --git a/tests/fullydistributed_grids/copy_serial_tria_01.cc b/tests/fullydistributed_grids/copy_serial_tria_01.cc new file mode 100644 index 0000000000..67024e9863 --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_01.cc @@ -0,0 +1,88 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Create a serial triangulation and copy it. + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "./tests.h" + +using namespace dealii; + +template +void +test(int n_refinements, MPI_Comm comm) +{ + // create serial triangulation + Triangulation basetria; + GridGenerator::hyper_L(basetria); + basetria.refine_global(n_refinements); + + GridTools::partition_triangulation_zorder( + Utilities::MPI::n_mpi_processes(comm), basetria); + + // create instance of pft + parallel::fullydistributed::Triangulation tria_pft(comm); + + // extract relevant information form serial triangulation + auto construction_data = parallel::fullydistributed::Utilities:: + create_construction_data_from_triangulation(basetria, comm); + + // actually create triangulation + tria_pft.create_triangulation(construction_data); + + // test triangulation + FE_Q fe(2); + DoFHandler dof_handler(tria_pft); + dof_handler.distribute_dofs(fe); + + // print statistics + print_statistics(tria_pft); + print_statistics(dof_handler); +} + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll all; + + const int n_refinements = 3; + const MPI_Comm comm = MPI_COMM_WORLD; + + { + deallog.push("2d"); + test<2>(n_refinements, comm); + deallog.pop(); + } + { + deallog.push("3d"); + test<3>(n_refinements, comm); + deallog.pop(); + } +} diff --git a/tests/fullydistributed_grids/copy_serial_tria_01.mpirun=1.output b/tests/fullydistributed_grids/copy_serial_tria_01.mpirun=1.output new file mode 100644 index 0000000000..2a7d16a41f --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_01.mpirun=1.output @@ -0,0 +1,15 @@ + +DEAL:0:2d::n_levels: 1 +DEAL:0:2d::n_cells: 192 +DEAL:0:2d::n_active_cells: 192 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 833 +DEAL:0:2d::n_locally_owned_dofs: 833 +DEAL:0:2d:: +DEAL:0:3d::n_levels: 1 +DEAL:0:3d::n_cells: 3584 +DEAL:0:3d::n_active_cells: 3584 +DEAL:0:3d:: +DEAL:0:3d::n_dofs: 31841 +DEAL:0:3d::n_locally_owned_dofs: 31841 +DEAL:0:3d:: diff --git a/tests/fullydistributed_grids/copy_serial_tria_01.mpirun=7.output b/tests/fullydistributed_grids/copy_serial_tria_01.mpirun=7.output new file mode 100644 index 0000000000..9e4a272b43 --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_01.mpirun=7.output @@ -0,0 +1,111 @@ + +DEAL:0:2d::n_levels: 1 +DEAL:0:2d::n_cells: 41 +DEAL:0:2d::n_active_cells: 41 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 193 +DEAL:0:2d::n_locally_owned_dofs: 193 +DEAL:0:2d:: +DEAL:0:3d::n_levels: 1 +DEAL:0:3d::n_cells: 728 +DEAL:0:3d::n_active_cells: 728 +DEAL:0:3d:: +DEAL:0:3d::n_dofs: 6851 +DEAL:0:3d::n_locally_owned_dofs: 6851 +DEAL:0:3d:: + +DEAL:1:2d::n_levels: 1 +DEAL:1:2d::n_cells: 54 +DEAL:1:2d::n_active_cells: 54 +DEAL:1:2d:: +DEAL:1:2d::n_dofs: 251 +DEAL:1:2d::n_locally_owned_dofs: 251 +DEAL:1:2d:: +DEAL:1:3d::n_levels: 1 +DEAL:1:3d::n_cells: 721 +DEAL:1:3d::n_active_cells: 721 +DEAL:1:3d:: +DEAL:1:3d::n_dofs: 6795 +DEAL:1:3d::n_locally_owned_dofs: 6795 +DEAL:1:3d:: + + +DEAL:2:2d::n_levels: 1 +DEAL:2:2d::n_cells: 59 +DEAL:2:2d::n_active_cells: 59 +DEAL:2:2d:: +DEAL:2:2d::n_dofs: 279 +DEAL:2:2d::n_locally_owned_dofs: 279 +DEAL:2:2d:: +DEAL:2:3d::n_levels: 1 +DEAL:2:3d::n_cells: 721 +DEAL:2:3d::n_active_cells: 721 +DEAL:2:3d:: +DEAL:2:3d::n_dofs: 6795 +DEAL:2:3d::n_locally_owned_dofs: 6795 +DEAL:2:3d:: + + +DEAL:3:2d::n_levels: 1 +DEAL:3:2d::n_cells: 48 +DEAL:3:2d::n_active_cells: 48 +DEAL:3:2d:: +DEAL:3:2d::n_dofs: 229 +DEAL:3:2d::n_locally_owned_dofs: 229 +DEAL:3:2d:: +DEAL:3:3d::n_levels: 1 +DEAL:3:3d::n_cells: 665 +DEAL:3:3d::n_active_cells: 665 +DEAL:3:3d:: +DEAL:3:3d::n_dofs: 6347 +DEAL:3:3d::n_locally_owned_dofs: 6347 +DEAL:3:3d:: + + +DEAL:4:2d::n_levels: 1 +DEAL:4:2d::n_cells: 51 +DEAL:4:2d::n_active_cells: 51 +DEAL:4:2d:: +DEAL:4:2d::n_dofs: 248 +DEAL:4:2d::n_locally_owned_dofs: 248 +DEAL:4:2d:: +DEAL:4:3d::n_levels: 1 +DEAL:4:3d::n_cells: 721 +DEAL:4:3d::n_active_cells: 721 +DEAL:4:3d:: +DEAL:4:3d::n_dofs: 6795 +DEAL:4:3d::n_locally_owned_dofs: 6795 +DEAL:4:3d:: + + +DEAL:5:2d::n_levels: 1 +DEAL:5:2d::n_cells: 49 +DEAL:5:2d::n_active_cells: 49 +DEAL:5:2d:: +DEAL:5:2d::n_dofs: 231 +DEAL:5:2d::n_locally_owned_dofs: 231 +DEAL:5:2d:: +DEAL:5:3d::n_levels: 1 +DEAL:5:3d::n_cells: 665 +DEAL:5:3d::n_active_cells: 665 +DEAL:5:3d:: +DEAL:5:3d::n_dofs: 6347 +DEAL:5:3d::n_locally_owned_dofs: 6347 +DEAL:5:3d:: + + +DEAL:6:2d::n_levels: 1 +DEAL:6:2d::n_cells: 38 +DEAL:6:2d::n_active_cells: 38 +DEAL:6:2d:: +DEAL:6:2d::n_dofs: 179 +DEAL:6:2d::n_locally_owned_dofs: 179 +DEAL:6:2d:: +DEAL:6:3d::n_levels: 1 +DEAL:6:3d::n_cells: 665 +DEAL:6:3d::n_active_cells: 665 +DEAL:6:3d:: +DEAL:6:3d::n_dofs: 6347 +DEAL:6:3d::n_locally_owned_dofs: 6347 +DEAL:6:3d:: + diff --git a/tests/fullydistributed_grids/copy_serial_tria_02.cc b/tests/fullydistributed_grids/copy_serial_tria_02.cc new file mode 100644 index 0000000000..06257590e1 --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_02.cc @@ -0,0 +1,103 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Create a serial triangulation with multigrid levels and copy it. + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "./tests.h" + +using namespace dealii; + +template +void +test(int n_refinements, const int n_subdivisions, MPI_Comm comm) +{ + // create serial triangulation + Triangulation basetria( + Triangulation::limit_level_difference_at_vertices); + GridGenerator::subdivided_hyper_cube(basetria, n_subdivisions); + basetria.refine_global(n_refinements); + + GridTools::partition_triangulation_zorder( + Utilities::MPI::n_mpi_processes(comm), basetria); + GridTools::partition_multigrid_levels(basetria); + + // create instance of pft + parallel::fullydistributed::Triangulation tria_pft(comm); + + // extract relevant information form serial triangulation + auto construction_data = parallel::fullydistributed::Utilities:: + create_construction_data_from_triangulation(basetria, comm, true); + + // actually create triangulation + tria_pft.create_triangulation(construction_data); + + // test triangulation + FE_Q fe(2); + DoFHandler dof_handler(tria_pft); + dof_handler.distribute_dofs(fe); + dof_handler.distribute_mg_dofs(); + + // print statistics + print_statistics(tria_pft, true); + print_statistics(dof_handler, true); +} + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll all; + + const MPI_Comm comm = MPI_COMM_WORLD; + + + { + deallog.push("1d"); + const int n_refinements = 8; + const int n_subdivisions = 8; + test<1>(n_refinements, n_subdivisions, comm); + deallog.pop(); + } + { + deallog.push("2d"); + const int n_refinements = 4; + const int n_subdivisions = 8; + test<2>(n_refinements, n_subdivisions, comm); + deallog.pop(); + } + + { + deallog.push("3d"); + const int n_refinements = 3; + const int n_subdivisions = 4; + test<3>(n_refinements, n_subdivisions, comm); + deallog.pop(); + } +} diff --git a/tests/fullydistributed_grids/copy_serial_tria_02.mpirun=1.output b/tests/fullydistributed_grids/copy_serial_tria_02.mpirun=1.output new file mode 100644 index 0000000000..93c3111b81 --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_02.mpirun=1.output @@ -0,0 +1,94 @@ + +DEAL:0:1d::n_levels: 9 +DEAL:0:1d::n_cells: 4088 +DEAL:0:1d::n_active_cells: 2048 +DEAL:0:1d::n_cells on level=0: 8 +DEAL:0:1d::n_cells on level=1: 16 +DEAL:0:1d::n_cells on level=2: 32 +DEAL:0:1d::n_cells on level=3: 64 +DEAL:0:1d::n_cells on level=4: 128 +DEAL:0:1d::n_cells on level=5: 256 +DEAL:0:1d::n_cells on level=6: 512 +DEAL:0:1d::n_cells on level=7: 1024 +DEAL:0:1d::n_cells on level=8: 2048 +DEAL:0:1d::n_active_cells on level=0: 0 +DEAL:0:1d::n_active_cells on level=1: 0 +DEAL:0:1d::n_active_cells on level=2: 0 +DEAL:0:1d::n_active_cells on level=3: 0 +DEAL:0:1d::n_active_cells on level=4: 0 +DEAL:0:1d::n_active_cells on level=5: 0 +DEAL:0:1d::n_active_cells on level=6: 0 +DEAL:0:1d::n_active_cells on level=7: 0 +DEAL:0:1d::n_active_cells on level=8: 2048 +DEAL:0:1d:: +DEAL:0:1d::n_dofs: 4097 +DEAL:0:1d::n_locally_owned_dofs: 4097 +DEAL:0:1d::n_dofs on level=0: 17 +DEAL:0:1d::n_dofs on level=1: 33 +DEAL:0:1d::n_dofs on level=2: 65 +DEAL:0:1d::n_dofs on level=3: 129 +DEAL:0:1d::n_dofs on level=4: 257 +DEAL:0:1d::n_dofs on level=5: 513 +DEAL:0:1d::n_dofs on level=6: 1025 +DEAL:0:1d::n_dofs on level=7: 2049 +DEAL:0:1d::n_dofs on level=8: 4097 +DEAL:0:1d::n_locally_owned_mg_dofs on level=0: 17 +DEAL:0:1d::n_locally_owned_mg_dofs on level=1: 33 +DEAL:0:1d::n_locally_owned_mg_dofs on level=2: 65 +DEAL:0:1d::n_locally_owned_mg_dofs on level=3: 129 +DEAL:0:1d::n_locally_owned_mg_dofs on level=4: 257 +DEAL:0:1d::n_locally_owned_mg_dofs on level=5: 513 +DEAL:0:1d::n_locally_owned_mg_dofs on level=6: 1025 +DEAL:0:1d::n_locally_owned_mg_dofs on level=7: 2049 +DEAL:0:1d::n_locally_owned_mg_dofs on level=8: 4097 +DEAL:0:1d:: +DEAL:0:2d::n_levels: 5 +DEAL:0:2d::n_cells: 21824 +DEAL:0:2d::n_active_cells: 16384 +DEAL:0:2d::n_cells on level=0: 64 +DEAL:0:2d::n_cells on level=1: 256 +DEAL:0:2d::n_cells on level=2: 1024 +DEAL:0:2d::n_cells on level=3: 4096 +DEAL:0:2d::n_cells on level=4: 16384 +DEAL:0:2d::n_active_cells on level=0: 0 +DEAL:0:2d::n_active_cells on level=1: 0 +DEAL:0:2d::n_active_cells on level=2: 0 +DEAL:0:2d::n_active_cells on level=3: 0 +DEAL:0:2d::n_active_cells on level=4: 16384 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 66049 +DEAL:0:2d::n_locally_owned_dofs: 66049 +DEAL:0:2d::n_dofs on level=0: 289 +DEAL:0:2d::n_dofs on level=1: 1089 +DEAL:0:2d::n_dofs on level=2: 4225 +DEAL:0:2d::n_dofs on level=3: 16641 +DEAL:0:2d::n_dofs on level=4: 66049 +DEAL:0:2d::n_locally_owned_mg_dofs on level=0: 289 +DEAL:0:2d::n_locally_owned_mg_dofs on level=1: 1089 +DEAL:0:2d::n_locally_owned_mg_dofs on level=2: 4225 +DEAL:0:2d::n_locally_owned_mg_dofs on level=3: 16641 +DEAL:0:2d::n_locally_owned_mg_dofs on level=4: 66049 +DEAL:0:2d:: +DEAL:0:3d::n_levels: 4 +DEAL:0:3d::n_cells: 37440 +DEAL:0:3d::n_active_cells: 32768 +DEAL:0:3d::n_cells on level=0: 64 +DEAL:0:3d::n_cells on level=1: 512 +DEAL:0:3d::n_cells on level=2: 4096 +DEAL:0:3d::n_cells on level=3: 32768 +DEAL:0:3d::n_active_cells on level=0: 0 +DEAL:0:3d::n_active_cells on level=1: 0 +DEAL:0:3d::n_active_cells on level=2: 0 +DEAL:0:3d::n_active_cells on level=3: 32768 +DEAL:0:3d:: +DEAL:0:3d::n_dofs: 274625 +DEAL:0:3d::n_locally_owned_dofs: 274625 +DEAL:0:3d::n_dofs on level=0: 729 +DEAL:0:3d::n_dofs on level=1: 4913 +DEAL:0:3d::n_dofs on level=2: 35937 +DEAL:0:3d::n_dofs on level=3: 274625 +DEAL:0:3d::n_locally_owned_mg_dofs on level=0: 729 +DEAL:0:3d::n_locally_owned_mg_dofs on level=1: 4913 +DEAL:0:3d::n_locally_owned_mg_dofs on level=2: 35937 +DEAL:0:3d::n_locally_owned_mg_dofs on level=3: 274625 +DEAL:0:3d:: diff --git a/tests/fullydistributed_grids/copy_serial_tria_02.mpirun=7.output b/tests/fullydistributed_grids/copy_serial_tria_02.mpirun=7.output new file mode 100644 index 0000000000..ef7391fab1 --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_02.mpirun=7.output @@ -0,0 +1,664 @@ + +DEAL:0:1d::n_levels: 9 +DEAL:0:1d::n_cells: 609 +DEAL:0:1d::n_active_cells: 306 +DEAL:0:1d::n_cells on level=0: 3 +DEAL:0:1d::n_cells on level=1: 6 +DEAL:0:1d::n_cells on level=2: 8 +DEAL:0:1d::n_cells on level=3: 12 +DEAL:0:1d::n_cells on level=4: 22 +DEAL:0:1d::n_cells on level=5: 40 +DEAL:0:1d::n_cells on level=6: 76 +DEAL:0:1d::n_cells on level=7: 148 +DEAL:0:1d::n_cells on level=8: 294 +DEAL:0:1d::n_active_cells on level=0: 0 +DEAL:0:1d::n_active_cells on level=1: 2 +DEAL:0:1d::n_active_cells on level=2: 2 +DEAL:0:1d::n_active_cells on level=3: 1 +DEAL:0:1d::n_active_cells on level=4: 2 +DEAL:0:1d::n_active_cells on level=5: 2 +DEAL:0:1d::n_active_cells on level=6: 2 +DEAL:0:1d::n_active_cells on level=7: 1 +DEAL:0:1d::n_active_cells on level=8: 294 +DEAL:0:1d:: +DEAL:0:1d::n_dofs: 587 +DEAL:0:1d::n_locally_owned_dofs: 587 +DEAL:0:1d::n_dofs on level=0: 7 +DEAL:0:1d::n_dofs on level=1: 13 +DEAL:0:1d::n_dofs on level=2: 17 +DEAL:0:1d::n_dofs on level=3: 25 +DEAL:0:1d::n_dofs on level=4: 45 +DEAL:0:1d::n_dofs on level=5: 81 +DEAL:0:1d::n_dofs on level=6: 153 +DEAL:0:1d::n_dofs on level=7: 297 +DEAL:0:1d::n_dofs on level=8: 589 +DEAL:0:1d::n_locally_owned_mg_dofs on level=0: 7 +DEAL:0:1d::n_locally_owned_mg_dofs on level=1: 13 +DEAL:0:1d::n_locally_owned_mg_dofs on level=2: 17 +DEAL:0:1d::n_locally_owned_mg_dofs on level=3: 25 +DEAL:0:1d::n_locally_owned_mg_dofs on level=4: 45 +DEAL:0:1d::n_locally_owned_mg_dofs on level=5: 81 +DEAL:0:1d::n_locally_owned_mg_dofs on level=6: 153 +DEAL:0:1d::n_locally_owned_mg_dofs on level=7: 297 +DEAL:0:1d::n_locally_owned_mg_dofs on level=8: 589 +DEAL:0:1d:: +DEAL:0:2d::n_levels: 5 +DEAL:0:2d::n_cells: 3570 +DEAL:0:2d::n_active_cells: 2682 +DEAL:0:2d::n_cells on level=0: 18 +DEAL:0:2d::n_cells on level=1: 72 +DEAL:0:2d::n_cells on level=2: 208 +DEAL:0:2d::n_cells on level=3: 704 +DEAL:0:2d::n_cells on level=4: 2568 +DEAL:0:2d::n_active_cells on level=0: 0 +DEAL:0:2d::n_active_cells on level=1: 20 +DEAL:0:2d::n_active_cells on level=2: 32 +DEAL:0:2d::n_active_cells on level=3: 62 +DEAL:0:2d::n_active_cells on level=4: 2568 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 10041 +DEAL:0:2d::n_locally_owned_dofs: 10041 +DEAL:0:2d::n_dofs on level=0: 91 +DEAL:0:2d::n_dofs on level=1: 325 +DEAL:0:2d::n_dofs on level=2: 897 +DEAL:0:2d::n_dofs on level=3: 2937 +DEAL:0:2d::n_dofs on level=4: 10505 +DEAL:0:2d::n_locally_owned_mg_dofs on level=0: 91 +DEAL:0:2d::n_locally_owned_mg_dofs on level=1: 325 +DEAL:0:2d::n_locally_owned_mg_dofs on level=2: 897 +DEAL:0:2d::n_locally_owned_mg_dofs on level=3: 2937 +DEAL:0:2d::n_locally_owned_mg_dofs on level=4: 10505 +DEAL:0:2d:: +DEAL:0:3d::n_levels: 4 +DEAL:0:3d::n_cells: 8263 +DEAL:0:3d::n_active_cells: 7234 +DEAL:0:3d::n_cells on level=0: 31 +DEAL:0:3d::n_cells on level=1: 248 +DEAL:0:3d::n_cells on level=2: 1176 +DEAL:0:3d::n_cells on level=3: 6808 +DEAL:0:3d::n_active_cells on level=0: 0 +DEAL:0:3d::n_active_cells on level=1: 101 +DEAL:0:3d::n_active_cells on level=2: 325 +DEAL:0:3d::n_active_cells on level=3: 6808 +DEAL:0:3d:: +DEAL:0:3d::n_dofs: 49815 +DEAL:0:3d::n_locally_owned_dofs: 49815 +DEAL:0:3d::n_dofs on level=0: 393 +DEAL:0:3d::n_dofs on level=1: 2521 +DEAL:0:3d::n_dofs on level=2: 10937 +DEAL:0:3d::n_dofs on level=3: 59385 +DEAL:0:3d::n_locally_owned_mg_dofs on level=0: 393 +DEAL:0:3d::n_locally_owned_mg_dofs on level=1: 2521 +DEAL:0:3d::n_locally_owned_mg_dofs on level=2: 10937 +DEAL:0:3d::n_locally_owned_mg_dofs on level=3: 59385 +DEAL:0:3d:: + +DEAL:1:1d::n_levels: 9 +DEAL:1:1d::n_cells: 627 +DEAL:1:1d::n_active_cells: 315 +DEAL:1:1d::n_cells on level=0: 3 +DEAL:1:1d::n_cells on level=1: 6 +DEAL:1:1d::n_cells on level=2: 8 +DEAL:1:1d::n_cells on level=3: 14 +DEAL:1:1d::n_cells on level=4: 24 +DEAL:1:1d::n_cells on level=5: 42 +DEAL:1:1d::n_cells on level=6: 80 +DEAL:1:1d::n_cells on level=7: 152 +DEAL:1:1d::n_cells on level=8: 298 +DEAL:1:1d::n_active_cells on level=0: 0 +DEAL:1:1d::n_active_cells on level=1: 2 +DEAL:1:1d::n_active_cells on level=2: 1 +DEAL:1:1d::n_active_cells on level=3: 2 +DEAL:1:1d::n_active_cells on level=4: 3 +DEAL:1:1d::n_active_cells on level=5: 2 +DEAL:1:1d::n_active_cells on level=6: 4 +DEAL:1:1d::n_active_cells on level=7: 3 +DEAL:1:1d::n_active_cells on level=8: 298 +DEAL:1:1d:: +DEAL:1:1d::n_dofs: 593 +DEAL:1:1d::n_locally_owned_dofs: 593 +DEAL:1:1d::n_dofs on level=0: 7 +DEAL:1:1d::n_dofs on level=1: 13 +DEAL:1:1d::n_dofs on level=2: 17 +DEAL:1:1d::n_dofs on level=3: 29 +DEAL:1:1d::n_dofs on level=4: 49 +DEAL:1:1d::n_dofs on level=5: 85 +DEAL:1:1d::n_dofs on level=6: 161 +DEAL:1:1d::n_dofs on level=7: 305 +DEAL:1:1d::n_dofs on level=8: 597 +DEAL:1:1d::n_locally_owned_mg_dofs on level=0: 7 +DEAL:1:1d::n_locally_owned_mg_dofs on level=1: 13 +DEAL:1:1d::n_locally_owned_mg_dofs on level=2: 17 +DEAL:1:1d::n_locally_owned_mg_dofs on level=3: 29 +DEAL:1:1d::n_locally_owned_mg_dofs on level=4: 49 +DEAL:1:1d::n_locally_owned_mg_dofs on level=5: 85 +DEAL:1:1d::n_locally_owned_mg_dofs on level=6: 161 +DEAL:1:1d::n_locally_owned_mg_dofs on level=7: 305 +DEAL:1:1d::n_locally_owned_mg_dofs on level=8: 597 +DEAL:1:1d:: +DEAL:1:2d::n_levels: 5 +DEAL:1:2d::n_cells: 4142 +DEAL:1:2d::n_active_cells: 3113 +DEAL:1:2d::n_cells on level=0: 26 +DEAL:1:2d::n_cells on level=1: 104 +DEAL:1:2d::n_cells on level=2: 284 +DEAL:1:2d::n_cells on level=3: 860 +DEAL:1:2d::n_cells on level=4: 2868 +DEAL:1:2d::n_active_cells on level=0: 0 +DEAL:1:2d::n_active_cells on level=1: 33 +DEAL:1:2d::n_active_cells on level=2: 69 +DEAL:1:2d::n_active_cells on level=3: 143 +DEAL:1:2d::n_active_cells on level=4: 2868 +DEAL:1:2d:: +DEAL:1:2d::n_dofs: 10718 +DEAL:1:2d::n_locally_owned_dofs: 10718 +DEAL:1:2d::n_dofs on level=0: 129 +DEAL:1:2d::n_dofs on level=1: 465 +DEAL:1:2d::n_dofs on level=2: 1225 +DEAL:1:2d::n_dofs on level=3: 3609 +DEAL:1:2d::n_dofs on level=4: 11802 +DEAL:1:2d::n_locally_owned_mg_dofs on level=0: 129 +DEAL:1:2d::n_locally_owned_mg_dofs on level=1: 465 +DEAL:1:2d::n_locally_owned_mg_dofs on level=2: 1225 +DEAL:1:2d::n_locally_owned_mg_dofs on level=3: 3609 +DEAL:1:2d::n_locally_owned_mg_dofs on level=4: 11802 +DEAL:1:2d:: +DEAL:1:3d::n_levels: 4 +DEAL:1:3d::n_cells: 9565 +DEAL:1:3d::n_active_cells: 8374 +DEAL:1:3d::n_cells on level=0: 37 +DEAL:1:3d::n_cells on level=1: 296 +DEAL:1:3d::n_cells on level=2: 1416 +DEAL:1:3d::n_cells on level=3: 7816 +DEAL:1:3d::n_active_cells on level=0: 0 +DEAL:1:3d::n_active_cells on level=1: 119 +DEAL:1:3d::n_active_cells on level=2: 439 +DEAL:1:3d::n_active_cells on level=3: 7816 +DEAL:1:3d:: +DEAL:1:3d::n_dofs: 54905 +DEAL:1:3d::n_locally_owned_dofs: 54905 +DEAL:1:3d::n_dofs on level=0: 463 +DEAL:1:3d::n_dofs on level=1: 2989 +DEAL:1:3d::n_dofs on level=2: 13189 +DEAL:1:3d::n_dofs on level=3: 68597 +DEAL:1:3d::n_locally_owned_mg_dofs on level=0: 463 +DEAL:1:3d::n_locally_owned_mg_dofs on level=1: 2989 +DEAL:1:3d::n_locally_owned_mg_dofs on level=2: 13189 +DEAL:1:3d::n_locally_owned_mg_dofs on level=3: 68597 +DEAL:1:3d:: + + +DEAL:2:1d::n_levels: 9 +DEAL:2:1d::n_cells: 623 +DEAL:2:1d::n_active_cells: 313 +DEAL:2:1d::n_cells on level=0: 3 +DEAL:2:1d::n_cells on level=1: 6 +DEAL:2:1d::n_cells on level=2: 8 +DEAL:2:1d::n_cells on level=3: 14 +DEAL:2:1d::n_cells on level=4: 24 +DEAL:2:1d::n_cells on level=5: 42 +DEAL:2:1d::n_cells on level=6: 78 +DEAL:2:1d::n_cells on level=7: 152 +DEAL:2:1d::n_cells on level=8: 296 +DEAL:2:1d::n_active_cells on level=0: 0 +DEAL:2:1d::n_active_cells on level=1: 2 +DEAL:2:1d::n_active_cells on level=2: 1 +DEAL:2:1d::n_active_cells on level=3: 2 +DEAL:2:1d::n_active_cells on level=4: 3 +DEAL:2:1d::n_active_cells on level=5: 3 +DEAL:2:1d::n_active_cells on level=6: 2 +DEAL:2:1d::n_active_cells on level=7: 4 +DEAL:2:1d::n_active_cells on level=8: 296 +DEAL:2:1d:: +DEAL:2:1d::n_dofs: 589 +DEAL:2:1d::n_locally_owned_dofs: 589 +DEAL:2:1d::n_dofs on level=0: 7 +DEAL:2:1d::n_dofs on level=1: 13 +DEAL:2:1d::n_dofs on level=2: 17 +DEAL:2:1d::n_dofs on level=3: 29 +DEAL:2:1d::n_dofs on level=4: 49 +DEAL:2:1d::n_dofs on level=5: 85 +DEAL:2:1d::n_dofs on level=6: 157 +DEAL:2:1d::n_dofs on level=7: 305 +DEAL:2:1d::n_dofs on level=8: 593 +DEAL:2:1d::n_locally_owned_mg_dofs on level=0: 7 +DEAL:2:1d::n_locally_owned_mg_dofs on level=1: 13 +DEAL:2:1d::n_locally_owned_mg_dofs on level=2: 17 +DEAL:2:1d::n_locally_owned_mg_dofs on level=3: 29 +DEAL:2:1d::n_locally_owned_mg_dofs on level=4: 49 +DEAL:2:1d::n_locally_owned_mg_dofs on level=5: 85 +DEAL:2:1d::n_locally_owned_mg_dofs on level=6: 157 +DEAL:2:1d::n_locally_owned_mg_dofs on level=7: 305 +DEAL:2:1d::n_locally_owned_mg_dofs on level=8: 593 +DEAL:2:1d:: +DEAL:2:2d::n_levels: 5 +DEAL:2:2d::n_cells: 3870 +DEAL:2:2d::n_active_cells: 2908 +DEAL:2:2d::n_cells on level=0: 22 +DEAL:2:2d::n_cells on level=1: 88 +DEAL:2:2d::n_cells on level=2: 248 +DEAL:2:2d::n_cells on level=3: 784 +DEAL:2:2d::n_cells on level=4: 2728 +DEAL:2:2d::n_active_cells on level=0: 0 +DEAL:2:2d::n_active_cells on level=1: 26 +DEAL:2:2d::n_active_cells on level=2: 52 +DEAL:2:2d::n_active_cells on level=3: 102 +DEAL:2:2d::n_active_cells on level=4: 2728 +DEAL:2:2d:: +DEAL:2:2d::n_dofs: 10393 +DEAL:2:2d::n_locally_owned_dofs: 10393 +DEAL:2:2d::n_dofs on level=0: 109 +DEAL:2:2d::n_dofs on level=1: 393 +DEAL:2:2d::n_dofs on level=2: 1065 +DEAL:2:2d::n_dofs on level=3: 3273 +DEAL:2:2d::n_dofs on level=4: 11177 +DEAL:2:2d::n_locally_owned_mg_dofs on level=0: 109 +DEAL:2:2d::n_locally_owned_mg_dofs on level=1: 393 +DEAL:2:2d::n_locally_owned_mg_dofs on level=2: 1065 +DEAL:2:2d::n_locally_owned_mg_dofs on level=3: 3273 +DEAL:2:2d::n_locally_owned_mg_dofs on level=4: 11177 +DEAL:2:2d:: +DEAL:2:3d::n_levels: 4 +DEAL:2:3d::n_cells: 9081 +DEAL:2:3d::n_active_cells: 7950 +DEAL:2:3d::n_cells on level=0: 33 +DEAL:2:3d::n_cells on level=1: 264 +DEAL:2:3d::n_cells on level=2: 1304 +DEAL:2:3d::n_cells on level=3: 7480 +DEAL:2:3d::n_active_cells on level=0: 0 +DEAL:2:3d::n_active_cells on level=1: 101 +DEAL:2:3d::n_active_cells on level=2: 369 +DEAL:2:3d::n_active_cells on level=3: 7480 +DEAL:2:3d:: +DEAL:2:3d::n_dofs: 53645 +DEAL:2:3d::n_locally_owned_dofs: 53645 +DEAL:2:3d::n_dofs on level=0: 413 +DEAL:2:3d::n_dofs on level=1: 2665 +DEAL:2:3d::n_dofs on level=2: 12089 +DEAL:2:3d::n_dofs on level=3: 65433 +DEAL:2:3d::n_locally_owned_mg_dofs on level=0: 413 +DEAL:2:3d::n_locally_owned_mg_dofs on level=1: 2665 +DEAL:2:3d::n_locally_owned_mg_dofs on level=2: 12089 +DEAL:2:3d::n_locally_owned_mg_dofs on level=3: 65433 +DEAL:2:3d:: + + +DEAL:3:1d::n_levels: 9 +DEAL:3:1d::n_cells: 631 +DEAL:3:1d::n_active_cells: 317 +DEAL:3:1d::n_cells on level=0: 3 +DEAL:3:1d::n_cells on level=1: 6 +DEAL:3:1d::n_cells on level=2: 10 +DEAL:3:1d::n_cells on level=3: 16 +DEAL:3:1d::n_cells on level=4: 24 +DEAL:3:1d::n_cells on level=5: 44 +DEAL:3:1d::n_cells on level=6: 80 +DEAL:3:1d::n_cells on level=7: 152 +DEAL:3:1d::n_cells on level=8: 296 +DEAL:3:1d::n_active_cells on level=0: 0 +DEAL:3:1d::n_active_cells on level=1: 1 +DEAL:3:1d::n_active_cells on level=2: 2 +DEAL:3:1d::n_active_cells on level=3: 4 +DEAL:3:1d::n_active_cells on level=4: 2 +DEAL:3:1d::n_active_cells on level=5: 4 +DEAL:3:1d::n_active_cells on level=6: 4 +DEAL:3:1d::n_active_cells on level=7: 4 +DEAL:3:1d::n_active_cells on level=8: 296 +DEAL:3:1d:: +DEAL:3:1d::n_dofs: 589 +DEAL:3:1d::n_locally_owned_dofs: 589 +DEAL:3:1d::n_dofs on level=0: 7 +DEAL:3:1d::n_dofs on level=1: 13 +DEAL:3:1d::n_dofs on level=2: 21 +DEAL:3:1d::n_dofs on level=3: 33 +DEAL:3:1d::n_dofs on level=4: 49 +DEAL:3:1d::n_dofs on level=5: 89 +DEAL:3:1d::n_dofs on level=6: 161 +DEAL:3:1d::n_dofs on level=7: 305 +DEAL:3:1d::n_dofs on level=8: 593 +DEAL:3:1d::n_locally_owned_mg_dofs on level=0: 7 +DEAL:3:1d::n_locally_owned_mg_dofs on level=1: 13 +DEAL:3:1d::n_locally_owned_mg_dofs on level=2: 21 +DEAL:3:1d::n_locally_owned_mg_dofs on level=3: 33 +DEAL:3:1d::n_locally_owned_mg_dofs on level=4: 49 +DEAL:3:1d::n_locally_owned_mg_dofs on level=5: 89 +DEAL:3:1d::n_locally_owned_mg_dofs on level=6: 161 +DEAL:3:1d::n_locally_owned_mg_dofs on level=7: 305 +DEAL:3:1d::n_locally_owned_mg_dofs on level=8: 593 +DEAL:3:1d:: +DEAL:3:2d::n_levels: 5 +DEAL:3:2d::n_cells: 4177 +DEAL:3:2d::n_active_cells: 3140 +DEAL:3:2d::n_cells on level=0: 29 +DEAL:3:2d::n_cells on level=1: 116 +DEAL:3:2d::n_cells on level=2: 296 +DEAL:3:2d::n_cells on level=3: 864 +DEAL:3:2d::n_cells on level=4: 2872 +DEAL:3:2d::n_active_cells on level=0: 0 +DEAL:3:2d::n_active_cells on level=1: 42 +DEAL:3:2d::n_active_cells on level=2: 80 +DEAL:3:2d::n_active_cells on level=3: 146 +DEAL:3:2d::n_active_cells on level=4: 2872 +DEAL:3:2d:: +DEAL:3:2d::n_dofs: 10750 +DEAL:3:2d::n_locally_owned_dofs: 10750 +DEAL:3:2d::n_dofs on level=0: 145 +DEAL:3:2d::n_dofs on level=1: 521 +DEAL:3:2d::n_dofs on level=2: 1290 +DEAL:3:2d::n_dofs on level=3: 3642 +DEAL:3:2d::n_dofs on level=4: 11834 +DEAL:3:2d::n_locally_owned_mg_dofs on level=0: 145 +DEAL:3:2d::n_locally_owned_mg_dofs on level=1: 521 +DEAL:3:2d::n_locally_owned_mg_dofs on level=2: 1290 +DEAL:3:2d::n_locally_owned_mg_dofs on level=3: 3642 +DEAL:3:2d::n_locally_owned_mg_dofs on level=4: 11834 +DEAL:3:2d:: +DEAL:3:3d::n_levels: 4 +DEAL:3:3d::n_cells: 10750 +DEAL:3:3d::n_active_cells: 9412 +DEAL:3:3d::n_cells on level=0: 46 +DEAL:3:3d::n_cells on level=1: 368 +DEAL:3:3d::n_cells on level=2: 1680 +DEAL:3:3d::n_cells on level=3: 8656 +DEAL:3:3d::n_active_cells on level=0: 0 +DEAL:3:3d::n_active_cells on level=1: 158 +DEAL:3:3d::n_active_cells on level=2: 598 +DEAL:3:3d::n_active_cells on level=3: 8656 +DEAL:3:3d:: +DEAL:3:3d::n_dofs: 58265 +DEAL:3:3d::n_locally_owned_dofs: 58265 +DEAL:3:3d::n_dofs on level=0: 561 +DEAL:3:3d::n_dofs on level=1: 3665 +DEAL:3:3d::n_dofs on level=2: 15617 +DEAL:3:3d::n_dofs on level=3: 76129 +DEAL:3:3d::n_locally_owned_mg_dofs on level=0: 561 +DEAL:3:3d::n_locally_owned_mg_dofs on level=1: 3665 +DEAL:3:3d::n_locally_owned_mg_dofs on level=2: 15617 +DEAL:3:3d::n_locally_owned_mg_dofs on level=3: 76129 +DEAL:3:3d:: + + +DEAL:4:1d::n_levels: 9 +DEAL:4:1d::n_cells: 625 +DEAL:4:1d::n_active_cells: 314 +DEAL:4:1d::n_cells on level=0: 3 +DEAL:4:1d::n_cells on level=1: 6 +DEAL:4:1d::n_cells on level=2: 10 +DEAL:4:1d::n_cells on level=3: 14 +DEAL:4:1d::n_cells on level=4: 24 +DEAL:4:1d::n_cells on level=5: 42 +DEAL:4:1d::n_cells on level=6: 78 +DEAL:4:1d::n_cells on level=7: 152 +DEAL:4:1d::n_cells on level=8: 296 +DEAL:4:1d::n_active_cells on level=0: 0 +DEAL:4:1d::n_active_cells on level=1: 1 +DEAL:4:1d::n_active_cells on level=2: 3 +DEAL:4:1d::n_active_cells on level=3: 2 +DEAL:4:1d::n_active_cells on level=4: 3 +DEAL:4:1d::n_active_cells on level=5: 3 +DEAL:4:1d::n_active_cells on level=6: 2 +DEAL:4:1d::n_active_cells on level=7: 4 +DEAL:4:1d::n_active_cells on level=8: 296 +DEAL:4:1d:: +DEAL:4:1d::n_dofs: 589 +DEAL:4:1d::n_locally_owned_dofs: 589 +DEAL:4:1d::n_dofs on level=0: 7 +DEAL:4:1d::n_dofs on level=1: 13 +DEAL:4:1d::n_dofs on level=2: 21 +DEAL:4:1d::n_dofs on level=3: 29 +DEAL:4:1d::n_dofs on level=4: 49 +DEAL:4:1d::n_dofs on level=5: 85 +DEAL:4:1d::n_dofs on level=6: 157 +DEAL:4:1d::n_dofs on level=7: 305 +DEAL:4:1d::n_dofs on level=8: 593 +DEAL:4:1d::n_locally_owned_mg_dofs on level=0: 7 +DEAL:4:1d::n_locally_owned_mg_dofs on level=1: 13 +DEAL:4:1d::n_locally_owned_mg_dofs on level=2: 21 +DEAL:4:1d::n_locally_owned_mg_dofs on level=3: 29 +DEAL:4:1d::n_locally_owned_mg_dofs on level=4: 49 +DEAL:4:1d::n_locally_owned_mg_dofs on level=5: 85 +DEAL:4:1d::n_locally_owned_mg_dofs on level=6: 157 +DEAL:4:1d::n_locally_owned_mg_dofs on level=7: 305 +DEAL:4:1d::n_locally_owned_mg_dofs on level=8: 593 +DEAL:4:1d:: +DEAL:4:2d::n_levels: 5 +DEAL:4:2d::n_cells: 3870 +DEAL:4:2d::n_active_cells: 2908 +DEAL:4:2d::n_cells on level=0: 22 +DEAL:4:2d::n_cells on level=1: 88 +DEAL:4:2d::n_cells on level=2: 248 +DEAL:4:2d::n_cells on level=3: 784 +DEAL:4:2d::n_cells on level=4: 2728 +DEAL:4:2d::n_active_cells on level=0: 0 +DEAL:4:2d::n_active_cells on level=1: 26 +DEAL:4:2d::n_active_cells on level=2: 52 +DEAL:4:2d::n_active_cells on level=3: 102 +DEAL:4:2d::n_active_cells on level=4: 2728 +DEAL:4:2d:: +DEAL:4:2d::n_dofs: 10393 +DEAL:4:2d::n_locally_owned_dofs: 10393 +DEAL:4:2d::n_dofs on level=0: 109 +DEAL:4:2d::n_dofs on level=1: 393 +DEAL:4:2d::n_dofs on level=2: 1065 +DEAL:4:2d::n_dofs on level=3: 3273 +DEAL:4:2d::n_dofs on level=4: 11177 +DEAL:4:2d::n_locally_owned_mg_dofs on level=0: 109 +DEAL:4:2d::n_locally_owned_mg_dofs on level=1: 393 +DEAL:4:2d::n_locally_owned_mg_dofs on level=2: 1065 +DEAL:4:2d::n_locally_owned_mg_dofs on level=3: 3273 +DEAL:4:2d::n_locally_owned_mg_dofs on level=4: 11177 +DEAL:4:2d:: +DEAL:4:3d::n_levels: 4 +DEAL:4:3d::n_cells: 9081 +DEAL:4:3d::n_active_cells: 7950 +DEAL:4:3d::n_cells on level=0: 33 +DEAL:4:3d::n_cells on level=1: 264 +DEAL:4:3d::n_cells on level=2: 1304 +DEAL:4:3d::n_cells on level=3: 7480 +DEAL:4:3d::n_active_cells on level=0: 0 +DEAL:4:3d::n_active_cells on level=1: 101 +DEAL:4:3d::n_active_cells on level=2: 369 +DEAL:4:3d::n_active_cells on level=3: 7480 +DEAL:4:3d:: +DEAL:4:3d::n_dofs: 53645 +DEAL:4:3d::n_locally_owned_dofs: 53645 +DEAL:4:3d::n_dofs on level=0: 413 +DEAL:4:3d::n_dofs on level=1: 2665 +DEAL:4:3d::n_dofs on level=2: 12089 +DEAL:4:3d::n_dofs on level=3: 65433 +DEAL:4:3d::n_locally_owned_mg_dofs on level=0: 413 +DEAL:4:3d::n_locally_owned_mg_dofs on level=1: 2665 +DEAL:4:3d::n_locally_owned_mg_dofs on level=2: 12089 +DEAL:4:3d::n_locally_owned_mg_dofs on level=3: 65433 +DEAL:4:3d:: + + +DEAL:5:1d::n_levels: 9 +DEAL:5:1d::n_cells: 631 +DEAL:5:1d::n_active_cells: 317 +DEAL:5:1d::n_cells on level=0: 3 +DEAL:5:1d::n_cells on level=1: 6 +DEAL:5:1d::n_cells on level=2: 10 +DEAL:5:1d::n_cells on level=3: 16 +DEAL:5:1d::n_cells on level=4: 24 +DEAL:5:1d::n_cells on level=5: 42 +DEAL:5:1d::n_cells on level=6: 80 +DEAL:5:1d::n_cells on level=7: 152 +DEAL:5:1d::n_cells on level=8: 298 +DEAL:5:1d::n_active_cells on level=0: 0 +DEAL:5:1d::n_active_cells on level=1: 1 +DEAL:5:1d::n_active_cells on level=2: 2 +DEAL:5:1d::n_active_cells on level=3: 4 +DEAL:5:1d::n_active_cells on level=4: 3 +DEAL:5:1d::n_active_cells on level=5: 2 +DEAL:5:1d::n_active_cells on level=6: 4 +DEAL:5:1d::n_active_cells on level=7: 3 +DEAL:5:1d::n_active_cells on level=8: 298 +DEAL:5:1d:: +DEAL:5:1d::n_dofs: 593 +DEAL:5:1d::n_locally_owned_dofs: 593 +DEAL:5:1d::n_dofs on level=0: 7 +DEAL:5:1d::n_dofs on level=1: 13 +DEAL:5:1d::n_dofs on level=2: 21 +DEAL:5:1d::n_dofs on level=3: 33 +DEAL:5:1d::n_dofs on level=4: 49 +DEAL:5:1d::n_dofs on level=5: 85 +DEAL:5:1d::n_dofs on level=6: 161 +DEAL:5:1d::n_dofs on level=7: 305 +DEAL:5:1d::n_dofs on level=8: 597 +DEAL:5:1d::n_locally_owned_mg_dofs on level=0: 7 +DEAL:5:1d::n_locally_owned_mg_dofs on level=1: 13 +DEAL:5:1d::n_locally_owned_mg_dofs on level=2: 21 +DEAL:5:1d::n_locally_owned_mg_dofs on level=3: 33 +DEAL:5:1d::n_locally_owned_mg_dofs on level=4: 49 +DEAL:5:1d::n_locally_owned_mg_dofs on level=5: 85 +DEAL:5:1d::n_locally_owned_mg_dofs on level=6: 161 +DEAL:5:1d::n_locally_owned_mg_dofs on level=7: 305 +DEAL:5:1d::n_locally_owned_mg_dofs on level=8: 597 +DEAL:5:1d:: +DEAL:5:2d::n_levels: 5 +DEAL:5:2d::n_cells: 4146 +DEAL:5:2d::n_active_cells: 3116 +DEAL:5:2d::n_cells on level=0: 26 +DEAL:5:2d::n_cells on level=1: 104 +DEAL:5:2d::n_cells on level=2: 288 +DEAL:5:2d::n_cells on level=3: 860 +DEAL:5:2d::n_cells on level=4: 2868 +DEAL:5:2d::n_active_cells on level=0: 0 +DEAL:5:2d::n_active_cells on level=1: 32 +DEAL:5:2d::n_active_cells on level=2: 73 +DEAL:5:2d::n_active_cells on level=3: 143 +DEAL:5:2d::n_active_cells on level=4: 2868 +DEAL:5:2d:: +DEAL:5:2d::n_dofs: 10718 +DEAL:5:2d::n_locally_owned_dofs: 10718 +DEAL:5:2d::n_dofs on level=0: 129 +DEAL:5:2d::n_dofs on level=1: 465 +DEAL:5:2d::n_dofs on level=2: 1241 +DEAL:5:2d::n_dofs on level=3: 3609 +DEAL:5:2d::n_dofs on level=4: 11802 +DEAL:5:2d::n_locally_owned_mg_dofs on level=0: 129 +DEAL:5:2d::n_locally_owned_mg_dofs on level=1: 465 +DEAL:5:2d::n_locally_owned_mg_dofs on level=2: 1241 +DEAL:5:2d::n_locally_owned_mg_dofs on level=3: 3609 +DEAL:5:2d::n_locally_owned_mg_dofs on level=4: 11802 +DEAL:5:2d:: +DEAL:5:3d::n_levels: 4 +DEAL:5:3d::n_cells: 9565 +DEAL:5:3d::n_active_cells: 8374 +DEAL:5:3d::n_cells on level=0: 37 +DEAL:5:3d::n_cells on level=1: 296 +DEAL:5:3d::n_cells on level=2: 1416 +DEAL:5:3d::n_cells on level=3: 7816 +DEAL:5:3d::n_active_cells on level=0: 0 +DEAL:5:3d::n_active_cells on level=1: 119 +DEAL:5:3d::n_active_cells on level=2: 439 +DEAL:5:3d::n_active_cells on level=3: 7816 +DEAL:5:3d:: +DEAL:5:3d::n_dofs: 54905 +DEAL:5:3d::n_locally_owned_dofs: 54905 +DEAL:5:3d::n_dofs on level=0: 463 +DEAL:5:3d::n_dofs on level=1: 2989 +DEAL:5:3d::n_dofs on level=2: 13189 +DEAL:5:3d::n_dofs on level=3: 68597 +DEAL:5:3d::n_locally_owned_mg_dofs on level=0: 463 +DEAL:5:3d::n_locally_owned_mg_dofs on level=1: 2989 +DEAL:5:3d::n_locally_owned_mg_dofs on level=2: 13189 +DEAL:5:3d::n_locally_owned_mg_dofs on level=3: 68597 +DEAL:5:3d:: + + +DEAL:6:1d::n_levels: 9 +DEAL:6:1d::n_cells: 606 +DEAL:6:1d::n_active_cells: 304 +DEAL:6:1d::n_cells on level=0: 2 +DEAL:6:1d::n_cells on level=1: 4 +DEAL:6:1d::n_cells on level=2: 8 +DEAL:6:1d::n_cells on level=3: 12 +DEAL:6:1d::n_cells on level=4: 22 +DEAL:6:1d::n_cells on level=5: 40 +DEAL:6:1d::n_cells on level=6: 76 +DEAL:6:1d::n_cells on level=7: 148 +DEAL:6:1d::n_cells on level=8: 294 +DEAL:6:1d::n_active_cells on level=0: 0 +DEAL:6:1d::n_active_cells on level=1: 0 +DEAL:6:1d::n_active_cells on level=2: 2 +DEAL:6:1d::n_active_cells on level=3: 1 +DEAL:6:1d::n_active_cells on level=4: 2 +DEAL:6:1d::n_active_cells on level=5: 2 +DEAL:6:1d::n_active_cells on level=6: 2 +DEAL:6:1d::n_active_cells on level=7: 1 +DEAL:6:1d::n_active_cells on level=8: 294 +DEAL:6:1d:: +DEAL:6:1d::n_dofs: 587 +DEAL:6:1d::n_locally_owned_dofs: 587 +DEAL:6:1d::n_dofs on level=0: 5 +DEAL:6:1d::n_dofs on level=1: 9 +DEAL:6:1d::n_dofs on level=2: 17 +DEAL:6:1d::n_dofs on level=3: 25 +DEAL:6:1d::n_dofs on level=4: 45 +DEAL:6:1d::n_dofs on level=5: 81 +DEAL:6:1d::n_dofs on level=6: 153 +DEAL:6:1d::n_dofs on level=7: 297 +DEAL:6:1d::n_dofs on level=8: 589 +DEAL:6:1d::n_locally_owned_mg_dofs on level=0: 5 +DEAL:6:1d::n_locally_owned_mg_dofs on level=1: 9 +DEAL:6:1d::n_locally_owned_mg_dofs on level=2: 17 +DEAL:6:1d::n_locally_owned_mg_dofs on level=3: 25 +DEAL:6:1d::n_locally_owned_mg_dofs on level=4: 45 +DEAL:6:1d::n_locally_owned_mg_dofs on level=5: 81 +DEAL:6:1d::n_locally_owned_mg_dofs on level=6: 153 +DEAL:6:1d::n_locally_owned_mg_dofs on level=7: 297 +DEAL:6:1d::n_locally_owned_mg_dofs on level=8: 589 +DEAL:6:1d:: +DEAL:6:2d::n_levels: 5 +DEAL:6:2d::n_cells: 3565 +DEAL:6:2d::n_active_cells: 2678 +DEAL:6:2d::n_cells on level=0: 17 +DEAL:6:2d::n_cells on level=1: 68 +DEAL:6:2d::n_cells on level=2: 208 +DEAL:6:2d::n_cells on level=3: 704 +DEAL:6:2d::n_cells on level=4: 2568 +DEAL:6:2d::n_active_cells on level=0: 0 +DEAL:6:2d::n_active_cells on level=1: 16 +DEAL:6:2d::n_active_cells on level=2: 32 +DEAL:6:2d::n_active_cells on level=3: 62 +DEAL:6:2d::n_active_cells on level=4: 2568 +DEAL:6:2d:: +DEAL:6:2d::n_dofs: 10041 +DEAL:6:2d::n_locally_owned_dofs: 10041 +DEAL:6:2d::n_dofs on level=0: 87 +DEAL:6:2d::n_dofs on level=1: 309 +DEAL:6:2d::n_dofs on level=2: 897 +DEAL:6:2d::n_dofs on level=3: 2937 +DEAL:6:2d::n_dofs on level=4: 10505 +DEAL:6:2d::n_locally_owned_mg_dofs on level=0: 87 +DEAL:6:2d::n_locally_owned_mg_dofs on level=1: 309 +DEAL:6:2d::n_locally_owned_mg_dofs on level=2: 897 +DEAL:6:2d::n_locally_owned_mg_dofs on level=3: 2937 +DEAL:6:2d::n_locally_owned_mg_dofs on level=4: 10505 +DEAL:6:2d:: +DEAL:6:3d::n_levels: 4 +DEAL:6:3d::n_cells: 8263 +DEAL:6:3d::n_active_cells: 7234 +DEAL:6:3d::n_cells on level=0: 31 +DEAL:6:3d::n_cells on level=1: 248 +DEAL:6:3d::n_cells on level=2: 1176 +DEAL:6:3d::n_cells on level=3: 6808 +DEAL:6:3d::n_active_cells on level=0: 0 +DEAL:6:3d::n_active_cells on level=1: 101 +DEAL:6:3d::n_active_cells on level=2: 325 +DEAL:6:3d::n_active_cells on level=3: 6808 +DEAL:6:3d:: +DEAL:6:3d::n_dofs: 49815 +DEAL:6:3d::n_locally_owned_dofs: 49815 +DEAL:6:3d::n_dofs on level=0: 393 +DEAL:6:3d::n_dofs on level=1: 2521 +DEAL:6:3d::n_dofs on level=2: 10937 +DEAL:6:3d::n_dofs on level=3: 59385 +DEAL:6:3d::n_locally_owned_mg_dofs on level=0: 393 +DEAL:6:3d::n_locally_owned_mg_dofs on level=1: 2521 +DEAL:6:3d::n_locally_owned_mg_dofs on level=2: 10937 +DEAL:6:3d::n_locally_owned_mg_dofs on level=3: 59385 +DEAL:6:3d:: + diff --git a/tests/fullydistributed_grids/copy_serial_tria_03.cc b/tests/fullydistributed_grids/copy_serial_tria_03.cc new file mode 100644 index 0000000000..78dd545b51 --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_03.cc @@ -0,0 +1,115 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Create a serial triangulation with manifold and hanging nodes and copy it. + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include "./tests.h" + +using namespace dealii; + +template +void +test(int n_refinements, const int n_subdivisions, MPI_Comm comm) +{ + // create serial triangulation + Triangulation basetria( + Triangulation::limit_level_difference_at_vertices); + + + const Point center(1, 0); + const double inner_radius = 0.5, outer_radius = 1.0; + GridGenerator::hyper_shell( + basetria, center, inner_radius, outer_radius, n_subdivisions); + // basetria.reset_all_manifolds (); + for (int step = 0; step < n_refinements; ++step) + { + for (auto &cell : basetria.active_cell_iterators()) + { + // if(cell->is_locally_owned ()) + for (unsigned int v = 0; v < GeometryInfo<2>::vertices_per_cell; ++v) + { + const double distance_from_center = + center.distance(cell->vertex(v)); + if (std::fabs(distance_from_center - inner_radius) < 1e-10) + { + cell->set_refine_flag(); + break; + } + } + } + basetria.execute_coarsening_and_refinement(); + } + + GridTools::partition_triangulation_zorder( + Utilities::MPI::n_mpi_processes(comm), basetria); + // if(n_refinements!=0) + GridTools::partition_multigrid_levels(basetria); + + // create instance of pft + parallel::fullydistributed::Triangulation tria_pft(comm); + + tria_pft.set_manifold(0, SphericalManifold(center)); + + // extract relevant information form pdt + auto construction_data = parallel::fullydistributed::Utilities:: + create_construction_data_from_triangulation(basetria, comm, true); + + // actually create triangulation + tria_pft.create_triangulation(construction_data); + + + // test triangulation + FE_Q fe(2); + DoFHandler dof_handler(tria_pft); + dof_handler.distribute_dofs(fe); + dof_handler.distribute_mg_dofs(); + + // print statistics + print_statistics(tria_pft, true); + print_statistics(dof_handler, true); +} + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll all; + + const MPI_Comm comm = MPI_COMM_WORLD; + + { + deallog.push("2d"); + const int n_refinements = 4; + const int n_subdivisions = 8; + test<2>(n_refinements, n_subdivisions, comm); + deallog.pop(); + } +} diff --git a/tests/fullydistributed_grids/copy_serial_tria_03.mpirun=1.output b/tests/fullydistributed_grids/copy_serial_tria_03.mpirun=1.output new file mode 100644 index 0000000000..61defb35c7 --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_03.mpirun=1.output @@ -0,0 +1,28 @@ + +DEAL:0:2d::n_levels: 5 +DEAL:0:2d::n_cells: 488 +DEAL:0:2d::n_active_cells: 368 +DEAL:0:2d::n_cells on level=0: 8 +DEAL:0:2d::n_cells on level=1: 32 +DEAL:0:2d::n_cells on level=2: 64 +DEAL:0:2d::n_cells on level=3: 128 +DEAL:0:2d::n_cells on level=4: 256 +DEAL:0:2d::n_active_cells on level=0: 0 +DEAL:0:2d::n_active_cells on level=1: 16 +DEAL:0:2d::n_active_cells on level=2: 32 +DEAL:0:2d::n_active_cells on level=3: 64 +DEAL:0:2d::n_active_cells on level=4: 256 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 1840 +DEAL:0:2d::n_locally_owned_dofs: 1840 +DEAL:0:2d::n_dofs on level=0: 48 +DEAL:0:2d::n_dofs on level=1: 160 +DEAL:0:2d::n_dofs on level=2: 320 +DEAL:0:2d::n_dofs on level=3: 640 +DEAL:0:2d::n_dofs on level=4: 1280 +DEAL:0:2d::n_locally_owned_mg_dofs on level=0: 48 +DEAL:0:2d::n_locally_owned_mg_dofs on level=1: 160 +DEAL:0:2d::n_locally_owned_mg_dofs on level=2: 320 +DEAL:0:2d::n_locally_owned_mg_dofs on level=3: 640 +DEAL:0:2d::n_locally_owned_mg_dofs on level=4: 1280 +DEAL:0:2d:: diff --git a/tests/fullydistributed_grids/copy_serial_tria_03.mpirun=7.output b/tests/fullydistributed_grids/copy_serial_tria_03.mpirun=7.output new file mode 100644 index 0000000000..5c3d876201 --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_03.mpirun=7.output @@ -0,0 +1,202 @@ + +DEAL:0:2d::n_levels: 5 +DEAL:0:2d::n_cells: 108 +DEAL:0:2d::n_active_cells: 82 +DEAL:0:2d::n_cells on level=0: 4 +DEAL:0:2d::n_cells on level=1: 16 +DEAL:0:2d::n_cells on level=2: 20 +DEAL:0:2d::n_cells on level=3: 28 +DEAL:0:2d::n_cells on level=4: 40 +DEAL:0:2d::n_active_cells on level=0: 0 +DEAL:0:2d::n_active_cells on level=1: 11 +DEAL:0:2d::n_active_cells on level=2: 13 +DEAL:0:2d::n_active_cells on level=3: 18 +DEAL:0:2d::n_active_cells on level=4: 40 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 331 +DEAL:0:2d::n_locally_owned_dofs: 331 +DEAL:0:2d::n_dofs on level=0: 27 +DEAL:0:2d::n_dofs on level=1: 85 +DEAL:0:2d::n_dofs on level=2: 105 +DEAL:0:2d::n_dofs on level=3: 145 +DEAL:0:2d::n_dofs on level=4: 205 +DEAL:0:2d::n_locally_owned_mg_dofs on level=0: 27 +DEAL:0:2d::n_locally_owned_mg_dofs on level=1: 85 +DEAL:0:2d::n_locally_owned_mg_dofs on level=2: 105 +DEAL:0:2d::n_locally_owned_mg_dofs on level=3: 145 +DEAL:0:2d::n_locally_owned_mg_dofs on level=4: 205 +DEAL:0:2d:: + +DEAL:1:2d::n_levels: 5 +DEAL:1:2d::n_cells: 145 +DEAL:1:2d::n_active_cells: 110 +DEAL:1:2d::n_cells on level=0: 5 +DEAL:1:2d::n_cells on level=1: 20 +DEAL:1:2d::n_cells on level=2: 28 +DEAL:1:2d::n_cells on level=3: 36 +DEAL:1:2d::n_cells on level=4: 56 +DEAL:1:2d::n_active_cells on level=0: 0 +DEAL:1:2d::n_active_cells on level=1: 13 +DEAL:1:2d::n_active_cells on level=2: 19 +DEAL:1:2d::n_active_cells on level=3: 22 +DEAL:1:2d::n_active_cells on level=4: 56 +DEAL:1:2d:: +DEAL:1:2d::n_dofs: 424 +DEAL:1:2d::n_locally_owned_dofs: 424 +DEAL:1:2d::n_dofs on level=0: 33 +DEAL:1:2d::n_dofs on level=1: 105 +DEAL:1:2d::n_dofs on level=2: 150 +DEAL:1:2d::n_dofs on level=3: 190 +DEAL:1:2d::n_dofs on level=4: 290 +DEAL:1:2d::n_locally_owned_mg_dofs on level=0: 33 +DEAL:1:2d::n_locally_owned_mg_dofs on level=1: 105 +DEAL:1:2d::n_locally_owned_mg_dofs on level=2: 150 +DEAL:1:2d::n_locally_owned_mg_dofs on level=3: 190 +DEAL:1:2d::n_locally_owned_mg_dofs on level=4: 290 +DEAL:1:2d:: + + +DEAL:2:2d::n_levels: 5 +DEAL:2:2d::n_cells: 137 +DEAL:2:2d::n_active_cells: 104 +DEAL:2:2d::n_cells on level=0: 5 +DEAL:2:2d::n_cells on level=1: 20 +DEAL:2:2d::n_cells on level=2: 24 +DEAL:2:2d::n_cells on level=3: 36 +DEAL:2:2d::n_cells on level=4: 52 +DEAL:2:2d::n_active_cells on level=0: 0 +DEAL:2:2d::n_active_cells on level=1: 14 +DEAL:2:2d::n_active_cells on level=2: 15 +DEAL:2:2d::n_active_cells on level=3: 23 +DEAL:2:2d::n_active_cells on level=4: 52 +DEAL:2:2d:: +DEAL:2:2d::n_dofs: 405 +DEAL:2:2d::n_locally_owned_dofs: 405 +DEAL:2:2d::n_dofs on level=0: 33 +DEAL:2:2d::n_dofs on level=1: 105 +DEAL:2:2d::n_dofs on level=2: 130 +DEAL:2:2d::n_dofs on level=3: 190 +DEAL:2:2d::n_dofs on level=4: 270 +DEAL:2:2d::n_locally_owned_mg_dofs on level=0: 33 +DEAL:2:2d::n_locally_owned_mg_dofs on level=1: 105 +DEAL:2:2d::n_locally_owned_mg_dofs on level=2: 130 +DEAL:2:2d::n_locally_owned_mg_dofs on level=3: 190 +DEAL:2:2d::n_locally_owned_mg_dofs on level=4: 270 +DEAL:2:2d:: + + +DEAL:3:2d::n_levels: 5 +DEAL:3:2d::n_cells: 107 +DEAL:3:2d::n_active_cells: 81 +DEAL:3:2d::n_cells on level=0: 3 +DEAL:3:2d::n_cells on level=1: 12 +DEAL:3:2d::n_cells on level=2: 20 +DEAL:3:2d::n_cells on level=3: 28 +DEAL:3:2d::n_cells on level=4: 44 +DEAL:3:2d::n_active_cells on level=0: 0 +DEAL:3:2d::n_active_cells on level=1: 7 +DEAL:3:2d::n_active_cells on level=2: 13 +DEAL:3:2d::n_active_cells on level=3: 17 +DEAL:3:2d::n_active_cells on level=4: 44 +DEAL:3:2d:: +DEAL:3:2d::n_dofs: 338 +DEAL:3:2d::n_locally_owned_dofs: 338 +DEAL:3:2d::n_dofs on level=0: 21 +DEAL:3:2d::n_dofs on level=1: 65 +DEAL:3:2d::n_dofs on level=2: 105 +DEAL:3:2d::n_dofs on level=3: 145 +DEAL:3:2d::n_dofs on level=4: 225 +DEAL:3:2d::n_locally_owned_mg_dofs on level=0: 21 +DEAL:3:2d::n_locally_owned_mg_dofs on level=1: 65 +DEAL:3:2d::n_locally_owned_mg_dofs on level=2: 105 +DEAL:3:2d::n_locally_owned_mg_dofs on level=3: 145 +DEAL:3:2d::n_locally_owned_mg_dofs on level=4: 225 +DEAL:3:2d:: + + +DEAL:4:2d::n_levels: 5 +DEAL:4:2d::n_cells: 141 +DEAL:4:2d::n_active_cells: 107 +DEAL:4:2d::n_cells on level=0: 5 +DEAL:4:2d::n_cells on level=1: 20 +DEAL:4:2d::n_cells on level=2: 28 +DEAL:4:2d::n_cells on level=3: 36 +DEAL:4:2d::n_cells on level=4: 52 +DEAL:4:2d::n_active_cells on level=0: 0 +DEAL:4:2d::n_active_cells on level=1: 13 +DEAL:4:2d::n_active_cells on level=2: 19 +DEAL:4:2d::n_active_cells on level=3: 23 +DEAL:4:2d::n_active_cells on level=4: 52 +DEAL:4:2d:: +DEAL:4:2d::n_dofs: 392 +DEAL:4:2d::n_locally_owned_dofs: 392 +DEAL:4:2d::n_dofs on level=0: 33 +DEAL:4:2d::n_dofs on level=1: 105 +DEAL:4:2d::n_dofs on level=2: 150 +DEAL:4:2d::n_dofs on level=3: 190 +DEAL:4:2d::n_dofs on level=4: 270 +DEAL:4:2d::n_locally_owned_mg_dofs on level=0: 33 +DEAL:4:2d::n_locally_owned_mg_dofs on level=1: 105 +DEAL:4:2d::n_locally_owned_mg_dofs on level=2: 150 +DEAL:4:2d::n_locally_owned_mg_dofs on level=3: 190 +DEAL:4:2d::n_locally_owned_mg_dofs on level=4: 270 +DEAL:4:2d:: + + +DEAL:5:2d::n_levels: 5 +DEAL:5:2d::n_cells: 145 +DEAL:5:2d::n_active_cells: 110 +DEAL:5:2d::n_cells on level=0: 5 +DEAL:5:2d::n_cells on level=1: 20 +DEAL:5:2d::n_cells on level=2: 28 +DEAL:5:2d::n_cells on level=3: 40 +DEAL:5:2d::n_cells on level=4: 52 +DEAL:5:2d::n_active_cells on level=0: 0 +DEAL:5:2d::n_active_cells on level=1: 13 +DEAL:5:2d::n_active_cells on level=2: 18 +DEAL:5:2d::n_active_cells on level=3: 27 +DEAL:5:2d::n_active_cells on level=4: 52 +DEAL:5:2d:: +DEAL:5:2d::n_dofs: 391 +DEAL:5:2d::n_locally_owned_dofs: 391 +DEAL:5:2d::n_dofs on level=0: 33 +DEAL:5:2d::n_dofs on level=1: 105 +DEAL:5:2d::n_dofs on level=2: 150 +DEAL:5:2d::n_dofs on level=3: 210 +DEAL:5:2d::n_dofs on level=4: 270 +DEAL:5:2d::n_locally_owned_mg_dofs on level=0: 33 +DEAL:5:2d::n_locally_owned_mg_dofs on level=1: 105 +DEAL:5:2d::n_locally_owned_mg_dofs on level=2: 150 +DEAL:5:2d::n_locally_owned_mg_dofs on level=3: 210 +DEAL:5:2d::n_locally_owned_mg_dofs on level=4: 270 +DEAL:5:2d:: + + +DEAL:6:2d::n_levels: 5 +DEAL:6:2d::n_cells: 111 +DEAL:6:2d::n_active_cells: 84 +DEAL:6:2d::n_cells on level=0: 3 +DEAL:6:2d::n_cells on level=1: 12 +DEAL:6:2d::n_cells on level=2: 20 +DEAL:6:2d::n_cells on level=3: 28 +DEAL:6:2d::n_cells on level=4: 48 +DEAL:6:2d::n_active_cells on level=0: 0 +DEAL:6:2d::n_active_cells on level=1: 7 +DEAL:6:2d::n_active_cells on level=2: 13 +DEAL:6:2d::n_active_cells on level=3: 16 +DEAL:6:2d::n_active_cells on level=4: 48 +DEAL:6:2d:: +DEAL:6:2d::n_dofs: 346 +DEAL:6:2d::n_locally_owned_dofs: 346 +DEAL:6:2d::n_dofs on level=0: 21 +DEAL:6:2d::n_dofs on level=1: 65 +DEAL:6:2d::n_dofs on level=2: 105 +DEAL:6:2d::n_dofs on level=3: 145 +DEAL:6:2d::n_dofs on level=4: 245 +DEAL:6:2d::n_locally_owned_mg_dofs on level=0: 21 +DEAL:6:2d::n_locally_owned_mg_dofs on level=1: 65 +DEAL:6:2d::n_locally_owned_mg_dofs on level=2: 105 +DEAL:6:2d::n_locally_owned_mg_dofs on level=3: 145 +DEAL:6:2d::n_locally_owned_mg_dofs on level=4: 245 +DEAL:6:2d:: + diff --git a/tests/fullydistributed_grids/copy_serial_tria_04.cc b/tests/fullydistributed_grids/copy_serial_tria_04.cc new file mode 100644 index 0000000000..86dcf04392 --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_04.cc @@ -0,0 +1,129 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Create a serial triangulation with periodic face in x-direction and copy it. + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "./tests.h" + +using namespace dealii; + +template +void +test(const int n_refinements, const int n_subdivisions, MPI_Comm comm) +{ + const double left = 0; + const double right = 1; + + auto add_periodicy = [&](dealii::Triangulation &tria) { + std::vector< + GridTools::PeriodicFacePair::cell_iterator>> + periodic_faces; + auto cell = tria.begin(); + auto endc = tria.end(); + for (; cell != endc; ++cell) + for (unsigned int face_number = 0; + face_number < GeometryInfo::faces_per_cell; + ++face_number) + if (std::fabs(cell->face(face_number)->center()(0) - left) < 1e-12) + cell->face(face_number)->set_all_boundary_ids(1); + else if (std::fabs(cell->face(face_number)->center()(0) - right) < + 1e-12) + cell->face(face_number)->set_all_boundary_ids(2); + + GridTools::collect_periodic_faces(tria, 1, 2, 0, periodic_faces); + + tria.add_periodicity(periodic_faces); + }; + + // create serial triangulation + Triangulation basetria; + GridGenerator::subdivided_hyper_cube(basetria, n_subdivisions); + // new: add periodicy on serial mesh + add_periodicy(basetria); + basetria.refine_global(n_refinements); + + GridTools::partition_triangulation_zorder( + Utilities::MPI::n_mpi_processes(comm), basetria); + + // create instance of pft + parallel::fullydistributed::Triangulation tria_pft(comm); + + // extract relevant information form serial triangulation + auto construction_data = parallel::fullydistributed::Utilities:: + create_construction_data_from_triangulation(basetria, comm); + + // actually create triangulation + tria_pft.create_triangulation(construction_data); + + // new: add periodicy on fullydistributed mesh (!!!) + add_periodicy(tria_pft); + + // test triangulation + FE_Q fe(2); + DoFHandler dof_handler(tria_pft); + dof_handler.distribute_dofs(fe); + + // print statistics + print_statistics(tria_pft); + print_statistics(dof_handler); +} + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll all; + + const MPI_Comm comm = MPI_COMM_WORLD; + + { + deallog.push("1d"); + const int n_refinements = 4; + const int n_subdivisions = 8; + test<1>(n_refinements, n_subdivisions, comm); + deallog.pop(); + } + + { + deallog.push("2d"); + const int n_refinements = 4; + const int n_subdivisions = 8; + test<2>(n_refinements, n_subdivisions, comm); + deallog.pop(); + } + + { + deallog.push("2d"); + const int n_refinements = 3; + const int n_subdivisions = 4; + test<3>(n_refinements, n_subdivisions, comm); + deallog.pop(); + } +} diff --git a/tests/fullydistributed_grids/copy_serial_tria_04.mpirun=1.output b/tests/fullydistributed_grids/copy_serial_tria_04.mpirun=1.output new file mode 100644 index 0000000000..05c0b2ee75 --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_04.mpirun=1.output @@ -0,0 +1,22 @@ + +DEAL:0:1d::n_levels: 1 +DEAL:0:1d::n_cells: 128 +DEAL:0:1d::n_active_cells: 128 +DEAL:0:1d:: +DEAL:0:1d::n_dofs: 257 +DEAL:0:1d::n_locally_owned_dofs: 257 +DEAL:0:1d:: +DEAL:0:2d::n_levels: 1 +DEAL:0:2d::n_cells: 16384 +DEAL:0:2d::n_active_cells: 16384 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 66049 +DEAL:0:2d::n_locally_owned_dofs: 66049 +DEAL:0:2d:: +DEAL:0:2d::n_levels: 1 +DEAL:0:2d::n_cells: 32768 +DEAL:0:2d::n_active_cells: 32768 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 274625 +DEAL:0:2d::n_locally_owned_dofs: 274625 +DEAL:0:2d:: diff --git a/tests/fullydistributed_grids/copy_serial_tria_04.mpirun=7.output b/tests/fullydistributed_grids/copy_serial_tria_04.mpirun=7.output new file mode 100644 index 0000000000..dd196bd0ba --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_04.mpirun=7.output @@ -0,0 +1,160 @@ + +DEAL:0:1d::n_levels: 1 +DEAL:0:1d::n_cells: 20 +DEAL:0:1d::n_active_cells: 20 +DEAL:0:1d:: +DEAL:0:1d::n_dofs: 42 +DEAL:0:1d::n_locally_owned_dofs: 42 +DEAL:0:1d:: +DEAL:0:2d::n_levels: 1 +DEAL:0:2d::n_cells: 2502 +DEAL:0:2d::n_active_cells: 2502 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 10338 +DEAL:0:2d::n_locally_owned_dofs: 10338 +DEAL:0:2d:: +DEAL:0:2d::n_levels: 1 +DEAL:0:2d::n_cells: 5968 +DEAL:0:2d::n_active_cells: 5968 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 53441 +DEAL:0:2d::n_locally_owned_dofs: 53441 +DEAL:0:2d:: + +DEAL:1:1d::n_levels: 1 +DEAL:1:1d::n_cells: 20 +DEAL:1:1d::n_active_cells: 20 +DEAL:1:1d:: +DEAL:1:1d::n_dofs: 41 +DEAL:1:1d::n_locally_owned_dofs: 41 +DEAL:1:1d:: +DEAL:1:2d::n_levels: 1 +DEAL:1:2d::n_cells: 2618 +DEAL:1:2d::n_active_cells: 2618 +DEAL:1:2d:: +DEAL:1:2d::n_dofs: 10829 +DEAL:1:2d::n_locally_owned_dofs: 10829 +DEAL:1:2d:: +DEAL:1:2d::n_levels: 1 +DEAL:1:2d::n_cells: 6556 +DEAL:1:2d::n_active_cells: 6556 +DEAL:1:2d:: +DEAL:1:2d::n_dofs: 59555 +DEAL:1:2d::n_locally_owned_dofs: 59555 +DEAL:1:2d:: + + +DEAL:2:1d::n_levels: 1 +DEAL:2:1d::n_cells: 20 +DEAL:2:1d::n_active_cells: 20 +DEAL:2:1d:: +DEAL:2:1d::n_dofs: 41 +DEAL:2:1d::n_locally_owned_dofs: 41 +DEAL:2:1d:: +DEAL:2:2d::n_levels: 1 +DEAL:2:2d::n_cells: 2566 +DEAL:2:2d::n_active_cells: 2566 +DEAL:2:2d:: +DEAL:2:2d::n_dofs: 10594 +DEAL:2:2d::n_locally_owned_dofs: 10594 +DEAL:2:2d:: +DEAL:2:2d::n_levels: 1 +DEAL:2:2d::n_cells: 6304 +DEAL:2:2d::n_active_cells: 6304 +DEAL:2:2d:: +DEAL:2:2d::n_dofs: 56601 +DEAL:2:2d::n_locally_owned_dofs: 56601 +DEAL:2:2d:: + + +DEAL:3:1d::n_levels: 1 +DEAL:3:1d::n_cells: 22 +DEAL:3:1d::n_active_cells: 22 +DEAL:3:1d:: +DEAL:3:1d::n_dofs: 45 +DEAL:3:1d::n_locally_owned_dofs: 45 +DEAL:3:1d:: +DEAL:3:2d::n_levels: 1 +DEAL:3:2d::n_cells: 2668 +DEAL:3:2d::n_active_cells: 2668 +DEAL:3:2d:: +DEAL:3:2d::n_dofs: 11134 +DEAL:3:2d::n_locally_owned_dofs: 11134 +DEAL:3:2d:: +DEAL:3:2d::n_levels: 1 +DEAL:3:2d::n_cells: 6968 +DEAL:3:2d::n_active_cells: 6968 +DEAL:3:2d:: +DEAL:3:2d::n_dofs: 63785 +DEAL:3:2d::n_locally_owned_dofs: 63785 +DEAL:3:2d:: + + +DEAL:4:1d::n_levels: 1 +DEAL:4:1d::n_cells: 20 +DEAL:4:1d::n_active_cells: 20 +DEAL:4:1d:: +DEAL:4:1d::n_dofs: 41 +DEAL:4:1d::n_locally_owned_dofs: 41 +DEAL:4:1d:: +DEAL:4:2d::n_levels: 1 +DEAL:4:2d::n_cells: 2566 +DEAL:4:2d::n_active_cells: 2566 +DEAL:4:2d:: +DEAL:4:2d::n_dofs: 10594 +DEAL:4:2d::n_locally_owned_dofs: 10594 +DEAL:4:2d:: +DEAL:4:2d::n_levels: 1 +DEAL:4:2d::n_cells: 6304 +DEAL:4:2d::n_active_cells: 6304 +DEAL:4:2d:: +DEAL:4:2d::n_dofs: 56601 +DEAL:4:2d::n_locally_owned_dofs: 56601 +DEAL:4:2d:: + + +DEAL:5:1d::n_levels: 1 +DEAL:5:1d::n_cells: 20 +DEAL:5:1d::n_active_cells: 20 +DEAL:5:1d:: +DEAL:5:1d::n_dofs: 41 +DEAL:5:1d::n_locally_owned_dofs: 41 +DEAL:5:1d:: +DEAL:5:2d::n_levels: 1 +DEAL:5:2d::n_cells: 2618 +DEAL:5:2d::n_active_cells: 2618 +DEAL:5:2d:: +DEAL:5:2d::n_dofs: 10829 +DEAL:5:2d::n_locally_owned_dofs: 10829 +DEAL:5:2d:: +DEAL:5:2d::n_levels: 1 +DEAL:5:2d::n_cells: 6556 +DEAL:5:2d::n_active_cells: 6556 +DEAL:5:2d:: +DEAL:5:2d::n_dofs: 59555 +DEAL:5:2d::n_locally_owned_dofs: 59555 +DEAL:5:2d:: + + +DEAL:6:1d::n_levels: 1 +DEAL:6:1d::n_cells: 20 +DEAL:6:1d::n_active_cells: 20 +DEAL:6:1d:: +DEAL:6:1d::n_dofs: 42 +DEAL:6:1d::n_locally_owned_dofs: 42 +DEAL:6:1d:: +DEAL:6:2d::n_levels: 1 +DEAL:6:2d::n_cells: 2502 +DEAL:6:2d::n_active_cells: 2502 +DEAL:6:2d:: +DEAL:6:2d::n_dofs: 10338 +DEAL:6:2d::n_locally_owned_dofs: 10338 +DEAL:6:2d:: +DEAL:6:2d::n_levels: 1 +DEAL:6:2d::n_cells: 5968 +DEAL:6:2d::n_active_cells: 5968 +DEAL:6:2d:: +DEAL:6:2d::n_dofs: 53441 +DEAL:6:2d::n_locally_owned_dofs: 53441 +DEAL:6:2d:: + diff --git a/tests/fullydistributed_grids/copy_serial_tria_05.cc b/tests/fullydistributed_grids/copy_serial_tria_05.cc new file mode 100644 index 0000000000..67521b23d0 --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_05.cc @@ -0,0 +1,102 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Create a serial triangulation with a few cells (so that there are processes +// which do not get any cells) and copy it. + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "./tests.h" + +using namespace dealii; + +template +void +test(int n_refinements, const int n_subdivisions, MPI_Comm comm) +{ + // create create serial triangulation + Triangulation basetria( + Triangulation::limit_level_difference_at_vertices); + GridGenerator::subdivided_hyper_cube(basetria, n_subdivisions); + basetria.refine_global(n_refinements); + + GridTools::partition_triangulation_zorder( + Utilities::MPI::n_mpi_processes(comm), basetria); + GridTools::partition_multigrid_levels(basetria); + + // create instance of pft + parallel::fullydistributed::Triangulation tria_pft(comm); + + // extract relevant information form serial triangulation + auto construction_data = parallel::fullydistributed::Utilities:: + create_construction_data_from_triangulation(basetria, comm, true); + + // actually create triangulation + tria_pft.create_triangulation(construction_data); + + // test triangulation + FE_Q fe(2); + DoFHandler dof_handler(tria_pft); + dof_handler.distribute_dofs(fe); + dof_handler.distribute_mg_dofs(); + + // print statistics + print_statistics(tria_pft); + print_statistics(dof_handler); +} + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll all; + + const MPI_Comm comm = MPI_COMM_WORLD; + + { + deallog.push("1d"); + const int n_refinements = 1; + const int n_subdivisions = 1; + test<1>(n_refinements, n_subdivisions, comm); + deallog.pop(); + } + { + deallog.push("2d"); + const int n_refinements = 1; + const int n_subdivisions = 1; + test<2>(n_refinements, n_subdivisions, comm); + deallog.pop(); + } + { + deallog.push("3d"); + const int n_refinements = 1; + const int n_subdivisions = 1; + test<3>(n_refinements, n_subdivisions, comm); + deallog.pop(); + } +} diff --git a/tests/fullydistributed_grids/copy_serial_tria_05.mpirun=9.output b/tests/fullydistributed_grids/copy_serial_tria_05.mpirun=9.output new file mode 100644 index 0000000000..d54cacf8f4 --- /dev/null +++ b/tests/fullydistributed_grids/copy_serial_tria_05.mpirun=9.output @@ -0,0 +1,206 @@ + +DEAL:0:1d::n_levels: 1 +DEAL:0:1d::n_cells: 1 +DEAL:0:1d::n_active_cells: 1 +DEAL:0:1d:: +DEAL:0:1d::n_dofs: 0 +DEAL:0:1d::n_locally_owned_dofs: 0 +DEAL:0:1d:: +DEAL:0:2d::n_levels: 1 +DEAL:0:2d::n_cells: 1 +DEAL:0:2d::n_active_cells: 1 +DEAL:0:2d:: +DEAL:0:2d::n_dofs: 0 +DEAL:0:2d::n_locally_owned_dofs: 0 +DEAL:0:2d:: +DEAL:0:3d::n_levels: 1 +DEAL:0:3d::n_cells: 1 +DEAL:0:3d::n_active_cells: 1 +DEAL:0:3d:: +DEAL:0:3d::n_dofs: 0 +DEAL:0:3d::n_locally_owned_dofs: 0 +DEAL:0:3d:: + +DEAL:1:1d::n_levels: 1 +DEAL:1:1d::n_cells: 1 +DEAL:1:1d::n_active_cells: 1 +DEAL:1:1d:: +DEAL:1:1d::n_dofs: 0 +DEAL:1:1d::n_locally_owned_dofs: 0 +DEAL:1:1d:: +DEAL:1:2d::n_levels: 1 +DEAL:1:2d::n_cells: 1 +DEAL:1:2d::n_active_cells: 1 +DEAL:1:2d:: +DEAL:1:2d::n_dofs: 0 +DEAL:1:2d::n_locally_owned_dofs: 0 +DEAL:1:2d:: +DEAL:1:3d::n_levels: 2 +DEAL:1:3d::n_cells: 9 +DEAL:1:3d::n_active_cells: 8 +DEAL:1:3d:: +DEAL:1:3d::n_dofs: 125 +DEAL:1:3d::n_locally_owned_dofs: 125 +DEAL:1:3d:: + + +DEAL:2:1d::n_levels: 1 +DEAL:2:1d::n_cells: 1 +DEAL:2:1d::n_active_cells: 1 +DEAL:2:1d:: +DEAL:2:1d::n_dofs: 0 +DEAL:2:1d::n_locally_owned_dofs: 0 +DEAL:2:1d:: +DEAL:2:2d::n_levels: 2 +DEAL:2:2d::n_cells: 5 +DEAL:2:2d::n_active_cells: 4 +DEAL:2:2d:: +DEAL:2:2d::n_dofs: 25 +DEAL:2:2d::n_locally_owned_dofs: 25 +DEAL:2:2d:: +DEAL:2:3d::n_levels: 1 +DEAL:2:3d::n_cells: 1 +DEAL:2:3d::n_active_cells: 1 +DEAL:2:3d:: +DEAL:2:3d::n_dofs: 0 +DEAL:2:3d::n_locally_owned_dofs: 0 +DEAL:2:3d:: + + +DEAL:3:1d::n_levels: 1 +DEAL:3:1d::n_cells: 1 +DEAL:3:1d::n_active_cells: 1 +DEAL:3:1d:: +DEAL:3:1d::n_dofs: 0 +DEAL:3:1d::n_locally_owned_dofs: 0 +DEAL:3:1d:: +DEAL:3:2d::n_levels: 1 +DEAL:3:2d::n_cells: 1 +DEAL:3:2d::n_active_cells: 1 +DEAL:3:2d:: +DEAL:3:2d::n_dofs: 0 +DEAL:3:2d::n_locally_owned_dofs: 0 +DEAL:3:2d:: +DEAL:3:3d::n_levels: 1 +DEAL:3:3d::n_cells: 1 +DEAL:3:3d::n_active_cells: 1 +DEAL:3:3d:: +DEAL:3:3d::n_dofs: 0 +DEAL:3:3d::n_locally_owned_dofs: 0 +DEAL:3:3d:: + + +DEAL:4:1d::n_levels: 2 +DEAL:4:1d::n_cells: 3 +DEAL:4:1d::n_active_cells: 2 +DEAL:4:1d:: +DEAL:4:1d::n_dofs: 5 +DEAL:4:1d::n_locally_owned_dofs: 5 +DEAL:4:1d:: +DEAL:4:2d::n_levels: 1 +DEAL:4:2d::n_cells: 1 +DEAL:4:2d::n_active_cells: 1 +DEAL:4:2d:: +DEAL:4:2d::n_dofs: 0 +DEAL:4:2d::n_locally_owned_dofs: 0 +DEAL:4:2d:: +DEAL:4:3d::n_levels: 1 +DEAL:4:3d::n_cells: 1 +DEAL:4:3d::n_active_cells: 1 +DEAL:4:3d:: +DEAL:4:3d::n_dofs: 0 +DEAL:4:3d::n_locally_owned_dofs: 0 +DEAL:4:3d:: + + +DEAL:5:1d::n_levels: 1 +DEAL:5:1d::n_cells: 1 +DEAL:5:1d::n_active_cells: 1 +DEAL:5:1d:: +DEAL:5:1d::n_dofs: 0 +DEAL:5:1d::n_locally_owned_dofs: 0 +DEAL:5:1d:: +DEAL:5:2d::n_levels: 1 +DEAL:5:2d::n_cells: 1 +DEAL:5:2d::n_active_cells: 1 +DEAL:5:2d:: +DEAL:5:2d::n_dofs: 0 +DEAL:5:2d::n_locally_owned_dofs: 0 +DEAL:5:2d:: +DEAL:5:3d::n_levels: 1 +DEAL:5:3d::n_cells: 1 +DEAL:5:3d::n_active_cells: 1 +DEAL:5:3d:: +DEAL:5:3d::n_dofs: 0 +DEAL:5:3d::n_locally_owned_dofs: 0 +DEAL:5:3d:: + + +DEAL:6:1d::n_levels: 1 +DEAL:6:1d::n_cells: 1 +DEAL:6:1d::n_active_cells: 1 +DEAL:6:1d:: +DEAL:6:1d::n_dofs: 0 +DEAL:6:1d::n_locally_owned_dofs: 0 +DEAL:6:1d:: +DEAL:6:2d::n_levels: 1 +DEAL:6:2d::n_cells: 1 +DEAL:6:2d::n_active_cells: 1 +DEAL:6:2d:: +DEAL:6:2d::n_dofs: 0 +DEAL:6:2d::n_locally_owned_dofs: 0 +DEAL:6:2d:: +DEAL:6:3d::n_levels: 1 +DEAL:6:3d::n_cells: 1 +DEAL:6:3d::n_active_cells: 1 +DEAL:6:3d:: +DEAL:6:3d::n_dofs: 0 +DEAL:6:3d::n_locally_owned_dofs: 0 +DEAL:6:3d:: + + +DEAL:7:1d::n_levels: 1 +DEAL:7:1d::n_cells: 1 +DEAL:7:1d::n_active_cells: 1 +DEAL:7:1d:: +DEAL:7:1d::n_dofs: 0 +DEAL:7:1d::n_locally_owned_dofs: 0 +DEAL:7:1d:: +DEAL:7:2d::n_levels: 1 +DEAL:7:2d::n_cells: 1 +DEAL:7:2d::n_active_cells: 1 +DEAL:7:2d:: +DEAL:7:2d::n_dofs: 0 +DEAL:7:2d::n_locally_owned_dofs: 0 +DEAL:7:2d:: +DEAL:7:3d::n_levels: 1 +DEAL:7:3d::n_cells: 1 +DEAL:7:3d::n_active_cells: 1 +DEAL:7:3d:: +DEAL:7:3d::n_dofs: 0 +DEAL:7:3d::n_locally_owned_dofs: 0 +DEAL:7:3d:: + + +DEAL:8:1d::n_levels: 1 +DEAL:8:1d::n_cells: 1 +DEAL:8:1d::n_active_cells: 1 +DEAL:8:1d:: +DEAL:8:1d::n_dofs: 0 +DEAL:8:1d::n_locally_owned_dofs: 0 +DEAL:8:1d:: +DEAL:8:2d::n_levels: 1 +DEAL:8:2d::n_cells: 1 +DEAL:8:2d::n_active_cells: 1 +DEAL:8:2d:: +DEAL:8:2d::n_dofs: 0 +DEAL:8:2d::n_locally_owned_dofs: 0 +DEAL:8:2d:: +DEAL:8:3d::n_levels: 1 +DEAL:8:3d::n_cells: 1 +DEAL:8:3d::n_active_cells: 1 +DEAL:8:3d:: +DEAL:8:3d::n_dofs: 0 +DEAL:8:3d::n_locally_owned_dofs: 0 +DEAL:8:3d:: + diff --git a/tests/fullydistributed_grids/tests.h b/tests/fullydistributed_grids/tests.h new file mode 100644 index 0000000000..67cdbd71bb --- /dev/null +++ b/tests/fullydistributed_grids/tests.h @@ -0,0 +1,75 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + +#ifndef dealii_fully_distributed_tests_h +#define dealii_fully_distributed_tests_h + +#include "../tests.h" + +using namespace dealii; + +template +void +print_statistics( + const parallel::fullydistributed::Triangulation &tria, + bool do_mg = false) +{ + deallog << "n_levels: " << tria.n_levels() << std::endl; + deallog << "n_cells: " << tria.n_cells() << std::endl; + deallog << "n_active_cells: " << tria.n_active_cells() + << std::endl; + + if (do_mg) + { + for (auto level = 0u; level < tria.n_levels(); level++) + deallog << "n_cells on level=" << level << ": " + << tria.n_cells(level) << std::endl; + + for (auto level = 0u; level < tria.n_levels(); level++) + deallog << "n_active_cells on level=" << level << ": " + << tria.n_active_cells(level) << std::endl; + } + + deallog << std::endl; +} + +template +void +print_statistics(const DoFHandler &dof_handler, + bool do_mg = false) +{ + deallog << "n_dofs: " << dof_handler.n_dofs() + << std::endl; + deallog << "n_locally_owned_dofs: " + << dof_handler.n_locally_owned_dofs() << std::endl; + + const auto n_levels = dof_handler.get_triangulation().n_levels(); + + if (do_mg) + { + for (auto level = 0u; level < n_levels; level++) + deallog << "n_dofs on level=" << level << ": " + << dof_handler.n_dofs(level) << std::endl; + + for (auto level = 0u; level < n_levels; level++) + deallog << "n_locally_owned_mg_dofs on level=" << level << ": " + << dof_handler.locally_owned_mg_dofs(level).n_elements() + << std::endl; + } + + deallog << std::endl; +} + +#endif -- 2.39.5