From f38eba09d27cd6b5203c45b08f2fb820ab21f88a Mon Sep 17 00:00:00 2001 From: wolf Date: Wed, 18 Oct 2000 08:22:38 +0000 Subject: [PATCH] Many changes to GridReordering. Will have to clean up and have to test that more, but in a usable state at least. git-svn-id: https://svn.dealii.org/trunk@3446 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/include/grid/grid_reordering.h | 8 +- deal.II/deal.II/source/grid/grid_in.cc | 81 +++++++++- .../deal.II/source/grid/grid_reordering.cc | 145 +++++++++++------- 3 files changed, 173 insertions(+), 61 deletions(-) diff --git a/deal.II/deal.II/include/grid/grid_reordering.h b/deal.II/deal.II/include/grid/grid_reordering.h index 08a8121031..30c4f6f970 100644 --- a/deal.II/deal.II/include/grid/grid_reordering.h +++ b/deal.II/deal.II/include/grid/grid_reordering.h @@ -95,9 +95,13 @@ class GridReorderingInfo<3> * orientations of a face in * 2d. It is the quadrilateral * rotated in all four - * orientations. + * orientations, and also viewed + * from the back, i.e. vertices + * not numbered in + * counter-clockwise sense but in + * the other direction. */ - static const unsigned int rotational_states_of_faces = 4; + static const unsigned int rotational_states_of_faces = 8; }; diff --git a/deal.II/deal.II/source/grid/grid_in.cc b/deal.II/deal.II/source/grid/grid_in.cc index 8205cf08d2..256f8884ff 100644 --- a/deal.II/deal.II/source/grid/grid_in.cc +++ b/deal.II/deal.II/source/grid/grid_in.cc @@ -22,10 +22,6 @@ - -#include - - template GridIn::GridIn () : tria(0) {}; @@ -545,5 +541,82 @@ GridIn<2>::debug_output_grid (const vector > &cells, #endif +#if deal_II_dimension == 3 + +template <> +void +GridIn<3>::debug_output_grid (const vector > &cells, + const vector > &vertices, + ostream &out) +{ + for (unsigned int cell=0; cell; diff --git a/deal.II/deal.II/source/grid/grid_reordering.cc b/deal.II/deal.II/source/grid/grid_reordering.cc index 633a4ac1b7..a00418662b 100644 --- a/deal.II/deal.II/source/grid/grid_reordering.cc +++ b/deal.II/deal.II/source/grid/grid_reordering.cc @@ -228,19 +228,41 @@ GridReordering<3>::Cell::insert_faces (map &global_faces) { { vertices[3], vertices[2], vertices[6], vertices[7] } }, { { vertices[0], vertices[4], vertices[7], vertices[3] } } }; Face new_faces[GeometryInfo::faces_per_cell][rotational_states_of_faces] - = { { new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0] }, - { new_faces_tmp[1], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0] }, - { new_faces_tmp[2], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0] }, - { new_faces_tmp[3], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0] }, - { new_faces_tmp[4], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0] }, - { new_faces_tmp[5], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0] } }; - + = { { new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], + new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0] }, + { new_faces_tmp[1], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], + new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0] }, + { new_faces_tmp[2], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], + new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0] }, + { new_faces_tmp[3], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], + new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0] }, + { new_faces_tmp[4], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], + new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0] }, + { new_faces_tmp[5], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], + new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0], new_faces_tmp[0] }}; + + // first do the faces in their + // usual direction for (unsigned int face=0; face::faces_per_cell; ++face) - for (unsigned int rot=1; rot::vertices_per_face; ++v) new_faces[face][rot].vertices[v] = new_faces[face][0].vertices[(v+rot) % GeometryInfo::vertices_per_face]; - + // then do everything as viewed + // from the back. this is simple, + // as we only have to revert + // indices 1 and 3 + for (unsigned int face=0; face::faces_per_cell; ++face) + for (unsigned int rot=rotational_states_of_faces/2; rot::vertices_per_face; ++v) + new_faces[face][rot].vertices[v] + = new_faces[face][rot-rotational_states_of_faces/2].vertices[v]; + swap (new_faces[face][rot].vertices[1], + new_faces[face][rot].vertices[3]); + }; + + // now insert all the faces, by now // without specific order with // respect to the orientational @@ -282,23 +304,49 @@ GridReordering<3>::Cell::insert_faces (map &global_faces) // that the present cell is one of // the neighbors for (unsigned int face=0; face::faces_per_cell; ++face) - for (unsigned int rot=0; rotsecond.adjacent_cells[0] == - FaceData::invalid_adjacent_cell) + { +// cout << "Entering cell " << cell_no << " as adjacent to face <"; +// for (unsigned int i=0; i<4; ++i) +// cout << new_faces_ptr[0][face]->first.vertices[i] << ' '; +// cout << '>'; + + if (new_faces_ptr[0][face]->second.adjacent_cells[0] == + FaceData::invalid_adjacent_cell) + { +// cout << " as neighbor 0" << endl; // no, faces had not been // used before, so we are the // first adjacent cell - new_faces_ptr[rot][face]->second.adjacent_cells[0] = cell_no; - else + for (unsigned int rot=0; rotsecond.adjacent_cells[0] + == FaceData::invalid_adjacent_cell, + ExcInternalError()); + new_faces_ptr[rot][face]->second.adjacent_cells[0] = cell_no; + }; + } + else + { // otherwise: cell had been // entered before, so we are // the second neighbor - { - Assert (new_faces_ptr[rot][face]->second.adjacent_cells[1] == - FaceData::invalid_adjacent_cell, - ExcInternalError()); - new_faces_ptr[rot][face]->second.adjacent_cells[1] = cell_no; - }; + const unsigned int + previous_neighbor = new_faces_ptr[0][face]->second.adjacent_cells[0]; +// cout << " as neighbor 1 (previous: " << previous_neighbor << ")" << endl; + for (unsigned int rot=0; rotsecond.adjacent_cells[0] == + previous_neighbor, + ExcInternalError()); + Assert (new_faces_ptr[rot][face]->second.adjacent_cells[1] == + FaceData::invalid_adjacent_cell, + ExcInternalError()); + new_faces_ptr[rot][face]->second.adjacent_cells[1] = cell_no; + }; + }; + }; + + // we still have to link cell in // its 24 different orientations to @@ -394,22 +442,27 @@ GridReordering<3>::Cell::insert_faces (map &global_faces) // we have already created for (unsigned int face=0; face::faces_per_cell; ++face) { - unsigned int f, r; - for (f=0; f::faces_per_cell; ++f) - for (r=0; r::faces_per_cell); ++f) + for (unsigned int r=0; r::faces_per_cell) && - (r == rotational_states_of_cells)), - ExcInternalError()); + Assert (face_found == true, ExcInternalError()); }; +// for (unsigned int face=0; face::faces_per_cell; ++face) +// cout << "cell_orientation_faces[" << rot << "][" << face << "]=" +// << cell_orientation_faces[rot][face].first << '.' +// << cell_orientation_faces[rot][face].second +// << endl; // more checks: make sure // that each of the @@ -439,6 +492,7 @@ GridReordering<3>::Cell::insert_faces (map &global_faces) // once, so no more checks // necessary }; + // that's it: we now know which // faces build up this cell in // each of its possible @@ -454,7 +508,7 @@ GridReordering<3>::Cell::insert_faces (map &global_faces) // link the faces in their // directions to the cell in each // of its orientations - for (unsigned int rot=0; rotational_states_of_cells; ++rot) + for (unsigned int rot=0; rot::faces_per_cell; ++face) faces[rot][face] = new_faces_ptr [cell_orientation_faces[rot][face].second] @@ -467,20 +521,9 @@ GridReordering<3>::Cell::insert_faces (map &global_faces) template void GridReordering::Cell::fix_cell_neighbors () { +// cout << "Fixing neighbors for cell " << cell_no << endl; for (unsigned int face=0; face::faces_per_cell; ++face) { - // first assert that the - // neighborship info of all - // versions of the same face is - // identical - for (unsigned int rot=1; rotsecond.adjacent_cells[adjacent_cell] - == - faces[0][face]->second.adjacent_cells[adjacent_cell], - ExcInternalError()); - - // then insert the neighbor // behind this face as neighbor // of the present cell. note @@ -536,6 +579,7 @@ void GridReordering::Cell::find_backtracking_point () // of course, not hold for cell 0, // from which we should never be // forced to track back + track_back_to_cell = cell_no-1; if (cell_no == 0) track_back_to_cell = 0; else @@ -883,7 +927,7 @@ void GridReordering::find_reordering (vector > &cells, if (rotation_states.size() > max_size) { max_size = rotation_states.size(); - if (max_size % 10 == 0) +// if (max_size % 10 == 0) cout << "New max size " << rotation_states.size() << endl; }; @@ -1147,9 +1191,6 @@ GridReordering::presort_cells (vector > &cells, if (i->second.adjacent_cells[k] != FaceData::invalid_adjacent_cell) i->second.adjacent_cells[k] = new_cell_numbers[i->second.adjacent_cells[k]]; -// for (unsigned int i=0; i" << new_cell_numbers[i] << "]"; - return new_cell_numbers; }; @@ -1158,17 +1199,6 @@ GridReordering::presort_cells (vector > &cells, template void GridReordering::reorder_cells (vector > &original_cells) { - // the present function might - // actually work in 3d, but the - // ones it calls probably not. will - // have to think about what needs - // to be changed. however, rather - // than killing the program when - // calling functions that may not - // work, kill it here if the - // dimension is not appropriate - Assert (dim==2, ExcNotImplemented()); - // we need more information than // provided by the input parameter, // in particular we need @@ -1195,7 +1225,10 @@ void GridReordering::reorder_cells (vector > &original_cells) // insert the neighbor indices into // the cells themselves for (unsigned int cell_no=0; cell_no:: reorder_cells (vector > &); #endif + + -- 2.39.5