From 43a163799b62ea8f476e34265a80e6dcd60d472b Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 23 Jul 1998 12:55:57 +0000 Subject: [PATCH] Change structure of the tria.h file a bit to single out parts which are not needed by everyone. git-svn-id: https://svn.dealii.org/trunk@453 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/tria.h | 387 +----------------- deal.II/deal.II/include/grid/tria_levels.h | 405 +++++++++++++++++++ deal.II/deal.II/source/dofs/dof_handler.cc | 1 + deal.II/deal.II/source/grid/tria.cc | 1 + deal.II/deal.II/source/grid/tria_accessor.cc | 1 + 5 files changed, 409 insertions(+), 386 deletions(-) create mode 100644 deal.II/deal.II/include/grid/tria_levels.h diff --git a/deal.II/deal.II/include/grid/tria.h b/deal.II/deal.II/include/grid/tria.h index 276fe663a1..139c931ecc 100644 --- a/deal.II/deal.II/include/grid/tria.h +++ b/deal.II/deal.II/include/grid/tria.h @@ -5,8 +5,6 @@ /*---------------------------- tria.h ---------------------------*/ #include -#include -#include #include @@ -19,6 +17,7 @@ template class LineAccessor; template class QuadAccessor; template class CellAccessor; +template class TriangulationLevel; template class TriaRawIterator; template class TriaIterator; @@ -58,390 +57,6 @@ enum MeshSmoothing { -/** - * General template for information belonging to one level of a multilevel - * hierarchy of a triangulation. This template is only declared to allow - * specializations for different dimensions. - * - * @see TriangulationLevel<1> - * @see TriangulationLevel<2> - */ -template -class TriangulationLevel; - - -/** - * Store all information which belongs to one level of the multilevel hierarchy. - * - * In #TriangulationLevel<0># all data is stored which is not - * dependant on the dimension, e.g. a field to store the - * refinement flag for the cells (what a cell actually is - * is declared elsewhere), etc. Actually, it is only cell-based - * data, like neighborship info or refinement flags. There is another - * field, which may fit in here, namely the material data (for cells) - * or the boundary indicators (for faces), but since we need for a line - * or quad either boundary information or material data, we store them - * with the lines and quads rather than with the common data. We may, - * however lose some memory in three dimensions, when we need the - * material data for cell, boundary data for the quads, but nothing - * for the lines. Since we only store one byte per line, quad or hex, - * this is a minor loss and we can live with that. - * - * @memo Information belonging to one level of the multilevel hierarchy. - */ -template <> -class TriangulationLevel<0> { - public: - /** - * Flags for the cells whether they are - * to be refined or not. The meaning - * what a cell is, is dimension specific, - * therefore also the length of this - * vector depends on the dimension: in - * one dimension, the length of this - * vector equals the length of the - * #lines# vector, in two dimensions - * that of the #quads# vector, etc. - */ - vector refine_flags; - - /** - * Same meaning as the one above, but - * specifies whether a cell must be - * coarsened. - */ - vector coarsen_flags; - - /** - * Levels and indices of the neighbors - * of the cells. Convention is, that the - * neighbors of the cell with index #i# - * are stored in the fields following - * $i*(2*real_space_dimension)$, e.g. in - * one spatial dimension, the neighbors - * of cell 0 are stored in #neighbors[0]# - * and #neighbors[1]#, the neighbors of - * cell 1 are stored in #neighbors[2]# - * and #neighbors[3]#, and so on. - * - * In neighbors, #neighbors[i].first# is - * the level, while #neighbors[i].first# - * is the index of the neighbor. - * - * If a neighbor does not exist (cell is - * at the boundary), #level=index=-1# - * is set. - * - * {\bf Conventions:} The #i#th neighbor - * of a cell is the one which shares - * the #i#th face (#Line# in 2D, #Quad# - * in 3D) of this cell. - * - * The neighbor of a cell has at most the - * same level as this cell, i.e. it may - * or may not be refined. - * - * In one dimension, a neighbor may have - * any level less or equal the level of - * this cell. If it has the same level, - * it may be refined an arbitrary number - * of times, but the neighbor pointer - * still points to the cell on the same - * level, while the neighbors of the - * childs of the neighbor may point to - * this cell or its children. - * - * In two and more dimensions, the - * neighbor is either on the same level - * and refined (in which case its children - * have neighbor pointers to this cell or - * its direct children), unrefined on - * the same level or one level down (in - * which case its neighbor pointer points - * to the mother cell of this cell). - */ - vector > neighbors; - - /** - * Reserve enough space to accomodate - * #total_cells# cells on this level. - * Since there are no #used# flags on this - * level, you have to give to total number - * of cells, not only the number of newly - * to accomodate ones, like in the - * #TriangulationLevel::reserve_space# - * functions, with #N>0#. - * - * Since the - * number of neighbors per cell depends - * on the dimensions, you have to pass - * that additionally. - */ - void reserve_space (const unsigned int total_cells, - const unsigned int dimension); - - /** - * Check the memory consistency of the - * different containers. Should only be - * called with the prepro flag #DEBUG# - * set. The function should be called from - * the functions of the higher - * #TriangulationLevel# classes. - */ - void monitor_memory (const unsigned int true_dimension) const; - - /** - * Exception - */ - DeclException3 (ExcMemoryWasted, - char*, int, int, - << "The container " << arg1 << " contains " - << arg2 << " elements, but it`s capacity is " - << arg3 << "."); - /** - * Exception - */ - DeclException2 (ExcMemoryInexact, - int, int, - << "The containers have sizes " << arg1 << " and " - << arg2 << ", which is not as expected."); -}; - - - -/** - * Store all information which belongs to one level of the multilevel hierarchy. - * - * In one dimension, this is a list of the lines associated with this level, - * as well as a list with the indices of the children of these lines. - * The #TriangulationsLevel# objects of higher dimensions are derived from - * this one. - * - * @memo Information belonging to one level of the multilevel hierarchy. - */ -template <> -class TriangulationLevel<1> : public TriangulationLevel<0> { - private: - - /** - * This subclass groups together all that - * is needed to describe the lines on one - * level. - */ - struct LinesData { - /** - * Vector of the lines belonging to - * this level. The index of the line - * on this level equals the index in - * this container, while the global - * index of a line is stored in the - * line itself. - */ - vector lines; - /** - * Index of the first child of a line - * in the list on the next level. - * Since when lines are refined, both - * children are created at the same - * time, they are appended to the list - * on the next level after each other. - * We therefore only store the index - * of the first child, the second - * follows immediately afterwards. - * - * If a line has no children, -1 is - * stored in this list. A line is - * called active if it has no - * children. The function - * #TriaIterator::active()# - * tests for this. - */ - vector children; - - /** - * Vector storing whether a line is - * used in the #lines# vector. - * - * Since it is difficult to delete - * elements in a #vector#, when an - * element is not needed any more - * (e.g. after derefinement), it is - * not deleted from the list, but - * rather the according #used# flag - * is set to #false#. - */ - vector used; - - /** - * Make available a field for user data, - * one bit per line. This field is usually - * used when an operation runs over all - * cells and needs information whether - * another cell (e.g. a neighbor) has - * already been processed. - * - * You can clear all used flags using - * #Triangulation<>::clear_user_flags()#. - */ - vector user_flags; - - /** - * Store boundary and material data. In - * one dimension, this field stores - * the material id of a line, which is - * number between 0 and 254. In more - * than one dimension, lines have no - * material id, but they may be at the - * boundary; then, we store the - * boundary indicator in this field, - * which denotes to which part of the - * boundary this line belongs and which - * boundary conditions hold on this - * part. The boundary indicator also - * is a number between zero and 254; - * the id 255 is reserved for lines - * in the interior and may be used - * to check whether a line is at the - * boundary or not, which otherwise - * is not possible if you don't know - * which cell it belongs to. - */ - vector material_id; - }; - - public: - /** - * Data about the lines. - */ - LinesData lines; - - /** - * Assert that enough space is allocated - * to accomodate #new_lines# new lines. - * This function does not only call - * #vector::reserve()#, but does really - * append the needed elements. - * There are pendants for higher - * dimensions, which you have to call - * explicitely (they can't hand down the - * call because there is no easy relation - * between the number of new quads and - * the number of new lines, etc.). Also - * don't forget to call the - * #TriangulationLevel<0>::reserve_space# - * function. - */ - void reserve_space (const unsigned int new_lines); - - /** - * Check the memory consistency of the - * different containers. Should only be - * called with the prepro flag #DEBUG# - * set. The function should be called from - * the functions of the higher - * #TriangulationLevel# classes. - */ - void monitor_memory (const unsigned int true_dimension) const; -}; - - - - -/** - * Store all information which belongs to one level of the multilevel hierarchy. - * - * In 2D this is a vector of the lines and one of the - * quads on this levels, as well as a the two associated vectors holding - * information about the children of these lines and quads. - * - * The vector of lines and their children is derived from - * #TriangulationLevel<1>#. - * - * @memo Information belonging to one level of the multilevel hierarchy. - */ -template <> -class TriangulationLevel<2> : public TriangulationLevel<1> -{ - /** - * This subclass groups together all that - * is needed to describe the quads on one - * level. - * - * It is fully analogous to the - * #LinesData# structure inherited from - * #Triangulation<1>#. - */ - struct QuadsData { - /** - * Same as for the #lines# array. - */ - vector quads; - /** - * Same as for the #LineData::chilren# - * array, but since there are four - * children, the index points to the - * first while the other three are - * following immediately afterwards. - */ - vector children; - - /** - * Same as for #LineData::used#. - */ - vector used; - - /** - * Same as for #LineData::used#. - */ - vector user_flags; - - /** - * Store boundary and material data. In - * two dimension, this field stores - * the material id of a quad, which is - * number between 0 and 254. In more - * than two dimensions, quads have no - * material id, but they may be at the - * boundary; then, we store the - * boundary indicator in this field, - * which denotes to which part of the - * boundary this line belongs and which - * boundary conditions hold on this - * part. The boundary indicator also - * is a number between zero and 254; - * the id 255 is reserved for quads - * in the interior and may be used - * to check whether a quad is at the - * boundary or not, which otherwise - * is not possible if you don't know - * which cell it belongs to. - */ - vector material_id; - }; - - public: - /** - * Data about the quads. - */ - QuadsData quads; - - /** - * Assert that enough space is allocated - * to accomodate #new_quads# new quads. - */ - void reserve_space (const unsigned int new_quads); - - /** - * Check the memory consistency of the - * different containers. Should only be - * called with the prepro flag #DEBUG# - * set. The function should be called from - * the functions of the higher - * #TriangulationLevel# classes. - */ - void monitor_memory (const unsigned int true_dimension) const; -}; - diff --git a/deal.II/deal.II/include/grid/tria_levels.h b/deal.II/deal.II/include/grid/tria_levels.h new file mode 100644 index 0000000000..db4f3fe701 --- /dev/null +++ b/deal.II/deal.II/include/grid/tria_levels.h @@ -0,0 +1,405 @@ +/*---------------------------- tria_levels.h ---------------------------*/ +/* $Id$ */ +#ifndef __tria_levels_H +#define __tria_levels_H +/*---------------------------- tria_levels.h ---------------------------*/ + + + +#include +#include +#include +#include + + +/** + * General template for information belonging to one level of a multilevel + * hierarchy of a triangulation. This template is only declared to allow + * specializations for different dimensions. + * + * @see TriangulationLevel<1> + * @see TriangulationLevel<2> + */ +template +class TriangulationLevel; + + +/** + * Store all information which belongs to one level of the multilevel hierarchy. + * + * In #TriangulationLevel<0># all data is stored which is not + * dependant on the dimension, e.g. a field to store the + * refinement flag for the cells (what a cell actually is + * is declared elsewhere), etc. Actually, it is only cell-based + * data, like neighborship info or refinement flags. There is another + * field, which may fit in here, namely the material data (for cells) + * or the boundary indicators (for faces), but since we need for a line + * or quad either boundary information or material data, we store them + * with the lines and quads rather than with the common data. We may, + * however lose some memory in three dimensions, when we need the + * material data for cell, boundary data for the quads, but nothing + * for the lines. Since we only store one byte per line, quad or hex, + * this is a minor loss and we can live with that. + * + * @memo Information belonging to one level of the multilevel hierarchy. + */ +template <> +class TriangulationLevel<0> { + public: + /** + * Flags for the cells whether they are + * to be refined or not. The meaning + * what a cell is, is dimension specific, + * therefore also the length of this + * vector depends on the dimension: in + * one dimension, the length of this + * vector equals the length of the + * #lines# vector, in two dimensions + * that of the #quads# vector, etc. + */ + vector refine_flags; + + /** + * Same meaning as the one above, but + * specifies whether a cell must be + * coarsened. + */ + vector coarsen_flags; + + /** + * Levels and indices of the neighbors + * of the cells. Convention is, that the + * neighbors of the cell with index #i# + * are stored in the fields following + * $i*(2*real_space_dimension)$, e.g. in + * one spatial dimension, the neighbors + * of cell 0 are stored in #neighbors[0]# + * and #neighbors[1]#, the neighbors of + * cell 1 are stored in #neighbors[2]# + * and #neighbors[3]#, and so on. + * + * In neighbors, #neighbors[i].first# is + * the level, while #neighbors[i].first# + * is the index of the neighbor. + * + * If a neighbor does not exist (cell is + * at the boundary), #level=index=-1# + * is set. + * + * {\bf Conventions:} The #i#th neighbor + * of a cell is the one which shares + * the #i#th face (#Line# in 2D, #Quad# + * in 3D) of this cell. + * + * The neighbor of a cell has at most the + * same level as this cell, i.e. it may + * or may not be refined. + * + * In one dimension, a neighbor may have + * any level less or equal the level of + * this cell. If it has the same level, + * it may be refined an arbitrary number + * of times, but the neighbor pointer + * still points to the cell on the same + * level, while the neighbors of the + * childs of the neighbor may point to + * this cell or its children. + * + * In two and more dimensions, the + * neighbor is either on the same level + * and refined (in which case its children + * have neighbor pointers to this cell or + * its direct children), unrefined on + * the same level or one level down (in + * which case its neighbor pointer points + * to the mother cell of this cell). + */ + vector > neighbors; + + /** + * Reserve enough space to accomodate + * #total_cells# cells on this level. + * Since there are no #used# flags on this + * level, you have to give to total number + * of cells, not only the number of newly + * to accomodate ones, like in the + * #TriangulationLevel::reserve_space# + * functions, with #N>0#. + * + * Since the + * number of neighbors per cell depends + * on the dimensions, you have to pass + * that additionally. + */ + void reserve_space (const unsigned int total_cells, + const unsigned int dimension); + + /** + * Check the memory consistency of the + * different containers. Should only be + * called with the prepro flag #DEBUG# + * set. The function should be called from + * the functions of the higher + * #TriangulationLevel# classes. + */ + void monitor_memory (const unsigned int true_dimension) const; + + /** + * Exception + */ + DeclException3 (ExcMemoryWasted, + char*, int, int, + << "The container " << arg1 << " contains " + << arg2 << " elements, but it`s capacity is " + << arg3 << "."); + /** + * Exception + */ + DeclException2 (ExcMemoryInexact, + int, int, + << "The containers have sizes " << arg1 << " and " + << arg2 << ", which is not as expected."); +}; + + + +/** + * Store all information which belongs to one level of the multilevel hierarchy. + * + * In one dimension, this is a list of the lines associated with this level, + * as well as a list with the indices of the children of these lines. + * The #TriangulationsLevel# objects of higher dimensions are derived from + * this one. + * + * @memo Information belonging to one level of the multilevel hierarchy. + */ +template <> +class TriangulationLevel<1> : public TriangulationLevel<0> { + private: + + /** + * This subclass groups together all that + * is needed to describe the lines on one + * level. + */ + struct LinesData { + /** + * Vector of the lines belonging to + * this level. The index of the line + * on this level equals the index in + * this container, while the global + * index of a line is stored in the + * line itself. + */ + vector lines; + /** + * Index of the first child of a line + * in the list on the next level. + * Since when lines are refined, both + * children are created at the same + * time, they are appended to the list + * on the next level after each other. + * We therefore only store the index + * of the first child, the second + * follows immediately afterwards. + * + * If a line has no children, -1 is + * stored in this list. A line is + * called active if it has no + * children. The function + * #TriaIterator::active()# + * tests for this. + */ + vector children; + + /** + * Vector storing whether a line is + * used in the #lines# vector. + * + * Since it is difficult to delete + * elements in a #vector#, when an + * element is not needed any more + * (e.g. after derefinement), it is + * not deleted from the list, but + * rather the according #used# flag + * is set to #false#. + */ + vector used; + + /** + * Make available a field for user data, + * one bit per line. This field is usually + * used when an operation runs over all + * cells and needs information whether + * another cell (e.g. a neighbor) has + * already been processed. + * + * You can clear all used flags using + * #Triangulation<>::clear_user_flags()#. + */ + vector user_flags; + + /** + * Store boundary and material data. In + * one dimension, this field stores + * the material id of a line, which is + * number between 0 and 254. In more + * than one dimension, lines have no + * material id, but they may be at the + * boundary; then, we store the + * boundary indicator in this field, + * which denotes to which part of the + * boundary this line belongs and which + * boundary conditions hold on this + * part. The boundary indicator also + * is a number between zero and 254; + * the id 255 is reserved for lines + * in the interior and may be used + * to check whether a line is at the + * boundary or not, which otherwise + * is not possible if you don't know + * which cell it belongs to. + */ + vector material_id; + }; + + public: + /** + * Data about the lines. + */ + LinesData lines; + + /** + * Assert that enough space is allocated + * to accomodate #new_lines# new lines. + * This function does not only call + * #vector::reserve()#, but does really + * append the needed elements. + * There are pendants for higher + * dimensions, which you have to call + * explicitely (they can't hand down the + * call because there is no easy relation + * between the number of new quads and + * the number of new lines, etc.). Also + * don't forget to call the + * #TriangulationLevel<0>::reserve_space# + * function. + */ + void reserve_space (const unsigned int new_lines); + + /** + * Check the memory consistency of the + * different containers. Should only be + * called with the prepro flag #DEBUG# + * set. The function should be called from + * the functions of the higher + * #TriangulationLevel# classes. + */ + void monitor_memory (const unsigned int true_dimension) const; +}; + + + + +/** + * Store all information which belongs to one level of the multilevel hierarchy. + * + * In 2D this is a vector of the lines and one of the + * quads on this levels, as well as a the two associated vectors holding + * information about the children of these lines and quads. + * + * The vector of lines and their children is derived from + * #TriangulationLevel<1>#. + * + * @memo Information belonging to one level of the multilevel hierarchy. + */ +template <> +class TriangulationLevel<2> : public TriangulationLevel<1> +{ + /** + * This subclass groups together all that + * is needed to describe the quads on one + * level. + * + * It is fully analogous to the + * #LinesData# structure inherited from + * #Triangulation<1>#. + */ + struct QuadsData { + /** + * Same as for the #lines# array. + */ + vector quads; + /** + * Same as for the #LineData::chilren# + * array, but since there are four + * children, the index points to the + * first while the other three are + * following immediately afterwards. + */ + vector children; + + /** + * Same as for #LineData::used#. + */ + vector used; + + /** + * Same as for #LineData::used#. + */ + vector user_flags; + + /** + * Store boundary and material data. In + * two dimension, this field stores + * the material id of a quad, which is + * number between 0 and 254. In more + * than two dimensions, quads have no + * material id, but they may be at the + * boundary; then, we store the + * boundary indicator in this field, + * which denotes to which part of the + * boundary this line belongs and which + * boundary conditions hold on this + * part. The boundary indicator also + * is a number between zero and 254; + * the id 255 is reserved for quads + * in the interior and may be used + * to check whether a quad is at the + * boundary or not, which otherwise + * is not possible if you don't know + * which cell it belongs to. + */ + vector material_id; + }; + + public: + /** + * Data about the quads. + */ + QuadsData quads; + + /** + * Assert that enough space is allocated + * to accomodate #new_quads# new quads. + */ + void reserve_space (const unsigned int new_quads); + + /** + * Check the memory consistency of the + * different containers. Should only be + * called with the prepro flag #DEBUG# + * set. The function should be called from + * the functions of the higher + * #TriangulationLevel# classes. + */ + void monitor_memory (const unsigned int true_dimension) const; +}; + + + + +/*---------------------------- tria_levels.h ---------------------------*/ +/* end of #ifndef __tria_levels_H */ +#endif +/*---------------------------- tria_levels.h ---------------------------*/ diff --git a/deal.II/deal.II/source/dofs/dof_handler.cc b/deal.II/deal.II/source/dofs/dof_handler.cc index a2855ab38e..e4a921619e 100644 --- a/deal.II/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/deal.II/source/dofs/dof_handler.cc @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 5b9eba2378..2b72797abd 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -1,6 +1,7 @@ /* $Id$ */ #include +#include #include #include #include diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index 629f49f691..51d54549cd 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -1,6 +1,7 @@ /* $Id$ */ #include +#include #include #include #include -- 2.39.5