From aad6e587046a9d6d83957d48bc227d8d304a901a Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 10 Jan 2003 16:37:09 +0000 Subject: [PATCH] Have a DoFAccessor::get_fe() function, and use it instead of dof_handler->selected_fe. This is a first step towards using the accessor classes also for other DoFHandlers than just the DoFHandler. git-svn-id: https://svn.dealii.org/trunk@6911 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/dofs/dof_accessor.h | 9 +++ .../include/dofs/dof_accessor.templates.h | 65 +++++++++++-------- deal.II/deal.II/include/dofs/dof_handler.h | 6 ++ deal.II/deal.II/source/dofs/dof_accessor.cc | 60 ++++++++--------- deal.II/doc/news/2002/c-3-4.html | 11 ++++ 5 files changed, 94 insertions(+), 57 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_accessor.h b/deal.II/deal.II/include/dofs/dof_accessor.h index 15800badec..a41663021e 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.h @@ -26,6 +26,7 @@ template class SparseMatrix; template class Vector; template class DoFHandler; +template class FiniteElement; template class DoFObjectAccessor; template class DoFObjectAccessor<0, dim>; @@ -100,6 +101,14 @@ class DoFAccessor const DoFHandler & get_dof_handler () const; + /** + * Return the finite element that + * is used on the cell pointed to + * by this iterator. + */ + const FiniteElement & + get_fe () const; + /** * Copy operator. */ diff --git a/deal.II/deal.II/include/dofs/dof_accessor.templates.h b/deal.II/deal.II/include/dofs/dof_accessor.templates.h index 81e62c226c..d4a7da8e92 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.templates.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.templates.h @@ -55,6 +55,7 @@ DoFAccessor::set_dof_handler (DoFHandler *dh) template +inline const DoFHandler & DoFAccessor::get_dof_handler () const { @@ -63,6 +64,16 @@ DoFAccessor::get_dof_handler () const +template +inline +const FiniteElement & +DoFAccessor::get_fe () const +{ + return *dof_handler->selected_fe; +} + + + template inline DoFAccessor & @@ -96,12 +107,12 @@ DoFObjectAccessor<1,dim>::dof_index (const unsigned int i) const Assert (this->dof_handler != 0, typename BaseClass::ExcInvalidObject()); // make sure a FE has been selected // and enough room was reserved - Assert (this->dof_handler->selected_fe != 0, typename BaseClass::ExcInvalidObject()); - Assert (idof_handler->selected_fe->dofs_per_line, - ExcIndexRange (i, 0, this->dof_handler->selected_fe->dofs_per_line)); + Assert (&this->get_fe() != 0, typename BaseClass::ExcInvalidObject()); + Assert (iget_fe().dofs_per_line, + ExcIndexRange (i, 0, this->get_fe().dofs_per_line)); return this->dof_handler->levels[this->present_level] - ->line_dofs[this->present_index*this->dof_handler->selected_fe->dofs_per_line+i]; + ->line_dofs[this->present_index*this->get_fe().dofs_per_line+i]; } @@ -123,13 +134,13 @@ DoFObjectAccessor<1,dim>::vertex_dof_index (const unsigned int vertex, typedef DoFAccessor BaseClass; Assert (this->dof_handler != 0, typename BaseClass::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, typename BaseClass::ExcInvalidObject()); + Assert (&this->get_fe() != 0, typename BaseClass::ExcInvalidObject()); Assert (vertex<2, ExcIndexRange (i,0,2)); - Assert (idof_handler->selected_fe->dofs_per_vertex, - ExcIndexRange (i, 0, this->dof_handler->selected_fe->dofs_per_vertex)); + Assert (iget_fe().dofs_per_vertex, + ExcIndexRange (i, 0, this->get_fe().dofs_per_vertex)); const unsigned int dof_number = (this->vertex_index(vertex) * - this->dof_handler->selected_fe->dofs_per_vertex + + this->get_fe().dofs_per_vertex + i); return this->dof_handler->vertex_dofs[dof_number]; } @@ -152,7 +163,7 @@ DoFObjectAccessor<1,dim>::get_dof_indices (std::vector &dof_indice typedef DoFAccessor BaseClass; Assert (this->dof_handler != 0, typename BaseClass::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, typename BaseClass::ExcInvalidObject()); + Assert (&this->get_fe() != 0, typename BaseClass::ExcInvalidObject()); Assert (dof_indices.size() == (2*this->dof_handler->get_fe().dofs_per_vertex + this->dof_handler->get_fe().dofs_per_line), typename BaseClass::ExcVectorDoesNotMatch()); @@ -219,13 +230,13 @@ unsigned int DoFObjectAccessor<2,dim>::dof_index (const unsigned int i) const typename DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected // and enough room was reserved - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (idof_handler->selected_fe->dofs_per_quad, - ExcIndexRange (i, 0, this->dof_handler->selected_fe->dofs_per_quad)); + Assert (iget_fe().dofs_per_quad, + ExcIndexRange (i, 0, this->get_fe().dofs_per_quad)); return this->dof_handler->levels[this->present_level] - ->quad_dofs[this->present_index*this->dof_handler->selected_fe->dofs_per_quad+i]; + ->quad_dofs[this->present_index*this->get_fe().dofs_per_quad+i]; } @@ -237,14 +248,14 @@ DoFObjectAccessor<2,dim>::vertex_dof_index (const unsigned int vertex, { Assert (this->dof_handler != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); Assert (vertex<4, ExcIndexRange (i,0,4)); - Assert (idof_handler->selected_fe->dofs_per_vertex, - ExcIndexRange (i, 0, this->dof_handler->selected_fe->dofs_per_vertex)); + Assert (iget_fe().dofs_per_vertex, + ExcIndexRange (i, 0, this->get_fe().dofs_per_vertex)); const unsigned int dof_number = (this->vertex_index(vertex) * - this->dof_handler->selected_fe->dofs_per_vertex + + this->get_fe().dofs_per_vertex + i); return this->dof_handler->vertex_dofs[dof_number]; } @@ -263,7 +274,7 @@ DoFObjectAccessor<2,dim>::get_dof_indices (std::vector &dof_indice { Assert (this->dof_handler != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); Assert (dof_indices.size() == (4*this->dof_handler->get_fe().dofs_per_vertex + 4*this->dof_handler->get_fe().dofs_per_line + @@ -356,13 +367,13 @@ DoFObjectAccessor<3,dim>::dof_index (const unsigned int i) const typename DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected // and enough room was reserved - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (idof_handler->selected_fe->dofs_per_hex, - ExcIndexRange (i, 0, this->dof_handler->selected_fe->dofs_per_hex)); + Assert (iget_fe().dofs_per_hex, + ExcIndexRange (i, 0, this->get_fe().dofs_per_hex)); return this->dof_handler->levels[this->present_level] - ->hex_dofs[this->present_index*this->dof_handler->selected_fe->dofs_per_hex+i]; + ->hex_dofs[this->present_index*this->get_fe().dofs_per_hex+i]; } @@ -374,14 +385,14 @@ DoFObjectAccessor<3,dim>::vertex_dof_index (const unsigned int vertex, { Assert (this->dof_handler != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); Assert (vertex<8, ExcIndexRange (i,0,8)); - Assert (idof_handler->selected_fe->dofs_per_vertex, - ExcIndexRange (i, 0, this->dof_handler->selected_fe->dofs_per_vertex)); + Assert (iget_fe().dofs_per_vertex, + ExcIndexRange (i, 0, this->get_fe().dofs_per_vertex)); const unsigned int dof_number = (this->vertex_index(vertex) * - this->dof_handler->selected_fe->dofs_per_vertex + + this->get_fe().dofs_per_vertex + i); return this->dof_handler->vertex_dofs[dof_number]; } @@ -394,7 +405,7 @@ DoFObjectAccessor<3,dim>::get_dof_indices (std::vector &dof_indice { Assert (this->dof_handler != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); Assert (dof_indices.size() == (8*this->dof_handler->get_fe().dofs_per_vertex + 12*this->dof_handler->get_fe().dofs_per_line + diff --git a/deal.II/deal.II/include/dofs/dof_handler.h b/deal.II/deal.II/include/dofs/dof_handler.h index ee5c0864a0..1f1b4f6f33 100644 --- a/deal.II/deal.II/include/dofs/dof_handler.h +++ b/deal.II/deal.II/include/dofs/dof_handler.h @@ -23,6 +23,7 @@ #include #include +template class DoFAccessor; template class DoFCellAccessor; template class DoFLevel; template class DoFObjectAccessor; @@ -1143,6 +1144,11 @@ class DoFHandler : public Subscriptor, */ std::vector vertex_dofs; + /** + * Make accessor objects friends. + */ + template friend class DoFAccessor; + /** * Make accessor objects friends. */ diff --git a/deal.II/deal.II/source/dofs/dof_accessor.cc b/deal.II/deal.II/source/dofs/dof_accessor.cc index 2c35389d5b..7470d91d56 100644 --- a/deal.II/deal.II/source/dofs/dof_accessor.cc +++ b/deal.II/deal.II/source/dofs/dof_accessor.cc @@ -38,13 +38,13 @@ void DoFObjectAccessor<1, dim>::set_dof_index (const unsigned int i, typename DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected // and enough room was reserved - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (idof_handler->selected_fe->dofs_per_line, - ExcIndexRange (i, 0, this->dof_handler->selected_fe->dofs_per_line)); + Assert (iget_fe().dofs_per_line, + ExcIndexRange (i, 0, this->get_fe().dofs_per_line)); this->dof_handler->levels[this->present_level] - ->line_dofs[this->present_index*this->dof_handler->selected_fe->dofs_per_line+i] = index; + ->line_dofs[this->present_index*this->get_fe().dofs_per_line+i] = index; } @@ -68,14 +68,14 @@ void DoFObjectAccessor<1, dim>::set_vertex_dof_index (const unsigned int vertex, Assert (this->dof_handler != 0, typename BaseClass::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename BaseClass::ExcInvalidObject()); Assert (vertex<2, ExcIndexRange (i,0,2)); - Assert (idof_handler->selected_fe->dofs_per_vertex, - ExcIndexRange (i, 0, this->dof_handler->selected_fe->dofs_per_vertex)); + Assert (iget_fe().dofs_per_vertex, + ExcIndexRange (i, 0, this->get_fe().dofs_per_vertex)); const unsigned int dof_number = (this->vertex_index(vertex) * - this->dof_handler->selected_fe->dofs_per_vertex + + this->get_fe().dofs_per_vertex + i); this->dof_handler->vertex_dofs[dof_number] = index; } @@ -100,7 +100,7 @@ distribute_local_to_global (const Vector &local_source, Assert (this->dof_handler != 0, typename BaseClass::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename BaseClass::ExcInvalidObject()); Assert (local_source.size() == (2*this->dof_handler->get_fe().dofs_per_vertex + this->dof_handler->get_fe().dofs_per_line), @@ -139,7 +139,7 @@ distribute_local_to_global (const FullMatrix &local_source, Assert (this->dof_handler != 0, typename BaseClass::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename BaseClass::ExcInvalidObject()); Assert (local_source.m() == (2*this->dof_handler->get_fe().dofs_per_vertex + this->dof_handler->get_fe().dofs_per_line), @@ -237,13 +237,13 @@ void DoFObjectAccessor<2, dim>::set_dof_index (const unsigned int i, typename DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected // and enough room was reserved - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (idof_handler->selected_fe->dofs_per_quad, - ExcIndexRange (i, 0, this->dof_handler->selected_fe->dofs_per_quad)); + Assert (iget_fe().dofs_per_quad, + ExcIndexRange (i, 0, this->get_fe().dofs_per_quad)); this->dof_handler->levels[this->present_level] - ->quad_dofs[this->present_index*this->dof_handler->selected_fe->dofs_per_quad+i] = index; + ->quad_dofs[this->present_index*this->get_fe().dofs_per_quad+i] = index; } @@ -256,14 +256,14 @@ DoFObjectAccessor<2, dim>::set_vertex_dof_index (const unsigned int vertex, { Assert (this->dof_handler != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); Assert (vertex<4, ExcIndexRange (i,0,4)); - Assert (idof_handler->selected_fe->dofs_per_vertex, - ExcIndexRange (i, 0, this->dof_handler->selected_fe->dofs_per_vertex)); + Assert (iget_fe().dofs_per_vertex, + ExcIndexRange (i, 0, this->get_fe().dofs_per_vertex)); const unsigned int dof_number = (this->vertex_index(vertex) * - this->dof_handler->selected_fe->dofs_per_vertex + + this->get_fe().dofs_per_vertex + i); this->dof_handler->vertex_dofs[dof_number] = index; } @@ -276,7 +276,7 @@ distribute_local_to_global (const Vector &local_source, Vector &global_destination) const { Assert (this->dof_handler != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); Assert (local_source.size() == (4*this->dof_handler->get_fe().dofs_per_vertex + 4*this->dof_handler->get_fe().dofs_per_line + @@ -304,7 +304,7 @@ distribute_local_to_global (const FullMatrix &local_source, SparseMatrix &global_destination) const { Assert (this->dof_handler != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); Assert (local_source.m() == (4*this->dof_handler->get_fe().dofs_per_vertex + 4*this->dof_handler->get_fe().dofs_per_line + @@ -417,13 +417,13 @@ void DoFObjectAccessor<3, dim>::set_dof_index (const unsigned int i, typename DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected // and enough room was reserved - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (idof_handler->selected_fe->dofs_per_hex, - ExcIndexRange (i, 0, this->dof_handler->selected_fe->dofs_per_hex)); + Assert (iget_fe().dofs_per_hex, + ExcIndexRange (i, 0, this->get_fe().dofs_per_hex)); this->dof_handler->levels[this->present_level] - ->hex_dofs[this->present_index*this->dof_handler->selected_fe->dofs_per_hex+i] = index; + ->hex_dofs[this->present_index*this->get_fe().dofs_per_hex+i] = index; } @@ -435,15 +435,15 @@ void DoFObjectAccessor<3, dim>::set_vertex_dof_index (const unsigned int vertex, { Assert (this->dof_handler != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); Assert (vertex<8, ExcIndexRange (i,0,8)); - Assert (idof_handler->selected_fe->dofs_per_vertex, - ExcIndexRange (i, 0, this->dof_handler->selected_fe->dofs_per_vertex)); + Assert (iget_fe().dofs_per_vertex, + ExcIndexRange (i, 0, this->get_fe().dofs_per_vertex)); const unsigned int dof_number = (this->vertex_index(vertex) * - this->dof_handler->selected_fe->dofs_per_vertex + + this->get_fe().dofs_per_vertex + i); this->dof_handler->vertex_dofs[dof_number] = index; } @@ -457,7 +457,7 @@ distribute_local_to_global (const Vector &local_source, { Assert (this->dof_handler != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); Assert (local_source.size() == (8*this->dof_handler->get_fe().dofs_per_vertex + 12*this->dof_handler->get_fe().dofs_per_line + @@ -487,7 +487,7 @@ distribute_local_to_global (const FullMatrix &local_source, { Assert (this->dof_handler != 0, typename DoFAccessor::ExcInvalidObject()); - Assert (this->dof_handler->selected_fe != 0, + Assert (&this->get_fe() != 0, typename DoFAccessor::ExcInvalidObject()); Assert (local_source.m() == (8*this->dof_handler->get_fe().dofs_per_vertex + 12*this->dof_handler->get_fe().dofs_per_line + diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index 759cdf78b3..6c3d7ef387 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -539,6 +539,17 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

deal.II

    +
  1. + New: The DoF accessor classes now have a function get_fe() that returns a reference to the finite + element being used on this cell. The result is of course identical to + what a call to iterator->get_dof_handler().get_fe() would have + yielded. +
    + (WB 2003/01/10) +

    +
  2. New: Checked in new GridGenerator member function half_hyper_ball, -- 2.39.5