* printed which are on the boundary and which have a boundary indicator not
* equal to zero, since the latter is the default for boundary faces.
*
- * Since cells and faces are continuously numbered, the @p starting_index
- * for the numbering of the faces is passed also.
+ * Since (in the UCD format) geometric elements are continuously numbered,
+ * this function requires a parameter @p next_element_index providing the
+ * next geometric element number. This index should have a numerical value
+ * equal to one more than the index previously used to write a geometric
+ * element to @p out.
+ *
+ * @returns The next unused geometric element index.
+ *
+ * @warning @p next_element_index should be (at least) one larger than the
+ * current number of triangulation elements (lines, cells, faces) that have
+ * been written to @p out. Visualization programs may not load the saved
+ * file correctly if there are repeated indices.
*
* This function unfortunately can not be included in the regular @p
* write_ucd function, since it needs special treatment for the case
* call these functions, but the compiler would complain anyway when
* compiling the function for <tt>dim==1</tt>. Bad luck.
*/
-
-
template <int dim, int spacedim>
- void write_ucd_faces (const Triangulation<dim,spacedim> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_ucd_faces (const Triangulation<dim,spacedim> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const;
/**
* Declaration of the specialization of above function for 1d. Does nothing.
*/
- void write_ucd_faces (const Triangulation<1,1> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_ucd_faces (const Triangulation<1,1> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const;
/**
* Declaration of the specialization of above function for 1d, 2sd. Does
* nothing.
*/
- void write_ucd_faces (const Triangulation<1,2> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
- void write_ucd_faces (const Triangulation<1,3> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_ucd_faces (const Triangulation<1,2> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const;
+ unsigned int
+ write_ucd_faces (const Triangulation<1,3> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const;
/**
* printed which are on the boundary and which have a boundary indicator not
* equal to zero, since the latter is the default for boundary lines.
*
- * Since cells, faces and lines are continuously numbered, the @p
- * starting_index for the numbering of the faces is passed also.
+ * Since (in the UCD format) geometric elements are continuously numbered,
+ * this function requires a parameter @p next_element_index providing the
+ * next geometric element number. This index should have a numerical value
+ * equal to one more than the index previously used to write a geometric
+ * element to @p out.
+ *
+ * @returns The next unused geometric element index.
+ *
+ * @warning @p next_element_index should be (at least) one larger than the
+ * current number of triangulation elements (lines, cells, faces) that have
+ * been written to @p out. Visualization programs may not load the saved
+ * file correctly if there are repeated indices.
*
* This function unfortunately can not be included in the regular @p
* write_ucd function, since it needs special treatment for the case
* call these functions, but the compiler would complain anyway when
* compiling the function for <tt>dim==1/2</tt>. Bad luck.
*/
-
-
template <int dim, int spacedim>
- void write_ucd_lines (const Triangulation<dim,spacedim> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_ucd_lines (const Triangulation<dim,spacedim> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const;
/**
* Declaration of the specialization of above function for 1d. Does nothing.
*/
- void write_ucd_lines (const Triangulation<1,1> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_ucd_lines (const Triangulation<1,1> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const;
/**
* Declaration of the specialization of above function for 1d, 2sd. Does
* nothing.
*/
- void write_ucd_lines (const Triangulation<1,2> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
- void write_ucd_lines (const Triangulation<1,3> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_ucd_lines (const Triangulation<1,2> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const;
+ unsigned int
+ write_ucd_lines (const Triangulation<1,3> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const;
/**
* Declaration of the specialization of above function for 2d. Does nothing.
*/
- void write_ucd_lines (const Triangulation<2,2> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_ucd_lines (const Triangulation<2,2> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const;
/**
* Declaration of the specialization of above function for 2d, 3sd. Does
* nothing.
*/
- void write_ucd_lines (const Triangulation<2,3> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_ucd_lines (const Triangulation<2,3> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const;
/**
out << '\n';
}
- // write faces and lines with
- // non-zero boundary indicator
- unsigned int next_index = tria.n_active_cells()+1;
+ // write faces and lines with non-zero boundary indicator
+ unsigned int next_element_index = tria.n_active_cells()+1;
if (ucd_flags.write_faces)
- write_ucd_faces (tria, next_index, out);
+ {
+ next_element_index = write_ucd_faces (tria, next_element_index, out);
+ }
if (ucd_flags.write_lines)
- write_ucd_lines (tria, next_index, out);
+ {
+ next_element_index = write_ucd_lines (tria, next_element_index, out);
+ }
// make sure everything now gets to
// disk
&&
(cell->line(l)->user_flag_set() == false))
{
- out << current_element_index << " 1 ";
+ out << next_element_index << " 1 ";
out << static_cast<unsigned int>(cell->line(l)->boundary_id())
<< ' '
<< static_cast<unsigned int>(cell->line(l)->boundary_id())
-void GridOut::write_ucd_faces (const Triangulation<1> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_ucd_faces (const Triangulation<1> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_ucd_faces (const Triangulation<1,2> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_ucd_faces (const Triangulation<1,2> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_ucd_faces (const Triangulation<1,3> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_ucd_faces (const Triangulation<1,3> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_ucd_lines (const Triangulation<1> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_ucd_lines (const Triangulation<1> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_ucd_lines (const Triangulation<1,2> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_ucd_lines (const Triangulation<1,2> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_ucd_lines (const Triangulation<1,3> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_ucd_lines (const Triangulation<1,3> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_ucd_lines (const Triangulation<2> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_ucd_lines (const Triangulation<2> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_ucd_lines (const Triangulation<2,3> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_ucd_lines (const Triangulation<2,3> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
template <int dim, int spacedim>
-void GridOut::write_ucd_faces (const Triangulation<dim, spacedim> &tria,
- const unsigned int starting_index,
- std::ostream &out) const
+unsigned int
+GridOut::write_ucd_faces (const Triangulation<dim,spacedim> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const
{
+ unsigned int current_element_index = next_element_index;
typename Triangulation<dim,spacedim>::active_face_iterator face, endf;
- unsigned int index=starting_index;
for (face=tria.begin_active_face(), endf=tria.end_face();
face != endf; ++face)
if (face->at_boundary() &&
(face->boundary_id() != 0))
{
- out << index << " "
+ out << current_element_index << " "
<< static_cast<unsigned int>(face->boundary_id())
<< " ";
switch (dim)
out << face->vertex_index(GeometryInfo<dim-1>::ucd_to_deal[vertex])+1 << ' ';
out << '\n';
- ++index;
+ ++current_element_index;
}
+ return current_element_index;
}
template <int dim, int spacedim>
-void GridOut::write_ucd_lines (const Triangulation<dim, spacedim> &tria,
- const unsigned int starting_index,
- std::ostream &out) const
+unsigned int
+GridOut::write_ucd_lines(const Triangulation<dim, spacedim> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const
{
+ unsigned int current_element_index = next_element_index;
// save the user flags for lines so
// we can use these flags to track
// which ones we've already taken
.clear_user_flags_line ();
typename Triangulation<dim, spacedim>::active_cell_iterator cell, endc;
- unsigned int index=starting_index;
for (cell=tria.begin_active(), endc=tria.end();
cell != endc; ++cell)
&&
(cell->line(l)->user_flag_set() == false))
{
- out << index << " "
+ out << current_element_index << " "
<< static_cast<unsigned int>(cell->line(l)->boundary_id())
<< " line ";
// note: vertex numbers in ucd format are 1-base
// move on to the next line
// but mark the current one
// as taken care of
- ++index;
+ ++current_element_index;
cell->line(l)->set_user_flag();
}
// flags for the lines
const_cast<dealii::Triangulation<dim,spacedim>&>(tria)
.load_user_flags_line (line_flags);
+ return current_element_index;
}