From: Wolfgang Bangerth Date: Tue, 20 Dec 2005 23:23:08 +0000 (+0000) Subject: Avoid using std::endl, since it calls flush() -- which we don't really need after... X-Git-Tag: v8.0.0~12753 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50ef680dcce27d5bf6d835a765530646f51251fb;p=dealii.git Avoid using std::endl, since it calls flush() -- which we don't really need after every line has been output, but that incurs a significant overhead in terms of system calls. By replacing all uses of std::endl by '\n', John Henning reports that the number of system calls for the SPEC testcase has dropped from 2,157,042 to 15,811. Instead of std::endl therefore use '\n' and explicitly call flush() at the end of output functions. git-svn-id: https://svn.dealii.org/trunk@11902 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/source/data_out_base.cc b/deal.II/base/source/data_out_base.cc index 0175547eb0..e8ddf277ce 100644 --- a/deal.II/base/source/data_out_base.cc +++ b/deal.II/base/source/data_out_base.cc @@ -737,19 +737,19 @@ void DataOutBase::write_ucd (const std::vector > &patches, { std::time_t time1= std::time (0); std::tm *time = std::localtime(&time1); - out << "# This file was generated by the deal.II library." << std::endl + out << "# This file was generated by the deal.II library." << '\n' << "# Date = " << time->tm_year+1900 << "/" << time->tm_mon+1 << "/" - << time->tm_mday << std::endl + << time->tm_mday << '\n' << "# Time = " << time->tm_hour << ":" << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << std::endl - << "#" << std::endl + << std::setw(2) << time->tm_sec << '\n' + << "#" << '\n' << "# For a description of the UCD format see the AVS Developer's guide." - << std::endl - << "#" << std::endl; + << '\n' + << "#" << '\n'; } // start with ucd data @@ -758,7 +758,7 @@ void DataOutBase::write_ucd (const std::vector > &patches, << n_data_sets << ' ' << 0 << ' ' // no cell data at present << 0 // no model data - << std::endl; + << '\n'; /////////////////////////////// // first make up the list of used @@ -798,7 +798,7 @@ void DataOutBase::write_ucd (const std::vector > &patches, // fill with zeroes for (unsigned int i=spacedim; i<3; ++i) out << "0 "; - out << std::endl; + out << '\n'; } break; @@ -829,7 +829,7 @@ void DataOutBase::write_ucd (const std::vector > &patches, // fill with zeroes for (unsigned int i=spacedim; i<3; ++i) out << "0 "; - out << std::endl; + out << '\n'; ++present_node; } @@ -877,7 +877,7 @@ void DataOutBase::write_ucd (const std::vector > &patches, // fill with zeroes unnecessary here for (unsigned int i=spacedim; i<3; ++i) out << "0 "; - out << std::endl; + out << '\n'; ++present_node; } @@ -918,7 +918,7 @@ void DataOutBase::write_ucd (const std::vector > &patches, out << present_cell << " 0 line " // set material id to 0 << first_vertex_of_patch+i+1 << ' ' - << first_vertex_of_patch+i+1+1 << std::endl; + << first_vertex_of_patch+i+1+1 << '\n'; break; } @@ -933,7 +933,7 @@ void DataOutBase::write_ucd (const std::vector > &patches, << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j+1 << ' ' << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j+1+1 << ' ' << first_vertex_of_patch+i*(n_subdivisions+1)+j+1+1 - << std::endl; + << '\n'; ++present_cell; } break; @@ -956,7 +956,7 @@ void DataOutBase::write_ucd (const std::vector > &patches, << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j )*(n_subdivisions+1)+k+1+1 << ' ' << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j+1)*(n_subdivisions+1)+k+1+1 << ' ' << first_vertex_of_patch+(i*(n_subdivisions+1)+j+1 )*(n_subdivisions+1)+k+1+1 << ' ' - << std::endl; + << '\n'; ++present_cell; } break; @@ -987,7 +987,7 @@ void DataOutBase::write_ucd (const std::vector > &patches, Assert (false, ExcNotImplemented()); } } - out << std::endl; + out << '\n'; // note that we number starting with 1! Assert (present_cell == n_cells+1, @@ -1003,12 +1003,12 @@ void DataOutBase::write_ucd (const std::vector > &patches, for (unsigned int i=0; i > &patches, for (unsigned int data_set=0; data_setdata(data_set,i) << ' '; - out << std::endl; + out << '\n'; } break; @@ -1056,7 +1056,7 @@ void DataOutBase::write_ucd (const std::vector > &patches, for (unsigned int data_set=0; data_setdata(data_set,i*(n_subdivisions+1) + j) << ' '; - out << std::endl; + out << '\n'; ++present_node; } @@ -1077,7 +1077,7 @@ void DataOutBase::write_ucd (const std::vector > &patches, (i*(n_subdivisions+1)+j)*(n_subdivisions+1)+k) << ' '; - out << std::endl; + out << '\n'; ++present_node; } @@ -1093,6 +1093,10 @@ void DataOutBase::write_ucd (const std::vector > &patches, // no model data + // make sure everything now gets to + // disk + out.flush (); + // assert the stream is still ok AssertThrow (out, ExcIO()); } @@ -1145,7 +1149,7 @@ void DataOutBase::write_dx (const std::vector > &patches, // lexicographical, x varying // fastest out << "object \"vertices\" class array type float rank 1 shape " << spacedim - << " items " << n_nodes << " data follows" << std::endl; + << " items " << n_nodes << " data follows" << '\n'; /////////////////////////////// // first write the coordinates of all vertices @@ -1171,7 +1175,7 @@ void DataOutBase::write_dx (const std::vector > &patches, // write out coordinates for (unsigned int i=0; i > &patches, // write out coordinates for (unsigned int i=0; i > &patches, // write out coordinates for (unsigned int i=0; i > &patches, // write cells out << "object \"cells\" class array type int rank 1 shape " << GeometryInfo::vertices_per_cell << " items " << n_cells << " data follows" - << std::endl; + << '\n'; if (true) { @@ -1270,7 +1274,7 @@ void DataOutBase::write_dx (const std::vector > &patches, { for (unsigned int i=0; i > &patches, << first_vertex_of_patch+i*(n_subdivisions+1)+j+1 << '\t' << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j << '\t' << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j+1 - << std::endl; + << '\n'; } } break; @@ -1305,7 +1309,7 @@ void DataOutBase::write_dx (const std::vector > &patches, << first_vertex_of_patch+((i+1)*nvt+j+1)*nvt+k << '\t' << first_vertex_of_patch+((i+1)*nvt+j+1)*nvt+k+1 << '\t' ; - out << std::endl; + out << '\n'; } } break; @@ -1334,15 +1338,15 @@ void DataOutBase::write_dx (const std::vector > &patches, Assert (false, ExcNotImplemented()); } } - out << std::endl; + out << '\n'; } out << "attribute \"element type\" string \""; if (dim==1) out << "lines"; if (dim==2) out << "quads"; if (dim==3) out << "cubes"; - out << "\"" << std::endl - << "attribute \"ref\" string \"positions\"" << std::endl; + out << "\"" << '\n' + << "attribute \"ref\" string \"positions\"" << '\n'; //TODO:[GK] Patches must be of same size! ///////////////////////////// @@ -1386,7 +1390,7 @@ void DataOutBase::write_dx (const std::vector > &patches, const unsigned int ny = iy*dy; const unsigned int nz = iz*dz; - out << std::endl; + out << '\n'; // Direction -x // Last cell in row // of other patch @@ -1475,7 +1479,7 @@ void DataOutBase::write_dx (const std::vector > &patches, << patch_start+nx+ny+nz+dz; } } - out << std::endl; + out << '\n'; } } ///////////////////////////// @@ -1484,7 +1488,7 @@ void DataOutBase::write_dx (const std::vector > &patches, { out << "object \"data\" class array type float rank 1 shape " << n_data_sets - << " items " << n_nodes << " data follows" << std::endl; + << " items " << n_nodes << " data follows" << '\n'; // loop over all patches for (typename std::vector >::const_iterator patch=patches.begin(); @@ -1511,7 +1515,7 @@ void DataOutBase::write_dx (const std::vector > &patches, { for (unsigned int data_set=0; data_setdata(data_set,i) << '\t'; - out << std::endl; + out << '\n'; } break; @@ -1524,7 +1528,7 @@ void DataOutBase::write_dx (const std::vector > &patches, { for (unsigned int data_set=0; data_setdata(data_set,i*(n_subdivisions+1) + j) << '\t'; - out << std::endl; + out << '\n'; } break; @@ -1540,7 +1544,7 @@ void DataOutBase::write_dx (const std::vector > &patches, out << patch->data(data_set, (i*(n_subdivisions+1)+j)*(n_subdivisions+1)+k) << '\t'; - out << std::endl; + out << '\n'; } break; @@ -1550,21 +1554,21 @@ void DataOutBase::write_dx (const std::vector > &patches, Assert (false, ExcNotImplemented()); } } - out << "attribute \"dep\" string \"positions\"" << std::endl; + out << "attribute \"dep\" string \"positions\"" << '\n'; } else { out << "object \"data\" class constantarray type float rank 0 items " << n_nodes << " data follows" - << std::endl << '0' << std::endl; + << '\n' << '0' << '\n'; } // no model data - out << "object \"deal data\" class field" << std::endl - << "component \"positions\" value \"vertices\"" << std::endl - << "component \"connections\" value \"cells\"" << std::endl - << "component \"data\" value \"data\"" << std::endl; + out << "object \"deal data\" class field" << '\n' + << "component \"positions\" value \"vertices\"" << '\n' + << "component \"connections\" value \"cells\"" << '\n' + << "component \"data\" value \"data\"" << '\n'; if (flags.write_neighbors) - out << "component \"neighbors\" value \"neighbors\"" << std::endl; + out << "component \"neighbors\" value \"neighbors\"" << '\n'; if (true) { @@ -1577,10 +1581,14 @@ void DataOutBase::write_dx (const std::vector > &patches, << ' ' << time->tm_hour << ":" << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << '"' << std::endl; + << std::setw(2) << time->tm_sec << '"' << '\n'; } - out << "end" << std::endl; + out << "end" << '\n'; + // make sure everything now gets to + // disk + out.flush (); + // assert the stream is still ok AssertThrow (out, ExcIO()); } @@ -1607,19 +1615,19 @@ void DataOutBase::write_gnuplot (const std::vector > &patche // use const std::time_t time1= std::time (0); const std::tm *time = std::localtime(&time1); - out << "# This file was generated by the deal.II library." << std::endl + out << "# This file was generated by the deal.II library." << '\n' << "# Date = " << time->tm_year+1900 << "/" << time->tm_mon+1 << "/" - << time->tm_mday << std::endl + << time->tm_mday << '\n' << "# Time = " << time->tm_hour << ":" << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << std::endl - << "#" << std::endl + << std::setw(2) << time->tm_sec << '\n' + << "#" << '\n' << "# For a description of the GNUPLOT format see the GNUPLOT manual." - << std::endl - << "#" << std::endl + << '\n' + << "#" << '\n' << "# "; switch (spacedim) @@ -1642,7 +1650,7 @@ void DataOutBase::write_gnuplot (const std::vector > &patche out << '<' << data_names[i] << "> "; - out << std::endl; + out << '\n'; } @@ -1678,12 +1686,12 @@ void DataOutBase::write_gnuplot (const std::vector > &patche for (unsigned int data_set=0; data_setdata(data_set,i) << ' '; - out << std::endl; + out << '\n'; } // end of patch - out << std::endl - << std::endl; + out << '\n' + << '\n'; break; } @@ -1708,15 +1716,15 @@ void DataOutBase::write_gnuplot (const std::vector > &patche for (unsigned int data_set=0; data_setdata(data_set,i*(n_subdivisions+1) + j) << ' '; - out << std::endl; + out << '\n'; } // end of row in patch - out << std::endl; + out << '\n'; } // end of patch - out << std::endl; + out << '\n'; break; } @@ -1766,7 +1774,7 @@ void DataOutBase::write_gnuplot (const std::vector > &patche out << ' ' << patch->data(data_set, (i*(n_subdivisions+1) + j)*(n_subdivisions+1)+k); - out << std::endl; + out << '\n'; // write point there // and its data @@ -1783,11 +1791,11 @@ void DataOutBase::write_gnuplot (const std::vector > &patche out << ' ' << patch->data(data_set, ((i+1)*(n_subdivisions+1) + j)*(n_subdivisions+1)+k); - out << std::endl; + out << '\n'; // end of line - out << std::endl - << std::endl; + out << '\n' + << '\n'; } // line into positive y-direction @@ -1801,7 +1809,7 @@ void DataOutBase::write_gnuplot (const std::vector > &patche out << ' ' << patch->data(data_set, (i*(n_subdivisions+1) + j)*(n_subdivisions+1)+k); - out << std::endl; + out << '\n'; // write point there // and its data @@ -1818,11 +1826,11 @@ void DataOutBase::write_gnuplot (const std::vector > &patche out << ' ' << patch->data(data_set, (i*(n_subdivisions+1) + (j+1))*(n_subdivisions+1)+k); - out << std::endl; + out << '\n'; // end of line - out << std::endl - << std::endl; + out << '\n' + << '\n'; } // line into positive z-direction @@ -1836,7 +1844,7 @@ void DataOutBase::write_gnuplot (const std::vector > &patche out << ' ' << patch->data(data_set, (i*(n_subdivisions+1) + j)*(n_subdivisions+1)+k); - out << std::endl; + out << '\n'; // write point there // and its data @@ -1853,11 +1861,11 @@ void DataOutBase::write_gnuplot (const std::vector > &patche out << ' ' << patch->data(data_set, (i*(n_subdivisions+1) + j)*(n_subdivisions+1)+k+1); - out << std::endl; + out << '\n'; // end of line - out << std::endl - << std::endl; + out << '\n' + << '\n'; } } @@ -1870,6 +1878,10 @@ void DataOutBase::write_gnuplot (const std::vector > &patche } } + // make sure everything now gets to + // disk + out.flush (); + AssertThrow (out, ExcIO()); } @@ -1896,50 +1908,50 @@ void DataOutBase::write_povray (const std::vector > &patches // variables destroyed after use const std::time_t time1= std::time (0); const std::tm *time = std::localtime(&time1); - out << "/* This file was generated by the deal.II library." << std::endl + out << "/* This file was generated by the deal.II library." << '\n' << " Date = " << time->tm_year+1900 << "/" << time->tm_mon+1 << "/" - << time->tm_mday << std::endl + << time->tm_mday << '\n' << " Time = " << time->tm_hour << ":" << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << std::endl - << std::endl + << std::setw(2) << time->tm_sec << '\n' + << '\n' << " For a description of the POVRAY format see the POVRAY manual." - << std::endl - << "*/ " << std::endl; + << '\n' + << "*/ " << '\n'; // include files - out << "#include \"colors.inc\" " << std::endl - << "#include \"textures.inc\" " << std::endl; + out << "#include \"colors.inc\" " << '\n' + << "#include \"textures.inc\" " << '\n'; // use external include file for textures, // camera and light if (flags.external_data) - out << "#include \"data.inc\" " << std::endl; + out << "#include \"data.inc\" " << '\n'; else // all definitions in data file { // camera - out << std::endl << std::endl - << "camera {" << std::endl - << " location <1,4,-7>" << std::endl - << " look_at <0,0,0>" << std::endl - << " angle 30" << std::endl - << "}" << std::endl; + out << '\n' << '\n' + << "camera {" << '\n' + << " location <1,4,-7>" << '\n' + << " look_at <0,0,0>" << '\n' + << " angle 30" << '\n' + << "}" << '\n'; // light - out << std::endl - << "light_source {" << std::endl - << " <1,4,-7>" << std::endl - << " color Grey" << std::endl - << "}" << std::endl; - out << std::endl - << "light_source {" << std::endl - << " <0,20,0>" << std::endl - << " color White" << std::endl - << "}" << std::endl; + out << '\n' + << "light_source {" << '\n' + << " <1,4,-7>" << '\n' + << " color Grey" << '\n' + << "}" << '\n'; + out << '\n' + << "light_source {" << '\n' + << " <0,20,0>" << '\n' + << " color White" << '\n' + << "}" << '\n'; } } @@ -1975,28 +1987,28 @@ void DataOutBase::write_povray (const std::vector > &patches } } - out << "#declare HMIN=" << hmin << ";" << std::endl - << "#declare HMAX=" << hmax << ";" << std::endl << std::endl; + out << "#declare HMIN=" << hmin << ";" << '\n' + << "#declare HMAX=" << hmax << ";" << '\n' << '\n'; if (!flags.external_data) { // texture with scaled niveau lines // 10 lines in the surface - out << "#declare Tex=texture{" << std::endl - << " pigment {" << std::endl - << " gradient y" << std::endl - << " scale y*(HMAX-HMIN)*" << 0.1 << std::endl - << " color_map {" << std::endl - << " [0.00 color Light_Purple] " << std::endl - << " [0.95 color Light_Purple] " << std::endl - << " [1.00 color White] " << std::endl - << "} } }" << std::endl << std::endl; + out << "#declare Tex=texture{" << '\n' + << " pigment {" << '\n' + << " gradient y" << '\n' + << " scale y*(HMAX-HMIN)*" << 0.1 << '\n' + << " color_map {" << '\n' + << " [0.00 color Light_Purple] " << '\n' + << " [0.95 color Light_Purple] " << '\n' + << " [1.00 color White] " << '\n' + << "} } }" << '\n' << '\n'; } if (!flags.bicubic_patch) { // start of mesh header - out << std::endl - << "mesh {" << std::endl; + out << '\n' + << "mesh {" << '\n'; } // loop over all patches @@ -2130,12 +2142,12 @@ void DataOutBase::write_povray (const std::vector > &patches // writing smooth_triangles // down/right triangle - out << "smooth_triangle {" << std::endl << "\t<" + out << "smooth_triangle {" << '\n' << "\t<" << ver[dl](0) << "," << patch->data(0,dl) << "," << ver[dl](1) << ">, <" << nrml[dl](0) << ", " << nrml[dl](1) << ", " << nrml[dl](2) - << ">," << std::endl; + << ">," << '\n'; out << " \t<" << ver[dl+n_subdivisions+1](0) << "," << patch->data(0,dl+n_subdivisions+1) << "," @@ -2143,7 +2155,7 @@ void DataOutBase::write_povray (const std::vector > &patches << nrml[dl+n_subdivisions+1](0) << ", " << nrml[dl+n_subdivisions+1](1) << ", " << nrml[dl+n_subdivisions+1](2) - << ">," << std::endl; + << ">," << '\n'; out << "\t<" << ver[dl+n_subdivisions+2](0) << "," << patch->data(0,dl+n_subdivisions+2) << "," @@ -2151,15 +2163,15 @@ void DataOutBase::write_povray (const std::vector > &patches << nrml[dl+n_subdivisions+2](0) << ", " << nrml[dl+n_subdivisions+2](1) << ", " << nrml[dl+n_subdivisions+2](2) - << ">}" << std::endl; + << ">}" << '\n'; // upper/left triangle - out << "smooth_triangle {" << std::endl << "\t<" + out << "smooth_triangle {" << '\n' << "\t<" << ver[dl](0) << "," << patch->data(0,dl) << "," << ver[dl](1) << ">, <" << nrml[dl](0) << ", " << nrml[dl](1) << ", " << nrml[dl](2) - << ">," << std::endl; + << ">," << '\n'; out << "\t<" << ver[dl+n_subdivisions+2](0) << "," << patch->data(0,dl+n_subdivisions+2) << "," @@ -2167,44 +2179,44 @@ void DataOutBase::write_povray (const std::vector > &patches << nrml[dl+n_subdivisions+2](0) << ", " << nrml[dl+n_subdivisions+2](1) << ", " << nrml[dl+n_subdivisions+2](2) - << ">," << std::endl; + << ">," << '\n'; out << "\t<" << ver[dl+1](0) << "," << patch->data(0,dl+1) << "," << ver[dl+1](1) << ">, <" << nrml[dl+1](0) << ", " << nrml[dl+1](1) << ", " << nrml[dl+1](2) - << ">}" << std::endl; + << ">}" << '\n'; } else { // writing standard triangles // down/right triangle - out << "triangle {" << std::endl << "\t<" + out << "triangle {" << '\n' << "\t<" << ver[dl](0) << "," << patch->data(0,dl) << "," - << ver[dl](1) << ">," << std::endl; + << ver[dl](1) << ">," << '\n'; out << "\t<" << ver[dl+n_subdivisions+1](0) << "," << patch->data(0,dl+n_subdivisions+1) << "," - << ver[dl+n_subdivisions+1](1) << ">," << std::endl; + << ver[dl+n_subdivisions+1](1) << ">," << '\n'; out << "\t<" << ver[dl+n_subdivisions+2](0) << "," << patch->data(0,dl+n_subdivisions+2) << "," - << ver[dl+n_subdivisions+2](1) << ">}" << std::endl; + << ver[dl+n_subdivisions+2](1) << ">}" << '\n'; // upper/left triangle - out << "triangle {" << std::endl << "\t<" + out << "triangle {" << '\n' << "\t<" << ver[dl](0) << "," << patch->data(0,dl) << "," - << ver[dl](1) << ">," << std::endl; + << ver[dl](1) << ">," << '\n'; out << "\t<" << ver[dl+n_subdivisions+2](0) << "," << patch->data(0,dl+n_subdivisions+2) << "," - << ver[dl+n_subdivisions+2](1) << ">," << std::endl; + << ver[dl+n_subdivisions+2](1) << ">," << '\n'; out << "\t<" << ver[dl+1](0) << "," << patch->data(0,dl+1) << "," - << ver[dl+1](1) << ">}" << std::endl; + << ver[dl+1](1) << ">}" << '\n'; } } } @@ -2212,30 +2224,34 @@ void DataOutBase::write_povray (const std::vector > &patches else { // writing bicubic_patch Assert (n_subdivisions==3, ExcDimensionMismatch(n_subdivisions,3)); - out << std::endl - << "bicubic_patch {" << std::endl - << " type 0" << std::endl - << " flatness 0" << std::endl - << " u_steps 0" << std::endl - << " v_steps 0" << std::endl; + out << '\n' + << "bicubic_patch {" << '\n' + << " type 0" << '\n' + << " flatness 0" << '\n' + << " u_steps 0" << '\n' + << " v_steps 0" << '\n'; for (int i=0;i<16;++i) { out << "\t<" << ver[i](0) << "," << patch->data(0,i) << "," << ver[i](1) << ">"; if (i!=15) out << ","; - out << std::endl; + out << '\n'; } - out << " texture {Tex}" << std::endl - << "}" << std::endl; + out << " texture {Tex}" << '\n' + << "}" << '\n'; } } if (!flags.bicubic_patch) { // the end of the mesh - out << " texture {Tex}" << std::endl - << "}" << std::endl - << std::endl; + out << " texture {Tex}" << '\n' + << "}" << '\n' + << '\n'; } + // make sure everything now gets to + // disk + out.flush (); + AssertThrow (out, ExcIO()); } @@ -2506,16 +2522,16 @@ void DataOutBase::write_eps (const std::vector > &patches, // use std::time_t time1= std::time (0); std::tm *time = std::localtime(&time1); - out << "%!PS-Adobe-2.0 EPSF-1.2" << std::endl - << "%%Title: deal.II Output" << std::endl - << "%%Creator: the deal.II library" << std::endl + out << "%!PS-Adobe-2.0 EPSF-1.2" << '\n' + << "%%Title: deal.II Output" << '\n' + << "%%Creator: the deal.II library" << '\n' << "%%Creation Date: " << time->tm_year+1900 << "/" << time->tm_mon+1 << "/" << time->tm_mday << " - " << time->tm_hour << ":" << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << std::endl + << std::setw(2) << time->tm_sec << '\n' << "%%BoundingBox: " // lower left corner << "0 0 " @@ -2523,7 +2539,7 @@ void DataOutBase::write_eps (const std::vector > &patches, << static_cast( rint((x_max-x_min) * scale )) << ' ' << static_cast( rint((y_max-y_min) * scale )) - << std::endl; + << '\n'; // define some abbreviations to keep // the output small: @@ -2533,17 +2549,17 @@ void DataOutBase::write_eps (const std::vector > &patches, // sg=set gray value // lx=close the line and plot the line // lf=close the line and fill the interior - out << "/m {moveto} bind def" << std::endl - << "/l {lineto} bind def" << std::endl - << "/s {setrgbcolor} bind def" << std::endl - << "/sg {setgray} bind def" << std::endl - << "/lx {lineto closepath stroke} bind def" << std::endl - << "/lf {lineto closepath fill} bind def" << std::endl; + out << "/m {moveto} bind def" << '\n' + << "/l {lineto} bind def" << '\n' + << "/s {setrgbcolor} bind def" << '\n' + << "/sg {setgray} bind def" << '\n' + << "/lx {lineto closepath stroke} bind def" << '\n' + << "/lf {lineto closepath fill} bind def" << '\n'; - out << "%%EndProlog" << std::endl - << std::endl; + out << "%%EndProlog" << '\n' + << '\n'; // set fine lines - out << flags.line_width << " setlinewidth" << std::endl; + out << flags.line_width << " setlinewidth" << '\n'; // allow only five digits // for output (instead of the // default six); this should suffice @@ -2602,7 +2618,7 @@ void DataOutBase::write_eps (const std::vector > &patches, << (cell->vertices[1]-offset) * scale << " l " << (cell->vertices[2]-offset) * scale << " l " << (cell->vertices[3]-offset) * scale << " lf" - << std::endl; + << '\n'; } if (flags.draw_mesh) @@ -2611,9 +2627,9 @@ void DataOutBase::write_eps (const std::vector > &patches, << (cell->vertices[1]-offset) * scale << " l " << (cell->vertices[2]-offset) * scale << " l " << (cell->vertices[3]-offset) * scale << " lx" - << std::endl; + << '\n'; } - out << "showpage" << std::endl; + out << "showpage" << '\n'; break; } @@ -2621,6 +2637,12 @@ void DataOutBase::write_eps (const std::vector > &patches, default: Assert (false, ExcNotImplemented()); } + + // make sure everything now gets to + // disk + out.flush (); + + AssertThrow (out, ExcIO()); } @@ -2647,8 +2669,8 @@ void DataOutBase::write_gmv (const std::vector > &patches, /////////////////////// // preamble out << "gmvinput ascii" - << std::endl - << std::endl; + << '\n' + << '\n'; // first count the number of cells // and cells for later use @@ -2715,7 +2737,7 @@ void DataOutBase::write_gmv (const std::vector > &patches, // // note that we have to print // d=1..3 dimensions - out << "nodes " << n_nodes << std::endl; + out << "nodes " << n_nodes << '\n'; for (unsigned int d=1; d<=3; ++d) { for (typename std::vector >::const_iterator patch=patches.begin(); @@ -2803,17 +2825,17 @@ void DataOutBase::write_gmv (const std::vector > &patches, out << "0 "; } } - out << std::endl; + out << '\n'; } - out << std::endl; + out << '\n'; ///////////////////////////////// // now for the cells. note that // vertices are counted from 1 onwards if (true) { - out << "cells " << n_cells << std::endl; + out << "cells " << n_cells << '\n'; unsigned int first_vertex_of_patch = 0; @@ -2832,7 +2854,7 @@ void DataOutBase::write_gmv (const std::vector > &patches, for (unsigned int i=0; i > &patches, << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j+1 << ' ' << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j+1+1 << ' ' << first_vertex_of_patch+i*(n_subdivisions+1)+j+1+1 - << std::endl; + << '\n'; break; } @@ -2865,7 +2887,7 @@ void DataOutBase::write_gmv (const std::vector > &patches, << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j )*(n_subdivisions+1)+k+1+1 << ' ' << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j+1)*(n_subdivisions+1)+k+1+1 << ' ' << first_vertex_of_patch+(i*(n_subdivisions+1)+j+1 )*(n_subdivisions+1)+k+1+1 << ' ' - << std::endl; + << '\n'; } break; } @@ -2895,12 +2917,12 @@ void DataOutBase::write_gmv (const std::vector > &patches, Assert (false, ExcNotImplemented()); } } - out << std::endl; + out << '\n'; } /////////////////////////////////////// // data output. - out << "variable" << std::endl; + out << "variable" << '\n'; // now write the data vectors to // @p{out} first make sure that all @@ -2913,23 +2935,27 @@ void DataOutBase::write_gmv (const std::vector > &patches, // support explicitly here) for (unsigned int data_set=0; data_set(out, " ")); - out << std::endl - << std::endl; + out << '\n' + << '\n'; } // end of variable section - out << "endvars" << std::endl; + out << "endvars" << '\n'; // end of output out << "endgmv" - << std::endl; + << '\n'; + // make sure everything now gets to + // disk + out.flush (); + // assert the stream is still ok AssertThrow (out, ExcIO()); } @@ -2994,19 +3020,19 @@ void DataOutBase::write_tecplot (const std::vector > &patche { std::time_t time1= std::time (0); std::tm *time = std::localtime(&time1); - out << "# This file was generated by the deal.II library." << std::endl + out << "# This file was generated by the deal.II library." << '\n' << "# Date = " << time->tm_year+1900 << "/" << time->tm_mon+1 << "/" - << time->tm_mday << std::endl + << time->tm_mday << '\n' << "# Time = " << time->tm_hour << ":" << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << std::endl - << "#" << std::endl + << std::setw(2) << time->tm_sec << '\n' + << "#" << '\n' << "# For a description of the Tecplot format see the Tecplot documentation." - << std::endl - << "#" << std::endl; + << '\n' + << "#" << '\n'; out << "Variables="; @@ -3029,7 +3055,7 @@ void DataOutBase::write_tecplot (const std::vector > &patche for (unsigned int data_set=0; data_set 1) { @@ -3038,17 +3064,17 @@ void DataOutBase::write_tecplot (const std::vector > &patche switch (dim) { case 2: - out << "quadrilateral" << std::endl; + out << "quadrilateral" << '\n'; break; case 3: - out << "brick" << std::endl; + out << "brick" << '\n'; break; default: Assert (false, ExcNotImplemented()); } } else - out << "zone f=block, n=" << n_nodes << std::endl; + out << "zone f=block, n=" << n_nodes << '\n'; } @@ -3163,7 +3189,7 @@ void DataOutBase::write_tecplot (const std::vector > &patche Assert (false, ExcNotImplemented()); } } - out << std::endl; + out << '\n'; } @@ -3181,7 +3207,7 @@ void DataOutBase::write_tecplot (const std::vector > &patche std::copy (data_vectors[data_set].begin(), data_vectors[data_set].end(), std::ostream_iterator(out, "\n")); - out << std::endl; + out << '\n'; } @@ -3214,7 +3240,7 @@ void DataOutBase::write_tecplot (const std::vector > &patche << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j+1 << ' ' << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j+1+1 << ' ' << first_vertex_of_patch+i*(n_subdivisions+1)+j+1+1 - << std::endl; + << '\n'; } break; } @@ -3235,7 +3261,7 @@ void DataOutBase::write_tecplot (const std::vector > &patche << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j )*(n_subdivisions+1)+k+1+1 << ' ' << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j+1)*(n_subdivisions+1)+k+1+1 << ' ' << first_vertex_of_patch+(i*(n_subdivisions+1)+j+1 )*(n_subdivisions+1)+k+1+1 << ' ' - << std::endl; + << '\n'; } break; } @@ -3267,6 +3293,9 @@ void DataOutBase::write_tecplot (const std::vector > &patche } + // make sure everything now gets to + // disk + out.flush (); // assert the stream is still ok AssertThrow (out, ExcIO()); @@ -3762,7 +3791,7 @@ void DataOutBase::write_vtk (const std::vector > &patches, std::time_t time1= std::time (0); std::tm *time = std::localtime(&time1); out << "# vtk DataFile Version 3.0" - << std::endl + << '\n' << "This file was generated by the deal.II library on " << time->tm_year+1900 << "/" << time->tm_mon+1 << "/" @@ -3770,11 +3799,11 @@ void DataOutBase::write_vtk (const std::vector > &patches, << time->tm_hour << ":" << std::setw(2) << time->tm_min << ":" << std::setw(2) << time->tm_sec - << std::endl + << '\n' << "ASCII" - << std::endl + << '\n' << "DATASET UNSTRUCTURED_GRID" - << std::endl; + << '\n'; } @@ -3844,7 +3873,7 @@ void DataOutBase::write_vtk (const std::vector > &patches, // // note that we have to print // d=1..3 dimensions - out << "POINTS " << n_nodes << " double" << std::endl; + out << "POINTS " << n_nodes << " double" << '\n'; for (typename std::vector >::const_iterator patch=patches.begin(); patch!=patches.end(); ++patch) { @@ -3905,7 +3934,7 @@ void DataOutBase::write_vtk (const std::vector > &patches, (patch->vertices[4] * (1-x_frac))) * (1-y_frac) + ((patch->vertices[6] * x_frac) + (patch->vertices[7] * (1-x_frac))) * y_frac) * z_frac) - << std::endl; + << '\n'; } break; @@ -3922,7 +3951,7 @@ void DataOutBase::write_vtk (const std::vector > &patches, { out << "CELLS " << n_cells << ' ' << n_cells*(GeometryInfo::vertices_per_cell+1) - << std::endl; + << '\n'; unsigned int first_vertex_of_patch = 0; @@ -3941,7 +3970,7 @@ void DataOutBase::write_vtk (const std::vector > &patches, for (unsigned int i=0; i > &patches, << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j << ' ' << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j+1 << ' ' << first_vertex_of_patch+i*(n_subdivisions+1)+j+1 - << std::endl; + << '\n'; break; } @@ -3974,7 +4003,7 @@ void DataOutBase::write_vtk (const std::vector > &patches, << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j )*(n_subdivisions+1)+k+1 << ' ' << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j+1)*(n_subdivisions+1)+k+1 << ' ' << first_vertex_of_patch+(i*(n_subdivisions+1)+j+1 )*(n_subdivisions+1)+k+1 << ' ' - << std::endl; + << '\n'; } break; } @@ -4008,7 +4037,7 @@ void DataOutBase::write_vtk (const std::vector > &patches, // next output the types of the // cells. since all cells are // the same, this is simple - out << "CELL_TYPES " << n_cells << std::endl; + out << "CELL_TYPES " << n_cells << '\n'; for (unsigned int i=0; i > &patches, // here). all following data sets // are point data out << "POINT_DATA " << n_nodes - << std::endl; + << '\n'; for (unsigned int data_set=0; data_set(out, " ")); - out << std::endl; + out << '\n'; } + // make sure everything now gets to + // disk + out.flush (); + // assert the stream is still ok AssertThrow (out, ExcIO()); } @@ -4075,21 +4108,24 @@ write_deal_II_intermediate (const std::vector > &patches, // here because we may want to read in data // again even if we don't know in advance // the template parameters, see step-19 - out << dim << ' ' << spacedim << std::endl; + out << dim << ' ' << spacedim << '\n'; // then write a header - out << "[deal.II intermediate format graphics data]" << std::endl - << "[written by " << PACKAGE_STRING << "]" << std::endl; + out << "[deal.II intermediate format graphics data]" << '\n' + << "[written by " << PACKAGE_STRING << "]" << '\n'; - out << data_names.size() << std::endl; + out << data_names.size() << '\n'; for (unsigned int i=0; i]" - << std::endl; + << '\n'; // then write all the data that is // in this patch for (unsigned int i=0; i::vertices_per_cell; ++i) out << patch.vertices[i] << " "; - out << std::endl; + out << '\n'; for (unsigned int i=0; i::faces_per_cell; ++i) out << patch.neighbors[i] << " "; - out << std::endl; + out << '\n'; out << patch.patch_index << ' ' << patch.n_subdivisions - << std::endl; + << '\n'; - out << patch.data.n_rows() << ' ' << patch.data.n_cols() << std::endl; + out << patch.data.n_rows() << ' ' << patch.data.n_cols() << '\n'; for (unsigned int i=0; i &tria, // write the vertices out << "object \"vertices\" class array type float rank 1 shape " << dim << " items " << n_vertices << " data follows" - << std::endl; + << '\n'; for (unsigned int i=0; i &tria, { out << "object \"cells\" class array type int rank 1 shape " << n_vertices_per_cell - << " items " << n_cells << " data follows" << std::endl; + << " items " << n_cells << " data follows" << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) { for (unsigned int v=0; v::vertices_per_cell; ++v) out << '\t' << cell->vertex_index(GeometryInfo::dx_to_deal[v]); - out << std::endl; + out << '\n'; } out << "attribute \"element type\" string \""; if (dim==1) out << "lines"; if (dim==2) out << "quads"; if (dim==3) out << "cubes"; - out << "\"" << std::endl - << "attribute \"ref\" string \"positions\"" << std::endl << std::endl; + out << "\"" << '\n' + << "attribute \"ref\" string \"positions\"" << '\n' << '\n'; // Additional cell information out << "object \"material\" class array type int rank 0 items " - << n_cells << " data follows" << std::endl; + << n_cells << " data follows" << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) out << ' ' << (unsigned int)cell->material_id(); - out << std::endl - << "attribute \"dep\" string \"connections\"" << std::endl << std::endl; + out << '\n' + << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; out << "object \"level\" class array type int rank 0 items " - << n_cells << " data follows" << std::endl; + << n_cells << " data follows" << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) out << ' ' << cell->level(); - out << std::endl - << "attribute \"dep\" string \"connections\"" << std::endl << std::endl; + out << '\n' + << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; if (dx_flags.write_measure) { out << "object \"measure\" class array type float rank 0 items " - << n_cells << " data follows" << std::endl; + << n_cells << " data follows" << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) out << '\t' << cell->measure(); - out << std::endl - << "attribute \"dep\" string \"connections\"" << std::endl << std::endl; + out << '\n' + << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; } if (dx_flags.write_diameter) { out << "object \"diameter\" class array type float rank 0 items " - << n_cells << " data follows" << std::endl; + << n_cells << " data follows" << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) out << '\t' << cell->diameter(); - out << std::endl - << "attribute \"dep\" string \"connections\"" << std::endl << std::endl; + out << '\n' + << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; } } @@ -142,7 +142,7 @@ void GridOut::write_dx (const Triangulation &tria, out << "object \"faces\" class array type int rank 1 shape " << n_vertices_per_face << " items " << n_faces << " data follows" - << std::endl; + << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) { @@ -152,54 +152,54 @@ void GridOut::write_dx (const Triangulation &tria, for (unsigned int v=0; v::vertices_per_face; ++v) out << '\t' << face->vertex_index(GeometryInfo::dx_to_deal[v]); - out << std::endl; + out << '\n'; } } out << "attribute \"element type\" string \""; if (dim==2) out << "lines"; if (dim==3) out << "quads"; - out << "\"" << std::endl - << "attribute \"ref\" string \"positions\"" << std::endl << std::endl; + out << "\"" << '\n' + << "attribute \"ref\" string \"positions\"" << '\n' << '\n'; // Additional face information out << "object \"boundary\" class array type int rank 0 items " - << n_faces << " data follows" << std::endl; + << n_faces << " data follows" << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) { // Little trick to get -1 // for the interior for (unsigned int f=0;f::faces_per_cell;++f) out << ' ' << (int)(signed char)cell->face(f)->boundary_indicator(); - out << std::endl; + out << '\n'; } - out << "attribute \"dep\" string \"connections\"" << std::endl << std::endl; + out << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; if (dx_flags.write_measure) { out << "object \"face measure\" class array type float rank 0 items " - << n_faces << " data follows" << std::endl; + << n_faces << " data follows" << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) { for (unsigned int f=0;f::faces_per_cell;++f) out << ' ' << cell->face(f)->measure(); - out << std::endl; + out << '\n'; } - out << "attribute \"dep\" string \"connections\"" << std::endl << std::endl; + out << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; } if (dx_flags.write_diameter) { out << "object \"face diameter\" class array type float rank 0 items " - << n_faces << " data follows" << std::endl; + << n_faces << " data follows" << '\n'; for (cell = tria.begin_active(); cell != endc; ++cell) { for (unsigned int f=0;f::faces_per_cell;++f) out << ' ' << cell->face(f)->diameter(); - out << std::endl; + out << '\n'; } - out << "attribute \"dep\" string \"connections\"" << std::endl << std::endl; + out << "attribute \"dep\" string \"connections\"" << '\n' << '\n'; } } @@ -213,45 +213,51 @@ void GridOut::write_dx (const Triangulation &tria, } else { - } + } // The wrapper - out << "object \"deal data\" class field" << std::endl - << "component \"positions\" value \"vertices\"" << std::endl - << "component \"connections\" value \"cells\"" << std::endl; + out << "object \"deal data\" class field" << '\n' + << "component \"positions\" value \"vertices\"" << '\n' + << "component \"connections\" value \"cells\"" << '\n'; if (write_cells) { - out << "object \"cell data\" class field" << std::endl - << "component \"positions\" value \"vertices\"" << std::endl - << "component \"connections\" value \"cells\"" << std::endl; - out << "component \"material\" value \"material\"" << std::endl; - out << "component \"level\" value \"level\"" << std::endl; + out << "object \"cell data\" class field" << '\n' + << "component \"positions\" value \"vertices\"" << '\n' + << "component \"connections\" value \"cells\"" << '\n'; + out << "component \"material\" value \"material\"" << '\n'; + out << "component \"level\" value \"level\"" << '\n'; if (dx_flags.write_measure) - out << "component \"measure\" value \"measure\"" << std::endl; + out << "component \"measure\" value \"measure\"" << '\n'; if (dx_flags.write_diameter) - out << "component \"diameter\" value \"diameter\"" << std::endl; + out << "component \"diameter\" value \"diameter\"" << '\n'; } if (write_faces) { - out << "object \"face data\" class field" << std::endl - << "component \"positions\" value \"vertices\"" << std::endl - << "component \"connections\" value \"faces\"" << std::endl; - out << "component \"boundary\" value \"boundary\"" << std::endl; + out << "object \"face data\" class field" << '\n' + << "component \"positions\" value \"vertices\"" << '\n' + << "component \"connections\" value \"faces\"" << '\n'; + out << "component \"boundary\" value \"boundary\"" << '\n'; if (dx_flags.write_measure) - out << "component \"measure\" value \"face measure\"" << std::endl; + out << "component \"measure\" value \"face measure\"" << '\n'; if (dx_flags.write_diameter) - out << "component \"diameter\" value \"face diameter\"" << std::endl; + out << "component \"diameter\" value \"face diameter\"" << '\n'; } - out << std::endl - << "object \"grid data\" class group" << std::endl; + out << '\n' + << "object \"grid data\" class group" << '\n'; if (write_cells) - out << "member \"cells\" value \"cell data\"" << std::endl; + out << "member \"cells\" value \"cell data\"" << '\n'; if (write_faces) - out << "member \"faces\" value \"face data\"" << std::endl; - out << "end" << std::endl; + out << "member \"faces\" value \"face data\"" << '\n'; + out << "end" << '\n'; + + // make sure everything now gets to + // disk + out.flush (); + + AssertThrow (out, ExcIO()); } @@ -283,19 +289,19 @@ void GridOut::write_ucd (const Triangulation &tria, // use std::time_t time1= std::time (0); std::tm *time = std::localtime(&time1); - out << "# This file was generated by the deal.II library." << std::endl + out << "# This file was generated by the deal.II library." << '\n' << "# Date = " << time->tm_year+1900 << "/" << time->tm_mon+1 << "/" - << time->tm_mday << std::endl + << time->tm_mday << '\n' << "# Time = " << time->tm_hour << ":" << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << std::endl - << "#" << std::endl + << std::setw(2) << time->tm_sec << '\n' + << "#" << '\n' << "# For a description of the UCD format see the AVS Developer's guide." - << std::endl - << "#" << std::endl; + << '\n' + << "#" << '\n'; }; // start with ucd data @@ -304,7 +310,7 @@ void GridOut::write_ucd (const Triangulation &tria, n_boundary_faces(tria) : 0) << " 0 0 0" // no data - << std::endl; + << '\n'; // actually write the vertices. // note that we shall number them @@ -317,7 +323,7 @@ void GridOut::write_ucd (const Triangulation &tria, << vertices[i]; for (unsigned int d=dim+1; d<=3; ++d) out << " 0"; // fill with zeroes - out << std::endl; + out << '\n'; }; // write cells. Enumerate cells @@ -356,7 +362,7 @@ void GridOut::write_ucd (const Triangulation &tria, for (unsigned int vertex=0; vertex::vertices_per_cell; ++vertex) out << cell->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1 << ' '; - out << std::endl; + out << '\n'; }; // write faces with non-zero boundary @@ -364,6 +370,10 @@ void GridOut::write_ucd (const Triangulation &tria, if (ucd_flags.write_faces) write_ucd_faces (tria, cell_index, out); + // make sure everything now gets to + // disk + out.flush (); + AssertThrow (out, ExcIO()); } @@ -393,13 +403,13 @@ void GridOut::write_xfig (const Triangulation& tria, // The following text was copied // from an existing XFig file. - out << "#FIG 3.2\nLandscape\nCenter\nInches" << std::endl - << "A4\n100.00\nSingle" << std::endl + out << "#FIG 3.2\nLandscape\nCenter\nInches" << '\n' + << "A4\n100.00\nSingle" << '\n' // Background is transparent - << "-3" << std::endl - << "# generated by deal.II GridOut class" << std::endl - << "# reduce first number to scale up image" << std::endl - << "1200 2" << std::endl; + << "-3" << '\n' + << "# generated by deal.II GridOut class" << '\n' + << "# reduce first number to scale up image" << '\n' + << "1200 2" << '\n'; // We write all cells and cells on // coarser levels are behind cells @@ -435,7 +445,7 @@ void GridOut::write_xfig (const Triangulation& tria, // some style parameters << " 0 0 -1 0 0 " // number of points - << nv+1 << std::endl; + << nv+1 << '\n'; // For each point, write scaled // and shifted coordinates @@ -451,7 +461,7 @@ void GridOut::write_xfig (const Triangulation& tria, (p(d)-xfig_flags.offset(d))); out << '\t' << val; } - out << std::endl; + out << '\n'; } // Now write boundary edges static const unsigned int face_reorder[4]={2,1,3,0}; @@ -480,7 +490,7 @@ void GridOut::write_xfig (const Triangulation& tria, // some style parameters << " 0 0 -1 0 0 " // number of points - << nvf << std::endl; + << nvf << '\n'; // For each point, write scaled // and shifted coordinates @@ -496,11 +506,17 @@ void GridOut::write_xfig (const Triangulation& tria, (p(d)-xfig_flags.offset(d))); out << '\t' << val; } - out << std::endl; + out << '\n'; } } } } + + // make sure everything now gets to + // disk + out.flush (); + + AssertThrow (out, ExcIO()); } #endif @@ -574,7 +590,7 @@ void GridOut::write_ucd_faces (const Triangulation &tria, // note: vertex numbers are 1-base for (unsigned int vertex=0; vertex::vertices_per_face; ++vertex) out << face->vertex_index(GeometryInfo::ucd_to_deal[vertex])+1 << ' '; - out << std::endl; + out << '\n'; ++index; }; @@ -595,17 +611,22 @@ void GridOut::write_gnuplot (const Triangulation<1> &tria, for (; cell!=endc; ++cell) { if (gnuplot_flags.write_cell_numbers) - out << "# cell " << cell << std::endl; + out << "# cell " << cell << '\n'; out << cell->vertex(0) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << cell->vertex(1) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl - << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; break; } + + // make sure everything now gets to + // disk + out.flush (); + AssertThrow (out, ExcIO()); } @@ -652,7 +673,7 @@ void GridOut::write_gnuplot (const Triangulation<2> &tria, for (; cell!=endc; ++cell) { if (gnuplot_flags.write_cell_numbers) - out << "# cell " << cell << std::endl; + out << "# cell " << cell << '\n'; if (mapping==0 || !cell->at_boundary()) { @@ -666,12 +687,12 @@ void GridOut::write_gnuplot (const Triangulation<2> &tria, for (unsigned int i=0; i::vertices_per_cell; ++i) out << cell->vertex(GeometryInfo::ucd_to_deal[i]) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n'; out << cell->vertex(0) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl - << std::endl // double new line for gnuplot 3d plots - << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n' // double new line for gnuplot 3d plots + << '\n'; } else // cell is at boundary and we @@ -698,10 +719,10 @@ void GridOut::write_gnuplot (const Triangulation<2> &tria, (cell, q_projector->point(offset+i))) << ' ' << cell->level() << ' ' << static_cast(cell->material_id()) - << std::endl; + << '\n'; - out << std::endl - << std::endl; + out << '\n' + << '\n'; } else { @@ -713,22 +734,25 @@ void GridOut::write_gnuplot (const Triangulation<2> &tria, out << face->vertex(0) << ' ' << cell->level() << ' ' << static_cast(cell->material_id()) - << std::endl + << '\n' << face->vertex(1) << ' ' << cell->level() << ' ' << static_cast(cell->material_id()) - << std::endl - << std::endl - << std::endl; + << '\n' + << '\n' + << '\n'; } } } } if (q_projector != 0) - delete q_projector; - + delete q_projector; + // make sure everything now gets to + // disk + out.flush (); + AssertThrow (out, ExcIO()); } @@ -778,74 +802,74 @@ void GridOut::write_gnuplot (const Triangulation<3> &tria, for (; cell!=endc; ++cell) { if (gnuplot_flags.write_cell_numbers) - out << "# cell " << cell << std::endl; + out << "# cell " << cell << '\n'; if (mapping==0 || n_points==2 || !cell->has_boundary_lines()) { // front face out << cell->vertex(0) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << cell->vertex(1) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << cell->vertex(5) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << cell->vertex(4) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << cell->vertex(0) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl - << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; // back face out << cell->vertex(2) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << cell->vertex(3) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << cell->vertex(7) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << cell->vertex(6) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << cell->vertex(2) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl - << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; // now for the four connecting lines out << cell->vertex(0) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << cell->vertex(2) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl - << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; out << cell->vertex(1) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << cell->vertex(3) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl - << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; out << cell->vertex(5) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << cell->vertex(7) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl - << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; out << cell->vertex(4) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << cell->vertex(6) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl - << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n' + << '\n'; } else { @@ -864,27 +888,27 @@ void GridOut::write_gnuplot (const Triangulation<3> &tria, cell, q_projector->point(offset+i*n_points+j)); out << p0 << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n'; out << (mapping->transform_unit_to_real_cell( cell, q_projector->point(offset+(i+1)*n_points+j))) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n'; out << (mapping->transform_unit_to_real_cell( cell, q_projector->point(offset+(i+1)*n_points+j+1))) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n'; out << (mapping->transform_unit_to_real_cell( cell, q_projector->point(offset+i*n_points+j+1))) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n'; // and the // first // point // again out << p0 << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl; - out << std::endl << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n'; + out << '\n' << '\n'; } } else @@ -913,17 +937,17 @@ void GridOut::write_gnuplot (const Triangulation<3> &tria, out << (mapping->transform_unit_to_real_cell (cell, (1-boundary_points[i][0])*u0+boundary_points[i][0]*u1)) << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n'; } else out << v0 << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl + << ' ' << static_cast(cell->material_id()) << '\n' << v1 << ' ' << cell->level() - << ' ' << static_cast(cell->material_id()) << std::endl; + << ' ' << static_cast(cell->material_id()) << '\n'; - out << std::endl << std::endl; + out << '\n' << '\n'; } } } @@ -934,6 +958,10 @@ void GridOut::write_gnuplot (const Triangulation<3> &tria, delete q_projector; + // make sure everything now gets to + // disk + out.flush (); + AssertThrow (out, ExcIO()); } @@ -1232,16 +1260,16 @@ void GridOut::write_eps (const Triangulation &tria, // use std::time_t time1= std::time (0); std::tm *time = std::localtime(&time1); - out << "%!PS-Adobe-2.0 EPSF-1.2" << std::endl - << "%%Title: deal.II Output" << std::endl - << "%%Creator: the deal.II library" << std::endl + out << "%!PS-Adobe-2.0 EPSF-1.2" << '\n' + << "%%Title: deal.II Output" << '\n' + << "%%Creator: the deal.II library" << '\n' << "%%Creation Date: " << time->tm_year+1900 << "/" << time->tm_mon+1 << "/" << time->tm_mday << " - " << time->tm_hour << ":" << std::setw(2) << time->tm_min << ":" - << std::setw(2) << time->tm_sec << std::endl + << std::setw(2) << time->tm_sec << '\n' << "%%BoundingBox: " // lower left corner << "0 0 " @@ -1249,7 +1277,7 @@ void GridOut::write_eps (const Triangulation &tria, << static_cast(std::floor(( (x_max-x_min) * scale )+1)) << ' ' << static_cast(std::floor(( (y_max-y_min) * scale )+1)) - << std::endl; + << '\n'; // define some abbreviations to keep // the output small: @@ -1257,10 +1285,10 @@ void GridOut::write_eps (const Triangulation &tria, // x=execute line stroke // b=black pen // r=red pen - out << "/m {moveto} bind def" << std::endl - << "/x {lineto stroke} bind def" << std::endl - << "/b {0 0 0 setrgbcolor} def" << std::endl - << "/r {1 0 0 setrgbcolor} def" << std::endl; + out << "/m {moveto} bind def" << '\n' + << "/x {lineto stroke} bind def" << '\n' + << "/b {0 0 0 setrgbcolor} def" << '\n' + << "/r {1 0 0 setrgbcolor} def" << '\n'; // calculate colors for level // coloring; level 0 is black, @@ -1271,7 +1299,7 @@ void GridOut::write_eps (const Triangulation &tria, << (max_level) << " add " << (0.66666/std::max(1U,(max_level-1))) - << " mul 1 0.8 sethsbcolor} def" << std::endl; + << " mul 1 0.8 sethsbcolor} def" << '\n'; // in 2d, we can also plot cell // and vertex numbers, but this @@ -1297,14 +1325,14 @@ void GridOut::write_eps (const Triangulation &tria, "{pop} ifelse} forall} bind def\n" "/MCshow { currentpoint stroke m\n" "exch dup MFwidth -2 div 3 -1 roll R MFshow } def\n") - << std::endl; + << '\n'; }; - out << "%%EndProlog" << std::endl - << std::endl; + out << "%%EndProlog" << '\n' + << '\n'; // set fine lines - out << eps_flags_base.line_width << " setlinewidth" << std::endl; + out << eps_flags_base.line_width << " setlinewidth" << '\n'; }; // now write the lines @@ -1320,18 +1348,18 @@ void GridOut::write_eps (const Triangulation &tria, out << line->level << " l " << (line->first - offset) * scale << " m " - << (line->second - offset) * scale << " x" << std::endl; + << (line->second - offset) * scale << " x" << '\n'; else out << ((line->colorize && eps_flags_base.color_lines_on_user_flag) ? "r " : "b ") << (line->first - offset) * scale << " m " - << (line->second - offset) * scale << " x" << std::endl; + << (line->second - offset) * scale << " x" << '\n'; // finally write the cell numbers // in 2d, if that is desired if ((dim == 2) && (eps_flags_2.write_cell_numbers == true)) { out << "(Helvetica) findfont 140 scalefont setfont" - << std::endl; + << '\n'; typename Triangulation::active_cell_iterator cell = tria.begin_active (), @@ -1340,7 +1368,7 @@ void GridOut::write_eps (const Triangulation &tria, { out << (cell->center()(0)-offset(0))*scale << ' ' << (cell->center()(1)-offset(1))*scale - << " m" << std::endl + << " m" << '\n' << "[ [(Helvetica) 12.0 0.0 true true ("; if (eps_flags_2.write_cell_number_level) out << cell; @@ -1349,7 +1377,7 @@ void GridOut::write_eps (const Triangulation &tria, out << ")] " << "] -6 MCshow" - << std::endl; + << '\n'; }; }; @@ -1357,7 +1385,7 @@ void GridOut::write_eps (const Triangulation &tria, if ((dim == 2) && (eps_flags_2.write_vertex_numbers == true)) { out << "(Helvetica) findfont 140 scalefont setfont" - << std::endl; + << '\n'; // have a list of those // vertices which we have @@ -1379,17 +1407,21 @@ void GridOut::write_eps (const Triangulation &tria, out << (cell->vertex(vertex)(0)-offset(0))*scale << ' ' << (cell->vertex(vertex)(1)-offset(1))*scale - << " m" << std::endl + << " m" << '\n' << "[ [(Helvetica) 10.0 0.0 true true (" << cell->vertex_index(vertex) << ")] " << "] -6 MCshow" - << std::endl; + << '\n'; }; }; - out << "showpage" << std::endl; + out << "showpage" << '\n'; + // make sure everything now gets to + // disk + out.flush (); + AssertThrow (out, ExcIO()); }