From: Wolfgang Bangerth Date: Tue, 14 Apr 2015 21:46:55 +0000 (-0500) Subject: Replace a double loop over cells and indices by a single loop and the use of cell... X-Git-Tag: v8.3.0-rc1~263^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d1c1565723c7d6ed672c3384d8aefa9cabce1f1;p=dealii.git Replace a double loop over cells and indices by a single loop and the use of cell->active_cell_index(). --- diff --git a/source/grid/grid_out.cc b/source/grid/grid_out.cc index f94f424ef0..ee2ef0a984 100644 --- a/source/grid/grid_out.cc +++ b/source/grid/grid_out.cc @@ -1047,11 +1047,9 @@ void GridOut::write_msh (const Triangulation &tria, // write cells. Enumerate cells // consecutively, starting with 1 - unsigned int cell_index=1; - for (cell=tria.begin_active(); - cell!=endc; ++cell, ++cell_index) + for (cell=tria.begin_active(); cell!=endc; ++cell) { - out << cell_index << ' ' << elm_type << ' ' + out << cell->active_cell_index()+1 << ' ' << elm_type << ' ' << static_cast(cell->material_id()) << ' ' << cell->subdomain_id() << ' ' << GeometryInfo::vertices_per_cell << ' '; @@ -1066,10 +1064,11 @@ void GridOut::write_msh (const Triangulation &tria, // write faces and lines with // non-zero boundary indicator + unsigned int next_index = tria.n_active_cells()+1; if (msh_flags.write_faces) - write_msh_faces (tria, cell_index, out); + write_msh_faces (tria, next_index, out); if (msh_flags.write_lines) - write_msh_lines (tria, cell_index, out); + write_msh_lines (tria, next_index, out); out << "$ENDELM" << std::endl; @@ -1146,11 +1145,9 @@ void GridOut::write_ucd (const Triangulation &tria, // write cells. Enumerate cells // consecutively, starting with 1 - unsigned int cell_index=1; - for (cell=tria.begin_active(); - cell!=endc; ++cell, ++cell_index) + for (cell=tria.begin_active(); cell!=endc; ++cell) { - out << cell_index << ' ' + out << cell->active_cell_index()+1 << ' ' << static_cast(cell->material_id()) << ' '; switch (dim) @@ -1191,10 +1188,11 @@ void GridOut::write_ucd (const Triangulation &tria, // write faces and lines with // non-zero boundary indicator + unsigned int next_index = tria.n_active_cells()+1; if (ucd_flags.write_faces) - write_ucd_faces (tria, cell_index, out); + write_ucd_faces (tria, next_index, out); if (ucd_flags.write_lines) - write_ucd_lines (tria, cell_index, out); + write_ucd_lines (tria, next_index, out); // make sure everything now gets to // disk @@ -2376,9 +2374,7 @@ void GridOut::write_mathgl (const Triangulation &tria, endc=tria.end (); // No global indices in deal.II, so we make one up here. - unsigned int cell_global_index = 0; - - for (; cell!=endc; ++cell, ++cell_global_index) + for (; cell!=endc; ++cell) { for (unsigned int i=0; i &tria, // else // out << "\nfalse"; - out << "\nlist " << axes[i] << cell_global_index << " "; + out << "\nlist " << axes[i] << cell->active_cell_index() << " "; for (unsigned int j=0; j::vertices_per_cell; ++j) out << cell->vertex(j)[i] << " "; }