Reference documentation for deal.II version Git 3f1f337db3 2021-10-23 13:19:02 -0600
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
tria_description.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2019 - 2021 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_grid_construction_utilities_h
17 #define dealii_grid_construction_utilities_h
18 
19 #include <deal.II/base/config.h>
20 
21 #include <deal.II/base/mpi.h>
22 
23 #include <deal.II/grid/cell_id.h>
24 #include <deal.II/grid/tria.h>
25 
27 
28 
30 
31 /*------------------------------------------------------------------------*/
32 
68 template <int structdim>
69 struct CellData
70 {
76  std::vector<unsigned int> vertices;
77 
85  union
86  {
96 
107  };
108 
118 
126  CellData(
127  const unsigned int n_vertices = GeometryInfo<structdim>::vertices_per_cell);
128 
132  bool
133  operator==(const CellData<structdim> &other) const;
134 
140  template <class Archive>
141  void
142  serialize(Archive &ar, const unsigned int version);
143 
144  static_assert(structdim > 0,
145  "The class CellData can only be used for structdim>0.");
146 };
147 
148 
149 
205 {
212  std::vector<CellData<1>> boundary_lines;
213 
224  std::vector<CellData<2>> boundary_quads;
225 
234  bool
235  check_consistency(const unsigned int dim) const;
236 };
237 
238 
239 template <int structdim>
240 template <class Archive>
241 void
242 CellData<structdim>::serialize(Archive &ar, const unsigned int /*version*/)
243 {
244  ar &vertices;
245  ar &material_id;
246  ar &boundary_id;
247  ar &manifold_id;
248 }
249 
255 {
260  enum Settings
261  {
272  };
273 
286  template <int dim>
287  struct CellData
288  {
294  template <class Archive>
295  void
296  serialize(Archive &ar, const unsigned int /*version*/);
297 
301  bool
302  operator==(const CellData<dim> &other) const;
303 
308 
313 
318 
323 
329  std::array<types::manifold_id, GeometryInfo<dim>::lines_per_cell>
331 
337  std::array<types::manifold_id,
338  dim == 1 ? 1 : GeometryInfo<3>::quads_per_cell>
340 
345  std::vector<std::pair<unsigned int, types::boundary_id>> boundary_ids;
346  };
347 
351  template <int dim, int spacedim>
352  struct Description
353  {
359  template <class Archive>
360  void
361  serialize(Archive &ar, const unsigned int /*version*/);
362 
366  bool
367  operator==(const Description<dim, spacedim> &other) const;
368 
372  std::vector<::CellData<dim>> coarse_cells;
373 
377  std::vector<Point<spacedim>> coarse_cell_vertices;
378 
384  std::vector<types::coarse_cell_id> coarse_cell_index_to_coarse_cell_id;
385 
391  std::vector<std::vector<CellData<dim>>> cell_infos;
392 
403 
408 
413  };
414 
415 
421  namespace Utilities
422  {
488  template <int dim, int spacedim = dim>
491  const ::Triangulation<dim, spacedim> &tria,
492  const MPI_Comm & comm,
495  const unsigned int my_rank_in = numbers::invalid_unsigned_int);
496 
517  template <int dim, int spacedim>
520  const Triangulation<dim, spacedim> & tria,
524 
529  template <int dim, int spacedim>
532  const Triangulation<dim, spacedim> & tria,
535  & mg_partitions,
538 
596  template <int dim, int spacedim = dim>
599  const std::function<void(::Triangulation<dim, spacedim> &)>
600  & serial_grid_generator,
601  const std::function<void(::Triangulation<dim, spacedim> &,
602  const MPI_Comm &,
603  const unsigned int)> &serial_grid_partitioner,
604  const MPI_Comm & comm,
605  const int group_size = 1,
606  const typename Triangulation<dim, spacedim>::MeshSmoothing smoothing =
608  const TriangulationDescription::Settings setting =
610 
611  } // namespace Utilities
612 
613 
614 
615  template <int dim>
616  template <class Archive>
617  void
618  CellData<dim>::serialize(Archive &ar, const unsigned int /*version*/)
619  {
620  ar &id;
621  ar &subdomain_id;
622  ar &level_subdomain_id;
623  ar &manifold_id;
624  if (dim >= 2)
625  ar &manifold_line_ids;
626  if (dim >= 3)
627  ar &manifold_quad_ids;
628  ar &boundary_ids;
629  }
630 
631 
632  template <int dim, int spacedim>
633  template <class Archive>
634  void
636  const unsigned int /*version*/)
637  {
638  ar &coarse_cells;
641  ar &cell_infos;
642  ar &settings;
643  ar &smoothing;
644  }
645 
646 
647 
648  template <int dim>
649  bool
651  {
652  if (this->id != other.id)
653  return false;
654  if (this->subdomain_id != other.subdomain_id)
655  return false;
656  if (this->level_subdomain_id != other.level_subdomain_id)
657  return false;
658  if (this->manifold_id != other.manifold_id)
659  return false;
660  if (dim >= 2 && this->manifold_line_ids != other.manifold_line_ids)
661  return false;
662  if (dim >= 3 && this->manifold_quad_ids != other.manifold_quad_ids)
663  return false;
664  if (this->boundary_ids != other.boundary_ids)
665  return false;
666 
667  return true;
668  }
669 
670 
671 
672  template <int dim, int spacedim>
673  bool
675  const Description<dim, spacedim> &other) const
676  {
677  if (this->coarse_cells != other.coarse_cells)
678  return false;
679  if (this->coarse_cell_vertices != other.coarse_cell_vertices)
680  return false;
683  return false;
684  if (this->cell_infos != other.cell_infos)
685  return false;
686  if (this->settings != other.settings)
687  return false;
688  if (this->smoothing != other.smoothing)
689  return false;
690 
691  return true;
692  }
693 } // namespace TriangulationDescription
694 
695 
697 
698 #endif
std::vector< CellData< 1 > > boundary_lines
static const unsigned int invalid_unsigned_int
Definition: types.h:196
unsigned int manifold_id
Definition: types.h:141
std::vector<::CellData< dim > > coarse_cells
const ::Triangulation< dim, spacedim > & tria
std::vector< std::pair< unsigned int, types::boundary_id > > boundary_ids
CellData(const unsigned int n_vertices=GeometryInfo< structdim >::vertices_per_cell)
bool operator==(const CellData< structdim > &other) const
std::vector< unsigned int > vertices
std::vector< types::coarse_cell_id > coarse_cell_index_to_coarse_cell_id
std::array< types::manifold_id, GeometryInfo< dim >::lines_per_cell > manifold_line_ids
std::vector< types::coarse_cell_id > coarse_cell_index_to_coarse_cell_id
types::boundary_id boundary_id
std::array< unsigned int, 4 > binary_type
Definition: cell_id.h:80
bool operator==(const AlignedVector< T > &lhs, const AlignedVector< T > &rhs)
Triangulation< dim, spacedim >::MeshSmoothing smoothing
std::array< types::manifold_id, dim==1 ? 1 :GeometryInfo< 3 >::quads_per_cell > manifold_quad_ids
unsigned int subdomain_id
Definition: types.h:43
void partition(const SparsityPattern &sparsity_pattern, const unsigned int n_partitions, std::vector< unsigned int > &partition_indices, const Partitioner partitioner=Partitioner::metis)
Description< dim, spacedim > create_description_from_triangulation_in_groups(const std::function< void(::Triangulation< dim, spacedim > &)> &serial_grid_generator, const std::function< void(::Triangulation< dim, spacedim > &, const MPI_Comm &, const unsigned int)> &serial_grid_partitioner, const MPI_Comm &comm, const int group_size=1, const typename Triangulation< dim, spacedim >::MeshSmoothing smoothing=::Triangulation< dim, spacedim >::none, const TriangulationDescription::Settings setting=TriangulationDescription::Settings::default_setting)
types::material_id material_id
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:401
std::vector< std::vector< CellData< dim > > > cell_infos
types::manifold_id manifold_id
std::vector<::CellData< dim > > coarse_cells
const TriangulationDescription::Settings settings
std::vector< std::vector< CellData< dim > > > cell_infos
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:400
std::vector< CellData< 2 > > boundary_quads
const MPI_Comm & comm
std::vector< Point< spacedim > > coarse_cell_vertices
Description< dim, spacedim > create_description_from_triangulation(const Triangulation< dim, spacedim > &tria, const LinearAlgebra::distributed::Vector< double > &partition, const std::vector< LinearAlgebra::distributed::Vector< double >> &mg_partitions, const TriangulationDescription::Settings settings=TriangulationDescription::Settings::default_setting)
std::vector< std::pair< unsigned int, Point< spacedim > > > coarse_cell_vertices
void serialize(Archive &ar, const unsigned int version)