From 509808eb8a6e13f60eac66140c684e6bdcff2912 Mon Sep 17 00:00:00 2001 From: heister Date: Fri, 25 Apr 2014 21:14:12 +0000 Subject: [PATCH] move shared_tria into separate files git-svn-id: https://svn.dealii.org/branches/branch_sharedtria@32834 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/deal.II/distributed/shared_tria.h | 112 ++++++++++++++++++ deal.II/include/deal.II/distributed/tria.h | 65 ---------- .../deal.II/grid/tria_accessor.templates.h | 1 + deal.II/source/distributed/CMakeLists.txt | 2 + deal.II/source/distributed/shared_tria.cc | 112 ++++++++++++++++++ .../source/distributed/shared_tria.inst.in | 36 ++++++ deal.II/source/distributed/tria.cc | 67 ----------- deal.II/source/distributed/tria.inst.in | 11 -- 8 files changed, 263 insertions(+), 143 deletions(-) create mode 100644 deal.II/include/deal.II/distributed/shared_tria.h create mode 100644 deal.II/source/distributed/shared_tria.cc create mode 100644 deal.II/source/distributed/shared_tria.inst.in diff --git a/deal.II/include/deal.II/distributed/shared_tria.h b/deal.II/include/deal.II/distributed/shared_tria.h new file mode 100644 index 0000000000..2ae1949971 --- /dev/null +++ b/deal.II/include/deal.II/distributed/shared_tria.h @@ -0,0 +1,112 @@ +// --------------------------------------------------------------------- +// $Id: tria.h 32739 2014-04-08 16:39:47Z denis.davydov $ +// +// Copyright (C) 2008 - 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + +#ifndef __deal2__distributed__shared_tria_h +#define __deal2__distributed__shared_tria_h + + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#ifdef DEAL_II_WITH_MPI +# include +#endif + + +DEAL_II_NAMESPACE_OPEN + +template class Triangulation; + +namespace parallel +{ + namespace shared + { + + /** + * This is an extension of dealii::Triangulation class to automatically + * partition trianguation using MPI. + */ + template + class Triangulation : public dealii::Triangulation + { + public: + typedef typename dealii::Triangulation::active_cell_iterator active_cell_iterator; + typedef typename dealii::Triangulation::cell_iterator cell_iterator; + + /** + * Constructor. + */ + Triangulation (MPI_Comm mpi_communicator); + + /** + * Destructor. + */ + virtual ~Triangulation (); + + /** + * Return locally owned subdomain id, + * which is equivalent to the rank of the current mpi process in + * communicator provided to class constructor. + */ + types::subdomain_id locally_owned_subdomain () const; + + /** + * Return MPI communicator used by this triangulation. + */ + MPI_Comm get_communicator () const; + + /** + * Coarsen and refine the mesh according to refinement and + * coarsening flags set. + * + * This step is equivalent to the dealii::Triangulation class + * with an addition of calling dealii::GridTools::partition_triangulation() at the end. + */ + virtual void execute_coarsening_and_refinement (); + + /** + * Create a triangulation. + * + * This function also partitions triangulation based on the + * MPI communicator provided to constructor. + */ + virtual void create_triangulation (const std::vector< Point< spacedim > > &vertices, + const std::vector< CellData< dim > > &cells, + const SubCellData &subcelldata); + + + private: + MPI_Comm mpi_communicator; + types::subdomain_id my_subdomain; + types::subdomain_id num_subdomains; + }; + } +} + +DEAL_II_NAMESPACE_CLOSE + +#endif diff --git a/deal.II/include/deal.II/distributed/tria.h b/deal.II/include/deal.II/distributed/tria.h index 6a465589dc..b00a01b224 100644 --- a/deal.II/include/deal.II/distributed/tria.h +++ b/deal.II/include/deal.II/distributed/tria.h @@ -931,71 +931,6 @@ namespace parallel #endif -namespace parallel -{ - namespace shared - { - - /** - * This is an extension of dealii::Triangulation class to automatically - * partition trianguation using MPI. - */ - template - class Triangulation : public dealii::Triangulation - { - public: - typedef typename dealii::Triangulation::active_cell_iterator active_cell_iterator; - typedef typename dealii::Triangulation::cell_iterator cell_iterator; - - /** - * Constructor. - */ - Triangulation (MPI_Comm mpi_communicator); - - /** - * Destructor. - */ - virtual ~Triangulation (); - - /** - * Return locally owned subdomain id, - * which is equivalent to the rank of the current mpi process in - * communicator provided to class constructor. - */ - types::subdomain_id locally_owned_subdomain () const; - - /** - * Return MPI communicator used by this triangulation. - */ - MPI_Comm get_communicator () const; - - /** - * Coarsen and refine the mesh according to refinement and - * coarsening flags set. - * - * This step is equivalent to the dealii::Triangulation class - * with an addition of calling dealii::GridTools::partition_triangulation() at the end. - */ - virtual void execute_coarsening_and_refinement (); - - /** - * Create a triangulation. - * - * This function also partitions triangulation based on the - * MPI communicator provided to constructor. - */ - virtual void create_triangulation (const std::vector< Point< spacedim > > &vertices, - const std::vector< CellData< dim > > &cells, - const SubCellData &subcelldata); - - - private: - MPI_Comm mpi_communicator; - types::subdomain_id my_subdomain; - types::subdomain_id num_subdomains; - }; - } -} DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/include/deal.II/grid/tria_accessor.templates.h b/deal.II/include/deal.II/grid/tria_accessor.templates.h index 1bf410ee64..16b0be5840 100644 --- a/deal.II/include/deal.II/grid/tria_accessor.templates.h +++ b/deal.II/include/deal.II/grid/tria_accessor.templates.h @@ -28,6 +28,7 @@ #include #include #include +#include #include diff --git a/deal.II/source/distributed/CMakeLists.txt b/deal.II/source/distributed/CMakeLists.txt index 4bb6e252cd..53069c9bb2 100644 --- a/deal.II/source/distributed/CMakeLists.txt +++ b/deal.II/source/distributed/CMakeLists.txt @@ -20,12 +20,14 @@ SET(_src grid_refinement.cc solution_transfer.cc tria.cc + shared_tria.cc ) SET(_inst grid_refinement.inst.in solution_transfer.inst.in tria.inst.in + shared_tria.inst.in ) FILE(GLOB _header diff --git a/deal.II/source/distributed/shared_tria.cc b/deal.II/source/distributed/shared_tria.cc new file mode 100644 index 0000000000..e01636453e --- /dev/null +++ b/deal.II/source/distributed/shared_tria.cc @@ -0,0 +1,112 @@ +// --------------------------------------------------------------------- +// $Id: tria.cc 32807 2014-04-22 15:01:57Z heister $ +// +// Copyright (C) 2008 - 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include +#include + + +DEAL_II_NAMESPACE_OPEN + + +namespace parallel +{ + namespace shared + { + template + Triangulation::Triangulation (MPI_Comm mpi_communicator): + dealii::Triangulation(), + mpi_communicator (Utilities::MPI:: + duplicate_communicator(mpi_communicator)), + my_subdomain (Utilities::MPI::this_mpi_process (this->mpi_communicator)), + num_subdomains(Utilities::MPI::n_mpi_processes(mpi_communicator)) + { + + } + + + template + Triangulation::~Triangulation () + { + + } + + + + template + types::subdomain_id + Triangulation::locally_owned_subdomain () const + { + return my_subdomain; + } + + template + void + Triangulation::execute_coarsening_and_refinement () { + dealii::Triangulation::execute_coarsening_and_refinement (); + dealii::GridTools::partition_triangulation (num_subdomains, *this); + } + + template + void + Triangulation::create_triangulation (const std::vector< Point< spacedim > > &vertices, + const std::vector< CellData< dim > > &cells, + const SubCellData &subcelldata) { + try + { + dealii::Triangulation:: + create_triangulation (vertices, cells, subcelldata); + } + catch (const typename dealii::Triangulation::DistortedCellList &) + { + // the underlying triangulation should not be checking for distorted + // cells + AssertThrow (false, ExcInternalError()); + } + dealii::GridTools::partition_triangulation (num_subdomains, *this); + } + + + template + MPI_Comm + Triangulation::get_communicator () const + { + return mpi_communicator; + } + + } +} + + +/*-------------- Explicit Instantiations -------------------------------*/ +#include "shared_tria.inst" + + +DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/distributed/shared_tria.inst.in b/deal.II/source/distributed/shared_tria.inst.in new file mode 100644 index 0000000000..f6a863a443 --- /dev/null +++ b/deal.II/source/distributed/shared_tria.inst.in @@ -0,0 +1,36 @@ +// --------------------------------------------------------------------- +// $Id: tria.inst.in 32674 2014-03-20 16:57:24Z denis.davydov $ +// +// Copyright (C) 2010 - 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +for (deal_II_dimension : DIMENSIONS) + { + namespace parallel + \{ + namespace shared + \{ + template class Triangulation; +# if deal_II_dimension < 3 + template class Triangulation; +# endif +# if deal_II_dimension < 2 + template class Triangulation; +# endif + \} + \} + + } + diff --git a/deal.II/source/distributed/tria.cc b/deal.II/source/distributed/tria.cc index 7fa42b2373..6a22f877f5 100644 --- a/deal.II/source/distributed/tria.cc +++ b/deal.II/source/distributed/tria.cc @@ -3973,73 +3973,6 @@ namespace parallel #endif // DEAL_II_WITH_P4EST -namespace parallel -{ - namespace shared - { - template - Triangulation::Triangulation (MPI_Comm mpi_communicator): - dealii::Triangulation(), - mpi_communicator (Utilities::MPI:: - duplicate_communicator(mpi_communicator)), - my_subdomain (Utilities::MPI::this_mpi_process (this->mpi_communicator)), - num_subdomains(Utilities::MPI::n_mpi_processes(mpi_communicator)) - { - - } - - - template - Triangulation::~Triangulation () - { - - } - - - - template - types::subdomain_id - Triangulation::locally_owned_subdomain () const - { - return my_subdomain; - } - - template - void - Triangulation::execute_coarsening_and_refinement () { - dealii::Triangulation::execute_coarsening_and_refinement (); - dealii::GridTools::partition_triangulation (num_subdomains, *this); - } - - template - void - Triangulation::create_triangulation (const std::vector< Point< spacedim > > &vertices, - const std::vector< CellData< dim > > &cells, - const SubCellData &subcelldata) { - try - { - dealii::Triangulation:: - create_triangulation (vertices, cells, subcelldata); - } - catch (const typename dealii::Triangulation::DistortedCellList &) - { - // the underlying triangulation should not be checking for distorted - // cells - AssertThrow (false, ExcInternalError()); - } - dealii::GridTools::partition_triangulation (num_subdomains, *this); - } - - - template - MPI_Comm - Triangulation::get_communicator () const - { - return mpi_communicator; - } - - } -} /*-------------- Explicit Instantiations -------------------------------*/ diff --git a/deal.II/source/distributed/tria.inst.in b/deal.II/source/distributed/tria.inst.in index 3b80440cb5..b5199699f3 100644 --- a/deal.II/source/distributed/tria.inst.in +++ b/deal.II/source/distributed/tria.inst.in @@ -61,17 +61,6 @@ for (deal_II_dimension : DIMENSIONS) # if deal_II_dimension < 3 template class Triangulation; # endif -# if deal_II_dimension < 2 - template class Triangulation; -# endif - \} - - namespace shared - \{ - template class Triangulation; -# if deal_II_dimension < 3 - template class Triangulation; -# endif # if deal_II_dimension < 2 template class Triangulation; # endif -- 2.39.5