// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
#include <cmath>
-//TODO[WB]: TriaObjectAccessor<dim,N> should never be used since we have specializations. Can we remove the implementations of functions, or what are they there for?
-
/*------------------------ Functions: TriaAccessor ---------------------------*/
template <int dim>
}
-/*------------------------ Functions: TriaObjectAccessor ---------------------------*/
-
-
-template <int celldim, int dim>
-inline
-bool
-TriaObjectAccessor<celldim,dim>::used () const
-{
- Assert (this->state() == IteratorState::valid,
- typename TriaAccessor<dim>::ExcDereferenceInvalidObject());
- return this->tria->levels[this->present_level]->hexes.used[this->present_index];
-}
-
-
-
-template<int celldim, int dim>
-inline
-bool
-TriaObjectAccessor<celldim,dim>::user_flag_set () const
-{
- Assert (this->used(), typename TriaAccessor<dim>::ExcCellNotUsed());
- return this->tria->levels[this->present_level]->hexes.user_flags[this->present_index];
-}
-
-
-
-template<int celldim, int dim>
-inline
-void
-TriaObjectAccessor<celldim,dim>::set_user_flag () const
-{
- Assert (this->used(), typename TriaAccessor<dim>::ExcCellNotUsed());
- this->tria->levels[this->present_level]->hexes.user_flags[this->present_index] = true;
-}
-
-
-
-template<int celldim, int dim>
-inline
-void TriaObjectAccessor<celldim,dim>::clear_user_flag () const
-{
- Assert (this->used(), typename TriaAccessor<dim>::ExcCellNotUsed());
- this->tria->levels[this->present_level]->hexes.user_flags[this->present_index] = false;
-}
-
-
-
-template<int celldim, int dim>
-inline
-TriaIterator<dim,TriaObjectAccessor<1,dim> >
-TriaObjectAccessor<celldim,dim>::line (const unsigned int i) const
-{
- Assert (this->used(), typename TriaAccessor<dim>::ExcCellNotUsed());
- Assert (i < GeometryInfo<celldim>::lines_per_cell,
- ExcIndexRange(i,0,GeometryInfo<celldim>::lines_per_cell));
-
- switch(celldim)
- {
- case 2:
- return
- TriaIterator<dim,TriaObjectAccessor<1,dim> >
- (
- this->tria,
- this->present_level,
- line_index (i)
- );
- case 3:
- if (i<4)
- return quad(0)->line(i);
- else
- if (i<8)
- return quad(1)->line(i-4);
- else
- switch (i)
- {
- case 8:
- return quad(2)->line(3);
- case 9:
- return quad(2)->line(1);
- case 10:
- return quad(4)->line(1);
- case 11:
- return quad(4)->line(3);
- }
- break;
- default:
- Assert(false, ExcNotImplemented());
- }
-
- return TriaIterator<dim,TriaObjectAccessor<1,dim> >(this->tria, -1, -1, 0);
-}
-
-
-
-template<int celldim, int dim>
-inline
-TriaIterator<dim,TriaObjectAccessor<2,dim> >
-TriaObjectAccessor<celldim,dim>::quad (const unsigned int i) const
-{
- Assert (this->used(), typename TriaAccessor<dim>::ExcCellNotUsed());
- Assert (i < GeometryInfo<celldim>::quads_per_cell,
- ExcIndexRange(i,0,GeometryInfo<celldim>::quads_per_cell));
- return
- TriaIterator<dim,TriaObjectAccessor<2,dim> >
- (
- this->tria,
- this->present_level,
- quad_index (i)
- );
-}
-
-
-
-template<int celldim, int dim>
-inline
-unsigned int
-TriaObjectAccessor<celldim,dim>::line_index (const unsigned int i) const
-{
- Assert (i < GeometryInfo<celldim>::lines_per_cell,
- ExcIndexRange(i,0,GeometryInfo<celldim>::lines_per_cell));
-
- switch(celldim)
- {
- case 2:
- return this->tria->levels[this->present_level]
- ->quads.quads[this->present_index].line(i);
- case 3:
- if (i<4)
- return quad(0)->line_index(i);
- else
- if (i<8)
- return quad(1)->line_index(i-4);
- else
- switch (i)
- {
- case 8:
- return quad(2)->line_index(3);
- case 9:
- return quad(2)->line_index(1);
- case 10:
- return quad(4)->line_index(1);
- case 11:
- return quad(4)->line_index(3);
- };
- break;
- default:
- Assert(false, ExcNotImplemented());
- }
- return 0;
-}
-
-
-
-template<int celldim, int dim>
-inline
-unsigned int
-TriaObjectAccessor<celldim,dim>::quad_index (const unsigned int i) const
-{
- Assert (i < GeometryInfo<celldim>::quads_per_cell,
- ExcIndexRange(i,0,GeometryInfo<celldim>::quads_per_cell));
-
- return this->tria->levels[this->present_level]->hexes.hexes[this->present_index].quad(i);
-}
-
-
-
-template<int celldim, int dim>
-inline
-TriaIterator<dim,TriaObjectAccessor<celldim,dim> >
-TriaObjectAccessor<celldim,dim>::child (const unsigned int i) const
-{
- Assert (i < GeometryInfo<celldim>::children_per_cell,
- ExcIndexRange(i,0,GeometryInfo<celldim>::children_per_cell));
-
- TriaIterator<dim,TriaObjectAccessor<celldim,dim> >
- q (this->tria, this->present_level+1, child_index (i));
-
- Assert ((q.state() == IteratorState::past_the_end) || q->used(),
- typename TriaAccessor<dim>::ExcUnusedCellAsChild());
-
- return q;
-}
-
-
-
-template<int celldim, int dim>
-inline
-int TriaObjectAccessor<celldim,dim>::child_index (const unsigned int i) const
-{
- Assert (i < GeometryInfo<celldim>::children_per_cell,
- ExcIndexRange(i,0,GeometryInfo<celldim>::children_per_cell));
- return this->tria->levels[this->present_level]->hexes.children[this->present_index]+i;
-}
-
-
-
-template<int celldim, int dim>
-bool TriaObjectAccessor<celldim,dim>::has_children () const
-{
- Assert (this->state() == IteratorState::valid,
- typename TriaAccessor<dim>::ExcDereferenceInvalidObject());
- return (this->tria->levels[this->present_level]->hexes.children[this->present_index] != -1);
-}
-
-
-
-template<int celldim, int dim>
-inline
-unsigned int
-TriaObjectAccessor<celldim,dim>::max_refinement_depth () const
-{
- if (!has_children())
- return 0;
-
- const unsigned int depths[8] = { child(0)->max_refinement_depth() + 1,
- child(1)->max_refinement_depth() + 1,
- child(2)->max_refinement_depth() + 1,
- child(3)->max_refinement_depth() + 1,
- child(4)->max_refinement_depth() + 1,
- child(5)->max_refinement_depth() + 1,
- child(6)->max_refinement_depth() + 1,
- child(7)->max_refinement_depth() + 1 };
- return std::max (std::max (std::max (depths[0], depths[1]),
- std::max (depths[2], depths[3])),
- std::max (std::max (depths[4], depths[5]),
- std::max (depths[6], depths[7])));
-}
-
-
-
-template<int celldim, int dim>
-inline
-void
-TriaObjectAccessor<celldim,dim>::operator ++ ()
-{
- ++this->present_index;
- // is index still in the range of
- // the vector?
- while (this->present_index
- >=
- static_cast<int>(this->tria->levels[this->present_level]->hexes.hexes.size()))
- {
- // no -> go one level up
- ++this->present_level;
- this->present_index = 0;
- // highest level reached?
- if (this->present_level >= static_cast<int>(this->tria->levels.size()))
- {
- // return with past the end pointer
- this->present_level = this->present_index = -1;
- return;
- };
- };
-}
-
-
-
-template<int celldim, int dim>
-inline
-void
-TriaObjectAccessor<celldim,dim>::operator -- ()
-{
- --this->present_index;
- // is index still in the range of
- // the vector?
- while (this->present_index < 0)
- {
- // no -> go one level down
- --this->present_level;
- // lowest level reached?
- if (this->present_level == -1)
- {
- // return with past the end pointer
- this->present_level = this->present_index = -1;
- return;
- };
- // else
- this->present_index = this->tria->levels[this->present_level]->hexes.hexes.size()-1;
- };
-}
-
-
/*------------------------ Functions: CellAccessor<dim> -----------------------*/