From: Guido Kanschat Date: Tue, 4 Apr 2006 22:43:42 +0000 (+0000) Subject: make write functions const and remove irritating specializations X-Git-Tag: v8.0.0~11910 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc26fc35bb1ab557f03666dcc1fee3e09ce7c8d4;p=dealii.git make write functions const and remove irritating specializations git-svn-id: https://svn.dealii.org/trunk@12820 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/grid_out.h b/deal.II/deal.II/include/grid/grid_out.h index 24753608f1..a4485ffbc9 100644 --- a/deal.II/deal.II/include/grid/grid_out.h +++ b/deal.II/deal.II/include/grid/grid_out.h @@ -761,7 +761,7 @@ class GridOut */ template void write_dx (const Triangulation &tria, - std::ostream &out); + std::ostream &out) const; /** * Write the triangulation in the @@ -822,25 +822,10 @@ class GridOut * documentation of the * GridOutFlags::Gnuplot() class. */ - void write_gnuplot (const Triangulation<3> &tria, - std::ostream &out, - const Mapping<3> *mapping=0); - - /** - * Specialization of above - * function for 2d - */ - void write_gnuplot (const Triangulation<2> &tria, - std::ostream &out, - const Mapping<2> *mapping=0); - - /** - * Declaration of the specialization - * of above function for 1d. - */ - void write_gnuplot (const Triangulation<1> &tria, + template + void write_gnuplot (const Triangulation &tria, std::ostream &out, - const Mapping<1> *mapping=0); + const Mapping *mapping=0) const; /** * Write the triangulation in the @@ -878,7 +863,7 @@ class GridOut */ template void write_msh (const Triangulation &tria, - std::ostream &out); + std::ostream &out) const; /** * Write the triangulation in the @@ -917,7 +902,7 @@ class GridOut */ template void write_ucd (const Triangulation &tria, - std::ostream &out); + std::ostream &out) const; /** * Write the triangulation in the @@ -978,17 +963,7 @@ class GridOut template void write_eps (const Triangulation &tria, std::ostream &out, - const Mapping *mapping=0); - - /** - * Declaration of the - * specialization of above - * function for 1d. This function - * is presently not implemented. - */ - void write_eps (const Triangulation<1> &tria, - std::ostream &out, - const Mapping<1> *mapping=0); + const Mapping *mapping=0) const; /** * Write two-dimensional XFig-file. @@ -1017,7 +992,7 @@ class GridOut template void write_xfig (const Triangulation &tria, std::ostream &out, - const Mapping *mapping=0); + const Mapping *mapping=0) const; /** * Write grid to @p out according @@ -1030,7 +1005,7 @@ class GridOut void write (const Triangulation &tria, std::ostream &out, const OutputFormat output_format, - const Mapping *mapping=0); + const Mapping *mapping=0) const; /** * Write mesh in default format @@ -1039,7 +1014,7 @@ class GridOut template void write (const Triangulation &tria, std::ostream &out, - const Mapping *mapping=0); + const Mapping *mapping=0) const; /** * Set flags for DX output diff --git a/deal.II/deal.II/source/grid/grid_out.cc b/deal.II/deal.II/source/grid/grid_out.cc index fccd06d2d9..a7508fb9f5 100644 --- a/deal.II/deal.II/source/grid/grid_out.cc +++ b/deal.II/deal.II/source/grid/grid_out.cc @@ -34,7 +34,7 @@ template void GridOut::write_dx (const Triangulation &, - std::ostream &) + std::ostream &) const { Assert (false, ExcNotImplemented()); } @@ -44,7 +44,7 @@ void GridOut::write_dx (const Triangulation &, template void GridOut::write_dx (const Triangulation &tria, - std::ostream &out) + std::ostream &out) const { //TODO:[GK] allow for boundary faces only Assert(dx_flags.write_all_faces, ExcNotImplemented()); @@ -266,7 +266,7 @@ void GridOut::write_dx (const Triangulation &tria, template void GridOut::write_msh (const Triangulation &tria, - std::ostream &out) + std::ostream &out) const { AssertThrow (out, ExcIO()); @@ -402,9 +402,10 @@ void GridOut::write_msh (const Triangulation &tria, AssertThrow (out, ExcIO()); } - template + +template void GridOut::write_ucd (const Triangulation &tria, - std::ostream &out) + std::ostream &out) const { AssertThrow (out, ExcIO()); @@ -518,10 +519,11 @@ void GridOut::write_ucd (const Triangulation &tria, #if deal_II_dimension != 2 - template -void GridOut::write_xfig (const Triangulation&, - std::ostream&, - const Mapping*) +template +void GridOut::write_xfig ( + const Triangulation&, + std::ostream&, + const Mapping*) const { Assert (false, ExcNotImplemented()); } @@ -530,10 +532,11 @@ void GridOut::write_xfig (const Triangulation&, //TODO:[GK] Obey parameters //TODO:[GK] Flip y-axis? - template -void GridOut::write_xfig (const Triangulation& tria, - std::ostream& out, - const Mapping* /*mapping*/) +template +void GridOut::write_xfig ( + const Triangulation& tria, + std::ostream& out, + const Mapping* /*mapping*/) const { const unsigned int nv = GeometryInfo::vertices_per_cell; const unsigned int nf = GeometryInfo::faces_per_cell; @@ -785,14 +788,16 @@ void GridOut::write_ucd_faces (const Triangulation &tria, #if deal_II_dimension==1 -void GridOut::write_gnuplot (const Triangulation<1> &tria, - std::ostream &out, - const Mapping<1> *) +template +void GridOut::write_gnuplot ( + const Triangulation &tria, + std::ostream &out, + const Mapping *) const { AssertThrow (out, ExcIO()); - Triangulation<1>::active_cell_iterator cell=tria.begin_active(); - const Triangulation<1>::active_cell_iterator endc=tria.end(); + typename Triangulation::active_cell_iterator cell=tria.begin_active(); + const typename Triangulation::active_cell_iterator endc=tria.end(); for (; cell!=endc; ++cell) { if (gnuplot_flags.write_cell_numbers) @@ -820,19 +825,20 @@ void GridOut::write_gnuplot (const Triangulation<1> &tria, #if deal_II_dimension==2 -void GridOut::write_gnuplot (const Triangulation<2> &tria, - std::ostream &out, - const Mapping<2> *mapping) +template +void GridOut::write_gnuplot ( + const Triangulation &tria, + std::ostream &out, + const Mapping *mapping) const { AssertThrow (out, ExcIO()); - const unsigned int dim=2; const unsigned int n_additional_points= gnuplot_flags.n_boundary_face_points; const unsigned int n_points=2+n_additional_points; - Triangulation::active_cell_iterator cell=tria.begin_active(); - const Triangulation::active_cell_iterator endc=tria.end(); + typename Triangulation::active_cell_iterator cell=tria.begin_active(); + const typename Triangulation::active_cell_iterator endc=tria.end(); // if we are to treat curved // boundaries, then generate a @@ -840,7 +846,7 @@ void GridOut::write_gnuplot (const Triangulation<2> &tria, // used to probe boundary points at // curved faces Quadrature *q_projector=0; - std::vector > boundary_points; + std::vector > boundary_points; if (mapping!=0) { boundary_points.resize(n_points); @@ -850,7 +856,7 @@ void GridOut::write_gnuplot (const Triangulation<2> &tria, boundary_points[i](0)= 1.*i/(n_points-1); std::vector dummy_weights(n_points, 1./n_points); - Quadrature<1> quadrature(boundary_points, dummy_weights); + Quadrature quadrature(boundary_points, dummy_weights); q_projector = new Quadrature (QProjector::project_to_all_faces(quadrature)); } @@ -889,7 +895,7 @@ void GridOut::write_gnuplot (const Triangulation<2> &tria, for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) { - const Triangulation::face_iterator + const typename Triangulation::face_iterator face = cell->face(face_no); if (face->at_boundary()) { @@ -946,19 +952,19 @@ void GridOut::write_gnuplot (const Triangulation<2> &tria, #if deal_II_dimension==3 -void GridOut::write_gnuplot (const Triangulation<3> &tria, +template +void GridOut::write_gnuplot (const Triangulation &tria, std::ostream &out, - const Mapping<3> *mapping) + const Mapping *mapping) const { AssertThrow (out, ExcIO()); - const unsigned int dim=3; const unsigned int n_additional_points= gnuplot_flags.n_boundary_face_points; const unsigned int n_points=2+n_additional_points; - Triangulation::active_cell_iterator cell=tria.begin_active(); - const Triangulation::active_cell_iterator endc=tria.end(); + typename Triangulation::active_cell_iterator cell=tria.begin_active(); + const typename Triangulation::active_cell_iterator endc=tria.end(); // if we are to treat curved // boundaries, then generate a @@ -1060,7 +1066,7 @@ void GridOut::write_gnuplot (const Triangulation<3> &tria, { for (unsigned int face_no=0; face_no::faces_per_cell; ++face_no) { - const Triangulation::face_iterator + const typename Triangulation::face_iterator face = cell->face(face_no); if (face->at_boundary()) @@ -1098,10 +1104,10 @@ void GridOut::write_gnuplot (const Triangulation<3> &tria, } else { - for (unsigned int l=0; l::lines_per_face; ++l) + for (unsigned int l=0; l::lines_per_face; ++l) { - const Triangulation::line_iterator - line=face->line(l); + const typename Triangulation::line_iterator + line=face->line(l); const Point &v0=line->vertex(0), &v1=line->vertex(1); @@ -1111,7 +1117,7 @@ void GridOut::write_gnuplot (const Triangulation<3> &tria, // could be // replaced // by using - // QProjector<3>::project_to_line + // QProjector::project_to_line // which is // not yet // implemented @@ -1171,9 +1177,11 @@ struct LineEntry #if deal_II_dimension==1 -void GridOut::write_eps (const Triangulation<1> &, - std::ostream &, - const Mapping<1> *) +template +void GridOut::write_eps ( + const Triangulation &, + std::ostream &, + const Mapping *) const { Assert(false, ExcNotImplemented()); } @@ -1182,9 +1190,10 @@ void GridOut::write_eps (const Triangulation<1> &, #else template -void GridOut::write_eps (const Triangulation &tria, - std::ostream &out, - const Mapping *mapping) +void GridOut::write_eps ( + const Triangulation &tria, + std::ostream &out, + const Mapping *mapping) const { typedef std::list LineList; @@ -1196,10 +1205,10 @@ void GridOut::write_eps (const Triangulation &tria, // eps_flags_1, eps_flags_2, ... const GridOutFlags::EpsFlagsBase &eps_flags_base = (dim==2 ? - static_cast(eps_flags_2) : + static_cast(eps_flags_2) : (dim==3 ? - static_cast(eps_flags_3) : - *static_cast(0))); + static_cast(eps_flags_3) : + *static_cast(0))); AssertThrow (out, ExcIO()); const unsigned int n_points = eps_flags_base.n_boundary_face_points; @@ -1618,7 +1627,7 @@ void GridOut::write ( const Triangulation &tria, std::ostream &out, const OutputFormat output_format, - const Mapping *mapping) + const Mapping *mapping) const { switch (output_format) { @@ -1658,25 +1667,40 @@ template void GridOut::write ( const Triangulation &tria, std::ostream &out, - const Mapping *mapping) + const Mapping *mapping) const { write(tria, out, default_format, mapping); } + +//TODO: Should all write functions be instantiated? + // explicit instantiations +template void GridOut::write_dx +(const Triangulation&, + std::ostream&) const; +template void GridOut::write_msh +(const Triangulation&, + std::ostream&) const; +template void GridOut::write_xfig +(const Triangulation&, + std::ostream&, + const Mapping*) const; +template void GridOut::write_gnuplot +(const Triangulation&, + std::ostream&, + const Mapping*) const; template void GridOut::write_ucd (const Triangulation &, - std::ostream &); -#if deal_II_dimension != 1 + std::ostream &) const; template void GridOut::write_eps (const Triangulation &, std::ostream &, - const Mapping *); -#endif + const Mapping *) const; template void GridOut::write (const Triangulation &, std::ostream &, const OutputFormat, - const Mapping *); + const Mapping *) const; template void GridOut::write (const Triangulation &, - std::ostream &, const Mapping *); + std::ostream &, const Mapping *) const;