00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __deal2__grid_reordering_internal_h
00013 #define __deal2__grid_reordering_internal_h
00014
00015
00016 #include <deal.II/base/config.h>
00017 #include <deal.II/grid/tria.h>
00018
00019 #include <map>
00020 #include <vector>
00021
00022 DEAL_II_NAMESPACE_OPEN
00023
00024
00025 namespace internal
00026 {
00033 namespace GridReordering2d
00034 {
00035
00054 bool
00055 is_consistent (const std::vector<CellData<2> > &cells);
00056
00057
00078 class ConnectGlobals
00079 {
00080 public:
00086 static const int EdgeToNode[4][2];
00087
00094 static const int NodeToEdge[4][2];
00095
00101 static const int DefaultOrientation[4][2];
00102 };
00103
00104
00111 class MQuad
00112 {
00113 public:
00120 MQuad (const unsigned int v0,
00121 const unsigned int v1,
00122 const unsigned int v2,
00123 const unsigned int v3,
00124 const unsigned int s0,
00125 const unsigned int s1,
00126 const unsigned int s2,
00127 const unsigned int s3,
00128 const CellData<2> &cd);
00129
00133 unsigned int v[4];
00137 unsigned int side[4];
00138
00144 CellData<2> original_cell_data;
00145 };
00146
00154 struct MSide
00155 {
00159 MSide (const unsigned int initv0,
00160 const unsigned int initv1);
00161
00167 bool operator==(const MSide& s2) const;
00168
00172 bool operator!=(const MSide& s2) const;
00173
00174 unsigned int v0;
00175 unsigned int v1;
00176 unsigned int Q0;
00177 unsigned int Q1;
00178
00182 unsigned int lsn0, lsn1;
00183 bool Oriented;
00184
00188 struct SideRectify;
00189
00196 struct SideSortLess;
00197 };
00198
00199
00200
00207 class GridReordering
00208 {
00209 public:
00210
00215 void reorient(std::vector<CellData<2> > &quads);
00216 private:
00217
00226 void build_graph (const std::vector<CellData<2> > &inquads);
00227
00261 void orient();
00262
00268 void get_quads(std::vector<CellData<2> > &outquads) const;
00269
00281 void orient_side (const unsigned int quadnum,
00282 const unsigned int localsidenum);
00283
00289 bool is_fully_oriented_quad (const unsigned int quadnum) const;
00290
00296 bool is_oriented_side (const unsigned int quadnum,
00297 const unsigned int lsn) const;
00298
00304 bool is_side_default_oriented (const unsigned int qnum,
00305 const unsigned int lsn) const;
00306
00315 bool get_unoriented_quad (unsigned int &UnOrQLoc) const;
00316
00324 bool get_unoriented_side (const unsigned int quadnum,
00325 unsigned int &sidenum) const;
00326
00345 bool side_hop (unsigned int &qnum,
00346 unsigned int &lsn) const;
00347
00352 std::vector<MSide> sides;
00357 std::vector<MQuad> mquads;
00358 };
00359 }
00360
00361
00368 namespace GridReordering3d
00369 {
00421 struct EdgeOrientation
00422 {
00426 char orientation;
00427
00431 bool operator == (const EdgeOrientation &edge_orientation) const;
00432
00436 bool operator != (const EdgeOrientation &edge_orientation) const;
00437 };
00438
00455 struct CheapEdge
00456 {
00460 const unsigned int node0;
00461
00465 const unsigned int node1;
00466
00472 CheapEdge (const unsigned int n0,
00473 const unsigned int n1);
00474
00479 bool operator< (const CheapEdge & e2) const;
00480 };
00481
00482
00483
00488 struct Edge
00489 {
00493 Edge (const unsigned int n0,
00494 const unsigned int n1);
00495
00499 unsigned int nodes[2];
00500
00509 EdgeOrientation orientation_flag;
00510
00525 unsigned int group;
00526
00530 std::vector<unsigned int> neighboring_cubes;
00531 };
00532
00554 struct Cell
00555 {
00559 Cell ();
00560
00564 unsigned int edges[GeometryInfo<3>::lines_per_cell];
00565
00569 unsigned int nodes[GeometryInfo<3>::vertices_per_cell];
00570
00579 EdgeOrientation local_orientation_flags[GeometryInfo<3>::lines_per_cell];
00580
00588 bool waiting_to_be_processed;
00589 };
00590
00591
00601 class Mesh
00602 {
00603 public:
00607 Mesh (const std::vector<CellData<3> > &incubes);
00608
00616 void
00617 export_to_deal_format (std::vector<CellData<3> > &outcubes) const;
00618
00619 private:
00623 std::vector<Edge> edge_list;
00624
00628 std::vector<Cell> cell_list;
00629
00634 void sanity_check() const;
00635
00643 void build_connectivity ();
00644
00649 Mesh (const Mesh&);
00650
00656 Mesh& operator=(const Mesh&);
00657
00663 void sanity_check_node (const Cell &cell,
00664 const unsigned int local_node_num) const;
00665
00670 friend class Orienter;
00671 };
00672
00673
00682 class Orienter
00683 {
00684 public:
00701 static
00702 bool
00703 orient_mesh (std::vector<CellData<3> > &incubes);
00704
00705 private:
00712 Mesh mesh;
00713
00718 unsigned int cur_posn;
00719
00724 unsigned int marker_cube;
00725
00731 unsigned int cur_edge_group;
00732
00741 std::vector<int> sheet_to_process;
00742
00743
00751 bool edge_orient_array[12];
00752
00766 Orienter (const std::vector<CellData<3> > &incubes);
00767
00775 bool orient_edges ();
00776
00783 void orient_cubes ();
00784
00785 bool get_next_unoriented_cube ();
00786
00793 bool is_oriented (const unsigned int cell_num) const;
00794
00795 bool orient_edges_in_current_cube ();
00796 bool orient_edge_set_in_current_cube (const unsigned int edge_set);
00797 bool orient_next_unoriented_edge ();
00798
00810 bool cell_is_consistent (const unsigned int cell_num) const;
00811
00812
00813 void get_adjacent_cubes ();
00814 bool get_next_active_cube ();
00815 };
00816 }
00817 }
00818
00819
00820 DEAL_II_NAMESPACE_CLOSE
00821
00822 #endif
00823