* Default: @p false.
*/
bool write_faces;
+ /**
+ * When writing a mesh, write boundary
+ * lines explicitly if their boundary
+ * indicator is not the default
+ * boundary indicator, which is zero.
+ * This is necessary if you later
+ * want to re-read the grid and want
+ * to get the same boundary indicators
+ * for the different parts of the
+ * boundary of the triangulation.
+ *
+ * It is not necessary if you only want
+ * to write the triangulation to
+ * view or print it.
+ *
+ * This is used only if
+ * <tt>dim==3</tt>, and ignored
+ * in all other cases.
+ *
+ * Default: @p false.
+ */
+ bool write_lines;
/**
* Constructor.
*/
- Msh (const bool write_faces = false);
+ Msh (const bool write_faces = false,
+ const bool write_lines = false);
/**
* Declare parameters in
* ParameterHandler.
*/
bool write_faces;
+ /**
+ * When writing a mesh, write boundary
+ * lines explicitly if their boundary
+ * indicator is not the default
+ * boundary indicator, which is zero.
+ * This is necessary if you later
+ * want to re-read the grid and want
+ * to get the same boundary indicators
+ * for the different parts of the
+ * boundary of the triangulation.
+ *
+ * It is not necessary if you only want
+ * to write the triangulation to
+ * view or print it.
+ *
+ * This directive is ignored if
+ * <tt>dim!=3</tt>.
+ *
+ * Default: @p false.
+ */
+ bool write_lines;
+
/**
* Constructor.
*/
Ucd (const bool write_preamble = true,
- const bool write_faces = false);
+ const bool write_faces = false,
+ const bool write_lines = false);
+
/**
* Declare parameters in
* ParameterHandler.
const unsigned int starting_index,
std::ostream &out) const;
+ /**
+ * Write the grid information about
+ * lines to @p out. Only those lines
+ * are 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.
+ *
+ * This function unfortunately
+ * can not be included in the
+ * regular @p write_msh function,
+ * since it needs special
+ * treatment for the case
+ * <tt>dim==1</tt> and
+ * <tt>dim==2</tt>, in which case
+ * the edge iterators are
+ * <tt>void*</tt>'s and lack the
+ * member functions which are
+ * called. We would not actually
+ * call these functions, but the
+ * compiler would complain anyway
+ * when compiling the function
+ * for <tt>dim==1/2</tt>. Bad luck.
+ */
+ template <int dim>
+ void write_msh_lines (const Triangulation<dim> &tria,
+ const unsigned int starting_index,
+ std::ostream &out) const;
+
+ /**
+ * Declaration of the specialization
+ * of above function for 1d. Does
+ * nothing.
+ */
+ void write_msh_lines (const Triangulation<1> &tria,
+ const unsigned int starting_index,
+ std::ostream &out) const;
+
+ /**
+ * Declaration of the specialization
+ * of above function for 2d. Does
+ * nothing.
+ */
+ void write_msh_lines (const Triangulation<2> &tria,
+ const unsigned int starting_index,
+ std::ostream &out) const;
+
/**
* Write the grid information about
* faces to @p out. Only those faces
* would complain anyway when compiling
* the function for <tt>dim==1</tt>. Bad luck.
*/
+
+
template <int dim>
void write_ucd_faces (const Triangulation<dim> &tria,
const unsigned int starting_index,
* nothing.
*/
void write_ucd_faces (const Triangulation<1> &tria,
+ const unsigned int starting_index,
+ std::ostream &out) const;
+
+
+ /**
+ * Write the grid information about
+ * lines to @p out. Only those lines
+ * are 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.
+ *
+ * This function unfortunately can not
+ * be included in the regular @p write_ucd
+ * function, since it needs special
+ * treatment for the case <tt>dim==1/2</tt>, in
+ * which case the edge iterators are
+ * <tt>void*</tt>'s and lack the member functions
+ * which are called. We would not actually
+ * call these functions, but the compiler
+ * would complain anyway when compiling
+ * the function for <tt>dim==1/2</tt>. Bad luck.
+ */
+
+
+ template <int dim>
+ void write_ucd_lines (const Triangulation<dim> &tria,
+ const unsigned int starting_index,
+ std::ostream &out) const;
+
+ /**
+ * Declaration of the specialization
+ * of above function for 1d. Does
+ * nothing.
+ */
+ void write_ucd_lines (const Triangulation<1> &tria,
+ const unsigned int starting_index,
+ std::ostream &out) const;
+
+ /**
+ * Declaration of the specialization
+ * of above function for 2d. Does
+ * nothing.
+ */
+ void write_ucd_lines (const Triangulation<2> &tria,
const unsigned int starting_index,
std::ostream &out) const;
* 1d. Simply returns zero.
*/
unsigned int n_boundary_faces (const Triangulation<1> &tria) const;
+
+ /**
+ * Return the number of lines in the
+ * triangulation which have a boundary
+ * indicator not equal to zero. Only
+ * these lines are explicitly printed
+ * in the <tt>write_*</tt> functions;
+ * all lines with indicator 255 are
+ * interior ones and an indicator with
+ * value zero for faces at the boundary
+ * are considered default.
+ *
+ * This function always returns an empty
+ * list in one and two dimensions.
+ *
+ * The reason for this function is the
+ * same as for @p write_ucd_faces. See
+ * there for more information.
+ */
+ template <int dim>
+ unsigned int n_boundary_lines (const Triangulation<dim> &tria) const;
+
+ /**
+ * Declaration of the specialization
+ * of above function for
+ * 1d. Simply returns zero.
+ */
+ unsigned int n_boundary_lines (const Triangulation<1> &tria) const;
+
+ /**
+ * Declaration of the specialization
+ * of above function for
+ * 2d. Simply returns zero.
+ */
+ unsigned int n_boundary_lines (const Triangulation<2> &tria) const;
};
}
- Msh::Msh (const bool write_faces) :
- write_faces (write_faces)
+ Msh::Msh (const bool write_faces,
+ const bool write_lines) :
+ write_faces (write_faces),
+ write_lines (write_lines)
{}
void Msh::declare_parameters (ParameterHandler& param)
{
param.declare_entry("Write faces", "false", Patterns::Bool());
+ param.declare_entry("Write lines", "false", Patterns::Bool());
}
void Msh::parse_parameters (ParameterHandler& param)
{
write_faces = param.get_bool("Write faces");
+ write_lines = param.get_bool("Write lines");
}
Ucd::Ucd (const bool write_preamble,
- const bool write_faces) :
+ const bool write_faces,
+ const bool write_lines) :
write_preamble (write_preamble),
- write_faces (write_faces)
+ write_faces (write_faces),
+ write_lines (write_lines)
{}
{
param.declare_entry("Write preamble", "true", Patterns::Bool());
param.declare_entry("Write faces", "false", Patterns::Bool());
+ param.declare_entry("Write lines", "false", Patterns::Bool());
}
{
write_preamble = param.get_bool("Write preamble");
write_faces = param.get_bool("Write faces");
+ write_lines = param.get_bool("Write lines");
}
// Write cells preamble
out << "$ENDNOD" << std::endl
<< "$ELM" << std::endl
- << tria.n_active_cells() + (msh_flags.write_faces ?
- n_boundary_faces(tria) : 0) << std::endl;
+ << tria.n_active_cells() + ( (msh_flags.write_faces ?
+ n_boundary_faces(tria) :0 ) +
+ ( msh_flags.write_lines ?
+ n_boundary_lines(tria) : 0 ) ) << std::endl;
/*
elm-type
out << std::endl;
};
- // write faces with non-zero boundary
- // indicator
- if (msh_flags.write_faces)
+ // write faces and lines with
+ // non-zero boundary indicator
+ if (msh_flags.write_faces)
write_msh_faces (tria, cell_index, out);
+ if (msh_flags.write_lines)
+ write_msh_lines (tria, cell_index, out);
out << "$ENDELM" << std::endl;
// start with ucd data
out << n_vertices << ' '
- << tria.n_active_cells() + (ucd_flags.write_faces ?
- n_boundary_faces(tria) :
- 0)
+ << tria.n_active_cells() + ( (ucd_flags.write_faces ?
+ n_boundary_faces(tria) : 0) +
+ (ucd_flags.write_lines ?
+ n_boundary_lines(tria) : 0) )
<< " 0 0 0" // no data
<< '\n';
out << '\n';
};
- // write faces with non-zero boundary
- // indicator
- if (ucd_flags.write_faces)
+ // write faces and lines with
+ // non-zero boundary indicator
+ if (ucd_flags.write_faces)
write_ucd_faces (tria, cell_index, out);
+ if (ucd_flags.write_lines)
+ write_ucd_lines (tria, cell_index, out);
// make sure everything now gets to
// disk
return 0;
}
+unsigned int GridOut::n_boundary_lines (const Triangulation<1> &) const
+{
+ return 0;
+}
+
+#endif
+
+
+#if deal_II_dimension == 2
+
+unsigned int GridOut::n_boundary_lines (const Triangulation<2> &) const
+{
+ return 0;
+}
+
#endif
+template <int dim>
+unsigned int GridOut::n_boundary_lines (const Triangulation<dim> &tria) const
+{
+ typename Triangulation<dim>::active_line_iterator edge, endedge;
+ unsigned int n_lines = 0;
+
+ for (edge=tria.begin_active_line(), endedge=tria.end_line();
+ edge != endedge; ++edge)
+ if ((edge->at_boundary()) &&
+ (edge->boundary_indicator() != 0))
+ n_lines++;
+
+ return n_lines;
+}
+
+
+
#if deal_II_dimension == 1
void GridOut::write_msh_faces (const Triangulation<1> &,
return;
}
+
+void GridOut::write_msh_lines (const Triangulation<1> &,
+ const unsigned int,
+ std::ostream &) const
+{
+ return;
+}
+
+#endif
+
+
+#if deal_II_dimension == 2
+
+void GridOut::write_msh_lines (const Triangulation<2> &,
+ const unsigned int,
+ std::ostream &) const
+{
+ return;
+}
+
#endif
}
+template <int dim>
+void GridOut::write_msh_lines (const Triangulation<dim> &tria,
+ const unsigned int starting_index,
+ std::ostream &out) const
+{
+ typename Triangulation<dim>::active_line_iterator line, endl;
+ unsigned int index=starting_index;
+
+ for (line=tria.begin_active_line(), endl=tria.end_line();
+ line != endl; ++line)
+ if (line->at_boundary() &&
+ (line->boundary_indicator() != 0))
+ {
+ out << index << " 1 ";
+ out << static_cast<unsigned int>(line->boundary_indicator())
+ << ' '
+ << static_cast<unsigned int>(line->boundary_indicator())
+ << " 2 ";
+ // note: vertex numbers are 1-base
+ for (unsigned int vertex=0; vertex<2; ++vertex)
+ out << ' '
+ << line->vertex_index(GeometryInfo<dim-2>::ucd_to_deal[vertex])+1;
+ out << '\n';
+
+ ++index;
+ };
+}
+
+
#if deal_II_dimension == 1
return;
}
+
+void GridOut::write_ucd_lines (const Triangulation<1> &,
+ const unsigned int,
+ std::ostream &) const
+{
+ return;
+}
+
+#endif
+
+
+
+#if deal_II_dimension == 2
+
+void GridOut::write_ucd_lines (const Triangulation<2> &,
+ const unsigned int,
+ std::ostream &) const
+{
+ return;
+}
+
#endif
+template <int dim>
+void GridOut::write_ucd_lines (const Triangulation<dim> &tria,
+ const unsigned int starting_index,
+ std::ostream &out) const
+{
+ typename Triangulation<dim>::active_line_iterator line, endl;
+ unsigned int index=starting_index;
+
+ for (line=tria.begin_active_line(), endl=tria.end_line();
+ line != endl; ++line)
+ if (line->at_boundary() &&
+ (line->boundary_indicator() != 0))
+ {
+ out << index << " "
+ << static_cast<unsigned int>(line->boundary_indicator())
+ << " line ";
+ // note: vertex numbers are 1-base
+ for (unsigned int vertex=0; vertex<2; ++vertex)
+ out << line->vertex_index(GeometryInfo<dim-2>::ucd_to_deal[vertex])+1 << ' ';
+ out << '\n';
+
+ ++index;
+ };
+}
+
+
#if deal_II_dimension==1
template <int dim>