* 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 GMSH, 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. GMSH will not load the saved file correctly if
+ * there are repeated indices.
*
* This function unfortunately can not be included in the regular @p
* write_msh function, since it needs special treatment for the case
* compiling the function for <tt>dim==1</tt>. Bad luck.
*/
template <int dim, int spacedim>
- void write_msh_faces (const Triangulation<dim,spacedim> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_msh_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_msh_faces (const Triangulation<1,1> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_msh_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_msh_faces (const Triangulation<1,2> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
- void write_msh_faces (const Triangulation<1,3> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_msh_faces (const Triangulation<1,2> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const;
+ unsigned int
+ write_msh_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 faces.
*
- * Since cells and faces are continuously numbered, the @p starting_index
- * for the numbering of the lines is passed also.
+ * Since, in GMSH, 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. GMSH will not load the saved file correctly if
+ * there are repeated indices.
*
* This function unfortunately can not be included in the regular @p
* write_msh function, since it needs special treatment for the case
* when compiling the function for <tt>dim==1/2</tt>. Bad luck.
*/
template <int dim, int spacedim>
- void write_msh_lines (const Triangulation<dim,spacedim> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_msh_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_msh_lines (const Triangulation<1,1> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_msh_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_msh_lines (const Triangulation<1,2> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
- void write_msh_lines (const Triangulation<1,3> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_msh_lines (const Triangulation<1,2> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const;
+ unsigned int
+ write_msh_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_msh_lines (const Triangulation<2,2> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_msh_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_msh_lines (const Triangulation<2,3> &tria,
- const unsigned int starting_index,
- std::ostream &out) const;
+ unsigned int
+ write_msh_lines (const Triangulation<2,3> &tria,
+ const unsigned int next_element_index,
+ std::ostream &out) const;
/**
* Write the grid information about faces to @p out. Only those faces are
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 (msh_flags.write_faces)
- write_msh_faces (tria, next_index, out);
+ {
+ next_element_index = write_msh_faces (tria, next_element_index, out);
+ }
if (msh_flags.write_lines)
- write_msh_lines (tria, next_index, out);
+ {
+ next_element_index = write_msh_lines (tria, next_element_index, out);
+ }
out << "$ENDELM\n";
-void GridOut::write_msh_faces (const Triangulation<1> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_msh_faces (const Triangulation<1> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_msh_faces (const Triangulation<1,2> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_msh_faces (const Triangulation<1,2> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_msh_faces (const Triangulation<1,3> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_msh_faces (const Triangulation<1,3> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_msh_lines (const Triangulation<1> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_msh_lines (const Triangulation<1> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_msh_lines (const Triangulation<1,2> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_msh_lines (const Triangulation<1,2> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_msh_lines (const Triangulation<1,3> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_msh_lines (const Triangulation<1,3> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_msh_lines (const Triangulation<2> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_msh_lines (const Triangulation<2> &,
+ const unsigned int next_element_index,
+ std::ostream &) const
{
- return;
+ return next_element_index;
}
-void GridOut::write_msh_lines (const Triangulation<2,3> &,
- const unsigned int,
- std::ostream &) const
+unsigned int
+GridOut::write_msh_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_msh_faces (const Triangulation<dim,spacedim> &tria,
- const unsigned int starting_index,
- std::ostream &out) const
+unsigned int
+GridOut::write_msh_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 << ' ';
switch (dim)
{
case 2:
<< 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_msh_lines (const Triangulation<dim, spacedim> &tria,
- const unsigned int starting_index,
- std::ostream &out) const
+unsigned int
+GridOut::write_msh_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 << " 1 ";
+ out << current_element_index << " 1 ";
out << static_cast<unsigned int>(cell->line(l)->boundary_id())
<< ' '
<< static_cast<unsigned int>(cell->line(l)->boundary_id())
// 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;
}