/* $Id$ */
+#include <grid/tria.h>
#include <grid/tria_boundary.h>
#include <grid/tria_iterator.h>
-#include <grid/tria.h>
#include <grid/geometry_info.h>
#include <basic/magic_numbers.h>
#include <basic/data_io.h>
#include <cmath>
-
-
template <int dim>
Triangulation<dim>::Triangulation (const bool smooth_grid) :
smooth_grid(smooth_grid)
};
+
+template <int dim>
+Triangulation<dim>::Triangulation (const Triangulation<dim> &) {
+ Assert (false, ExcInternalError());
+};
+
+
+
template <int dim>
Triangulation<dim>::~Triangulation () {
for (unsigned int i=0; i<levels.size(); ++i)
+/*--------- Put the next functions a bit out-or-order to avoid use before
+ --------- explicit specialization, which is not allowed. */
+
+template <>
+TriaDimensionInfo<1>::cell_iterator
+Triangulation<1>::begin (const unsigned int level) const {
+ return begin_line (level);
+};
+
+
+
+template <>
+TriaDimensionInfo<2>::cell_iterator
+Triangulation<2>::begin (const unsigned int level) const {
+ return begin_quad (level);
+};
+
+
+
+template <>
+TriaDimensionInfo<1>::raw_cell_iterator
+Triangulation<1>::end () const {
+ return end_line ();
+};
+
+
+
+template <>
+TriaDimensionInfo<2>::raw_cell_iterator
+Triangulation<2>::end () const {
+ return end_quad ();
+};
+
+
+/*-----------------------------------------------------------------*/
+
+
+
+template <int dim>
+void Triangulation<dim>::copy_triangulation (const Triangulation<dim> &old_tria) {
+ Assert (vertices.size() == 0, ExcTriangulationNotEmpty());
+ Assert (n_cells () == 0, ExcTriangulationNotEmpty());
+ Assert (levels.size () == 1, ExcTriangulationNotEmpty());
+ // copy normal elements
+ vertices = old_tria.vertices;
+ vertices_used = old_tria.vertices_used;
+ boundary = old_tria.boundary;
+ smooth_grid = old_tria.smooth_grid;
+
+ // delete only level previously existing,
+ // reserve space for new and copy
+ delete levels[0];
+ levels.clear ();
+ levels.reserve (old_tria.levels.size());
+ for (unsigned int level=0; level<old_tria.levels.size(); ++level)
+ levels.push_back (new TriangulationLevel<dim>(*old_tria.levels[level]));
+};
+
+
+
+template <>
void Triangulation<1>::create_triangulation (const vector<Point<1> > &v,
const vector<CellData<1> > &cells,
const SubCellData &) {
+template <>
void Triangulation<2>::create_triangulation (const vector<Point<2> > &v,
const vector<CellData<2> > &c,
const SubCellData &subcelldata) {
+template <>
void Triangulation<1>::create_hypercube (const double left,
const double right) {
Assert (vertices.size() == 0, ExcTriangulationNotEmpty());
+template <>
void Triangulation<2>::create_hypercube (const double left,
const double right) {
Assert (vertices.size() == 0, ExcTriangulationNotEmpty());
+template <>
void Triangulation<1>::create_hyper_L (const double, const double) {
Assert (false, ExcInternalError());
};
+template <>
void Triangulation<2>::create_hyper_L (const double a, const double b) {
const unsigned int dim=2;
const Point<dim> vertices[8] = { Point<dim> (a,a),
-void Triangulation<1>::create_hyper_ball (const Point<1>, const double) {
+template <>
+void Triangulation<1>::create_hyper_ball (const Point<1> &, const double) {
Assert (false, ExcInternalError());
};
-void Triangulation<2>::create_hyper_ball (const Point<2> p, const double radius) {
+template <>
+void Triangulation<2>::create_hyper_ball (const Point<2> &p, const double radius) {
const unsigned int dim=2;
const double a = 0.453; // equilibrate cell sizes
- const Point<dim> vertices[8] = { p+Point<dim>(-1,-1)*radius/sqrt(2),
- p+Point<dim>(+1,-1)*radius/sqrt(2),
- p+Point<dim>(-1,-1)*radius/sqrt(2)*a,
- p+Point<dim>(+1,-1)*radius/sqrt(2)*a,
- p+Point<dim>(-1,+1)*radius/sqrt(2)*a,
- p+Point<dim>(+1,+1)*radius/sqrt(2)*a,
- p+Point<dim>(-1,+1)*radius/sqrt(2),
- p+Point<dim>(+1,+1)*radius/sqrt(2) };
+ const Point<dim> vertices[8] = { p+Point<dim>(-1,-1)*(radius/sqrt(2)),
+ p+Point<dim>(+1,-1)*(radius/sqrt(2)),
+ p+Point<dim>(-1,-1)*(radius/sqrt(2)*a),
+ p+Point<dim>(+1,-1)*(radius/sqrt(2)*a),
+ p+Point<dim>(-1,+1)*(radius/sqrt(2)*a),
+ p+Point<dim>(+1,+1)*(radius/sqrt(2)*a),
+ p+Point<dim>(-1,+1)*(radius/sqrt(2)),
+ p+Point<dim>(+1,+1)*(radius/sqrt(2)) };
+
const int cell_vertices[5][4] = {{0, 1, 3, 2},
{0, 2, 4, 6},
{2, 3, 5, 4},
+template <>
void Triangulation<1>::clear_user_flags () {
cell_iterator cell = begin(),
endc = end();
+template <>
void Triangulation<2>::clear_user_flags () {
line_iterator line = begin_line(),
endl = end_line();
+template <>
void Triangulation<1>::save_user_flags (ostream &out) const {
save_user_flags_line (out);
};
+template <>
void Triangulation<2>::save_user_flags (ostream &out) const {
save_user_flags_line (out);
save_user_flags_quad (out);
+template <>
void Triangulation<1>::save_user_flags_quad (ostream &) const {
Assert (false, ExcFunctionNotUseful());
};
+template <>
void Triangulation<1>::load_user_flags_quad (istream &) {
Assert (false, ExcFunctionNotUseful());
};
+template <>
TriaDimensionInfo<1>::raw_cell_iterator
Triangulation<1>::begin_raw (const unsigned int level) const {
return begin_raw_line (level);
-TriaDimensionInfo<1>::cell_iterator
-Triangulation<1>::begin (const unsigned int level) const {
- return begin_line (level);
-};
-
-
-
+template <>
TriaDimensionInfo<1>::active_cell_iterator
Triangulation<1>::begin_active (const unsigned int level) const {
return begin_active_line (level);
-TriaDimensionInfo<1>::raw_cell_iterator
-Triangulation<1>::end () const {
- return end_line ();
-};
-
-
-
+template <>
TriaDimensionInfo<1>::raw_cell_iterator
Triangulation<1>::last_raw () const {
return last_raw_line ();
+template <>
TriaDimensionInfo<1>::raw_cell_iterator
Triangulation<1>::last_raw (const unsigned int level) const {
return last_raw_line (level);
+template <>
TriaDimensionInfo<1>::cell_iterator
Triangulation<1>::last () const {
return last_line ();
+template <>
TriaDimensionInfo<1>::cell_iterator
Triangulation<1>::last (const unsigned int level) const {
return last_line (level);
+template <>
TriaDimensionInfo<1>::active_cell_iterator
Triangulation<1>::last_active () const {
return last_active_line ();
+template <>
TriaDimensionInfo<1>::active_cell_iterator
Triangulation<1>::last_active (const unsigned int level) const {
return last_active_line (level);
+template <>
TriaDimensionInfo<2>::raw_cell_iterator
Triangulation<2>::begin_raw (const unsigned int level) const {
return begin_raw_quad (level);
-TriaDimensionInfo<2>::cell_iterator
-Triangulation<2>::begin (const unsigned int level) const {
- return begin_quad (level);
-};
-
-
-
+template <>
TriaDimensionInfo<2>::active_cell_iterator
Triangulation<2>::begin_active (const unsigned int level) const {
return begin_active_quad (level);
-TriaDimensionInfo<2>::raw_cell_iterator
-Triangulation<2>::end () const {
- return end_quad ();
-};
-
-
-
+template <>
TriaDimensionInfo<2>::raw_cell_iterator
Triangulation<2>::last_raw () const {
return last_raw_quad ();
+template <>
TriaDimensionInfo<2>::raw_cell_iterator
Triangulation<2>::last_raw (const unsigned int level) const {
return last_raw_quad (level);
+template <>
TriaDimensionInfo<2>::cell_iterator
Triangulation<2>::last () const {
return last_quad ();
+template <>
TriaDimensionInfo<2>::cell_iterator
Triangulation<2>::last (const unsigned int level) const {
return last_quad (level);
+template <>
TriaDimensionInfo<2>::active_cell_iterator
Triangulation<2>::last_active () const {
return last_active_quad ();
+template <>
TriaDimensionInfo<2>::active_cell_iterator
Triangulation<2>::last_active (const unsigned int level) const {
return last_active_quad (level);
+template <>
TriaDimensionInfo<1>::raw_face_iterator
Triangulation<1>::begin_raw_face (const unsigned int) const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::face_iterator
Triangulation<1>::begin_face (const unsigned int) const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::active_face_iterator
Triangulation<1>::begin_active_face (const unsigned int) const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::raw_face_iterator
Triangulation<1>::end_face () const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::raw_face_iterator
Triangulation<1>::last_raw_face () const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::raw_face_iterator
Triangulation<1>::last_raw_face (const unsigned int) const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::face_iterator
Triangulation<1>::last_face () const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::face_iterator
Triangulation<1>::last_face (const unsigned int) const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::active_face_iterator
Triangulation<1>::last_active_face () const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::active_face_iterator
Triangulation<1>::last_active_face (const unsigned int) const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<2>::raw_face_iterator
Triangulation<2>::begin_raw_face (const unsigned int level) const {
return begin_raw_line (level);
+template <>
TriaDimensionInfo<2>::face_iterator
Triangulation<2>::begin_face (const unsigned int level) const {
return begin_line (level);
+template <>
TriaDimensionInfo<2>::active_face_iterator
Triangulation<2>::begin_active_face (const unsigned int level) const {
return begin_active_line (level);
+template <>
TriaDimensionInfo<2>::raw_face_iterator
Triangulation<2>::end_face () const {
return end_line ();
+template <>
TriaDimensionInfo<2>::raw_face_iterator
Triangulation<2>::last_raw_face () const {
return last_raw_line ();
+template <>
TriaDimensionInfo<2>::raw_face_iterator
Triangulation<2>::last_raw_face (const unsigned int level) const {
return last_raw_line (level);
+template <>
TriaDimensionInfo<2>::face_iterator
Triangulation<2>::last_face () const {
return last_line ();
+template <>
TriaDimensionInfo<2>::face_iterator
Triangulation<2>::last_face (const unsigned int level) const {
return last_line (level);
+template <>
TriaDimensionInfo<2>::active_face_iterator
Triangulation<2>::last_active_face () const {
return last_active_line ();
+template <>
TriaDimensionInfo<2>::active_face_iterator
Triangulation<2>::last_active_face (const unsigned int level) const {
return last_active_line (level);
template <int dim>
typename TriaDimensionInfo<dim>::raw_line_iterator
Triangulation<dim>::begin_raw_line (unsigned int level) const {
- Assert (level<levels.size(),
- ExcInvalidLevel(level));
+ Assert (level<levels.size(), ExcInvalidLevel(level));
+
if (levels[level]->lines.lines.size() == 0)
return end_line ();
+template <>
TriaDimensionInfo<1>::raw_quad_iterator
Triangulation<1>::begin_raw_quad (unsigned int) const {
Assert (false, ExcFunctionNotUseful());
template <int dim>
typename TriaDimensionInfo<dim>::raw_quad_iterator
Triangulation<dim>::begin_raw_quad (unsigned int level) const {
- Assert (level<levels.size(),
- ExcInvalidLevel(level));
-
+ Assert (level<levels.size(), ExcInvalidLevel(level));
+
if (levels[level]->quads.quads.size() == 0)
return end_quad();
+template <>
TriaDimensionInfo<1>::quad_iterator
Triangulation<1>::begin_quad (unsigned int) const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::active_quad_iterator
Triangulation<1>::begin_active_quad (unsigned int) const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::raw_quad_iterator
Triangulation<1>::end_quad () const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::raw_quad_iterator
Triangulation<1>::last_raw_quad (const unsigned int) const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::raw_quad_iterator
Triangulation<1>::last_raw_quad () const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::quad_iterator
Triangulation<1>::last_quad (const unsigned int) const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::quad_iterator
Triangulation<1>::last_quad () const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::active_quad_iterator
Triangulation<1>::last_active_quad (const unsigned int) const {
Assert (false, ExcFunctionNotUseful());
+template <>
TriaDimensionInfo<1>::active_quad_iterator
Triangulation<1>::last_active_quad () const {
Assert (false, ExcFunctionNotUseful());
+template <>
unsigned int Triangulation<1>::n_cells (const unsigned int level) const {
return n_lines (level);
};
+template <>
unsigned int Triangulation<2>::n_cells (const unsigned int level) const {
return n_quads (level);
};
+template <>
unsigned int Triangulation<1>::n_active_cells (const unsigned int level) const {
return n_active_lines (level);
};
+template <>
unsigned int Triangulation<2>::n_active_cells (const unsigned int level) const {
return n_active_quads (level);
};
+template <>
unsigned int Triangulation<1>::n_quads (const unsigned int) const {
Assert (false, ExcFunctionNotUseful());
return 0;
+template <>
unsigned int Triangulation<1>::n_active_quads (const unsigned int) const {
Assert (false, ExcFunctionNotUseful());
return 0;
+template <>
unsigned int Triangulation<1>::max_adjacent_cells () const {
return 2;
};
+template <>
void Triangulation<1>::print_gnuplot (ostream &out,
const active_cell_iterator & cell) const {
out << cell->vertex(0) << " " << cell->level() << endl
+template <>
void Triangulation<2>::print_gnuplot (ostream &out,
const active_cell_iterator & cell) const {
out << cell->vertex(0) << " " << cell->level() << endl
Assert ((fraction>0) && (fraction<=1), ExcInvalidParameterValue());
// refine at least one cell
- const refine_cells = max(static_cast<int>(fraction*criteria.size()),
- 1);
+ const int refine_cells = max(static_cast<int>(fraction*criteria.size()),
+ 1);
dVector tmp(criteria);
nth_element (tmp.begin(),
+template <>
void Triangulation<1>::execute_refinement () {
prepare_refinement ();
+template <>
void Triangulation<2>::execute_refinement () {
prepare_refinement ();