From: Guido Kanschat Date: Thu, 25 Mar 2010 16:27:49 +0000 (+0000) Subject: Assignment of DoF iterators from TriaIterator X-Git-Tag: v8.0.0~6271 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce50155aea20496666611c809c3254c2207e6adf;p=dealii.git Assignment of DoF iterators from TriaIterator git-svn-id: https://svn.dealii.org/trunk@20893 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/dofs/dof_accessor.h b/deal.II/deal.II/include/dofs/dof_accessor.h index 36cacee7ed..d5266997dc 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -280,6 +280,15 @@ class DoFAccessor : public internal::DoFAccessor::Inheritance &a); + /** + * Copy operator used by the + * iterator class. Keeps the + * previously set dof handler, + * but sets the object + * coordinates of the TriaAccessor. + */ + void copy_from (const TriaAccessorBase &da); + /** * @name Accessing sub-objects */ 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 9c5ba69dbb..9f10acedf5 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.templates.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.templates.h @@ -33,8 +33,8 @@ DEAL_II_NAMESPACE_OPEN template -DoFAccessor:: -DoFAccessor () +inline +DoFAccessor::DoFAccessor () { Assert (false, ExcInvalidObject()); } @@ -43,11 +43,11 @@ DoFAccessor () template inline -DoFAccessor:: -DoFAccessor (const Triangulation *tria, - const int level, - const int index, - const DH *dof_handler) +DoFAccessor::DoFAccessor ( + const Triangulation *tria, + const int level, + const int index, + const DH *dof_handler) : internal::DoFAccessor::Inheritance::BaseClass (tria, @@ -60,8 +60,7 @@ DoFAccessor (const Triangulation *tria, template template -DoFAccessor:: -DoFAccessor (const InvalidAccessor &) +DoFAccessor::DoFAccessor (const InvalidAccessor &) { Assert (false, ExcInvalidObject()); } @@ -70,8 +69,8 @@ DoFAccessor (const InvalidAccessor &) template template -DoFAccessor:: -DoFAccessor (const DoFAccessor &) +inline +DoFAccessor::DoFAccessor (const DoFAccessor &) { Assert (false, ExcInvalidObject()); } @@ -98,6 +97,8 @@ DoFAccessor::get_dof_handler () const } +//TODO: This seems to set only the DH, not the other data. + template inline DoFAccessor & @@ -109,6 +110,18 @@ DoFAccessor::operator = (const DoFAccessor &da) +template +inline +void +DoFAccessor::copy_from ( + const TriaAccessorBase &da) +{ + Assert (this->dof_handler != 0, ExcInvalidObject()); + BaseClass::copy_from(da); +} + + + template inline void diff --git a/deal.II/deal.II/include/grid/tria_accessor.h b/deal.II/deal.II/include/grid/tria_accessor.h index e7b0e8d096..2425da41e2 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.h +++ b/deal.II/deal.II/include/grid/tria_accessor.h @@ -78,13 +78,6 @@ namespace TriaAccessorExceptions /** * @ingroup Exceptions */ - DeclException1 (ExcInvalidNeighbor, - int, - << "Neighbor indices must be between 0 and 2^dim-1, but " - << "yours was " << arg1); - /** - * @ingroup Exceptions - */ DeclException0 (ExcCellHasNoChildren); /** * @ingroup Exceptions @@ -676,6 +669,7 @@ class TriaAccessorBase * for syntactic correctness, none of the functions do anything but * generate errors. * + * @ingroup Accessors * @author Wolfgang Bangerth, 2008 */ template @@ -779,6 +773,7 @@ class InvalidAccessor : public TriaAccessorBase * spacedim@>dim the triangulation is of a manifold * embedded in a higher dimensional space). * + * @ingroup Accessors * @author Wolfgang Bangerth and others, 1998, 2000, 2008 */ template diff --git a/deal.II/deal.II/include/grid/tria_accessor.templates.h b/deal.II/deal.II/include/grid/tria_accessor.templates.h index f83877e04d..c9055a63a8 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.templates.h +++ b/deal.II/deal.II/include/grid/tria_accessor.templates.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -2029,8 +2029,7 @@ inline int CellAccessor::neighbor_index (const unsigned int i) const { - Assert (i::faces_per_cell, - TriaAccessorExceptions::ExcInvalidNeighbor(i)); + AssertIndexRange (i,GeometryInfo::faces_per_cell); return this->tria->levels[this->present_level]-> neighbors[this->present_index*GeometryInfo::faces_per_cell+i].second; } @@ -2042,8 +2041,7 @@ inline int CellAccessor::neighbor_level (const unsigned int i) const { - Assert (i::faces_per_cell, - TriaAccessorExceptions::ExcInvalidNeighbor(i)); + AssertIndexRange (i, GeometryInfo::faces_per_cell); return this->tria->levels[this->present_level]-> neighbors[this->present_index*GeometryInfo::faces_per_cell+i].first; } diff --git a/deal.II/deal.II/include/grid/tria_iterator.h b/deal.II/deal.II/include/grid/tria_iterator.h index 5b11ada076..736aa0d48e 100644 --- a/deal.II/deal.II/include/grid/tria_iterator.h +++ b/deal.II/deal.II/include/grid/tria_iterator.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -388,6 +388,24 @@ class TriaRawIterator : */ TriaRawIterator & operator = (const TriaRawIterator &); + /** + * Assignment operator. + */ +// template +// TriaRawIterator & operator = (const TriaRawIterator&); + + /** + * Assignment operator. + */ +// template +// TriaRawIterator & operator = (const TriaIterator&); + + /** + * Assignment operator. + */ +// template +// TriaRawIterator & operator = (const TriaActiveIterator&); + /** * Compare for equality. */ @@ -671,8 +689,8 @@ class TriaIterator : public TriaRawIterator * Assignment operator. */ TriaIterator & - operator = (const TriaIterator &); - + operator = (const TriaIterator&); + /** * Cross assignment operator. This * assignment is only valid if the @@ -680,7 +698,29 @@ class TriaIterator : public TriaRawIterator * element. */ TriaIterator & - operator = (const TriaRawIterator &); + operator = (const TriaRawIterator&); + + /** + * Assignment + * operator. Requires, that + * Accessor can be copied from + * OtherAccessor. + */ + template + TriaIterator & + operator = (const TriaIterator&); + + /** + * Cross assignment operator. This + * assignment is only valid if the + * given iterator points to a used + * element. Requires, that + * Accessor can be copied from + * OtherAccessor. + */ + template + TriaIterator & + operator = (const TriaRawIterator&); /**@name Advancement of iterators*/ /*@{*/ @@ -835,6 +875,15 @@ class TriaActiveIterator : public TriaIterator TriaActiveIterator & operator = (const TriaActiveIterator &); + /** + * Cross assignment operator. This + * assignment is only valid if the + * given iterator points to an active + * element. + */ + TriaActiveIterator & + operator = (const TriaIterator &); + /** * Cross assignment operator. This * assignment is only valid if the @@ -844,14 +893,38 @@ class TriaActiveIterator : public TriaIterator TriaActiveIterator & operator = (const TriaRawIterator &); + /** + * Assignment operator. Requires, that + * Accessor can be copied from + * OtherAccessor. + */ + template + TriaActiveIterator & + operator = (const TriaActiveIterator &); + + /** + * Cross assignment operator. This + * assignment is only valid if the + * given iterator points to an active + * element or past the end. Requires, that + * Accessor can be copied from + * OtherAccessor. + */ + template + TriaActiveIterator & + operator = (const TriaRawIterator &); + /** * Cross assignment operator. This * assignment is only valid if the * given iterator points to an active - * element or past the end. + * element. Requires, that + * Accessor can be copied from + * OtherAccessor. */ - TriaActiveIterator & - operator = (const TriaIterator &); + template + TriaActiveIterator & + operator = (const TriaIterator &); /** * Prefix ++ operator: ++i. This diff --git a/deal.II/deal.II/include/grid/tria_iterator.templates.h b/deal.II/deal.II/include/grid/tria_iterator.templates.h index 396bdd34d1..1f9ef4fea5 100644 --- a/deal.II/deal.II/include/grid/tria_iterator.templates.h +++ b/deal.II/deal.II/include/grid/tria_iterator.templates.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2010 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -70,6 +70,39 @@ TriaRawIterator::operator = (const TriaRawIterator &i) } +// template +// template +// inline +// TriaRawIterator & +// TriaRawIterator::operator = (const TriaRawIterator &i) +// { +// accessor.copy_from (i.accessor); +// return *this; +// } + + +// template +// template +// inline +// TriaRawIterator & +// TriaRawIterator::operator = (const TriaIterator &i) +// { +// accessor.copy_from (i.accessor); +// return *this; +// } + + +// template +// template +// inline +// TriaRawIterator & +// TriaRawIterator::operator = (const TriaActiveIterator &i) +// { +// accessor.copy_from (i.accessor); +// return *this; +// } + + template inline bool @@ -180,7 +213,19 @@ TriaIterator::TriaIterator (const Triangulation inline TriaIterator & -TriaIterator::operator = (const TriaIterator &i) { +TriaIterator::operator = (const TriaIterator &i) +{ + this->accessor.copy_from (i.accessor); + return *this; +} + + +template +template +inline +TriaIterator & +TriaIterator::operator = (const TriaIterator &i) +{ this->accessor.copy_from (i.accessor); return *this; } @@ -189,7 +234,8 @@ TriaIterator::operator = (const TriaIterator &i) { template inline TriaIterator & -TriaIterator::operator = (const TriaRawIterator &i) { +TriaIterator::operator = (const TriaRawIterator &i) +{ this->accessor.copy_from (i.accessor); #ifdef DEBUG // do this like this, because: @@ -207,8 +253,31 @@ TriaIterator::operator = (const TriaRawIterator &i) { template +template inline -TriaIterator & TriaIterator::operator ++ () { +TriaIterator & +TriaIterator::operator = (const TriaRawIterator &i) +{ + this->accessor.copy_from (i.accessor); +#ifdef DEBUG + // do this like this, because: + // if we write + // "Assert (IteratorState::past_the_end || used)" + // used() is called anyway, even if + // state==IteratorState::past_the_end, and will then + // throw the exception! + if (this->state() != IteratorState::past_the_end) + Assert (this->accessor.used(), + ExcAssignmentOfUnusedObject()); +#endif + return *this; +} + + +template +inline +TriaIterator & TriaIterator::operator ++ () +{ while (TriaRawIterator::operator++(), (this->state() == IteratorState::valid)) if (this->accessor.used() == true) @@ -219,7 +288,8 @@ TriaIterator & TriaIterator::operator ++ () { template inline -TriaIterator TriaIterator::operator ++ (int) { +TriaIterator TriaIterator::operator ++ (int) +{ TriaIterator tmp(*this); operator++ (); @@ -230,7 +300,8 @@ TriaIterator TriaIterator::operator ++ (int) { template inline TriaIterator & -TriaIterator::operator -- () { +TriaIterator::operator -- () +{ while (TriaRawIterator::operator--(), (this->state() == IteratorState::valid)) if (this->accessor.used() == true) @@ -242,7 +313,8 @@ TriaIterator::operator -- () { template inline TriaIterator -TriaIterator::operator -- (int) { +TriaIterator::operator -- (int) +{ TriaIterator tmp(*this); operator-- (); @@ -328,16 +400,51 @@ TriaActiveIterator::TriaActiveIterator (const Triangulation inline TriaActiveIterator & -TriaActiveIterator::operator = (const TriaActiveIterator &i) { +TriaActiveIterator::operator = (const TriaActiveIterator &i) +{ this->accessor.copy_from (i.accessor); return *this; } template +template inline TriaActiveIterator & -TriaActiveIterator::operator = (const TriaRawIterator &i) { +TriaActiveIterator::operator = (const TriaActiveIterator &i) +{ + this->accessor.copy_from (i.accessor); + return *this; +} + + +template +inline +TriaActiveIterator & +TriaActiveIterator::operator = (const TriaRawIterator &i) +{ + this->accessor.copy_from (i.accessor); +#ifdef DEBUG + // do this like this, because: + // if we write + // "Assert (IteratorState::past_the_end || !has_children())" + // has_chidlren() is called anyway, even if + // state==IteratorState::past_the_end, and will then + // throw the exception! + if (this->state() != IteratorState::past_the_end) + Assert (this->accessor.used() && this->accessor.has_children()==false, + ExcAssignmentOfInactiveObject()); +#endif + return *this; +} + + +template +template +inline +TriaActiveIterator & +TriaActiveIterator::operator = (const TriaRawIterator &i) +{ this->accessor.copy_from (i.accessor); #ifdef DEBUG // do this like this, because: @@ -355,9 +462,32 @@ TriaActiveIterator::operator = (const TriaRawIterator &i) { template +template inline TriaActiveIterator & -TriaActiveIterator::operator = (const TriaIterator &i) { +TriaActiveIterator::operator = (const TriaIterator &i) +{ + this->accessor.copy_from (i.accessor); +#ifdef DEBUG + // do this like this, because: + // if we write + // "Assert (IteratorState::past_the_end || !has_children())" + // has_children() is called anyway, even if + // state==IteratorState::past_the_end, and will then + // throw the exception! + if (this->state() != IteratorState::past_the_end) + Assert (this->accessor.has_children()==false, + ExcAssignmentOfInactiveObject()); +#endif + return *this; +} + + +template +inline +TriaActiveIterator & +TriaActiveIterator::operator = (const TriaIterator &i) +{ this->accessor.copy_from (i.accessor); #ifdef DEBUG // do this like this, because: diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index 8202baa93c..4f6ab581b5 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -1237,8 +1237,7 @@ template void CellAccessor::set_neighbor (const unsigned int i, const TriaIterator > &pointer) const { - Assert (i::faces_per_cell, - TriaAccessorExceptions::ExcInvalidNeighbor(i)); + AssertIndexRange (i, GeometryInfo::faces_per_cell); if (pointer.state() == IteratorState::valid) { @@ -1265,8 +1264,7 @@ void CellAccessor::set_neighbor (const unsigned int i, template unsigned int CellAccessor::neighbor_of_neighbor_internal (const unsigned int neighbor) const { - Assert (neighbor < GeometryInfo::faces_per_cell, - TriaAccessorExceptions::ExcInvalidNeighbor(neighbor)); + AssertIndexRange (neighbor, GeometryInfo::faces_per_cell); if (dim==1) return GeometryInfo::opposite_face[neighbor]; @@ -1341,8 +1339,7 @@ template std::pair CellAccessor::neighbor_of_coarser_neighbor (const unsigned int neighbor) const { - Assert (neighbor < GeometryInfo::faces_per_cell, - TriaAccessorExceptions::ExcInvalidNeighbor(neighbor)); + AssertIndexRange (neighbor, GeometryInfo::faces_per_cell); // make sure that the neighbor is // on a coarser level Assert (neighbor_is_coarser(neighbor), diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index cb36bc9a87..002b7a948d 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -589,6 +589,14 @@ inconvenience this causes.

deal.II

    + +
  1. +

    Improved: DoFHandler iterators now can be assigned from a Triangulation iterator + after the dof handler was set once. +
    + (GK 2010/03/25) +

  2. +
  3. New: The function DoFRenumbering::downstream has now an additional bool