Reference documentation for deal.II version 8.4.2
grid_reordering_internal.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2003 - 2016 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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__grid_reordering_internal_h
17 #define dealii__grid_reordering_internal_h
18 
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/grid/tria.h>
22 
23 #include <map>
24 #include <vector>
25 
26 DEAL_II_NAMESPACE_OPEN
27 
28 
29 namespace internal
30 {
37  namespace GridReordering2d
38  {
39 
50  bool
51  is_consistent (const std::vector<CellData<2> > &cells);
52 
53 
75  {
76  public:
81  static const int EdgeToNode[4][2];
82 
87  static const int NodeToEdge[4][2];
88 
93  static const int DefaultOrientation[4][2];
94  };
95 
96 
103  class MQuad
104  {
105  public:
110  MQuad (const unsigned int v0,
111  const unsigned int v1,
112  const unsigned int v2,
113  const unsigned int v3,
114  const unsigned int s0,
115  const unsigned int s1,
116  const unsigned int s2,
117  const unsigned int s3,
118  const CellData<2> &cd);
119 
123  unsigned int v[4];
127  unsigned int side[4];
128 
134  };
135 
143  struct MSide
144  {
148  MSide (const unsigned int initv0,
149  const unsigned int initv1);
150 
154  bool operator==(const MSide &s2) const;
155 
159  bool operator!=(const MSide &s2) const;
160 
161  unsigned int v0;
162  unsigned int v1;
163  unsigned int Q0;
164  unsigned int Q1;
165 
169  unsigned int lsn0, lsn1;
170  bool Oriented;
171 
175  struct SideRectify;
176 
181  struct SideSortLess;
182  };
183 
184 
185 
193  {
194  public:
195 
199  void reorient(std::vector<CellData<2> > &quads);
200  private:
201 
207  void build_graph (const std::vector<CellData<2> > &inquads);
208 
229  void orient();
230 
234  void get_quads(std::vector<CellData<2> > &outquads) const;
235 
242  void orient_side (const unsigned int quadnum,
243  const unsigned int localsidenum);
244 
248  bool is_fully_oriented_quad (const unsigned int quadnum) const;
249 
253  bool is_oriented_side (const unsigned int quadnum,
254  const unsigned int lsn) const;
255 
259  bool is_side_default_oriented (const unsigned int qnum,
260  const unsigned int lsn) const;
261 
266  bool get_unoriented_quad (unsigned int &UnOrQLoc) const;
267 
272  bool get_unoriented_side (const unsigned int quadnum,
273  unsigned int &sidenum) const;
274 
283  bool side_hop (unsigned int &qnum,
284  unsigned int &lsn) const;
285 
289  std::vector<MSide> sides;
293  std::vector<MQuad> mquads;
294  };
295  } // namespace GridReordering2d
296 
297 
304  namespace GridReordering3d
305  {
330  {
335 
339  bool operator == (const EdgeOrientation &edge_orientation) const;
340 
344  bool operator != (const EdgeOrientation &edge_orientation) const;
345  };
346 
355  struct CheapEdge
356  {
360  const unsigned int node0;
361 
365  const unsigned int node1;
366 
370  CheapEdge (const unsigned int n0,
371  const unsigned int n1);
372 
376  bool operator< (const CheapEdge &e2) const;
377  };
378 
379 
380 
384  struct Edge
385  {
389  Edge (const unsigned int n0,
390  const unsigned int n1);
391 
395  unsigned int nodes[2];
396 
402 
410  unsigned int group;
411 
415  std::vector<unsigned int> neighboring_cubes;
416  };
417 
430  struct Cell
431  {
435  Cell ();
436 
440  unsigned int edges[GeometryInfo<3>::lines_per_cell];
441 
446 
452 
458  };
459 
460 
467  class Mesh
468  {
469  public:
473  Mesh (const std::vector<CellData<3> > &incubes);
474 
479  void
480  export_to_deal_format (std::vector<CellData<3> > &outcubes) const;
481 
482  private:
486  std::vector<Edge> edge_list;
487 
491  std::vector<Cell> cell_list;
492 
496  void sanity_check() const;
497 
502  void build_connectivity ();
503 
507  Mesh (const Mesh &);
508 
512  Mesh &operator=(const Mesh &);
513 
517  void sanity_check_node (const Cell &cell,
518  const unsigned int local_node_num) const;
519 
523  friend class Orienter;
524  };
525 
526 
531  class Orienter
532  {
533  public:
544  static
545  bool
546  orient_mesh (std::vector<CellData<3> > &incubes);
547 
548  private:
554 
558  unsigned int cur_posn;
559 
563  unsigned int marker_cube;
564 
569  unsigned int cur_edge_group;
570 
575  std::vector<int> sheet_to_process;
576 
577 
582  bool edge_orient_array[12];
583 
591  Orienter (const std::vector<CellData<3> > &incubes);
592 
598  bool orient_edges ();
599 
604  void orient_cubes ();
605 
606  bool get_next_unoriented_cube ();
607 
612  bool is_oriented (const unsigned int cell_num) const;
613 
614  bool orient_edges_in_current_cube ();
615  bool orient_edge_set_in_current_cube (const unsigned int edge_set);
616  bool orient_next_unoriented_edge ();
617 
623  bool cell_is_consistent (const unsigned int cell_num) const;
624 
625 
626  void get_adjacent_cubes ();
627  bool get_next_active_cube ();
628  };
629  } // namespace GridReordering3d
630 } // namespace internal
631 
632 
633 DEAL_II_NAMESPACE_CLOSE
634 
635 #endif
std::vector< unsigned int > neighboring_cubes
bool is_consistent(const std::vector< CellData< 2 > > &cells)