#include <grid/tria_boundary.h>
+#include <grid/tria_accessor.h>
#include <grid/tria_iterator.h>
#include <grid/tria.h>
#include <fstream>
#include <vector>
+// note: in non-debug mode, i.e. with optimizations, the file
+// dof_accessor.templates.h is included at the end of this file.
+// this includes a lot of templates and thus makes compilation
+// slower, but at the same time allows for more aggressive
+// inlining and thus faster code.
+
+
/**
* Define the basis for accessors to the degrees of freedom.
template <typename number>
void get_interpolated_dof_values (const Vector<number> &values,
Vector<number> &interpolated_values) const;
-// void get_interpolated_dof_values (const Vector<double> &values,
-// Vector<double> &interpolated_values) const;
-// void get_interpolated_dof_values (const Vector<float> &values,
-// Vector<float> &interpolated_values) const;
/**
* This function is the counterpart to
+// if in optimized mode: include more templates
+#ifndef DEBUG
+# include "dof_accessor.templates.h"
+#endif
--- /dev/null
+/*---------------------------- dof_accessor.templates.h ---------------------------*/
+/* $Id$ */
+#ifndef __dof_accessor_templates_H
+#define __dof_accessor_templates_H
+/*---------------------------- dof_accessor.templates.h ---------------------------*/
+
+
+#include <grid/dof_accessor.h>
+#include <grid/dof.h>
+#include <grid/dof_levels.h>
+#include <grid/tria_iterator.h>
+#include <grid/tria_iterator.templates.h>
+#include <fe/fe.h>
+
+#include <lac/vector.h>
+#include <lac/fullmatrix.h>
+#include <lac/sparsematrix.h>
+
+#include <vector>
+
+
+/*------------------------- Functions: DoFLineAccessor -----------------------*/
+
+template <int dim, typename BaseClass>
+inline
+int DoFLineAccessor<dim,BaseClass>::dof_index (const unsigned int i) const {
+ Assert (dof_handler != 0, ExcInvalidObject());
+ // make sure a FE has been selected
+ // and enough room was reserved
+ Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
+ Assert (i<dof_handler->selected_fe->dofs_per_line,
+ ExcInvalidIndex (i, 0, dof_handler->selected_fe->dofs_per_line));
+
+ return dof_handler->levels[present_level]
+ ->line_dofs[present_index*dof_handler->selected_fe->dofs_per_line+i];
+};
+
+
+
+
+template <int dim, typename BaseClass>
+inline
+int DoFLineAccessor<dim,BaseClass>::vertex_dof_index (const unsigned int vertex,
+ const unsigned int i) const {
+ Assert (dof_handler != 0, ExcInvalidObject());
+ Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
+ Assert (vertex<2, ExcInvalidIndex (i,0,2));
+ Assert (i<dof_handler->selected_fe->dofs_per_vertex,
+ ExcInvalidIndex (i, 0, dof_handler->selected_fe->dofs_per_vertex));
+
+ const unsigned int dof_number = (vertex_index(vertex) *
+ dof_handler->selected_fe->dofs_per_vertex +
+ i);
+ return dof_handler->vertex_dofs[dof_number];
+};
+
+
+
+template <int dim, typename BaseClass>
+inline
+void
+DoFLineAccessor<dim,BaseClass>::get_dof_indices (vector<int> &dof_indices) const {
+ Assert (dof_handler != 0, ExcInvalidObject());
+ Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
+ Assert (dof_indices.size() == (2*dof_handler->get_fe().dofs_per_vertex +
+ dof_handler->get_fe().dofs_per_line),
+ ExcVectorDoesNotMatch());
+
+ const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex,
+ dofs_per_line = dof_handler->get_fe().dofs_per_line;
+ vector<int>::iterator next = dof_indices.begin();
+ for (unsigned int vertex=0; vertex<2; ++vertex)
+ for (unsigned int d=0; d<dofs_per_vertex; ++d)
+ *next++ = vertex_dof_index(vertex,d);
+ for (unsigned int d=0; d<dofs_per_line; ++d)
+ *next++ = dof_index(d);
+};
+
+
+
+template <int dim, typename BaseClass>
+inline
+TriaIterator<dim,DoFLineAccessor<dim,BaseClass> >
+DoFLineAccessor<dim,BaseClass>::child (const unsigned int i) const {
+ TriaIterator<dim,DoFLineAccessor<dim,BaseClass> > q (tria,
+ present_level+1,
+ child_index (i),
+ dof_handler);
+
+#ifdef DEBUG
+ if (q.state() != past_the_end)
+ Assert (q->used(), typename TriaAccessor<dim>::ExcUnusedCellAsChild());
+#endif
+ return q;
+};
+
+
+
+template <int dim, typename BaseClass>
+inline
+void
+DoFLineAccessor<dim,BaseClass>::copy_from (const DoFLineAccessor<dim,BaseClass> &a) {
+ BaseClass::copy_from (a);
+ set_dof_handler (a.dof_handler);
+};
+
+
+
+
+/*------------------------- Functions: DoFQuadAccessor -----------------------*/
+
+template <int dim, typename BaseClass>
+inline
+int DoFQuadAccessor<dim,BaseClass>::dof_index (const unsigned int i) const {
+ Assert (dof_handler != 0, ExcInvalidObject());
+ // make sure a FE has been selected
+ // and enough room was reserved
+ Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
+ Assert (i<dof_handler->selected_fe->dofs_per_quad,
+ ExcInvalidIndex (i, 0, dof_handler->selected_fe->dofs_per_quad));
+
+ return dof_handler->levels[present_level]
+ ->quad_dofs[present_index*dof_handler->selected_fe->dofs_per_quad+i];
+};
+
+
+
+template <int dim, typename BaseClass>
+inline
+int DoFQuadAccessor<dim,BaseClass>::vertex_dof_index (const unsigned int vertex,
+ const unsigned int i) const {
+ Assert (dof_handler != 0, ExcInvalidObject());
+ Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
+ Assert (vertex<4, ExcInvalidIndex (i,0,4));
+ Assert (i<dof_handler->selected_fe->dofs_per_vertex,
+ ExcInvalidIndex (i, 0, dof_handler->selected_fe->dofs_per_vertex));
+
+ const unsigned int dof_number = (vertex_index(vertex) *
+ dof_handler->selected_fe->dofs_per_vertex +
+ i);
+ return dof_handler->vertex_dofs[dof_number];
+};
+
+
+
+template <int dim, typename BaseClass>
+inline
+void
+DoFQuadAccessor<dim,BaseClass>::get_dof_indices (vector<int> &dof_indices) const {
+ Assert (dof_handler != 0, ExcInvalidObject());
+ Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
+ Assert (dof_indices.size() == (4*dof_handler->get_fe().dofs_per_vertex +
+ 4*dof_handler->get_fe().dofs_per_line +
+ dof_handler->get_fe().dofs_per_quad),
+ ExcVectorDoesNotMatch());
+
+ const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex,
+ dofs_per_line = dof_handler->get_fe().dofs_per_line,
+ dofs_per_quad = dof_handler->get_fe().dofs_per_quad;
+ vector<int>::iterator next = dof_indices.begin();
+ for (unsigned int vertex=0; vertex<4; ++vertex)
+ for (unsigned int d=0; d<dofs_per_vertex; ++d)
+ *next++ = vertex_dof_index(vertex,d);
+ for (unsigned int line=0; line<4; ++line)
+ for (unsigned int d=0; d<dofs_per_line; ++d)
+ *next++ = this->line(line)->dof_index(d);
+ for (unsigned int d=0; d<dofs_per_quad; ++d)
+ *next++ = dof_index(d);
+};
+
+
+
+template <int dim, typename BaseClass>
+inline
+TriaIterator<dim,DoFLineAccessor<dim,LineAccessor<dim> > >
+DoFQuadAccessor<dim,BaseClass>::line (const unsigned int i) const {
+ Assert (i<4, ExcInvalidIndex (i, 0, 4));
+
+ return TriaIterator<dim,DoFLineAccessor<dim,LineAccessor<dim> > >
+ (
+ tria,
+ present_level,
+ line_index (i),
+ dof_handler
+ );
+};
+
+
+
+template <int dim, typename BaseClass>
+inline
+TriaIterator<dim,DoFQuadAccessor<dim,BaseClass> >
+DoFQuadAccessor<dim,BaseClass>::child (const unsigned int i) const {
+ TriaIterator<dim,DoFQuadAccessor<dim,BaseClass> > q (tria,
+ present_level+1,
+ child_index (i),
+ dof_handler);
+
+#ifdef DEBUG
+ if (q.state() != past_the_end)
+ Assert (q->used(), typename TriaAccessor<dim>::ExcUnusedCellAsChild());
+#endif
+ return q;
+};
+
+
+
+template <int dim, typename BaseClass>
+inline
+void
+DoFQuadAccessor<dim,BaseClass>::copy_from (const DoFQuadAccessor<dim,BaseClass> &a) {
+ BaseClass::copy_from (a);
+ set_dof_handler (a.dof_handler);
+};
+
+
+
+
+/*------------------------- Functions: DoFHexAccessor -----------------------*/
+
+
+template <int dim, typename BaseClass>
+inline
+int DoFHexAccessor<dim,BaseClass>::dof_index (const unsigned int i) const {
+ Assert (dof_handler != 0, ExcInvalidObject());
+ // make sure a FE has been selected
+ // and enough room was reserved
+ Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
+ Assert (i<dof_handler->selected_fe->dofs_per_hex,
+ ExcInvalidIndex (i, 0, dof_handler->selected_fe->dofs_per_hex));
+
+ return dof_handler->levels[present_level]
+ ->hex_dofs[present_index*dof_handler->selected_fe->dofs_per_hex+i];
+};
+
+
+
+template <int dim, typename BaseClass>
+inline
+int DoFHexAccessor<dim,BaseClass>::vertex_dof_index (const unsigned int vertex,
+ const unsigned int i) const {
+ Assert (dof_handler != 0, ExcInvalidObject());
+ Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
+ Assert (vertex<8, ExcInvalidIndex (i,0,8));
+ Assert (i<dof_handler->selected_fe->dofs_per_vertex,
+ ExcInvalidIndex (i, 0, dof_handler->selected_fe->dofs_per_vertex));
+
+ const unsigned int dof_number = (vertex_index(vertex) *
+ dof_handler->selected_fe->dofs_per_vertex +
+ i);
+ return dof_handler->vertex_dofs[dof_number];
+};
+
+
+
+template <int dim, typename BaseClass>
+inline
+void
+DoFHexAccessor<dim,BaseClass>::get_dof_indices (vector<int> &dof_indices) const {
+ Assert (dof_handler != 0, ExcInvalidObject());
+ Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
+ Assert (dof_indices.size() == (8*dof_handler->get_fe().dofs_per_vertex +
+ 12*dof_handler->get_fe().dofs_per_line +
+ 6*dof_handler->get_fe().dofs_per_quad +
+ dof_handler->get_fe().dofs_per_hex),
+ ExcVectorDoesNotMatch());
+
+ const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex,
+ dofs_per_line = dof_handler->get_fe().dofs_per_line,
+ dofs_per_quad = dof_handler->get_fe().dofs_per_quad,
+ dofs_per_hex = dof_handler->get_fe().dofs_per_hex;
+ vector<int>::iterator next = dof_indices.begin();
+ for (unsigned int vertex=0; vertex<8; ++vertex)
+ for (unsigned int d=0; d<dofs_per_vertex; ++d)
+ *next++ = vertex_dof_index(vertex,d);
+ for (unsigned int line=0; line<12; ++line)
+ for (unsigned int d=0; d<dofs_per_line; ++d)
+ *next++ = this->line(line)->dof_index(d);
+ for (unsigned int quad=0; quad<6; ++quad)
+ for (unsigned int d=0; d<dofs_per_quad; ++d)
+ *next++ = this->quad(quad)->dof_index(d);
+ for (unsigned int d=0; d<dofs_per_hex; ++d)
+ *next++ = dof_index(d);
+};
+
+
+
+template <int dim, typename BaseClass>
+inline
+TriaIterator<dim,DoFLineAccessor<dim,LineAccessor<dim> > >
+DoFHexAccessor<dim,BaseClass>::line (const unsigned int i) const {
+ TriaIterator<dim,LineAccessor<dim> > l = BaseClass::line(i);
+ return TriaIterator<dim,DoFLineAccessor<dim,LineAccessor<dim> > >
+ (
+ tria,
+ present_level,
+ l->index(),
+ dof_handler
+ );
+};
+
+
+
+template <int dim, typename BaseClass>
+inline
+TriaIterator<dim,DoFQuadAccessor<dim,QuadAccessor<dim> > >
+DoFHexAccessor<dim,BaseClass>::quad (const unsigned int i) const {
+ Assert (i<6, ExcInvalidIndex (i, 0, 6));
+
+ return TriaIterator<dim,DoFQuadAccessor<dim,QuadAccessor<dim> > >
+ (
+ tria,
+ present_level,
+ quad_index (i),
+ dof_handler
+ );
+};
+
+
+
+template <int dim, typename BaseClass>
+inline
+TriaIterator<dim,DoFHexAccessor<dim,BaseClass> >
+DoFHexAccessor<dim,BaseClass>::child (const unsigned int i) const {
+ TriaIterator<dim,DoFHexAccessor<dim,BaseClass> > q (tria,
+ present_level+1,
+ child_index (i),
+ dof_handler);
+
+#ifdef DEBUG
+ if (q.state() != past_the_end)
+ Assert (q->used(), typename TriaAccessor<dim>::ExcUnusedCellAsChild());
+#endif
+ return q;
+};
+
+
+
+template <int dim, typename BaseClass>
+void DoFHexAccessor<dim,BaseClass>::copy_from (const DoFHexAccessor<dim,BaseClass> &a) {
+ BaseClass::copy_from (a);
+ set_dof_handler (a.dof_handler);
+};
+
+
+
+
+/*------------------------- Functions: DoFCellAccessor -----------------------*/
+
+
+template <int dim>
+inline
+TriaIterator<dim,DoFCellAccessor<dim> >
+DoFCellAccessor<dim>::neighbor (const unsigned int i) const {
+ TriaIterator<dim,DoFCellAccessor<dim> > q (tria,
+ neighbor_level (i),
+ neighbor_index (i),
+ dof_handler);
+
+#ifdef DEBUG
+ if (q.state() != past_the_end)
+ Assert (q->used(), typename TriaAccessor<dim>::ExcUnusedCellAsNeighbor());
+#endif
+ return q;
+};
+
+
+
+template <int dim>
+inline
+TriaIterator<dim,DoFCellAccessor<dim> >
+DoFCellAccessor<dim>::child (const unsigned int i) const {
+ TriaIterator<dim,DoFCellAccessor<dim> > q (tria,
+ present_level+1,
+ child_index (i),
+ dof_handler);
+
+#ifdef DEBUG
+ if (q.state() != past_the_end)
+ Assert (q->used(), typename TriaAccessor<dim>::ExcUnusedCellAsChild());
+#endif
+ return q;
+};
+
+
+
+
+
+
+
+/*---------------------------- dof_accessor.templates.h ---------------------------*/
+/* end of #ifndef __dof_accessor_templates_H */
+#endif
+/*---------------------------- dof_accessor.templates.h ---------------------------*/
#include <base/exceptions.h>
#include <base/forward-declarations.h>
#include <basic/forward-declarations.h>
+#include <grid/tria_iterator_base.h>
+// note: in non-debug mode, i.e. with optimizations, the file
+// tria_accessor.templates.h is included at the end of this file.
+// this includes a lot of templates and thus makes compilation
+// slower, but at the same time allows for more aggressive
+// inlining and thus faster code.
-/**
- * The three states an iterator can be in: valid, past-the-end and
- * invalid.
- */
-enum IteratorState { valid, past_the_end, invalid };
-
-
-
/**
template <>
class TriaSubstructAccessor<1> : public LineAccessor<1> {
public:
+ /**
+ * Propagate the AccessorData type
+ * into the present class.
+ */
+ typedef typename LineAccessor<1>::AccessorData AccessorData;
/**
* Constructor
*/
template <>
class TriaSubstructAccessor<2> : public QuadAccessor<2> {
public:
+ /**
+ * Propagate the AccessorData type
+ * into the present class.
+ */
+ typedef typename QuadAccessor<2>::AccessorData AccessorData;
/**
* Constructor
*/
template <>
class TriaSubstructAccessor<3> : public HexAccessor<3> {
public:
+ /**
+ * Propagate the AccessorData type
+ * into the present class.
+ */
+ typedef typename HexAccessor<3>::AccessorData AccessorData;
+
/**
* Constructor
*/
template <int dim>
class CellAccessor : public TriaSubstructAccessor<dim> {
public:
+ /**
+ * Propagate the AccessorData type
+ * into the present class.
+ */
+ typedef typename TriaSubstructAccessor<dim>::AccessorData AccessorData;
+
/**
* Constructor.
*/
-
-
+// if in optimized mode: include more templates
+#ifndef DEBUG
+# include "tria_accessor.templates.h"
+#endif
/*---------------------------- tria_accessor.h ---------------------------*/
/* end of #ifndef __tria_accessor_H */
#endif
/*---------------------------- tria_accessor.h ---------------------------*/
+
+
+
+
+
--- /dev/null
+/*---------------------------- tria_accessor.templates.h ---------------------------*/
+/* $Id$ */
+#ifndef __tria_accessor_templates_H
+#define __tria_accessor_templates_H
+/*---------------------------- tria_accessor.templates.h ---------------------------*/
+
+
+#include <grid/tria.h>
+#include <grid/tria_levels.h>
+#include <grid/tria_iterator.h>
+#include <grid/tria_accessor.h>
+#include <grid/tria_iterator.templates.h>
+#include <grid/geometry_info.h>
+
+#include <cmath>
+
+
+/*------------------------ Functions: TriaAccessor ---------------------------*/
+
+
+template <int dim>
+inline
+void
+TriaAccessor<dim>::copy_from (const TriaAccessor<dim> &a) {
+ present_level = a.present_level;
+ present_index = a.present_index;
+ tria = a.tria;
+};
+
+
+
+template <int dim>
+inline
+bool
+TriaAccessor<dim>::operator == (const TriaAccessor<dim> &a) const {
+ Assert (tria == a.tria, ExcCantCompareIterators());
+ return ((present_index == a.present_index) &&
+ (present_level == a.present_level));
+};
+
+
+
+template <int dim>
+inline
+bool
+TriaAccessor<dim>::operator != (const TriaAccessor<dim> &a) const {
+ Assert (tria == a.tria, ExcCantCompareIterators());
+ return ((present_index != a.present_index) ||
+ (present_level != a.present_level));
+};
+
+
+
+template <int dim>
+inline
+int
+TriaAccessor<dim>::level () const {
+ return present_level;
+};
+
+
+
+template <int dim>
+inline
+int
+TriaAccessor<dim>::index () const {
+ return present_index;
+};
+
+
+
+template <int dim>
+inline
+IteratorState
+TriaAccessor<dim>::state () const {
+ if ((present_level>=0) && (present_index>=0))
+ return valid;
+ else
+ if ((present_level==-1) && (present_index==-1))
+ return past_the_end;
+ else
+ return invalid;
+};
+
+
+
+/*------------------------ Functions: LineAccessor ---------------------------*/
+
+
+
+
+template <int dim>
+inline
+bool
+LineAccessor<dim>::used () const {
+ Assert (state() == valid, ExcDereferenceInvalidObject());
+ return tria->levels[present_level]->lines.used[present_index];
+};
+
+
+
+
+template <int dim>
+inline
+bool
+LineAccessor<dim>::user_flag_set () const {
+ Assert (used(), ExcCellNotUsed());
+ return tria->levels[present_level]->lines.user_flags[present_index];
+};
+
+
+
+template <int dim>
+inline
+void
+LineAccessor<dim>::set_user_flag () const {
+ Assert (used(), ExcCellNotUsed());
+ tria->levels[present_level]->lines.user_flags[present_index] = true;
+};
+
+
+
+template <int dim>
+inline
+void
+LineAccessor<dim>::clear_user_flag () const {
+ Assert (used(), ExcCellNotUsed());
+ tria->levels[present_level]->lines.user_flags[present_index] = false;
+};
+
+
+
+
+template <int dim>
+inline
+TriaIterator<dim,LineAccessor<dim> >
+LineAccessor<dim>::child (const unsigned int i) const {
+ Assert (i<2, ExcInvalidIndex(i,0,1));
+
+ TriaIterator<dim,LineAccessor<dim> > q (tria, present_level+1, child_index (i));
+
+#ifdef DEBUG
+ if (q.state() != past_the_end)
+ Assert (q->used(), ExcUnusedCellAsChild());
+#endif
+ return q;
+};
+
+
+
+template <int dim>
+inline
+int
+LineAccessor<dim>::child_index (unsigned int i) const {
+ Assert (i<2, ExcInvalidIndex(i,0,1));
+ return tria->levels[present_level]->lines.children[present_index]+i;
+};
+
+
+
+
+template <int dim>
+inline
+bool
+LineAccessor<dim>::has_children () const {
+ Assert (state() == valid, ExcDereferenceInvalidObject());
+ return (tria->levels[present_level]->lines.children[present_index] != -1);
+}
+
+
+
+template <int dim>
+inline
+void
+LineAccessor<dim>::operator ++ () {
+ ++present_index;
+ // is index still in the range of
+ // the vector?
+ while (present_index
+ >=
+ (int)tria->levels[present_level]->lines.lines.size())
+ {
+ // no -> go one level up until we find
+ // one with more than zero cells
+ ++present_level;
+ present_index = 0;
+ // highest level reached?
+ if (present_level >= (int)tria->levels.size())
+ {
+ // return with past the end pointer
+ present_level = present_index = -1;
+ return;
+ };
+ };
+};
+
+
+
+template <int dim>
+inline
+void
+LineAccessor<dim>::operator -- () {
+ --present_index;
+ // is index still in the range of
+ // the vector?
+ while (present_index < 0)
+ {
+ // no -> go one level down
+ --present_level;
+ // lowest level reached?
+ if (present_level == -1)
+ {
+ // return with past the end pointer
+ present_level = present_index = -1;
+ return;
+ };
+ // else
+ present_index = tria->levels[present_level]->lines.lines.size()-1;
+ };
+};
+
+
+
+
+/*------------------------ Functions: QuadAccessor ---------------------------*/
+
+
+
+template <int dim>
+inline
+bool
+QuadAccessor<dim>::used () const {
+ Assert (state() == valid, ExcDereferenceInvalidObject());
+ return tria->levels[present_level]->quads.used[present_index];
+};
+
+
+
+
+template <int dim>
+inline
+bool
+QuadAccessor<dim>::user_flag_set () const {
+ Assert (used(), ExcCellNotUsed());
+ return tria->levels[present_level]->quads.user_flags[present_index];
+};
+
+
+
+template <int dim>
+inline
+void
+QuadAccessor<dim>::set_user_flag () const {
+ Assert (used(), ExcCellNotUsed());
+ tria->levels[present_level]->quads.user_flags[present_index] = true;
+};
+
+
+
+template <int dim>
+inline
+void
+QuadAccessor<dim>::clear_user_flag () const {
+ Assert (used(), ExcCellNotUsed());
+ tria->levels[present_level]->quads.user_flags[present_index] = false;
+};
+
+
+
+
+template <int dim>
+inline
+TriaIterator<dim,LineAccessor<dim> >
+QuadAccessor<dim>::line (const unsigned int i) const {
+ return
+ TriaIterator<dim,LineAccessor<dim> >
+ (
+ tria,
+ present_level,
+ line_index (i)
+ );
+};
+
+
+
+template <int dim>
+inline
+unsigned int
+QuadAccessor<dim>::line_index (unsigned int i) const {
+ Assert (i<4, ExcInvalidIndex(i,0,3));
+
+ return tria->levels[present_level]->quads.quads[present_index].line(i);
+};
+
+
+
+template <int dim>
+inline
+TriaIterator<dim,QuadAccessor<dim> >
+QuadAccessor<dim>::child (const unsigned int i) const {
+ Assert (i<4, ExcInvalidIndex(i,0,3));
+
+ TriaIterator<dim,QuadAccessor<dim> > q (tria, present_level+1, child_index (i));
+
+#ifdef DEBUG
+ if (q.state() != past_the_end)
+ Assert (q->used(), ExcUnusedCellAsChild());
+#endif
+ return q;
+};
+
+
+
+template <int dim>
+inline
+int QuadAccessor<dim>::child_index (unsigned int i) const {
+ Assert (i<4, ExcInvalidIndex(i,0,3));
+ return tria->levels[present_level]->quads.children[present_index]+i;
+};
+
+
+
+
+template <int dim>
+inline
+bool
+QuadAccessor<dim>::has_children () const {
+ Assert (state() == valid, ExcDereferenceInvalidObject());
+ return (tria->levels[present_level]->quads.children[present_index] != -1);
+};
+
+
+
+template <int dim>
+inline
+void
+QuadAccessor<dim>::operator ++ () {
+ ++present_index;
+ // is index still in the range of
+ // the vector?
+ while (present_index
+ >=
+ (int)tria->levels[present_level]->quads.quads.size())
+ {
+ // no -> go one level up
+ ++present_level;
+ present_index = 0;
+ // highest level reached?
+ if (present_level >= (int)tria->levels.size())
+ {
+ // return with past the end pointer
+ present_level = present_index = -1;
+ return;
+ };
+ };
+};
+
+
+
+template <int dim>
+inline
+void
+QuadAccessor<dim>::operator -- () {
+ --present_index;
+ // is index still in the range of
+ // the vector?
+ while (present_index < 0)
+ {
+ // no -> go one level down
+ --present_level;
+ // lowest level reached?
+ if (present_level == -1)
+ {
+ // return with past the end pointer
+ present_level = present_index = -1;
+ return;
+ };
+ // else
+ present_index = tria->levels[present_level]->quads.quads.size()-1;
+ };
+};
+
+
+
+
+/*------------------------ Functions: HexAccessor ---------------------------*/
+
+
+
+template <int dim>
+inline
+bool
+HexAccessor<dim>::used () const {
+ Assert (state() == valid, ExcDereferenceInvalidObject());
+ return tria->levels[present_level]->hexes.used[present_index];
+};
+
+
+
+template <int dim>
+inline
+bool
+HexAccessor<dim>::user_flag_set () const {
+ Assert (used(), ExcCellNotUsed());
+ return tria->levels[present_level]->hexes.user_flags[present_index];
+};
+
+
+
+template <int dim>
+inline
+void
+HexAccessor<dim>::set_user_flag () const {
+ Assert (used(), ExcCellNotUsed());
+ tria->levels[present_level]->hexes.user_flags[present_index] = true;
+};
+
+
+
+template <int dim>
+inline
+void HexAccessor<dim>::clear_user_flag () const {
+ Assert (used(), ExcCellNotUsed());
+ tria->levels[present_level]->hexes.user_flags[present_index] = false;
+};
+
+
+
+
+template <int dim>
+inline
+TriaIterator<dim,LineAccessor<dim> >
+HexAccessor<dim>::line (const unsigned int i) const {
+ Assert (used(), ExcCellNotUsed());
+ Assert (i<12, ExcInvalidIndex (i,0,11));
+
+ 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);
+ };
+ Assert (false, ExcInvalidIndex(i,0,11));
+ return TriaIterator<dim,LineAccessor<dim> >(tria, -1, -1, 0);
+};
+
+
+
+template <int dim>
+inline
+TriaIterator<dim,QuadAccessor<dim> >
+HexAccessor<dim>::quad (const unsigned int i) const {
+ Assert (used(), ExcCellNotUsed());
+ return
+ TriaIterator<dim,QuadAccessor<dim> >
+ (
+ tria,
+ present_level,
+ quad_index (i)
+ );
+};
+
+
+
+template <int dim>
+inline
+unsigned int
+HexAccessor<dim>::quad_index (unsigned int i) const {
+ Assert (i<6, ExcInvalidIndex(i,0,5));
+
+ return tria->levels[present_level]->hexes.hexes[present_index].quad(i);
+};
+
+
+
+template <int dim>
+inline
+TriaIterator<dim,HexAccessor<dim> >
+HexAccessor<dim>::child (const unsigned int i) const {
+ Assert (i<6, ExcInvalidIndex(i,0,5));
+
+ TriaIterator<dim,HexAccessor<dim> > q (tria, present_level+1, child_index (i));
+
+#ifdef DEBUG
+ if (q.state() != past_the_end)
+ Assert (q->used(), ExcUnusedCellAsChild());
+#endif
+ return q;
+};
+
+
+
+template <int dim>
+inline
+int HexAccessor<dim>::child_index (unsigned int i) const {
+ Assert (i<8, ExcInvalidIndex(i,0,7));
+ return tria->levels[present_level]->hexes.children[present_index]+i;
+};
+
+
+
+
+template <int dim>
+inline
+void
+HexAccessor<dim>::operator ++ () {
+ ++present_index;
+ // is index still in the range of
+ // the vector?
+ while (present_index
+ >=
+ (int)tria->levels[present_level]->hexes.hexes.size())
+ {
+ // no -> go one level up
+ ++present_level;
+ present_index = 0;
+ // highest level reached?
+ if (present_level >= (int)tria->levels.size())
+ {
+ // return with past the end pointer
+ present_level = present_index = -1;
+ return;
+ };
+ };
+};
+
+
+
+template <int dim>
+inline
+void
+HexAccessor<dim>::operator -- () {
+ --present_index;
+ // is index still in the range of
+ // the vector?
+ while (present_index < 0)
+ {
+ // no -> go one level down
+ --present_level;
+ // lowest level reached?
+ if (present_level == -1)
+ {
+ // return with past the end pointer
+ present_level = present_index = -1;
+ return;
+ };
+ // else
+ present_index = tria->levels[present_level]->hexes.hexes.size()-1;
+ };
+};
+
+
+
+
+/*------------------------ Functions: CellAccessor<dim> -----------------------*/
+
+
+template <>
+inline
+Triangulation<1>::face_iterator
+CellAccessor<1>::face (const unsigned int) const {
+ Assert (false, ExcNotUsefulForThisDimension());
+ return 0;
+};
+
+
+
+template <>
+inline
+Triangulation<2>::face_iterator
+CellAccessor<2>::face (const unsigned int i) const {
+ return line(i);
+};
+
+
+
+template <>
+inline
+Triangulation<3>::face_iterator
+CellAccessor<3>::face (const unsigned int i) const {
+ return quad(i);
+};
+
+
+
+template <int dim>
+inline
+int
+CellAccessor<dim>::neighbor_index (const unsigned int i) const {
+ Assert (i<GeometryInfo<dim>::faces_per_cell,
+ typename TriaSubstructAccessor<dim>::ExcInvalidNeighbor(i));
+ return tria->levels[present_level]->
+ neighbors[present_index*GeometryInfo<dim>::faces_per_cell+i].second;
+};
+
+
+
+template <int dim>
+inline
+int
+CellAccessor<dim>::neighbor_level (const unsigned int i) const {
+ Assert (i<GeometryInfo<dim>::faces_per_cell,
+ typename TriaSubstructAccessor<dim>::ExcInvalidNeighbor(i));
+ return tria->levels[present_level]->
+ neighbors[present_index*GeometryInfo<dim>::faces_per_cell+i].first;
+};
+
+
+
+
+template <int dim>
+inline
+bool
+CellAccessor<dim>::refine_flag_set () const {
+ Assert (used(), typename TriaSubstructAccessor<dim>::ExcCellNotUsed());
+ // cells flagged for refinement must be active
+ // (the #set_refine_flag# function checks this,
+ // but activity may change when refinement is
+ // executed and for some reason the refine
+ // flag is not cleared).
+ Assert (active() || !tria->levels[present_level]->refine_flags[present_index],
+ ExcRefineCellNotActive());
+ return tria->levels[present_level]->refine_flags[present_index];
+};
+
+
+
+template <int dim>
+inline
+void
+CellAccessor<dim>::set_refine_flag () const {
+ Assert (used() && active(), ExcRefineCellNotActive());
+ Assert (!coarsen_flag_set(), ExcCellFlaggedForCoarsening());
+
+ tria->levels[present_level]->refine_flags[present_index] = true;
+};
+
+
+
+template <int dim>
+inline
+void
+CellAccessor<dim>::clear_refine_flag () const {
+ Assert (used() && active(), ExcRefineCellNotActive());
+ tria->levels[present_level]->refine_flags[present_index] = false;
+};
+
+
+
+template <int dim>
+inline
+bool
+CellAccessor<dim>::coarsen_flag_set () const {
+ Assert (used(), typename TriaSubstructAccessor<dim>::ExcCellNotUsed());
+ // cells flagged for coarsening must be active
+ // (the #set_refine_flag# function checks this,
+ // but activity may change when refinement is
+ // executed and for some reason the refine
+ // flag is not cleared).
+ Assert (active() || !tria->levels[present_level]->coarsen_flags[present_index],
+ ExcRefineCellNotActive());
+ return tria->levels[present_level]->coarsen_flags[present_index];
+};
+
+
+
+template <int dim>
+inline
+void
+CellAccessor<dim>::set_coarsen_flag () const {
+ Assert (used() && active(), ExcRefineCellNotActive());
+ Assert (!refine_flag_set(), ExcCellFlaggedForRefinement());
+
+ tria->levels[present_level]->coarsen_flags[present_index] = true;
+};
+
+
+
+template <int dim>
+inline
+void
+CellAccessor<dim>::clear_coarsen_flag () const {
+ Assert (used() && active(), ExcRefineCellNotActive());
+ tria->levels[present_level]->coarsen_flags[present_index] = false;
+};
+
+
+
+template <int dim>
+inline
+TriaIterator<dim,CellAccessor<dim> >
+CellAccessor<dim>::neighbor (const unsigned int i) const {
+ TriaIterator<dim,CellAccessor<dim> > q (tria, neighbor_level (i), neighbor_index (i));
+
+#ifdef DEBUG
+ if (q.state() != past_the_end)
+ Assert (q->used(),
+ typename TriaSubstructAccessor<dim>::ExcUnusedCellAsNeighbor());
+#endif
+ return q;
+};
+
+
+
+template <int dim>
+inline
+TriaIterator<dim,CellAccessor<dim> >
+CellAccessor<dim>::child (const unsigned int i) const {
+ TriaIterator<dim,CellAccessor<dim> > q (tria, present_level+1, child_index (i));
+
+#ifdef DEBUG
+ if (q.state() != past_the_end)
+ Assert (q->used(),
+ typename TriaSubstructAccessor<dim>::ExcUnusedCellAsChild());
+#endif
+ return q;
+};
+
+
+
+template <int dim>
+inline
+bool
+CellAccessor<dim>::active () const {
+ return !has_children();
+};
+
+
+
+
+
+
+/*---------------------------- tria_accessor.templates.h ---------------------------*/
+/* end of #ifndef __tria_accessor_templates_H */
+#endif
+/*---------------------------- tria_accessor.templates.h ---------------------------*/
#include <iostream>
#include <base/exceptions.h>
#include <base/point.h>
-#include <grid/tria_accessor.h>
-
+#include <grid/tria_iterator_base.h>
+//#include <grid/tria_accessor.h>
+// note: in non-debug mode, i.e. with optimizations, the file
+// tria_iterator.templates.h is included at the end of this file.
+// this includes a lot of templates and thus makes compilation
+// slower, but at the same time allows for more aggressive
+// inlining and thus faster code.
+// if in optimized mode: include more templates
+#ifndef DEBUG
+# include "tria_iterator.templates.h"
+#endif
+
+
/*---------------------------- tria-iterator.h ---------------------------*/
/* end of #ifndef __tria_iterator_H */
#endif
-/* $Id$ */
-/* Copyright W. Bangerth, University of Heidelberg, 1998 */
+/*---------------------------- tria_iterator.templates.h ---------------------------*/
+/* Copyright W. Bangerth, University of Heidelberg, 1998 */
+/* $Id$ */
+#ifndef __tria_iterator_templates_H
+#define __tria_iterator_templates_H
+/*---------------------------- tria_iterator.templates.h ---------------------------*/
#include <grid/tria.h>
#include <grid/tria_iterator.h>
template <int dim, typename Accessor>
+inline
TriaRawIterator<dim,Accessor>::TriaRawIterator () :
accessor (0, -2, -2, 0) {};
template <int dim, typename Accessor>
+inline
TriaRawIterator<dim,Accessor>::TriaRawIterator (const TriaRawIterator<dim,Accessor> &i) :
accessor (i.accessor) {};
template <int dim, typename Accessor>
+inline
TriaRawIterator<dim,Accessor>::TriaRawIterator (Triangulation<dim> *parent,
const int level,
const int index,
template <int dim, typename Accessor>
+inline
TriaRawIterator<dim,Accessor> &
TriaRawIterator<dim,Accessor>::operator = (const TriaRawIterator<dim,Accessor> &i) {
accessor.copy_from (i.accessor);
template <int dim, typename Accessor>
+inline
bool
TriaRawIterator<dim,Accessor>::operator == (const TriaRawIterator<dim,Accessor> &i) const {
return accessor == i.accessor;
template <int dim, typename Accessor>
+inline
bool
TriaRawIterator<dim,Accessor>::operator != (const TriaRawIterator<dim,Accessor> &i) const {
return accessor != i.accessor;
template <int dim, typename Accessor>
-TriaRawIterator<dim,Accessor> TriaRawIterator<dim,Accessor>::operator ++ (int) {
+inline
+TriaRawIterator<dim,Accessor>
+TriaRawIterator<dim,Accessor>::operator ++ (int) {
TriaRawIterator<dim,Accessor> tmp(*this);
operator++ ();
template <int dim, typename Accessor>
-TriaRawIterator<dim,Accessor> TriaRawIterator<dim,Accessor>::operator -- (int) {
+inline
+TriaRawIterator<dim,Accessor>
+TriaRawIterator<dim,Accessor>::operator -- (int) {
TriaRawIterator<dim,Accessor> tmp(*this);
operator-- ();
template <int dim, typename Accessor>
+inline
TriaIterator<dim,Accessor>::TriaIterator () :
TriaRawIterator<dim,Accessor> () {};
template <int dim, typename Accessor>
+inline
TriaIterator<dim,Accessor>::
TriaIterator (const TriaIterator<dim,Accessor> &i) :
TriaRawIterator<dim,Accessor> (static_cast<TriaRawIterator<dim,Accessor> >(i)) {};
template <int dim, typename Accessor>
+inline
TriaIterator<dim,Accessor>::
TriaIterator (const TriaRawIterator<dim,Accessor> &i) :
TriaRawIterator<dim,Accessor> (i)
template <int dim, typename Accessor>
+inline
TriaIterator<dim,Accessor>::TriaIterator (Triangulation<dim> *parent,
const int level,
const int index,
template <int dim, typename Accessor>
+inline
TriaIterator<dim,Accessor> &
TriaIterator<dim,Accessor>::operator = (const TriaIterator<dim,Accessor> &i) {
accessor.copy_from (i.accessor);
template <int dim, typename Accessor>
+inline
TriaIterator<dim,Accessor> &
TriaIterator<dim,Accessor>::operator = (const TriaRawIterator<dim,Accessor> &i) {
accessor.copy_from (i.accessor);
template <int dim, typename Accessor>
+inline
TriaIterator<dim,Accessor> & TriaIterator<dim,Accessor>::operator ++ () {
while (TriaRawIterator<dim,Accessor>::operator++(),
(state() == valid))
template <int dim, typename Accessor>
+inline
TriaIterator<dim,Accessor> TriaIterator<dim,Accessor>::operator ++ (int) {
TriaIterator<dim,Accessor> tmp(*this);
operator++ ();
template <int dim, typename Accessor>
-TriaIterator<dim,Accessor> & TriaIterator<dim,Accessor>::operator -- () {
+inline
+TriaIterator<dim,Accessor> &
+TriaIterator<dim,Accessor>::operator -- () {
while (TriaRawIterator<dim,Accessor>::operator--(),
(state() == valid))
if (accessor.used() == true)
template <int dim, typename Accessor>
-TriaIterator<dim,Accessor> TriaIterator<dim,Accessor>::operator -- (int) {
+inline
+TriaIterator<dim,Accessor>
+TriaIterator<dim,Accessor>::operator -- (int) {
TriaIterator<dim,Accessor> tmp(*this);
operator-- ();
template <int dim, typename Accessor>
+inline
TriaActiveIterator<dim,Accessor>::TriaActiveIterator () :
TriaIterator<dim,Accessor> () {};
template <int dim, typename Accessor>
+inline
TriaActiveIterator<dim,Accessor>::
TriaActiveIterator (const TriaActiveIterator<dim,Accessor> &i) :
TriaIterator<dim,Accessor> (static_cast<TriaIterator<dim,Accessor> >(i)) {};
template <int dim, typename Accessor>
+inline
TriaActiveIterator<dim,Accessor>::
TriaActiveIterator (const TriaRawIterator<dim,Accessor> &i) :
TriaIterator<dim,Accessor> (i)
template <int dim, typename Accessor>
+inline
TriaActiveIterator<dim,Accessor>::
TriaActiveIterator (const TriaIterator<dim,Accessor> &i) :
TriaIterator<dim,Accessor> (i)
template <int dim, typename Accessor>
+inline
TriaActiveIterator<dim,Accessor>::TriaActiveIterator (Triangulation<dim> *parent,
const int level,
const int index,
template <int dim, typename Accessor>
+inline
TriaActiveIterator<dim,Accessor> &
TriaActiveIterator<dim,Accessor>::operator = (const TriaActiveIterator<dim,Accessor> &i) {
accessor.copy_from (i.accessor);
template <int dim, typename Accessor>
+inline
TriaActiveIterator<dim,Accessor> &
TriaActiveIterator<dim,Accessor>::operator = (const TriaRawIterator<dim,Accessor> &i) {
accessor.copy_from (i.accessor);
template <int dim, typename Accessor>
+inline
TriaActiveIterator<dim,Accessor> &
TriaActiveIterator<dim,Accessor>::operator = (const TriaIterator<dim,Accessor> &i) {
accessor.copy_from (i.accessor);
template <int dim, typename Accessor>
-TriaActiveIterator<dim,Accessor> & TriaActiveIterator<dim,Accessor>::operator ++ () {
+inline
+TriaActiveIterator<dim,Accessor> &
+TriaActiveIterator<dim,Accessor>::operator ++ () {
while (TriaIterator<dim,Accessor>::operator++(),
(state() == valid))
if (accessor.has_children() == false)
template <int dim, typename Accessor>
-TriaActiveIterator<dim,Accessor> TriaActiveIterator<dim,Accessor>::operator ++ (int) {
+inline
+TriaActiveIterator<dim,Accessor>
+TriaActiveIterator<dim,Accessor>::operator ++ (int) {
TriaActiveIterator<dim,Accessor> tmp(*this);
operator++ ();
template <int dim, typename Accessor>
-TriaActiveIterator<dim,Accessor> & TriaActiveIterator<dim,Accessor>::operator -- () {
+inline
+TriaActiveIterator<dim,Accessor> &
+TriaActiveIterator<dim,Accessor>::operator -- () {
while (TriaIterator<dim,Accessor>::operator--(),
(state() == valid))
if (accessor.has_children() == false)
template <int dim, typename Accessor>
+inline
TriaActiveIterator<dim,Accessor> TriaActiveIterator<dim,Accessor>::operator -- (int) {
TriaActiveIterator<dim,Accessor> tmp(*this);
operator-- ();
-
-
-
-
-
+/*---------------------------- tria_iterator.templates.h ---------------------------*/
+/* end of #ifndef __tria_iterator_templates_H */
+#endif
+/*---------------------------- tria_iterator.templates.h ---------------------------*/
| perl -pe 's!(\.\./lib/2d/[^ ]+)_DIM_PLACEHOLDER!$$1_2d!g;' \
| perl -pe 's!(\.\./lib/3d/[^ ]+)_DIM_PLACEHOLDER!$$1_3d!g;' \
>> ../lib/Makefile.dep
+ @echo ============================ Done
else
@echo ============================ Not remaking Makefile since in nested mode
endif
#include <grid/dof_accessor.h>
+#include <grid/dof_accessor.templates.h>
#include <grid/dof.h>
#include <grid/dof_levels.h>
#include <grid/tria_iterator.h>
/*------------------------- Functions: DoFLineAccessor -----------------------*/
-template <int dim, typename BaseClass>
-inline
-int DoFLineAccessor<dim,BaseClass>::dof_index (const unsigned int i) const {
- Assert (dof_handler != 0, ExcInvalidObject());
- // make sure a FE has been selected
- // and enough room was reserved
- Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
- Assert (i<dof_handler->selected_fe->dofs_per_line,
- ExcInvalidIndex (i, 0, dof_handler->selected_fe->dofs_per_line));
-
- return dof_handler->levels[present_level]
- ->line_dofs[present_index*dof_handler->selected_fe->dofs_per_line+i];
-};
-
-
-
-
template <int dim, typename BaseClass>
void DoFLineAccessor<dim,BaseClass>::set_dof_index (const unsigned int i,
-template <int dim, typename BaseClass>
-inline
-int DoFLineAccessor<dim,BaseClass>::vertex_dof_index (const unsigned int vertex,
- const unsigned int i) const {
- Assert (dof_handler != 0, ExcInvalidObject());
- Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
- Assert (vertex<2, ExcInvalidIndex (i,0,2));
- Assert (i<dof_handler->selected_fe->dofs_per_vertex,
- ExcInvalidIndex (i, 0, dof_handler->selected_fe->dofs_per_vertex));
-
- const unsigned int dof_number = (vertex_index(vertex) *
- dof_handler->selected_fe->dofs_per_vertex +
- i);
- return dof_handler->vertex_dofs[dof_number];
-};
-
-
-
template <int dim, typename BaseClass>
void DoFLineAccessor<dim,BaseClass>::set_vertex_dof_index (const unsigned int vertex,
const unsigned int i,
-template <int dim, typename BaseClass>
-void
-DoFLineAccessor<dim,BaseClass>::get_dof_indices (vector<int> &dof_indices) const {
- Assert (dof_handler != 0, ExcInvalidObject());
- Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
- Assert (dof_indices.size() == (2*dof_handler->get_fe().dofs_per_vertex +
- dof_handler->get_fe().dofs_per_line),
- ExcVectorDoesNotMatch());
-
- const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex,
- dofs_per_line = dof_handler->get_fe().dofs_per_line;
- vector<int>::iterator next = dof_indices.begin();
- for (unsigned int vertex=0; vertex<2; ++vertex)
- for (unsigned int d=0; d<dofs_per_vertex; ++d)
- *next++ = vertex_dof_index(vertex,d);
- for (unsigned int d=0; d<dofs_per_line; ++d)
- *next++ = dof_index(d);
-};
-
-
-
-template <int dim, typename BaseClass>
-TriaIterator<dim,DoFLineAccessor<dim,BaseClass> >
-DoFLineAccessor<dim,BaseClass>::child (const unsigned int i) const {
- TriaIterator<dim,DoFLineAccessor<dim,BaseClass> > q (tria,
- present_level+1,
- child_index (i),
- dof_handler);
-
-#ifdef DEBUG
- if (q.state() != past_the_end)
- Assert (q->used(), typename TriaAccessor<dim>::ExcUnusedCellAsChild());
-#endif
- return q;
-};
-
-
-
template <int dim, typename BaseClass>
void DoFLineAccessor<dim,BaseClass>::
distribute_local_to_global (const Vector<double> &local_source,
-template <int dim, typename BaseClass>
-void DoFLineAccessor<dim,BaseClass>::copy_from (const DoFLineAccessor<dim,BaseClass> &a) {
- BaseClass::copy_from (a);
- set_dof_handler (a.dof_handler);
-};
-
-
-
/*------------------------- Functions: DoFQuadAccessor -----------------------*/
-template <int dim, typename BaseClass>
-inline
-int DoFQuadAccessor<dim,BaseClass>::dof_index (const unsigned int i) const {
- Assert (dof_handler != 0, ExcInvalidObject());
- // make sure a FE has been selected
- // and enough room was reserved
- Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
- Assert (i<dof_handler->selected_fe->dofs_per_quad,
- ExcInvalidIndex (i, 0, dof_handler->selected_fe->dofs_per_quad));
-
- return dof_handler->levels[present_level]
- ->quad_dofs[present_index*dof_handler->selected_fe->dofs_per_quad+i];
-};
-
-
-
template <int dim, typename BaseClass>
void DoFQuadAccessor<dim,BaseClass>::set_dof_index (const unsigned int i,
const int index) const {
-template <int dim, typename BaseClass>
-inline
-int DoFQuadAccessor<dim,BaseClass>::vertex_dof_index (const unsigned int vertex,
- const unsigned int i) const {
- Assert (dof_handler != 0, ExcInvalidObject());
- Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
- Assert (vertex<4, ExcInvalidIndex (i,0,4));
- Assert (i<dof_handler->selected_fe->dofs_per_vertex,
- ExcInvalidIndex (i, 0, dof_handler->selected_fe->dofs_per_vertex));
-
- const unsigned int dof_number = (vertex_index(vertex) *
- dof_handler->selected_fe->dofs_per_vertex +
- i);
- return dof_handler->vertex_dofs[dof_number];
-};
-
-
-
template <int dim, typename BaseClass>
void DoFQuadAccessor<dim,BaseClass>::set_vertex_dof_index (const unsigned int vertex,
const unsigned int i,
-template <int dim, typename BaseClass>
-void
-DoFQuadAccessor<dim,BaseClass>::get_dof_indices (vector<int> &dof_indices) const {
- Assert (dof_handler != 0, ExcInvalidObject());
- Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
- Assert (dof_indices.size() == (4*dof_handler->get_fe().dofs_per_vertex +
- 4*dof_handler->get_fe().dofs_per_line +
- dof_handler->get_fe().dofs_per_quad),
- ExcVectorDoesNotMatch());
-
- const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex,
- dofs_per_line = dof_handler->get_fe().dofs_per_line,
- dofs_per_quad = dof_handler->get_fe().dofs_per_quad;
- vector<int>::iterator next = dof_indices.begin();
- for (unsigned int vertex=0; vertex<4; ++vertex)
- for (unsigned int d=0; d<dofs_per_vertex; ++d)
- *next++ = vertex_dof_index(vertex,d);
- for (unsigned int line=0; line<4; ++line)
- for (unsigned int d=0; d<dofs_per_line; ++d)
- *next++ = this->line(line)->dof_index(d);
- for (unsigned int d=0; d<dofs_per_quad; ++d)
- *next++ = dof_index(d);
-};
-
-
-
-template <int dim, typename BaseClass>
-TriaIterator<dim,DoFLineAccessor<dim,LineAccessor<dim> > >
-DoFQuadAccessor<dim,BaseClass>::line (const unsigned int i) const {
- Assert (i<4, ExcInvalidIndex (i, 0, 4));
-
- return TriaIterator<dim,DoFLineAccessor<dim,LineAccessor<dim> > >
- (
- tria,
- present_level,
- line_index (i),
- dof_handler
- );
-};
-
-
-
-template <int dim, typename BaseClass>
-TriaIterator<dim,DoFQuadAccessor<dim,BaseClass> >
-DoFQuadAccessor<dim,BaseClass>::child (const unsigned int i) const {
- TriaIterator<dim,DoFQuadAccessor<dim,BaseClass> > q (tria,
- present_level+1,
- child_index (i),
- dof_handler);
-
-#ifdef DEBUG
- if (q.state() != past_the_end)
- Assert (q->used(), typename TriaAccessor<dim>::ExcUnusedCellAsChild());
-#endif
- return q;
-};
-
-
-
template <int dim, typename BaseClass>
void DoFQuadAccessor<dim,BaseClass>::
distribute_local_to_global (const Vector<double> &local_source,
-template <int dim, typename BaseClass>
-void DoFQuadAccessor<dim,BaseClass>::copy_from (const DoFQuadAccessor<dim,BaseClass> &a) {
- BaseClass::copy_from (a);
- set_dof_handler (a.dof_handler);
-};
-
-
/*------------------------- Functions: DoFHexAccessor -----------------------*/
-template <int dim, typename BaseClass>
-inline
-int DoFHexAccessor<dim,BaseClass>::dof_index (const unsigned int i) const {
- Assert (dof_handler != 0, ExcInvalidObject());
- // make sure a FE has been selected
- // and enough room was reserved
- Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
- Assert (i<dof_handler->selected_fe->dofs_per_hex,
- ExcInvalidIndex (i, 0, dof_handler->selected_fe->dofs_per_hex));
-
- return dof_handler->levels[present_level]
- ->hex_dofs[present_index*dof_handler->selected_fe->dofs_per_hex+i];
-};
-
-
-
template <int dim, typename BaseClass>
void DoFHexAccessor<dim,BaseClass>::set_dof_index (const unsigned int i,
const int index) const {
-template <int dim, typename BaseClass>
-inline
-int DoFHexAccessor<dim,BaseClass>::vertex_dof_index (const unsigned int vertex,
- const unsigned int i) const {
- Assert (dof_handler != 0, ExcInvalidObject());
- Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
- Assert (vertex<8, ExcInvalidIndex (i,0,8));
- Assert (i<dof_handler->selected_fe->dofs_per_vertex,
- ExcInvalidIndex (i, 0, dof_handler->selected_fe->dofs_per_vertex));
-
- const unsigned int dof_number = (vertex_index(vertex) *
- dof_handler->selected_fe->dofs_per_vertex +
- i);
- return dof_handler->vertex_dofs[dof_number];
-};
-
-
-
template <int dim, typename BaseClass>
void DoFHexAccessor<dim,BaseClass>::set_vertex_dof_index (const unsigned int vertex,
const unsigned int i,
-template <int dim, typename BaseClass>
-void
-DoFHexAccessor<dim,BaseClass>::get_dof_indices (vector<int> &dof_indices) const {
- Assert (dof_handler != 0, ExcInvalidObject());
- Assert (dof_handler->selected_fe != 0, ExcInvalidObject());
- Assert (dof_indices.size() == (8*dof_handler->get_fe().dofs_per_vertex +
- 12*dof_handler->get_fe().dofs_per_line +
- 6*dof_handler->get_fe().dofs_per_quad +
- dof_handler->get_fe().dofs_per_hex),
- ExcVectorDoesNotMatch());
-
- const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex,
- dofs_per_line = dof_handler->get_fe().dofs_per_line,
- dofs_per_quad = dof_handler->get_fe().dofs_per_quad,
- dofs_per_hex = dof_handler->get_fe().dofs_per_hex;
- vector<int>::iterator next = dof_indices.begin();
- for (unsigned int vertex=0; vertex<8; ++vertex)
- for (unsigned int d=0; d<dofs_per_vertex; ++d)
- *next++ = vertex_dof_index(vertex,d);
- for (unsigned int line=0; line<12; ++line)
- for (unsigned int d=0; d<dofs_per_line; ++d)
- *next++ = this->line(line)->dof_index(d);
- for (unsigned int quad=0; quad<6; ++quad)
- for (unsigned int d=0; d<dofs_per_quad; ++d)
- *next++ = this->quad(quad)->dof_index(d);
- for (unsigned int d=0; d<dofs_per_hex; ++d)
- *next++ = dof_index(d);
-};
-
-
-
-template <int dim, typename BaseClass>
-TriaIterator<dim,DoFLineAccessor<dim,LineAccessor<dim> > >
-DoFHexAccessor<dim,BaseClass>::line (const unsigned int i) const {
- TriaIterator<dim,LineAccessor<dim> > l = BaseClass::line(i);
- return TriaIterator<dim,DoFLineAccessor<dim,LineAccessor<dim> > >
- (
- tria,
- present_level,
- l->index(),
- dof_handler
- );
-};
-
-
-
-template <int dim, typename BaseClass>
-TriaIterator<dim,DoFQuadAccessor<dim,QuadAccessor<dim> > >
-DoFHexAccessor<dim,BaseClass>::quad (const unsigned int i) const {
- Assert (i<6, ExcInvalidIndex (i, 0, 6));
-
- return TriaIterator<dim,DoFQuadAccessor<dim,QuadAccessor<dim> > >
- (
- tria,
- present_level,
- quad_index (i),
- dof_handler
- );
-};
-
-
-
-template <int dim, typename BaseClass>
-TriaIterator<dim,DoFHexAccessor<dim,BaseClass> >
-DoFHexAccessor<dim,BaseClass>::child (const unsigned int i) const {
- TriaIterator<dim,DoFHexAccessor<dim,BaseClass> > q (tria,
- present_level+1,
- child_index (i),
- dof_handler);
-
-#ifdef DEBUG
- if (q.state() != past_the_end)
- Assert (q->used(), typename TriaAccessor<dim>::ExcUnusedCellAsChild());
-#endif
- return q;
-};
-
-
-
template <int dim, typename BaseClass>
void DoFHexAccessor<dim,BaseClass>::
distribute_local_to_global (const Vector<double> &local_source,
-template <int dim, typename BaseClass>
-void DoFHexAccessor<dim,BaseClass>::copy_from (const DoFHexAccessor<dim,BaseClass> &a) {
- BaseClass::copy_from (a);
- set_dof_handler (a.dof_handler);
-};
-
-
-
-
/*------------------------- Functions: DoFCellAccessor -----------------------*/
-template <int dim>
-TriaIterator<dim,DoFCellAccessor<dim> >
-DoFCellAccessor<dim>::neighbor (const unsigned int i) const {
- TriaIterator<dim,DoFCellAccessor<dim> > q (tria,
- neighbor_level (i),
- neighbor_index (i),
- dof_handler);
-
-#ifdef DEBUG
- if (q.state() != past_the_end)
- Assert (q->used(), typename TriaAccessor<dim>::ExcUnusedCellAsNeighbor());
-#endif
- return q;
-};
-
-
-
-template <int dim>
-TriaIterator<dim,DoFCellAccessor<dim> >
-DoFCellAccessor<dim>::child (const unsigned int i) const {
- TriaIterator<dim,DoFCellAccessor<dim> > q (tria,
- present_level+1,
- child_index (i),
- dof_handler);
-
-#ifdef DEBUG
- if (q.state() != past_the_end)
- Assert (q->used(), typename TriaAccessor<dim>::ExcUnusedCellAsChild());
-#endif
- return q;
-};
-
#if deal_II_dimension == 1
#include <grid/tria_levels.h>
#include <grid/tria_iterator.h>
#include <grid/tria_accessor.h>
+#include <grid/tria_accessor.templates.h>
#include <grid/tria_iterator.templates.h>
#include <grid/geometry_info.h>
-/*------------------------ Functions: LineAccessor ---------------------------*/
-
-template <int dim>
-void TriaAccessor<dim>::copy_from (const TriaAccessor<dim> &a) {
- present_level = a.present_level;
- present_index = a.present_index;
- tria = a.tria;
-};
-
-
-
-template <int dim>
-bool TriaAccessor<dim>::operator == (const TriaAccessor<dim> &a) const {
- Assert (tria == a.tria, ExcCantCompareIterators());
- return ((present_index == a.present_index) &&
- (present_level == a.present_level));
-};
-
-
-
-template <int dim>
-bool TriaAccessor<dim>::operator != (const TriaAccessor<dim> &a) const {
- Assert (tria == a.tria, ExcCantCompareIterators());
- return ((present_index != a.present_index) ||
- (present_level != a.present_level));
-};
-
-
-
-template <int dim>
-int TriaAccessor<dim>::level () const {
- return present_level;
-};
-
-
-
-template <int dim>
-int TriaAccessor<dim>::index () const {
- return present_index;
-};
-
-
-
-
-template <int dim>
-IteratorState TriaAccessor<dim>::state () const {
- if ((present_level>=0) && (present_index>=0))
- return valid;
- else
- if ((present_level==-1) && (present_index==-1))
- return past_the_end;
- else
- return invalid;
-};
-
-
-
-
-template <int dim>
-bool LineAccessor<dim>::used () const {
- Assert (state() == valid, ExcDereferenceInvalidObject());
- return tria->levels[present_level]->lines.used[present_index];
-};
-
-
-
template <int dim>
void LineAccessor<dim>::set_used_flag () const {
Assert (state() == valid, ExcDereferenceInvalidObject());
};
-template <int dim>
-bool LineAccessor<dim>::user_flag_set () const {
- Assert (used(), ExcCellNotUsed());
- return tria->levels[present_level]->lines.user_flags[present_index];
-};
-
-
-
-template <int dim>
-void LineAccessor<dim>::set_user_flag () const {
- Assert (used(), ExcCellNotUsed());
- tria->levels[present_level]->lines.user_flags[present_index] = true;
-};
-
-
-
-template <int dim>
-void LineAccessor<dim>::clear_user_flag () const {
- Assert (used(), ExcCellNotUsed());
- tria->levels[present_level]->lines.user_flags[present_index] = false;
-};
-
-
template <int dim>
void LineAccessor<dim>::recursively_set_user_flag () const {
Assert (used(), ExcCellNotUsed());
return tria->levels[present_level]->lines.user_pointers[present_index];
};
-
-
-
-
-template <int dim>
-TriaIterator<dim,LineAccessor<dim> >
-LineAccessor<dim>::child (const unsigned int i) const {
- Assert (i<2, ExcInvalidIndex(i,0,1));
- TriaIterator<dim,LineAccessor<dim> > q (tria, present_level+1, child_index (i));
-
-#ifdef DEBUG
- if (q.state() != past_the_end)
- Assert (q->used(), ExcUnusedCellAsChild());
-#endif
- return q;
-};
-
-
-template <int dim>
-int LineAccessor<dim>::child_index (unsigned int i) const {
- Assert (i<2, ExcInvalidIndex(i,0,1));
- return tria->levels[present_level]->lines.children[present_index]+i;
-};
-
-
-
template <int dim>
void LineAccessor<dim>::set_children (const int index) const {
-template <int dim>
-bool LineAccessor<dim>::has_children () const {
- Assert (state() == valid, ExcDereferenceInvalidObject());
- return (tria->levels[present_level]->lines.children[present_index] != -1);
-}
-
-
-
-template <int dim>
-void LineAccessor<dim>::operator ++ () {
- ++present_index;
- // is index still in the range of
- // the vector?
- while (present_index
- >=
- (int)tria->levels[present_level]->lines.lines.size())
- {
- // no -> go one level up until we find
- // one with more than zero cells
- ++present_level;
- present_index = 0;
- // highest level reached?
- if (present_level >= (int)tria->levels.size())
- {
- // return with past the end pointer
- present_level = present_index = -1;
- return;
- };
- };
-};
-
-
-
-template <int dim>
-void LineAccessor<dim>::operator -- () {
- --present_index;
- // is index still in the range of
- // the vector?
- while (present_index < 0)
- {
- // no -> go one level down
- --present_level;
- // lowest level reached?
- if (present_level == -1)
- {
- // return with past the end pointer
- present_level = present_index = -1;
- return;
- };
- // else
- present_index = tria->levels[present_level]->lines.lines.size()-1;
- };
-};
-
-
-
template <int dim>
unsigned char LineAccessor<dim>::boundary_indicator () const {
Assert (dim>=2, ExcNotUsefulForThisDimension());
-template <int dim>
-bool QuadAccessor<dim>::used () const {
- Assert (state() == valid, ExcDereferenceInvalidObject());
- return tria->levels[present_level]->quads.used[present_index];
-};
-
-
template <int dim>
-void QuadAccessor<dim>::set_used_flag () const {
+void
+QuadAccessor<dim>::set_used_flag () const {
Assert (state() == valid, ExcDereferenceInvalidObject());
tria->levels[present_level]->quads.used[present_index] = true;
};
-
-template <int dim>
-bool QuadAccessor<dim>::user_flag_set () const {
- Assert (used(), ExcCellNotUsed());
- return tria->levels[present_level]->quads.user_flags[present_index];
-};
-
-
-
-template <int dim>
-void QuadAccessor<dim>::set_user_flag () const {
- Assert (used(), ExcCellNotUsed());
- tria->levels[present_level]->quads.user_flags[present_index] = true;
-};
-
-
-
-template <int dim>
-void QuadAccessor<dim>::clear_user_flag () const {
- Assert (used(), ExcCellNotUsed());
- tria->levels[present_level]->quads.user_flags[present_index] = false;
-};
-
-
-
template <int dim>
void QuadAccessor<dim>::recursively_set_user_flag () const {
set_user_flag ();
-
-template <int dim>
-TriaIterator<dim,LineAccessor<dim> >
-QuadAccessor<dim>::line (const unsigned int i) const {
- return
- TriaIterator<dim,LineAccessor<dim> >
- (
- tria,
- present_level,
- line_index (i)
- );
-};
-
-
-
-template <int dim>
-unsigned int QuadAccessor<dim>::line_index (unsigned int i) const {
- Assert (i<4, ExcInvalidIndex(i,0,3));
-
- return tria->levels[present_level]->quads.quads[present_index].line(i);
-};
-
-
-
-template <int dim>
-TriaIterator<dim,QuadAccessor<dim> >
-QuadAccessor<dim>::child (const unsigned int i) const {
- Assert (i<4, ExcInvalidIndex(i,0,3));
-
- TriaIterator<dim,QuadAccessor<dim> > q (tria, present_level+1, child_index (i));
-
-#ifdef DEBUG
- if (q.state() != past_the_end)
- Assert (q->used(), ExcUnusedCellAsChild());
-#endif
- return q;
-};
-
-
-
-template <int dim>
-int QuadAccessor<dim>::child_index (unsigned int i) const {
- Assert (i<4, ExcInvalidIndex(i,0,3));
- return tria->levels[present_level]->quads.children[present_index]+i;
-};
-
-
-
template <int dim>
void QuadAccessor<dim>::set_children (const int index) const {
Assert (used(), ExcCellNotUsed());
-template <int dim>
-bool QuadAccessor<dim>::has_children () const {
- Assert (state() == valid, ExcDereferenceInvalidObject());
- return (tria->levels[present_level]->quads.children[present_index] != -1);
-};
-
-
-
-template <int dim>
-void QuadAccessor<dim>::operator ++ () {
- ++present_index;
- // is index still in the range of
- // the vector?
- while (present_index
- >=
- (int)tria->levels[present_level]->quads.quads.size())
- {
- // no -> go one level up
- ++present_level;
- present_index = 0;
- // highest level reached?
- if (present_level >= (int)tria->levels.size())
- {
- // return with past the end pointer
- present_level = present_index = -1;
- return;
- };
- };
-};
-
-
-
-template <int dim>
-void QuadAccessor<dim>::operator -- () {
- --present_index;
- // is index still in the range of
- // the vector?
- while (present_index < 0)
- {
- // no -> go one level down
- --present_level;
- // lowest level reached?
- if (present_level == -1)
- {
- // return with past the end pointer
- present_level = present_index = -1;
- return;
- };
- // else
- present_index = tria->levels[present_level]->quads.quads.size()-1;
- };
-};
-
-
-
template <int dim>
unsigned char QuadAccessor<dim>::boundary_indicator () const {
Assert (dim>=3, ExcNotUsefulForThisDimension());
-template <int dim>
-bool HexAccessor<dim>::used () const {
- Assert (state() == valid, ExcDereferenceInvalidObject());
- return tria->levels[present_level]->hexes.used[present_index];
-};
-
-
-
template <int dim>
void HexAccessor<dim>::set_used_flag () const {
Assert (state() == valid, ExcDereferenceInvalidObject());
-template <int dim>
-bool HexAccessor<dim>::user_flag_set () const {
- Assert (used(), ExcCellNotUsed());
- return tria->levels[present_level]->hexes.user_flags[present_index];
-};
-
-
-
-template <int dim>
-void HexAccessor<dim>::set_user_flag () const {
- Assert (used(), ExcCellNotUsed());
- tria->levels[present_level]->hexes.user_flags[present_index] = true;
-};
-
-
-
-template <int dim>
-void HexAccessor<dim>::clear_user_flag () const {
- Assert (used(), ExcCellNotUsed());
- tria->levels[present_level]->hexes.user_flags[present_index] = false;
-};
-
-
-
template <int dim>
void HexAccessor<dim>::recursively_set_user_flag () const {
set_user_flag ();
-
-template <int dim>
-TriaIterator<dim,LineAccessor<dim> >
-HexAccessor<dim>::line (const unsigned int i) const {
- Assert (used(), ExcCellNotUsed());
- Assert (i<12, ExcInvalidIndex (i,0,11));
-
- 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);
- };
- Assert (false, ExcInvalidIndex(i,0,11));
- return TriaIterator<dim,LineAccessor<dim> >(tria, -1, -1, 0);
-};
-
-
-
-template <int dim>
-TriaIterator<dim,QuadAccessor<dim> >
-HexAccessor<dim>::quad (const unsigned int i) const {
- Assert (used(), ExcCellNotUsed());
- return
- TriaIterator<dim,QuadAccessor<dim> >
- (
- tria,
- present_level,
- quad_index (i)
- );
-};
-
-
-
-template <int dim>
-unsigned int HexAccessor<dim>::quad_index (unsigned int i) const {
- Assert (i<6, ExcInvalidIndex(i,0,5));
-
- return tria->levels[present_level]->hexes.hexes[present_index].quad(i);
-};
-
-
-
-template <int dim>
-TriaIterator<dim,HexAccessor<dim> >
-HexAccessor<dim>::child (const unsigned int i) const {
- Assert (i<6, ExcInvalidIndex(i,0,5));
-
- TriaIterator<dim,HexAccessor<dim> > q (tria, present_level+1, child_index (i));
-
-#ifdef DEBUG
- if (q.state() != past_the_end)
- Assert (q->used(), ExcUnusedCellAsChild());
-#endif
- return q;
-};
-
-
-
-template <int dim>
-int HexAccessor<dim>::child_index (unsigned int i) const {
- Assert (i<8, ExcInvalidIndex(i,0,7));
- return tria->levels[present_level]->hexes.children[present_index]+i;
-};
-
-
-
template <int dim>
void HexAccessor<dim>::set_children (const int index) const {
Assert (used(), ExcCellNotUsed());
-template <int dim>
-void HexAccessor<dim>::operator ++ () {
- ++present_index;
- // is index still in the range of
- // the vector?
- while (present_index
- >=
- (int)tria->levels[present_level]->hexes.hexes.size())
- {
- // no -> go one level up
- ++present_level;
- present_index = 0;
- // highest level reached?
- if (present_level >= (int)tria->levels.size())
- {
- // return with past the end pointer
- present_level = present_index = -1;
- return;
- };
- };
-};
-
-
-
-template <int dim>
-void HexAccessor<dim>::operator -- () {
- --present_index;
- // is index still in the range of
- // the vector?
- while (present_index < 0)
- {
- // no -> go one level down
- --present_level;
- // lowest level reached?
- if (present_level == -1)
- {
- // return with past the end pointer
- present_level = present_index = -1;
- return;
- };
- // else
- present_index = tria->levels[present_level]->hexes.hexes.size()-1;
- };
-};
-
-
-
template <int dim>
unsigned char HexAccessor<dim>::boundary_indicator () const {
Assert (dim<4, ExcNotUsefulForThisDimension());
};
-
-template <>
-Triangulation<1>::face_iterator
-CellAccessor<1>::face (const unsigned int) const {
- Assert (false, ExcNotUsefulForThisDimension());
- return 0;
-};
-
#endif
+
/*------------------------ Functions: CellAccessor<2> -----------------------*/
= mat_id;
};
-
-
-template <>
-Triangulation<2>::face_iterator
-CellAccessor<2>::face (const unsigned int i) const {
- return line(i);
-};
-
#endif
= mat_id;
};
-
-
-template <>
-Triangulation<3>::face_iterator
-CellAccessor<3>::face (const unsigned int i) const {
- return quad(i);
-};
-
#endif
/*------------------------ Functions: CellAccessor<dim> -----------------------*/
-template <int dim>
-int CellAccessor<dim>::neighbor_index (const unsigned int i) const {
- Assert (i<GeometryInfo<dim>::faces_per_cell,
- typename TriaSubstructAccessor<dim>::ExcInvalidNeighbor(i));
- return tria->levels[present_level]->
- neighbors[present_index*GeometryInfo<dim>::faces_per_cell+i].second;
-};
-
-
-
-template <int dim>
-int CellAccessor<dim>::neighbor_level (const unsigned int i) const {
- Assert (i<GeometryInfo<dim>::faces_per_cell,
- typename TriaSubstructAccessor<dim>::ExcInvalidNeighbor(i));
- return tria->levels[present_level]->
- neighbors[present_index*GeometryInfo<dim>::faces_per_cell+i].first;
-};
-
-
-
template <int dim>
void CellAccessor<dim>::set_neighbor (const unsigned int i,
const TriaIterator<dim,CellAccessor<dim> > &pointer) const {
-template <int dim>
-bool CellAccessor<dim>::refine_flag_set () const {
- Assert (used(), typename TriaSubstructAccessor<dim>::ExcCellNotUsed());
- // cells flagged for refinement must be active
- // (the #set_refine_flag# function checks this,
- // but activity may change when refinement is
- // executed and for some reason the refine
- // flag is not cleared).
- Assert (active() || !tria->levels[present_level]->refine_flags[present_index],
- ExcRefineCellNotActive());
- return tria->levels[present_level]->refine_flags[present_index];
-};
-
-
-
-template <int dim>
-void CellAccessor<dim>::set_refine_flag () const {
- Assert (used() && active(), ExcRefineCellNotActive());
- Assert (!coarsen_flag_set(), ExcCellFlaggedForCoarsening());
-
- tria->levels[present_level]->refine_flags[present_index] = true;
-};
-
-
-
-template <int dim>
-void CellAccessor<dim>::clear_refine_flag () const {
- Assert (used() && active(), ExcRefineCellNotActive());
- tria->levels[present_level]->refine_flags[present_index] = false;
-};
-
-
-
-template <int dim>
-bool CellAccessor<dim>::coarsen_flag_set () const {
- Assert (used(), typename TriaSubstructAccessor<dim>::ExcCellNotUsed());
- // cells flagged for coarsening must be active
- // (the #set_refine_flag# function checks this,
- // but activity may change when refinement is
- // executed and for some reason the refine
- // flag is not cleared).
- Assert (active() || !tria->levels[present_level]->coarsen_flags[present_index],
- ExcRefineCellNotActive());
- return tria->levels[present_level]->coarsen_flags[present_index];
-};
-
-
-
-template <int dim>
-void CellAccessor<dim>::set_coarsen_flag () const {
- Assert (used() && active(), ExcRefineCellNotActive());
- Assert (!refine_flag_set(), ExcCellFlaggedForRefinement());
-
- tria->levels[present_level]->coarsen_flags[present_index] = true;
-};
-
-
-
-template <int dim>
-void CellAccessor<dim>::clear_coarsen_flag () const {
- Assert (used() && active(), ExcRefineCellNotActive());
- tria->levels[present_level]->coarsen_flags[present_index] = false;
-};
-
-
-
-template <int dim>
-TriaIterator<dim,CellAccessor<dim> >
-CellAccessor<dim>::neighbor (const unsigned int i) const {
- TriaIterator<dim,CellAccessor<dim> > q (tria, neighbor_level (i), neighbor_index (i));
-
-#ifdef DEBUG
- if (q.state() != past_the_end)
- Assert (q->used(),
- typename TriaSubstructAccessor<dim>::ExcUnusedCellAsNeighbor());
-#endif
- return q;
-};
-
-
-
-template <int dim>
-TriaIterator<dim,CellAccessor<dim> >
-CellAccessor<dim>::child (const unsigned int i) const {
- TriaIterator<dim,CellAccessor<dim> > q (tria, present_level+1, child_index (i));
-
-#ifdef DEBUG
- if (q.state() != past_the_end)
- Assert (q->used(),
- typename TriaSubstructAccessor<dim>::ExcUnusedCellAsChild());
-#endif
- return q;
-};
-
-
-
-template <int dim>
-bool CellAccessor<dim>::active () const {
- return !has_children();
-};
-
-
-
-
-
-
-
-
// explicit instantiations
#include <grid/tria_boundary.h>
+#include <grid/tria_accessor.h>
#include <grid/tria_iterator.h>
#include <grid/tria.h>
#include <fstream>