From 60b5c2b4bc5f55635b2a4b27b62fc3fb47ef1447 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 5 Nov 2012 00:18:10 +0000 Subject: [PATCH] Partial merge from the parallel_mg branch: Improve GridOut::write_xfig. git-svn-id: https://svn.dealii.org/trunk@27375 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 6 ++ deal.II/include/deal.II/grid/grid_out.h | 15 ++++ deal.II/source/grid/grid_out.cc | 91 ++++++++++++++++++++----- 3 files changed, 95 insertions(+), 17 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index ad8e51d12e..3b3c5f43f4 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -154,6 +154,12 @@ DoFHandler, in particular removal of specializations.

Specific improvements

    +
  1. Changed: GridOut::write_xfig has been improved in a number +of ways. In particular, one can now color cells based on a number +of different criteria that can be set in GridOutFlags::XFig. +
    +(Guido Kanschat, 2012/11/04) +
  2. New: The PETScWrappers::SparseDirectMUMPS class now allows to exploit symmetry of the matrix, using the PETScWrappers::SparseDirectMUMPS::set_symmetric_mode() function. diff --git a/deal.II/include/deal.II/grid/grid_out.h b/deal.II/include/deal.II/grid/grid_out.h index c79fae7bb0..ab84f71628 100644 --- a/deal.II/include/deal.II/grid/grid_out.h +++ b/deal.II/include/deal.II/grid/grid_out.h @@ -621,7 +621,22 @@ namespace GridOutFlags * Draw boundary lines. Default is true. */ bool draw_boundary; + /** + * An enum used for deciding which field is used for coloring the cells. + */ + enum Coloring { + /// Convert the material id into the cell color + material_id, + /// Convert the level into the cell color + level_number, + /// Convert the global subdomain id into the cell color + subdomain_id, + /// Convert the level subdomain id into the cell color + level_subdomain_id + } color_by; /** + * @deprecated Use the #color_by enum instead. If #color_by is different from #material_id, this flag is ignored. + * * Change color depending on * level. Default is false, therefore, * color is coded by material or diff --git a/deal.II/source/grid/grid_out.cc b/deal.II/source/grid/grid_out.cc index fc1d465955..f7a0fbfd86 100644 --- a/deal.II/source/grid/grid_out.cc +++ b/deal.II/source/grid/grid_out.cc @@ -1080,7 +1080,6 @@ void GridOut::write_xfig ( //TODO:[GK] Obey parameters -//TODO:[GK] Flip y-axis? template <> void GridOut::write_xfig ( const Triangulation<2>& tria, @@ -1095,13 +1094,55 @@ void GridOut::write_xfig ( // The following text was copied // from an existing XFig file. - out << "#FIG 3.2\nLandscape\nCenter\nInches" << '\n' - << "A4\n100.00\nSingle" << '\n' + out << "#FIG 3.2\nLandscape\nCenter\nInches" << std::endl + << "A4\n100.00\nSingle" << std::endl // Background is transparent - << "-3" << '\n' - << "# generated by deal.II GridOut class" << '\n' - << "# reduce first number to scale up image" << '\n' - << "1200 2" << '\n'; + << "-3" << std::endl + << "# generated by deal.II GridOut class" << std::endl + << "# reduce first number to scale up image" << std::endl + << "1200 2" << std::endl; + // Write custom palette + //grey + unsigned int colno = 32; + out << "0 " << colno++ << " #ff0000" << std::endl; + out << "0 " << colno++ << " #ff8000" << std::endl; + out << "0 " << colno++ << " #ffd000" << std::endl; + out << "0 " << colno++ << " #ffff00" << std::endl; + out << "0 " << colno++ << " #c0ff00" << std::endl; + out << "0 " << colno++ << " #80ff00" << std::endl; + out << "0 " << colno++ << " #00f000" << std::endl; + out << "0 " << colno++ << " #00f0c0" << std::endl; + out << "0 " << colno++ << " #00f0ff" << std::endl; + out << "0 " << colno++ << " #00c0ff" << std::endl; + out << "0 " << colno++ << " #0080ff" << std::endl; + out << "0 " << colno++ << " #0040ff" << std::endl; + out << "0 " << colno++ << " #0000c0" << std::endl; + out << "0 " << colno++ << " #5000ff" << std::endl; + out << "0 " << colno++ << " #8000ff" << std::endl; + out << "0 " << colno++ << " #b000ff" << std::endl; + out << "0 " << colno++ << " #ff00ff" << std::endl; + out << "0 " << colno++ << " #ff80ff" << std::endl; + // grey + for (unsigned int i=0;i<8;++i) + out << "0 " << colno++ << " #" << std::hex << 32*i+31 << 32*i+31 << 32*i+31 << std::dec << std::endl; + // green + for (unsigned int i=1;i<16;++i) + out << "0 " << colno++ << " #00" << std::hex << 16*i+15 << std::dec << "00" << std::endl; + // yellow + for (unsigned int i=1;i<16;++i) + out << "0 " << colno++ << " #" << std::hex << 16*i+15 << 16*i+15 << std::dec << "00" << std::endl; + // red + for (unsigned int i=1;i<16;++i) + out << "0 " << colno++ << " #" << std::hex << 16*i+15 << std::dec << "0000" << std::endl; + // purple + for (unsigned int i=1;i<16;++i) + out << "0 " << colno++ << " #" << std::hex << 16*i+15 << "00" << 16*i+15 << std::dec << std::endl; + // blue + for (unsigned int i=1;i<16;++i) + out << "0 " << colno++ << " #0000" << std::hex << 16*i+15 << std::dec << std::endl; + // cyan + for (unsigned int i=1;i<16;++i) + out << "0 " << colno++ << " #00" << std::hex << 16*i+15 << 16*i+15 << std::dec << std::endl; // We write all cells and cells on // coarser levels are behind cells @@ -1123,10 +1164,26 @@ void GridOut::write_xfig ( // with black line << " 0 "; // Fill color - if (xfig_flags.level_color) - out << cell->level() + 8; - else - out << cell->material_id() + 1; + switch(xfig_flags.color_by) + { +//TODO[GK]: Simplify after deprecation period is over + case GridOutFlags::XFig::material_id: + if (xfig_flags.level_color) + out << cell->level() + 32; + else + out << cell->material_id() + 32; + break; + case GridOutFlags::XFig::level_number: + out << cell->level() + 8; + break; + case GridOutFlags::XFig::subdomain_id: + out << cell->subdomain_id() + 32; + break; + case GridOutFlags::XFig::level_subdomain_id: + out << cell->level_subdomain_id() + 32; + break; + } + // Depth, unused, fill out << ' ' << (xfig_flags.level_depth @@ -1137,7 +1194,7 @@ void GridOut::write_xfig ( // some style parameters << " 0 0 -1 0 0 " // number of points - << nv+1 << '\n'; + << nv+1 << std::endl; // For each point, write scaled // and shifted coordinates @@ -1151,9 +1208,9 @@ void GridOut::write_xfig ( { int val = (int)(1200 * xfig_flags.scaling(d) * (p(d)-xfig_flags.offset(d))); - out << '\t' << val; + out << '\t' << ((d==0) ? val : -val); } - out << '\n'; + out << std::endl; } // Now write boundary edges static const unsigned int face_reorder[4]={2,1,3,0}; @@ -1182,7 +1239,7 @@ void GridOut::write_xfig ( // some style parameters << " 0 0 -1 0 0 " // number of points - << nvf << '\n'; + << nvf << std::endl; // For each point, write scaled // and shifted coordinates @@ -1196,9 +1253,9 @@ void GridOut::write_xfig ( { int val = (int)(1200 * xfig_flags.scaling(d) * (p(d)-xfig_flags.offset(d))); - out << '\t' << val; + out << '\t' << ((d==0) ? val : -val); } - out << '\n'; + out << std::endl; } } } -- 2.39.5