From 8d1022c5f0f588f26b04f71abc90d9836ff2d26c Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 23 Oct 2003 20:40:31 +0000 Subject: [PATCH] Many more clean-ups. git-svn-id: https://svn.dealii.org/trunk@8150 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/grid/grid_reordering_internal.h | 88 +-- .../deal.II/source/grid/grid_reordering.cc | 653 ++++++++++-------- 2 files changed, 377 insertions(+), 364 deletions(-) diff --git a/deal.II/deal.II/include/grid/grid_reordering_internal.h b/deal.II/deal.II/include/grid/grid_reordering_internal.h index c2eab607a0..9a63335a7f 100644 --- a/deal.II/deal.II/include/grid/grid_reordering_internal.h +++ b/deal.II/deal.II/include/grid/grid_reordering_internal.h @@ -427,9 +427,13 @@ namespace internal }; - class ElementInfo + struct ElementInfo { - public: + /** + * Constructor. + */ + ElementInfo (); + /** * The numbers of the edges * coming into node i are @@ -461,9 +465,9 @@ namespace internal int nodes_on_face[6][4]; }; - class DealElemInfo : public ElementInfo + + struct DealElemInfo : public ElementInfo { - public: DealElemInfo(); }; @@ -474,19 +478,14 @@ namespace internal * A conectivity and orientation * aware edge class. */ - class Edge + struct Edge { - public: /** * Simple constructor */ - Edge (int n0, int n1, int orient=0) - : - orientation_flag(orient), - group(0), - num_neighbouring_cubes(0), - neighbouring_cubes(NULL) - {nodes[0]=n0; nodes[1]=n1;}; + Edge (int n0, + int n1, + int orient=0); /** * Simple Destructor @@ -539,18 +538,17 @@ namespace internal * TODO: Need to move conectivity information out * of cell and into edge. */ - class Cell + struct Cell { - public: /** * The IDs for each of the edges. */ - int edges[12]; + int edges[GeometryInfo<3>::lines_per_cell]; /** * The IDs for each of the nodes. */ - int nodes[8]; + int nodes[GeometryInfo<3>::vertices_per_cell]; /** * Which way do the edges @@ -560,7 +558,7 @@ namespace internal * (1) or node 1 is the base * (-1). */ - int local_orientation_flags[12]; + int local_orientation_flags[GeometryInfo<3>::lines_per_cell]; /** * An internal flag used to @@ -574,36 +572,12 @@ namespace internal /** * Copy Constructor */ - Cell (const Cell &c) - { - for(int i=0;i<12;++i) - { - edges[i]=c.edges[i]; - local_orientation_flags[i]=c.local_orientation_flags[i]; - } - for(int i=0;i<8;++i) - { - nodes[i]=c.nodes[i]; - } - waiting_to_be_processed=c.waiting_to_be_processed; - } + Cell (const Cell &c); /** * Default Constructor */ - Cell() - { - for(int i=0;i<12;++i) - { - edges[i]=-1; - local_orientation_flags[i]=1; - } - for(int i=0;i<8;++i) - { - nodes[i]=-1; - } - waiting_to_be_processed=false; - } + Cell(); }; @@ -684,18 +658,14 @@ namespace internal }; + class Orienter { public: /** * Constructor. */ - Orienter() - { - for (unsigned int i=0; i<12; ++i) - edge_orient_array[i]=false; - } - + Orienter(); /** * The cube we're looking at now. @@ -708,7 +678,7 @@ namespace internal */ unsigned int marker_cube; - std::vector SheetToProcess; + std::vector sheet_to_process; int cur_edge_group; @@ -717,20 +687,20 @@ namespace internal bool orient_edges (Mesh &m); void orient_cubes (Mesh &m); - bool GetNextUnorientedCube (Mesh &m); + bool get_next_unoriented_cube (Mesh &m); bool is_oriented (const Mesh &m, int cell_num); - bool OrientEdgesInCurrentCube (Mesh &m); - bool OrientEdgeSetInCurrentCube (Mesh &m, - int edge_set); - bool OrientNextUnorientedEdge (Mesh &m); - bool Consistent (Mesh &m, + bool orient_edges_in_current_cube (Mesh &m); + bool orient_edge_set_in_current_cube (Mesh &m, + int edge_set); + bool orient_next_unoriented_edge (Mesh &m); + bool consistent (Mesh &m, int cell_num); - void GetAdjacentCubes (Mesh &m); - bool GetNextActiveCube (Mesh &m); + void get_adjacent_cubes (Mesh &m); + bool get_next_active_cube (Mesh &m); }; diff --git a/deal.II/deal.II/source/grid/grid_reordering.cc b/deal.II/deal.II/source/grid/grid_reordering.cc index 30311ee1fa..992c39655e 100644 --- a/deal.II/deal.II/source/grid/grid_reordering.cc +++ b/deal.II/deal.II/source/grid/grid_reordering.cc @@ -42,13 +42,13 @@ namespace internal namespace GridReordering2d { // -- Definition Of conectivity information -- - const int ConnectGlobals::EdgeToNode[4][2]= + const int ConnectGlobals::EdgeToNode[4][2] = { {0,1},{1,2},{2,3},{3,0} }; - const int ConnectGlobals::NodeToEdge[4][2]= + const int ConnectGlobals::NodeToEdge[4][2] = { {3,0},{0,1},{1,2},{2,3} }; - const int ConnectGlobals::DefaultOrientation[4][2]= + const int ConnectGlobals::DefaultOrientation[4][2] = {{0,1},{1,2},{3,2},{0,3}}; @@ -108,7 +108,7 @@ namespace internal // we want them // (std::set eliminates // duplicated by itself) - for (unsigned int i=0; i<4; ++i) + for (unsigned int i = 0; i<4; ++i) { const Edge e(reverse_edges[i].v1, reverse_edges[i].v0); edges.insert (e); @@ -141,28 +141,28 @@ namespace internal int s2vmin,s2vmax; if (s1.v0s2vmin) + if (s1vmin>s2vmin) return false; return s1vmax::iterator it=mquads.begin(); it!=mquads.end(); ++it) + int qctr = 0; + for (std::vector::iterator it = mquads.begin(); it != mquads.end(); ++it) { - for(unsigned int i=0;i<4;++i) + for (unsigned int i = 0;i<4;++i) { - MSide &ss =sides[(*it).side[i]]; - if(ss.Q0==static_cast(-1)) + MSide &ss = sides[(*it).side[i]]; + if (ss.Q0 == static_cast(-1)) { - ss.Q0=qctr; - ss.lsn0=i; + ss.Q0 = qctr; + ss.lsn0 = i; } - else if (ss.Q1==static_cast(-1)) + else if (ss.Q1 == static_cast(-1)) { - ss.Q1=qctr; - ss.lsn1=i; + ss.Q1 = qctr; + ss.lsn1 = i; } else AssertThrow (false, ExcInternalError()); @@ -354,14 +354,14 @@ namespace internal { // do what the comment in the // class declaration says - unsigned int qnum=0; + unsigned int qnum = 0; while(get_unoriented_quad(qnum)) { - unsigned int lsn=0; + unsigned int lsn = 0; while(get_unoriented_side(qnum,lsn)) { orient_side(qnum,lsn); - unsigned int qqnum=qnum; + unsigned int qqnum = qnum; while(side_hop(qqnum,lsn)) { // switch this face @@ -387,34 +387,34 @@ namespace internal MQuad &quad = mquads[quadnum]; int op_side_l = (localsidenum+2)%4; MSide &side = sides[mquads[quadnum].side[localsidenum]]; - const MSide &op_side =sides[mquads[quadnum].side[op_side_l]]; + const MSide &op_side = sides[mquads[quadnum].side[op_side_l]]; //is the opposite side oriented? if (op_side.Oriented) { //YES - Make the orientations match //Is op side in default orientation? - if (op_side.v0==quad.v[ConnectGlobals::DefaultOrientation[op_side_l][0]]) + if (op_side.v0 == quad.v[ConnectGlobals::DefaultOrientation[op_side_l][0]]) { //YES - side.v0=quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]]; - side.v1=quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]]; + side.v0 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]]; + side.v1 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]]; } else { //NO, its reversed - side.v0=quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]]; - side.v1=quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]]; + side.v0 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]]; + side.v1 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]]; } } else { //NO //Just use the default orientation - side.v0=quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]]; - side.v1=quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]]; + side.v0 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][0]]; + side.v1 = quad.v[ConnectGlobals::DefaultOrientation[localsidenum][1]]; } - side.Oriented=true; + side.Oriented = true; } @@ -448,7 +448,7 @@ namespace internal while( (UnOrQLoc(-1)) + if (opquad != static_cast(-1)) { qnum = opquad; return true; @@ -514,7 +514,7 @@ namespace internal { outquads.clear(); outquads.reserve(mquads.size()); - for(unsigned int qn=0;qn q = mquads[qn].original_cell_data; // Are the sides oriented? - Assert(is_fully_oriented_quad(qn), ExcInternalError()); + Assert (is_fully_oriented_quad(qn), ExcInternalError()); bool s[4]; //whether side 1 ,2, 3, 4 are in the default orientation - for(int sn=0;sn<4;sn++) + for (int sn = 0;sn<4;sn++) { - s[sn]=is_side_default_oriented(qn,sn); + s[sn] = is_side_default_oriented(qn,sn); } // Are they oriented in the "deal way"? - Assert(s[0]==s[2], ExcInternalError()); - Assert(s[1]==s[3], ExcInternalError()); + Assert (s[0] == s[2], ExcInternalError()); + Assert (s[1] == s[3], ExcInternalError()); // How much we rotate them by. int rotn = 2*(s[0]?1:0)+ ((s[0]^s[1])?1:0); - for(int i=0;i<4;++i) + for (int i = 0;i<4;++i) { - q.vertices[(i+rotn)%4]=mquads[qn].v[i]; + q.vertices[(i+rotn)%4] = mquads[qn].v[i]; } outquads.push_back(q); } @@ -549,7 +549,7 @@ namespace internal GridReordering::is_side_default_oriented (const unsigned int qnum, const unsigned int lsn) const { - return (sides[mquads[qnum].side[lsn]].v0 == + return (sides[mquads[qnum].side[lsn]].v0 == mquads[qnum].v[ConnectGlobals::DefaultOrientation[lsn][0]]); } } // namespace GridReordering2 @@ -615,10 +615,10 @@ namespace internal std::vector & cell_list = m.cell_list; std::vector & edge_list = m.edge_list; - const unsigned int cell_list_length=cell_list.size(); + const unsigned int cell_list_length = cell_list.size(); - unsigned int NumEdges=0; + unsigned int NumEdges = 0; // Correctly build the edge // list { @@ -626,33 +626,33 @@ namespace internal // edge_number associated // with a given CheapEdge std::map edge_map; - unsigned int ctr=0; - for(unsigned int cur_cell_id=0; - cur_cell_id cur_cell_edge_list_posn(NumEdges,0); - for(unsigned int cur_cell_id =0; - cur_cell_id::lines_per_cell; ++i) + { + edges[i] = c.edges[i]; + local_orientation_flags[i] = c.local_orientation_flags[i]; + } + + for (unsigned int i = 0; i::vertices_per_cell; ++i) + nodes[i] = c.nodes[i]; + + waiting_to_be_processed = c.waiting_to_be_processed; + } + + + + Cell::Cell () + { + for (unsigned int i = 0; i::lines_per_cell; ++i) + { + edges[i] = -1; + local_orientation_flags[i] = 1; + } + + for (unsigned int i = 0; i::vertices_per_cell; ++i) + nodes[i] = -1; + + waiting_to_be_processed = false; + } + + bool Mesh::sanity_check() const { - bool retval=true; - for(unsigned int i=0; i::reorder_cells(std::vector >& incubes, - std::vector > * node_vec_ptr) +void GridReordering<3>::reorder_cells(std::vector > &incubes, + std::vector > *node_vec_ptr) { - Assert(incubes.size()!=0, - ExcMessage("List of elements to orient was of zero length")); + Assert (incubes.size() != 0, + ExcMessage("List of elements to orient was of zero length")); // This keeps track of all the // local element conectivity @@ -1319,21 +1370,18 @@ void GridReordering<3>::reorder_cells(std::vector >& incubes, // empty. internal::GridReordering3d::Mesh the_mesh(deal_info); - if(node_vec_ptr!=NULL) - { - the_mesh.node_list=*node_vec_ptr; - } + if (node_vec_ptr != NULL) + the_mesh.node_list = *node_vec_ptr; // Copy the cells into our own // internal data format. - const unsigned int numelems=incubes.size(); - for(unsigned int i =0 ; i::reorder_cells(std::vector >& incubes, // Copy the elements from our // internal structure back into // their original location. - for(unsigned int i =0 ; i