From ce4da055df4c8e3585db11f532f64d09cc0d8601 Mon Sep 17 00:00:00 2001
From: Guido Kanschat
Date: Mon, 16 Aug 2010 12:20:15 +0000
Subject: [PATCH] default constructor for DoFHandler
git-svn-id: https://svn.dealii.org/trunk@21666 0785d39b-7218-0410-832d-ea1e28bc413d
---
deal.II/deal.II/include/dofs/dof_handler.h | 48 +++-
deal.II/deal.II/source/dofs/dof_handler.cc | 77 +++---
.../source/multigrid/mg_dof_handler.cc | 256 +++++++++---------
deal.II/doc/news/changes.h | 15 +-
4 files changed, 217 insertions(+), 179 deletions(-)
diff --git a/deal.II/deal.II/include/dofs/dof_handler.h b/deal.II/deal.II/include/dofs/dof_handler.h
index 279fbe5fa5..81f4992d79 100644
--- a/deal.II/deal.II/include/dofs/dof_handler.h
+++ b/deal.II/deal.II/include/dofs/dof_handler.h
@@ -208,17 +208,37 @@ class DoFHandler : public Subscriptor
* value.
*/
static const unsigned int default_fe_index = 0;
+
+ /**
+ * Standard constructor, not
+ * initializing any data. After
+ * constructing an object with
+ * this constructor, use
+ * initialize() to make a valid
+ * DoFHandler.
+ */
+ DoFHandler ();
/**
* Constructor. Take @p tria as the
* triangulation to work on.
*/
DoFHandler ( const Triangulation &tria);
-
+
/**
* Destructor.
*/
virtual ~DoFHandler ();
+
+ /**
+ * Assign a Triangulation and a
+ * FiniteElement to the
+ * DoFHandler and compute the
+ * distribution of degrees of
+ * freedom over the mesh.
+ */
+ void initialize(const Triangulation& tria,
+ const FiniteElement& fe);
/**
* Go through the triangulation and
@@ -1007,15 +1027,7 @@ class DoFHandler : public Subscriptor
* Exception
*/
DeclException0 (ExcInvalidTriangulation);
- /**
- * No finite element has been
- * assigned to this
- * DoFHandler. Call the function
- * DoFHandler::distribute_dofs()
- * before you attemped to do what
- * raised this exception.
- */
- DeclException0 (ExcNoFESelected);
+
/**
* @todo Replace by ExcInternalError.
*/
@@ -1060,8 +1072,16 @@ class DoFHandler : public Subscriptor
int,
<< "You tried to do something on level " << arg1
<< ", but this level is empty.");
-
+
+
protected:
+ /**
+ * The object containing
+ * information on the block structure.
+ */
+ BlockInfo block_info_object;
+
+ private:
/**
* Address of the triangulation to
@@ -1082,9 +1102,6 @@ class DoFHandler : public Subscriptor
* this object as well, though).
*/
SmartPointer,DoFHandler > selected_fe;
-
- BlockInfo block_info_object;
- private:
/**
* Copy constructor. I can see no reason
@@ -1186,7 +1203,7 @@ inline
const FiniteElement &
DoFHandler::get_fe () const
{
- Assert(selected_fe!=0, ExcNoFESelected());
+ Assert(selected_fe!=0, ExcNotInitialized());
return *selected_fe;
}
@@ -1196,6 +1213,7 @@ inline
const Triangulation &
DoFHandler::get_tria () const
{
+ Assert(tria != 0, ExcNotInitialized());
return *tria;
}
diff --git a/deal.II/deal.II/source/dofs/dof_handler.cc b/deal.II/deal.II/source/dofs/dof_handler.cc
index 9c2758fd9b..3a0757a1cc 100644
--- a/deal.II/deal.II/source/dofs/dof_handler.cc
+++ b/deal.II/deal.II/source/dofs/dof_handler.cc
@@ -697,6 +697,16 @@ DoFHandler::DoFHandler (const Triangulation &tria)
{}
+template
+DoFHandler::DoFHandler ()
+ :
+ tria(0, typeid(*this).name()),
+ selected_fe(0, typeid(*this).name()),
+ faces(NULL),
+ used_dofs (0)
+{}
+
+
template
DoFHandler::~DoFHandler ()
{
@@ -705,6 +715,19 @@ DoFHandler::~DoFHandler ()
}
+template
+void
+DoFHandler::initialize(
+ const Triangulation& t,
+ const FiniteElement& fe)
+{
+ tria = &t;
+ faces = NULL;
+ used_dofs = 0;
+ distribute_dofs(fe);
+}
+
+
/*------------------------ Cell iterator functions ------------------------*/
@@ -911,6 +934,7 @@ template
typename DoFHandler::raw_cell_iterator
DoFHandler::end_raw (const unsigned int level) const
{
+ Assert(tria != 0, ExcNotInitialized());
return (level == tria->n_levels()-1 ?
end() :
begin_raw (level+1));
@@ -921,6 +945,7 @@ template
typename DoFHandler::cell_iterator
DoFHandler::end (const unsigned int level) const
{
+ Assert(tria != 0, ExcNotInitialized());
return (level == tria->n_levels()-1 ?
cell_iterator(end()) :
begin (level+1));
@@ -931,6 +956,7 @@ template
typename DoFHandler::active_cell_iterator
DoFHandler::end_active (const unsigned int level) const
{
+ Assert(tria != 0, ExcNotInitialized());
return (level == tria->n_levels()-1 ?
active_cell_iterator(end()) :
begin_active (level+1));
@@ -1114,6 +1140,7 @@ template
typename DoFHandler::raw_line_iterator
DoFHandler::begin_raw_line (const unsigned int level) const
{
+ Assert(tria != 0, ExcNotInitialized());
switch (dim)
{
case 1:
@@ -1185,6 +1212,7 @@ template
typename DoFHandler::raw_line_iterator
DoFHandler::last_raw_line (const unsigned int level) const
{
+ Assert(tria != 0, ExcNotInitialized());
switch (dim)
{
case 1:
@@ -1450,6 +1478,7 @@ template
typename DoFHandler::raw_quad_iterator
DoFHandler::last_raw_quad (const unsigned int level) const
{
+ Assert(tria != 0, ExcNotInitialized());
switch (dim)
{
case 1:
@@ -1752,8 +1781,7 @@ DoFHandler::last_active_hex () const
template <>
unsigned int DoFHandler<1>::n_boundary_dofs () const
{
- Assert (selected_fe != 0, ExcNoFESelected());
- return 2*selected_fe->dofs_per_vertex;
+ return 2*get_fe().dofs_per_vertex;
}
@@ -1761,8 +1789,6 @@ unsigned int DoFHandler<1>::n_boundary_dofs () const
template <>
unsigned int DoFHandler<1>::n_boundary_dofs (const FunctionMap &boundary_indicators) const
{
- Assert (selected_fe != 0, ExcNoFESelected());
-
// check that only boundary
// indicators 0 and 1 are allowed
// in 1d
@@ -1771,7 +1797,7 @@ unsigned int DoFHandler<1>::n_boundary_dofs (const FunctionMap &boundary_indicat
Assert ((i->first == 0) || (i->first == 1),
ExcInvalidBoundaryIndicator());
- return boundary_indicators.size()*selected_fe->dofs_per_vertex;
+ return boundary_indicators.size()*get_fe().dofs_per_vertex;
}
@@ -1779,8 +1805,6 @@ unsigned int DoFHandler<1>::n_boundary_dofs (const FunctionMap &boundary_indicat
template <>
unsigned int DoFHandler<1>::n_boundary_dofs (const std::set &boundary_indicators) const
{
- Assert (selected_fe != 0, ExcNoFESelected());
-
// check that only boundary
// indicators 0 and 1 are allowed
// in 1d
@@ -1789,15 +1813,14 @@ unsigned int DoFHandler<1>::n_boundary_dofs (const std::set &boun
Assert ((*i == 0) || (*i == 1),
ExcInvalidBoundaryIndicator());
- return boundary_indicators.size()*selected_fe->dofs_per_vertex;
+ return boundary_indicators.size()*get_fe().dofs_per_vertex;
}
template <>
unsigned int DoFHandler<1,2>::n_boundary_dofs () const
{
- Assert (selected_fe != 0, ExcNoFESelected());
- return 2*selected_fe->dofs_per_vertex;
+ return 2*get_fe().dofs_per_vertex;
}
@@ -1805,8 +1828,6 @@ unsigned int DoFHandler<1,2>::n_boundary_dofs () const
template <>
unsigned int DoFHandler<1,2>::n_boundary_dofs (const FunctionMap &boundary_indicators) const
{
- Assert (selected_fe != 0, ExcNoFESelected());
-
// check that only boundary
// indicators 0 and 1 are allowed
// in 1d
@@ -1815,7 +1836,7 @@ unsigned int DoFHandler<1,2>::n_boundary_dofs (const FunctionMap &boundary_indic
Assert ((i->first == 0) || (i->first == 1),
ExcInvalidBoundaryIndicator());
- return boundary_indicators.size()*selected_fe->dofs_per_vertex;
+ return boundary_indicators.size()*get_fe().dofs_per_vertex;
}
@@ -1823,8 +1844,6 @@ unsigned int DoFHandler<1,2>::n_boundary_dofs (const FunctionMap &boundary_indic
template <>
unsigned int DoFHandler<1,2>::n_boundary_dofs (const std::set &boundary_indicators) const
{
- Assert (selected_fe != 0, ExcNoFESelected());
-
// check that only boundary
// indicators 0 and 1 are allowed
// in 1d
@@ -1833,7 +1852,7 @@ unsigned int DoFHandler<1,2>::n_boundary_dofs (const std::set &bo
Assert ((*i == 0) || (*i == 1),
ExcInvalidBoundaryIndicator());
- return boundary_indicators.size()*selected_fe->dofs_per_vertex;
+ return boundary_indicators.size()*get_fe().dofs_per_vertex;
}
#endif
@@ -1842,11 +1861,9 @@ unsigned int DoFHandler<1,2>::n_boundary_dofs (const std::set &bo
template
unsigned int DoFHandler::n_boundary_dofs () const
{
- Assert (selected_fe != 0, ExcNoFESelected());
-
std::set boundary_dofs;
- const unsigned int dofs_per_face = selected_fe->dofs_per_face;
+ const unsigned int dofs_per_face = get_fe().dofs_per_face;
std::vector dofs_on_face(dofs_per_face);
// loop over all faces to check
@@ -1877,13 +1894,12 @@ template
unsigned int
DoFHandler::n_boundary_dofs (const FunctionMap &boundary_indicators) const
{
- Assert (selected_fe != 0, ExcNoFESelected());
Assert (boundary_indicators.find(255) == boundary_indicators.end(),
ExcInvalidBoundaryIndicator());
std::set boundary_dofs;
- const unsigned int dofs_per_face = selected_fe->dofs_per_face;
+ const unsigned int dofs_per_face = get_fe().dofs_per_face;
std::vector dofs_on_face(dofs_per_face);
active_face_iterator face = begin_active_face (),
endf = end_face();
@@ -1904,13 +1920,12 @@ template
unsigned int
DoFHandler::n_boundary_dofs (const std::set &boundary_indicators) const
{
- Assert (selected_fe != 0, ExcNoFESelected());
Assert (boundary_indicators.find (255) == boundary_indicators.end(),
ExcInvalidBoundaryIndicator());
std::set boundary_dofs;
- const unsigned int dofs_per_face = selected_fe->dofs_per_face;
+ const unsigned int dofs_per_face = get_fe().dofs_per_face;
std::vector dofs_on_face(dofs_per_face);
active_face_iterator face = begin_active_face (),
endf = end_face();
@@ -2056,8 +2071,6 @@ template
unsigned int
DoFHandler::max_couplings_between_dofs () const
{
- Assert (selected_fe != 0, ExcNoFESelected());
-
return internal::DoFHandler::Implementation::max_couplings_between_dofs (*this);
}
@@ -2067,15 +2080,13 @@ template
unsigned int
DoFHandler::max_couplings_between_boundary_dofs () const
{
- Assert (selected_fe != 0, ExcNoFESelected());
-
switch (dim)
{
case 1:
- return selected_fe->dofs_per_vertex;
+ return get_fe().dofs_per_vertex;
case 2:
- return (3*selected_fe->dofs_per_vertex +
- 2*selected_fe->dofs_per_line);
+ return (3*get_fe().dofs_per_vertex +
+ 2*get_fe().dofs_per_line);
case 3:
// we need to take refinement of
// one boundary face into
@@ -2093,9 +2104,9 @@ DoFHandler::max_couplings_between_boundary_dofs () const
// harm since the matrix will cry
// foul if its requirements are
// not satisfied
- return (19*selected_fe->dofs_per_vertex +
- 28*selected_fe->dofs_per_line +
- 8*selected_fe->dofs_per_quad);
+ return (19*get_fe().dofs_per_vertex +
+ 28*get_fe().dofs_per_line +
+ 8*get_fe().dofs_per_quad);
default:
Assert (false, ExcNotImplemented());
return numbers::invalid_unsigned_int;
diff --git a/deal.II/deal.II/source/multigrid/mg_dof_handler.cc b/deal.II/deal.II/source/multigrid/mg_dof_handler.cc
index 2bcc73c50f..7ec46d3036 100644
--- a/deal.II/deal.II/source/multigrid/mg_dof_handler.cc
+++ b/deal.II/deal.II/source/multigrid/mg_dof_handler.cc
@@ -489,8 +489,7 @@ namespace internal
{
const unsigned int dim = 1;
- Assert (mg_dof_handler.selected_fe != 0, DoFHandler<1>::ExcNoFESelected());
- Assert (mg_dof_handler.tria->n_levels() > 0, DoFHandler<1>::ExcInvalidTriangulation());
+ Assert (mg_dof_handler.get_tria().n_levels() > 0, DoFHandler<1>::ExcInvalidTriangulation());
//////////////////////////
// DESTRUCTION
@@ -501,12 +500,12 @@ namespace internal
// first allocate space for the
// lines on each level
- for (unsigned int i=0; in_levels(); ++i)
+ for (unsigned int i=0; i);
- mg_dof_handler.mg_levels.back()->lines.dofs = std::vector(mg_dof_handler.tria->n_raw_lines(i) *
- mg_dof_handler.selected_fe->dofs_per_line,
+ mg_dof_handler.mg_levels.back()->lines.dofs = std::vector(mg_dof_handler.get_tria().n_raw_lines(i) *
+ mg_dof_handler.get_fe().dofs_per_line,
DoFHandler<1>::invalid_dof_index);
}
@@ -522,13 +521,13 @@ namespace internal
// over all cells and storing the
// maximum and minimum level each
// vertex we pass by belongs to
- mg_dof_handler.mg_vertex_dofs.resize (mg_dof_handler.tria->n_vertices());
+ mg_dof_handler.mg_vertex_dofs.resize (mg_dof_handler.get_tria().n_vertices());
- std::vector min_level (mg_dof_handler.tria->n_vertices(), mg_dof_handler.tria->n_levels());
- std::vector max_level (mg_dof_handler.tria->n_vertices(), 0);
+ std::vector min_level (mg_dof_handler.get_tria().n_vertices(), mg_dof_handler.get_tria().n_levels());
+ std::vector max_level (mg_dof_handler.get_tria().n_vertices(), 0);
- typename dealii::Triangulation::cell_iterator cell = mg_dof_handler.tria->begin(),
- endc = mg_dof_handler.tria->end();
+ typename dealii::Triangulation::cell_iterator cell = mg_dof_handler.get_tria().begin(),
+ endc = mg_dof_handler.get_tria().end();
for (; cell!=endc; ++cell)
for (unsigned int vertex=0; vertex::vertices_per_cell;
++vertex)
@@ -541,10 +540,10 @@ namespace internal
}
// now allocate the needed space
- for (unsigned int vertex=0; vertexn_vertices(); ++vertex)
- if (mg_dof_handler.tria->vertex_used(vertex))
+ for (unsigned int vertex=0; vertexn_levels(), ExcInternalError());
+ Assert (min_level[vertex] < mg_dof_handler.get_tria().n_levels(), ExcInternalError());
Assert (max_level[vertex] >= min_level[vertex], ExcInternalError());
mg_dof_handler.mg_vertex_dofs[vertex].init (min_level[vertex],
@@ -553,7 +552,7 @@ namespace internal
}
else
{
- Assert (min_level[vertex] == mg_dof_handler.tria->n_levels(), ExcInternalError());
+ Assert (min_level[vertex] == mg_dof_handler.get_tria().n_levels(), ExcInternalError());
Assert (max_level[vertex] == 0, ExcInternalError());
// reset to original state
@@ -568,9 +567,7 @@ namespace internal
void reserve_space (MGDoFHandler<2,spacedim> &mg_dof_handler)
{
const unsigned int dim = 2;
-
- Assert (mg_dof_handler.selected_fe != 0, DoFHandler<2>::ExcNoFESelected());
- Assert (mg_dof_handler.tria->n_levels() > 0, DoFHandler<2>::ExcInvalidTriangulation());
+ Assert (mg_dof_handler.get_tria().n_levels() > 0, DoFHandler<2>::ExcInvalidTriangulation());
////////////////////////////
// DESTRUCTION
@@ -581,18 +578,18 @@ namespace internal
// first allocate space for the
// lines and quads on each level
- for (unsigned int i=0; in_levels(); ++i)
+ for (unsigned int i=0; i);
- mg_dof_handler.mg_levels.back()->quads.dofs = std::vector (mg_dof_handler.tria->n_raw_quads(i) *
- mg_dof_handler.selected_fe->dofs_per_quad,
+ mg_dof_handler.mg_levels.back()->quads.dofs = std::vector (mg_dof_handler.get_tria().n_raw_quads(i) *
+ mg_dof_handler.get_fe().dofs_per_quad,
DoFHandler<2>::invalid_dof_index);
}
mg_dof_handler.mg_faces = new internal::DoFHandler::DoFFaces<2>;
- mg_dof_handler.mg_faces->lines.dofs = std::vector (mg_dof_handler.tria->n_raw_lines() *
- mg_dof_handler.selected_fe->dofs_per_line,
+ mg_dof_handler.mg_faces->lines.dofs = std::vector (mg_dof_handler.get_tria().n_raw_lines() *
+ mg_dof_handler.get_fe().dofs_per_line,
DoFHandler<2>::invalid_dof_index);
@@ -608,16 +605,16 @@ namespace internal
// over all cells and storing the
// maximum and minimum level each
// vertex we pass by belongs to
- mg_dof_handler.mg_vertex_dofs.resize (mg_dof_handler.tria->n_vertices());
+ mg_dof_handler.mg_vertex_dofs.resize (mg_dof_handler.get_tria().n_vertices());
// initialize these arrays with
// invalid values (min>max)
- std::vector min_level (mg_dof_handler.tria->n_vertices(),
- mg_dof_handler.tria->n_levels());
- std::vector max_level (mg_dof_handler.tria->n_vertices(), 0);
+ std::vector min_level (mg_dof_handler.get_tria().n_vertices(),
+ mg_dof_handler.get_tria().n_levels());
+ std::vector max_level (mg_dof_handler.get_tria().n_vertices(), 0);
- typename dealii::Triangulation::cell_iterator cell = mg_dof_handler.tria->begin(),
- endc = mg_dof_handler.tria->end();
+ typename dealii::Triangulation::cell_iterator cell = mg_dof_handler.get_tria().begin(),
+ endc = mg_dof_handler.get_tria().end();
for (; cell!=endc; ++cell)
for (unsigned int vertex=0; vertex::vertices_per_cell;
++vertex)
@@ -631,10 +628,10 @@ namespace internal
// now allocate the needed space
- for (unsigned int vertex=0; vertexn_vertices(); ++vertex)
- if (mg_dof_handler.tria->vertex_used(vertex))
+ for (unsigned int vertex=0; vertexn_levels(), ExcInternalError());
+ Assert (min_level[vertex] < mg_dof_handler.get_tria().n_levels(), ExcInternalError());
Assert (max_level[vertex] >= min_level[vertex], ExcInternalError());
mg_dof_handler.mg_vertex_dofs[vertex].init (min_level[vertex],
@@ -643,7 +640,7 @@ namespace internal
}
else
{
- Assert (min_level[vertex] == mg_dof_handler.tria->n_levels(), ExcInternalError());
+ Assert (min_level[vertex] == mg_dof_handler.get_tria().n_levels(), ExcInternalError());
Assert (max_level[vertex] == 0, ExcInternalError());
// reset to original state
@@ -659,8 +656,7 @@ namespace internal
{
const unsigned int dim = 3;
- Assert (mg_dof_handler.selected_fe != 0, DoFHandler<3>::ExcNoFESelected());
- Assert (mg_dof_handler.tria->n_levels() > 0, DoFHandler<3>::ExcInvalidTriangulation());
+ Assert (mg_dof_handler.get_tria().n_levels() > 0, DoFHandler<3>::ExcInvalidTriangulation());
////////////////////////////
// DESTRUCTION
@@ -671,21 +667,21 @@ namespace internal
// first allocate space for the
// lines and quads on each level
- for (unsigned int i=0; in_levels(); ++i)
+ for (unsigned int i=0; i);
mg_dof_handler.mg_levels.back()->hexes.dofs
- = std::vector (mg_dof_handler.tria->n_raw_hexs(i) *
- mg_dof_handler.selected_fe->dofs_per_hex,
+ = std::vector (mg_dof_handler.get_tria().n_raw_hexs(i) *
+ mg_dof_handler.get_fe().dofs_per_hex,
DoFHandler<3>::invalid_dof_index);
}
mg_dof_handler.mg_faces = new internal::DoFHandler::DoFFaces<3>;
- mg_dof_handler.mg_faces->lines.dofs = std::vector (mg_dof_handler.tria->n_raw_lines() *
- mg_dof_handler.selected_fe->dofs_per_line,
+ mg_dof_handler.mg_faces->lines.dofs = std::vector (mg_dof_handler.get_tria().n_raw_lines() *
+ mg_dof_handler.get_fe().dofs_per_line,
DoFHandler<3>::invalid_dof_index);
- mg_dof_handler.mg_faces->quads.dofs = std::vector (mg_dof_handler.tria->n_raw_quads() *
- mg_dof_handler.selected_fe->dofs_per_quad,
+ mg_dof_handler.mg_faces->quads.dofs = std::vector (mg_dof_handler.get_tria().n_raw_quads() *
+ mg_dof_handler.get_fe().dofs_per_quad,
DoFHandler<3>::invalid_dof_index);
@@ -701,13 +697,13 @@ namespace internal
// over all cells and storing the
// maximum and minimum level each
// vertex we pass by belongs to
- mg_dof_handler.mg_vertex_dofs.resize (mg_dof_handler.tria->n_vertices());
+ mg_dof_handler.mg_vertex_dofs.resize (mg_dof_handler.get_tria().n_vertices());
- std::vector min_level (mg_dof_handler.tria->n_vertices(), mg_dof_handler.tria->n_levels());
- std::vector max_level (mg_dof_handler.tria->n_vertices(), 0);
+ std::vector min_level (mg_dof_handler.get_tria().n_vertices(), mg_dof_handler.get_tria().n_levels());
+ std::vector max_level (mg_dof_handler.get_tria().n_vertices(), 0);
- typename dealii::Triangulation::cell_iterator cell = mg_dof_handler.tria->begin(),
- endc = mg_dof_handler.tria->end();
+ typename dealii::Triangulation::cell_iterator cell = mg_dof_handler.get_tria().begin(),
+ endc = mg_dof_handler.get_tria().end();
for (; cell!=endc; ++cell)
for (unsigned int vertex=0; vertex::vertices_per_cell;
++vertex)
@@ -721,10 +717,10 @@ namespace internal
// now allocate the needed space
- for (unsigned int vertex=0; vertexn_vertices(); ++vertex)
- if (mg_dof_handler.tria->vertex_used(vertex))
+ for (unsigned int vertex=0; vertexn_levels(), ExcInternalError());
+ Assert (min_level[vertex] < mg_dof_handler.get_tria().n_levels(), ExcInternalError());
Assert (max_level[vertex] >= min_level[vertex], ExcInternalError());
mg_dof_handler.mg_vertex_dofs[vertex].init (min_level[vertex],
@@ -733,7 +729,7 @@ namespace internal
}
else
{
- Assert (min_level[vertex] == mg_dof_handler.tria->n_levels(), ExcInternalError());
+ Assert (min_level[vertex] == mg_dof_handler.get_tria().n_levels(), ExcInternalError());
Assert (max_level[vertex] == 0, ExcInternalError());
// reset to original state
@@ -1072,7 +1068,7 @@ template
typename MGDoFHandler::raw_cell_iterator
MGDoFHandler::end_raw (const unsigned int level) const
{
- return (level == this->tria->n_levels()-1 ?
+ return (level == this->get_tria().n_levels()-1 ?
end() :
begin_raw (level+1));
}
@@ -1082,7 +1078,7 @@ template
typename MGDoFHandler::cell_iterator
MGDoFHandler::end (const unsigned int level) const
{
- return (level == this->tria->n_levels()-1 ?
+ return (level == this->get_tria().n_levels()-1 ?
cell_iterator(end()) :
begin (level+1));
}
@@ -1092,7 +1088,7 @@ template
typename MGDoFHandler::active_cell_iterator
MGDoFHandler::end_active (const unsigned int level) const
{
- return (level == this->tria->n_levels()-1 ?
+ return (level == this->get_tria().n_levels()-1 ?
active_cell_iterator(end()) :
begin_active (level+1));
}
@@ -1278,19 +1274,19 @@ MGDoFHandler::begin_raw_line (const unsigned int level) const
switch (dim)
{
case 1:
- Assert (leveltria->n_levels(), ExcInvalidLevel(level));
+ Assert (levelget_tria().n_levels(), ExcInvalidLevel(level));
- if (this->tria->n_raw_lines(level) == 0)
+ if (this->get_tria().n_raw_lines(level) == 0)
return end_line ();
- return raw_line_iterator (this->tria,
+ return raw_line_iterator (&this->get_tria(),
level,
0,
this);
default:
Assert (level == 0, ExcFacesHaveNoLevel());
- return raw_line_iterator (this->tria,
+ return raw_line_iterator (&this->get_tria(),
0,
0,
this);
@@ -1334,7 +1330,7 @@ template
typename MGDoFHandler::raw_line_iterator
MGDoFHandler::end_line () const
{
- return raw_line_iterator (this->tria,
+ return raw_line_iterator (&this->get_tria(),
-1,
-1,
this);
@@ -1349,20 +1345,20 @@ MGDoFHandler::last_raw_line (const unsigned int level) const
switch (dim)
{
case 1:
- Assert (leveltria->n_levels(), ExcInvalidLevel(level));
- Assert (this->tria->n_raw_lines(level) != 0,
+ Assert (levelget_tria().n_levels(), ExcInvalidLevel(level));
+ Assert (this->get_tria().n_raw_lines(level) != 0,
ExcEmptyLevel (level));
- return raw_line_iterator (this->tria,
+ return raw_line_iterator (&this->get_tria(),
level,
- this->tria->n_raw_lines(level)-1,
+ this->get_tria().n_raw_lines(level)-1,
this);
default:
Assert (level == 0, ExcFacesHaveNoLevel());
- return raw_line_iterator (this->tria,
+ return raw_line_iterator (&this->get_tria(),
0,
- this->tria->n_raw_lines()-1,
+ this->get_tria().n_raw_lines()-1,
this);
}
}
@@ -1374,7 +1370,7 @@ typename MGDoFHandler::raw_line_iterator
MGDoFHandler::last_raw_line () const
{
if (dim == 1)
- return last_raw_line (this->tria->n_levels()-1);
+ return last_raw_line (this->get_tria().n_levels()-1);
else
return last_raw_line (0);
}
@@ -1400,7 +1396,7 @@ typename MGDoFHandler::line_iterator
MGDoFHandler::last_line () const
{
if (dim == 1)
- return last_line (this->tria->n_levels()-1);
+ return last_line (this->get_tria().n_levels()-1);
else
return last_line (0);
}
@@ -1426,7 +1422,7 @@ typename MGDoFHandler::active_line_iterator
MGDoFHandler::last_active_line () const
{
if (dim == 1)
- return last_active_line (this->tria->n_levels()-1);
+ return last_active_line (this->get_tria().n_levels()-1);
else
return last_active_line (0);
}
@@ -1438,7 +1434,7 @@ MGDoFHandler::end_raw_line (const unsigned int level) const
{
Assert (dim == 1 || level == 0, ExcFacesHaveNoLevel());
if (dim == 1)
- return (level == this->tria->n_levels()-1 ?
+ return (level == this->get_tria().n_levels()-1 ?
end_line() :
begin_raw_line (level+1));
else
@@ -1452,7 +1448,7 @@ MGDoFHandler::end_line (const unsigned int level) const
{
Assert (dim == 1 || level == 0, ExcFacesHaveNoLevel());
if (dim == 1)
- return (level == this->tria->n_levels()-1 ?
+ return (level == this->get_tria().n_levels()-1 ?
line_iterator(end_line()) :
begin_line (level+1));
else
@@ -1466,7 +1462,7 @@ MGDoFHandler::end_active_line (const unsigned int level) const
{
Assert (dim == 1 || level == 0, ExcFacesHaveNoLevel());
if (dim == 1)
- return (level == this->tria->n_levels()-1 ?
+ return (level == this->get_tria().n_levels()-1 ?
active_line_iterator(end_line()) :
begin_active_line (level+1));
else
@@ -1489,12 +1485,12 @@ MGDoFHandler::begin_raw_quad (const unsigned int level) const
return raw_hex_iterator();
case 2:
{
- Assert (leveltria->n_levels(), ExcInvalidLevel(level));
+ Assert (levelget_tria().n_levels(), ExcInvalidLevel(level));
- if (this->tria->n_raw_quads(level) == 0)
+ if (this->get_tria().n_raw_quads(level) == 0)
return end_quad();
- return raw_quad_iterator (this->tria,
+ return raw_quad_iterator (&this->get_tria(),
level,
0,
this);
@@ -1504,7 +1500,7 @@ MGDoFHandler::begin_raw_quad (const unsigned int level) const
{
Assert (level == 0, ExcFacesHaveNoLevel());
- return raw_quad_iterator (this->tria,
+ return raw_quad_iterator (&this->get_tria(),
0,
0,
this);
@@ -1557,7 +1553,7 @@ MGDoFHandler::end_raw_quad (const unsigned int level) const
{
Assert (dim == 2 || level == 0, ExcFacesHaveNoLevel());
if (dim == 2)
- return (level == this->tria->n_levels()-1 ?
+ return (level == this->get_tria().n_levels()-1 ?
end_quad() :
begin_raw_quad (level+1));
else
@@ -1572,7 +1568,7 @@ MGDoFHandler::end_quad (const unsigned int level) const
{
Assert (dim == 2 || level == 0, ExcFacesHaveNoLevel());
if (dim == 2)
- return (level == this->tria->n_levels()-1 ?
+ return (level == this->get_tria().n_levels()-1 ?
quad_iterator(end_quad()) :
begin_quad (level+1));
else
@@ -1586,7 +1582,7 @@ MGDoFHandler::end_active_quad (const unsigned int level) const
{
Assert(dim == 2 || level == 0, ExcFacesHaveNoLevel());
if (dim == 2)
- return (level == this->tria->n_levels()-1 ?
+ return (level == this->get_tria().n_levels()-1 ?
active_quad_iterator(end_quad()) :
begin_active_quad (level+1));
else
@@ -1599,7 +1595,7 @@ template
typename MGDoFHandler::raw_quad_iterator
MGDoFHandler::end_quad () const
{
- return raw_quad_iterator (this->tria,
+ return raw_quad_iterator (&this->get_tria(),
-1,
-1,
this);
@@ -1617,19 +1613,19 @@ MGDoFHandler::last_raw_quad (const unsigned int level) const
Assert (false, ExcImpossibleInDim(1));
return raw_quad_iterator();
case 2:
- Assert (leveltria->n_levels(),
+ Assert (levelget_tria().n_levels(),
ExcInvalidLevel(level));
- Assert (this->tria->n_raw_quads(level) != 0,
+ Assert (this->get_tria().n_raw_quads(level) != 0,
ExcEmptyLevel (level));
- return raw_quad_iterator (this->tria,
+ return raw_quad_iterator (&this->get_tria(),
level,
- this->tria->n_raw_quads(level)-1,
+ this->get_tria().n_raw_quads(level)-1,
this);
case 3:
Assert (level == 0, ExcFacesHaveNoLevel());
- return raw_quad_iterator (this->tria,
+ return raw_quad_iterator (&this->get_tria(),
0,
- this->tria->n_raw_quads()-1,
+ this->get_tria().n_raw_quads()-1,
this);
default:
Assert (false, ExcNotImplemented());
@@ -1644,7 +1640,7 @@ typename MGDoFHandler::raw_quad_iterator
MGDoFHandler::last_raw_quad () const
{
if (dim == 2)
- return last_raw_quad (this->tria->n_levels()-1);
+ return last_raw_quad (this->get_tria().n_levels()-1);
else
return last_raw_quad (0);
}
@@ -1672,7 +1668,7 @@ typename MGDoFHandler::quad_iterator
MGDoFHandler::last_quad () const
{
if (dim == 2)
- return last_quad (this->tria->n_levels()-1);
+ return last_quad (this->get_tria().n_levels()-1);
else
return last_quad (0);
}
@@ -1700,7 +1696,7 @@ typename MGDoFHandler::active_quad_iterator
MGDoFHandler::last_active_quad () const
{
if (dim == 2)
- return last_active_quad (this->tria->n_levels()-1);
+ return last_active_quad (this->get_tria().n_levels()-1);
else
return last_active_quad (0);
}
@@ -1721,12 +1717,12 @@ MGDoFHandler::begin_raw_hex (const unsigned int level) const
return raw_hex_iterator();
case 3:
{
- Assert (leveltria->n_levels(), ExcInvalidLevel(level));
+ Assert (levelget_tria().n_levels(), ExcInvalidLevel(level));
- if (this->tria->n_raw_hexs(level) == 0)
+ if (this->get_tria().n_raw_hexs(level) == 0)
return end_hex();
- return raw_hex_iterator (this->tria,
+ return raw_hex_iterator (&this->get_tria(),
level,
0,
this);
@@ -1776,7 +1772,7 @@ template
typename MGDoFHandler::raw_hex_iterator
MGDoFHandler::end_raw_hex (const unsigned int level) const
{
- return (level == this->tria->n_levels()-1 ?
+ return (level == this->get_tria().n_levels()-1 ?
end_hex() :
begin_raw_hex (level+1));
}
@@ -1786,7 +1782,7 @@ template
typename MGDoFHandler::hex_iterator
MGDoFHandler::end_hex (const unsigned int level) const
{
- return (level == this->tria->n_levels()-1 ?
+ return (level == this->get_tria().n_levels()-1 ?
hex_iterator(end_hex()) :
begin_hex (level+1));
}
@@ -1796,7 +1792,7 @@ template
typename MGDoFHandler::active_hex_iterator
MGDoFHandler::end_active_hex (const unsigned int level) const
{
- return (level == this->tria->n_levels()-1 ?
+ return (level == this->get_tria().n_levels()-1 ?
active_hex_iterator(end_hex()) :
begin_active_hex (level+1));
}
@@ -1807,7 +1803,7 @@ template
typename MGDoFHandler::raw_hex_iterator
MGDoFHandler::end_hex () const
{
- return raw_hex_iterator (this->tria,
+ return raw_hex_iterator (&this->get_tria(),
-1,
-1,
this);
@@ -1827,14 +1823,14 @@ MGDoFHandler::last_raw_hex (const unsigned int level) const
return raw_hex_iterator();
case 3:
- Assert (leveltria->n_levels(),
+ Assert (levelget_tria().n_levels(),
ExcInvalidLevel(level));
- Assert (this->tria->n_raw_hexs(level) != 0,
+ Assert (this->get_tria().n_raw_hexs(level) != 0,
ExcEmptyLevel (level));
- return raw_hex_iterator (this->tria,
+ return raw_hex_iterator (&this->get_tria(),
level,
- this->tria->n_raw_hexs(level)-1,
+ this->get_tria().n_raw_hexs(level)-1,
this);
default:
Assert (false, ExcNotImplemented());
@@ -1848,7 +1844,7 @@ template
typename MGDoFHandler::raw_hex_iterator
MGDoFHandler::last_raw_hex () const
{
- return last_raw_hex (this->tria->n_levels()-1);
+ return last_raw_hex (this->get_tria().n_levels()-1);
}
@@ -1873,7 +1869,7 @@ template
typename MGDoFHandler::hex_iterator
MGDoFHandler::last_hex () const
{
- return last_hex (this->tria->n_levels()-1);
+ return last_hex (this->get_tria().n_levels()-1);
}
@@ -1898,7 +1894,7 @@ template
typename MGDoFHandler::active_hex_iterator
MGDoFHandler::last_active_hex () const
{
- return last_active_hex (this->tria->n_levels()-1);
+ return last_active_hex (this->get_tria().n_levels()-1);
}
@@ -1961,7 +1957,7 @@ void MGDoFHandler::distribute_dofs (const FiniteElementtria->n_levels(), 0);
+ mg_used_dofs.resize (this->get_tria().n_levels(), 0);
// Clear user flags because we will
// need them. But first we save
@@ -1972,12 +1968,12 @@ void MGDoFHandler::distribute_dofs (const FiniteElement user_flags;
- this->tria->save_user_flags(user_flags);
- const_cast &>(*(this->tria)).clear_user_flags ();
+ this->get_tria().save_user_flags(user_flags);
+ const_cast &>(this->get_tria()).clear_user_flags ();
// now distribute indices on each level
// separately
- for (unsigned int level=0; leveltria->n_levels(); ++level)
+ for (unsigned int level=0; levelget_tria().n_levels(); ++level)
{
unsigned int next_free_dof = offset;
cell_iterator cell = begin(level),
@@ -1990,7 +1986,7 @@ void MGDoFHandler::distribute_dofs (const FiniteElement &>(*(this->tria))
+ const_cast &>(this->get_tria())
.load_user_flags(user_flags);
this->block_info_object.initialize(*this, true);
@@ -2040,10 +2036,10 @@ void MGDoFHandler<1>::renumber_dofs (const unsigned int level,
// the present level
if ((i->get_coarsest_level() <= level) &&
(i->get_finest_level() >= level))
- for (unsigned int d=0; dselected_fe->dofs_per_vertex; ++d)
- i->set_index (level, d, this->selected_fe->dofs_per_vertex,
+ for (unsigned int d=0; dget_fe().dofs_per_vertex; ++d)
+ i->set_index (level, d, this->get_fe().dofs_per_vertex,
new_numbers[i->get_index (level, d,
- this->selected_fe->dofs_per_vertex)]);
+ this->get_fe().dofs_per_vertex)]);
for (std::vector::iterator i=mg_levels[level]->lines.dofs.begin();
i!=mg_levels[level]->lines.dofs.end(); ++i)
@@ -2074,17 +2070,17 @@ void MGDoFHandler<2>::renumber_dofs (const unsigned int level,
// the present level
if ((i->get_coarsest_level() <= level) &&
(i->get_finest_level() >= level))
- for (unsigned int d=0; dselected_fe->dofs_per_vertex; ++d)
- i->set_index (level, d, this->selected_fe->dofs_per_vertex,
+ for (unsigned int d=0; dget_fe().dofs_per_vertex; ++d)
+ i->set_index (level, d, this->get_fe().dofs_per_vertex,
new_numbers[i->get_index (level, d,
- this->selected_fe->dofs_per_vertex)]);
+ this->get_fe().dofs_per_vertex)]);
- if (this->selected_fe->dofs_per_line > 0)
+ if (this->get_fe().dofs_per_line > 0)
{
// save user flags as they will be modified
std::vector user_flags;
- this->tria->save_user_flags(user_flags);
- const_cast &>(*(this->tria)).clear_user_flags ();
+ this->get_tria().save_user_flags(user_flags);
+ const_cast &>(this->get_tria()).clear_user_flags ();
// flag all lines adjacent to cells of the current
// level, as those lines logically belong to the same
@@ -2102,12 +2098,12 @@ void MGDoFHandler<2>::renumber_dofs (const unsigned int level,
for( ; line != endline; ++line)
if (line->user_flag_set())
{
- for (unsigned int d=0; dselected_fe->dofs_per_line; ++d)
+ for (unsigned int d=0; dget_fe().dofs_per_line; ++d)
line->set_mg_dof_index (level, d, new_numbers[line->mg_dof_index(level, d)]);
line->clear_user_flag();
}
// finally, restore user flags
- const_cast &>(*(this->tria)).load_user_flags (user_flags);
+ const_cast &>(this->get_tria()).load_user_flags (user_flags);
}
for (std::vector::iterator i=mg_levels[level]->quads.dofs.begin();
@@ -2139,18 +2135,18 @@ void MGDoFHandler<3>::renumber_dofs (const unsigned int level,
// the present level
if ((i->get_coarsest_level() <= level) &&
(i->get_finest_level() >= level))
- for (unsigned int d=0; dselected_fe->dofs_per_vertex; ++d)
- i->set_index (level, d, this->selected_fe->dofs_per_vertex,
+ for (unsigned int d=0; dget_fe().dofs_per_vertex; ++d)
+ i->set_index (level, d, this->get_fe().dofs_per_vertex,
new_numbers[i->get_index (level, d,
- this->selected_fe->dofs_per_vertex)]);
+ this->get_fe().dofs_per_vertex)]);
// LINE DoFs
- if (this->selected_fe->dofs_per_line > 0)
+ if (this->get_fe().dofs_per_line > 0)
{
// save user flags as they will be modified
std::vector user_flags;
- this->tria->save_user_flags(user_flags);
- const_cast &>(*(this->tria)).clear_user_flags ();
+ this->get_tria().save_user_flags(user_flags);
+ const_cast &>(this->get_tria()).clear_user_flags ();
// flag all lines adjacent to cells of the current
// level, as those lines logically belong to the same
@@ -2170,21 +2166,21 @@ void MGDoFHandler<3>::renumber_dofs (const unsigned int level,
for( ; line != endline; ++line)
if (line->user_flag_set())
{
- for (unsigned int d=0; dselected_fe->dofs_per_line; ++d)
+ for (unsigned int d=0; dget_fe().dofs_per_line; ++d)
line->set_mg_dof_index (level, d, new_numbers[line->mg_dof_index(level, d)]);
line->clear_user_flag();
}
// finally, restore user flags
- const_cast &>(*(this->tria)).load_user_flags (user_flags);
+ const_cast &>(this->get_tria()).load_user_flags (user_flags);
}
// QUAD DoFs
- if (this->selected_fe->dofs_per_quad > 0)
+ if (this->get_fe().dofs_per_quad > 0)
{
// save user flags as they will be modified
std::vector user_flags;
- this->tria->save_user_flags(user_flags);
- const_cast &>(*(this->tria)).clear_user_flags ();
+ this->get_tria().save_user_flags(user_flags);
+ const_cast &>(this->get_tria()).clear_user_flags ();
// flag all quads adjacent to cells of the current
// level, as those lines logically belong to the same
@@ -2202,12 +2198,12 @@ void MGDoFHandler<3>::renumber_dofs (const unsigned int level,
for( ; quad != endline; ++quad)
if (quad->user_flag_set())
{
- for (unsigned int d=0; dselected_fe->dofs_per_quad; ++d)
+ for (unsigned int d=0; dget_fe().dofs_per_quad; ++d)
quad->set_mg_dof_index (level, d, new_numbers[quad->mg_dof_index(level, d)]);
quad->clear_user_flag();
}
// finally, restore user flags
- const_cast &>(*(this->tria)).load_user_flags (user_flags);
+ const_cast &>(this->get_tria()).load_user_flags (user_flags);
}
//HEX DoFs
diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h
index 06531d6f73..791a71cd7c 100644
--- a/deal.II/doc/news/changes.h
+++ b/deal.II/doc/news/changes.h
@@ -30,7 +30,13 @@ inconvenience this causes.
- - None.
+
+
- The fields DoFHandler::tria and DoFHandler::selected_fe are now
+private instead of protected. Inheriting classes can only access them
+through DoFHandler::get_tria() and DoFHandler::get_fe(), respectively.
+
+(GK 2010/08/16)
+
@@ -218,6 +224,13 @@ inconvenience this causes.
+ -
+
+ Improved: DoFHandler has a default constructor, so that it can be used in containers.
+
+ (GK 2010/08/16)
+
+
-
New: The functions VectorTools::project_boundary_values_curl_conforming
--
2.39.5