internal::Triangulation::TriaObjects<internal::Triangulation::Line> &
TriaObjectAccessor<1,1>::lines() const
{
- return this->tria->levels[this->present_level]->lines;
+ return this->tria->levels[this->present_level]->cells;
}
// the vector?
while (this->present_index
>=
- static_cast<int>(this->tria->levels[this->present_level]->lines.cells.size()))
+ static_cast<int>(this->tria->levels[this->present_level]->cells.cells.size()))
{
// no -> go one level up until we find
// one with more than zero cells
return;
}
// else
- this->present_index = this->tria->levels[this->present_level]->lines.cells.size()-1;
+ this->present_index = this->tria->levels[this->present_level]->cells.cells.size()-1;
}
}
internal::Triangulation::TriaObjects<internal::Triangulation::Quad> &
TriaObjectAccessor<2,2>::quads() const
{
- return this->tria->levels[this->present_level]->quads;
+ return this->tria->levels[this->present_level]->cells;
}
{
Assert (this->state() == IteratorState::valid,
TriaAccessorExceptions::ExcDereferenceInvalidObject());
- return this->tria->levels[this->present_level]->hexes.used[this->present_index];
+ return this->tria->levels[this->present_level]->cells.used[this->present_index];
}
TriaObjectAccessor<3,3>::user_flag_set () const
{
Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
- return this->tria->levels[this->present_level]->hexes.user_flags[this->present_index];
+ return this->tria->levels[this->present_level]->cells.user_flags[this->present_index];
}
TriaObjectAccessor<3,3>::set_user_flag () const
{
Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
- this->tria->levels[this->present_level]->hexes.user_flags[this->present_index] = true;
+ this->tria->levels[this->present_level]->cells.user_flags[this->present_index] = true;
}
void TriaObjectAccessor<3,3>::clear_user_flag () const
{
Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
- this->tria->levels[this->present_level]->hexes.user_flags[this->present_index] = false;
+ this->tria->levels[this->present_level]->cells.user_flags[this->present_index] = false;
}
{
Assert (i<6, ExcIndexRange(i,0,6));
- return this->tria->levels[this->present_level]->hexes.cells[this->present_index].face(i);
+ return this->tria->levels[this->present_level]->cells.cells[this->present_index].face(i);
}
{
Assert (this->state() == IteratorState::valid,
TriaAccessorExceptions::ExcDereferenceInvalidObject());
- return (this->tria->levels[this->present_level]->hexes.children[this->present_index] != -1);
+ return (this->tria->levels[this->present_level]->cells.children[this->present_index] != -1);
}
{
Assert (i<8, ExcIndexRange(i,0,8));
Assert (has_children(), TriaAccessorExceptions::ExcCellHasNoChildren());
- return this->tria->levels[this->present_level]->hexes.children[this->present_index]+i;
+ return this->tria->levels[this->present_level]->cells.children[this->present_index]+i;
}
ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell));
Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face
< this->tria->levels[this->present_level]
- ->hexes.face_orientations.size(),
+ ->cells.face_orientations.size(),
ExcInternalError());
return (this->tria->levels[this->present_level]
- ->hexes.face_orientations[this->present_index *
+ ->cells.face_orientations[this->present_index *
GeometryInfo<3>::faces_per_cell
+ face]);
}
ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell));
Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face
< this->tria->levels[this->present_level]
- ->hexes.face_flips.size(),
+ ->cells.face_flips.size(),
ExcInternalError());
return (this->tria->levels[this->present_level]
- ->hexes.face_flips[this->present_index *
+ ->cells.face_flips[this->present_index *
GeometryInfo<3>::faces_per_cell
+ face]);
}
ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell));
Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face
< this->tria->levels[this->present_level]
- ->hexes.face_rotations.size(),
+ ->cells.face_rotations.size(),
ExcInternalError());
return (this->tria->levels[this->present_level]
- ->hexes.face_rotations[this->present_index *
+ ->cells.face_rotations[this->present_index *
GeometryInfo<3>::faces_per_cell
+ face]);
}
// the vector?
while (this->present_index
>=
- static_cast<int>(this->tria->levels[this->present_level]->hexes.cells.size()))
+ static_cast<int>(this->tria->levels[this->present_level]->cells.cells.size()))
{
// no -> go one level up
++this->present_level;
return;
}
// else
- this->present_index = this->tria->levels[this->present_level]->hexes.cells.size()-1;
+ this->present_index = this->tria->levels[this->present_level]->cells.cells.size()-1;
}
}
{
namespace Triangulation
{
-
-/**
- * General template for information belonging to one level of a multilevel
- * hierarchy of a triangulation. However, only the cells are really
- * level-based data if anisotropic rfeinement is allowed. Therefore, only the
- * information concerning cells is considered here, the information concerning
- * cell-faces can be found in the <tt>TriaFaces</tt> classes.
- *
- * This template is only declared to allow
- * specializations for different dimensions.
- *
- * @ingroup grid
- */
- template <int dim>
- class TriaLevel
- {
- };
-
-
/**
* Store all information which belongs to one level of the multilevel
* hierarchy.
*
- * In TriaLevel<0> all data is stored which is not dependent on the
+ * In TriaLevel, all cell data is stored which is not dependent 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
+ * (what a cell actually is is declared elsewhere), etc. See also
+ * TriaObjects for non leveloriented data.
+ *
+ * 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
* material data for cells.
*
* @ingroup grid
- * @author Wolfgang Bangerth, 1998
+ * @author Wolfgang Bangerth, Guido Kanschat, 1998, 2007
*/
- template <>
- class TriaLevel<0>
+ template <int dim>
+ class TriaLevel
{
public:
/**
* of this object.
*/
unsigned int memory_consumption () const;
+
+ /**
+ * The object containing the data on lines and
+ * related functions
+ */
+ TriaObjects<TriaObject<dim> > cells;
+
/**
* Exception
<< "The containers have sizes " << arg1 << " and "
<< arg2 << ", which is not as expected.");
};
-
-
-
+
+//TODO: Replace TriaObjectsHex to avoid this specialization
+
/**
- * Store all information which belongs to one level of the multilevel hierarchy.
- *
- * In one dimension, this contains the lines on this level.
- *
- * @ingroup grid
- * @author Wolfgang Bangerth, 1998
+ * Specialization of TriaLevels for 3D. Since we need TriaObjectsHex
+ * instead of TriaObjects. Refer to the documentation of the template
+ * for details.
*/
- template <>
- class TriaLevel<1> : public TriaLevel<0>
-
+ template<>
+ class TriaLevel<3>
{
public:
- /**
- * The object containing the data on lines and
- * related functions
- */
- TriaObjects<Line> lines;
-
- public:
- /**
- * Determine an estimate for the
- * memory consumption (in bytes)
- * of this object.
- */
+ std::vector<bool> refine_flags;
+ std::vector<bool> coarsen_flags;
+ std::vector<std::pair<int,int> > neighbors;
+ std::vector<unsigned int> subdomain_ids;
+ void reserve_space (const unsigned int total_cells,
+ const unsigned int dimension);
+ void monitor_memory (const unsigned int true_dimension) const;
unsigned int memory_consumption () const;
- };
-
+ TriaObjectsHex cells;
-/**
- * Store all information which belongs to one level of the multilevel hierarchy.
- *
- * In 2D this is a vector ocontains the quads on this level.
- *
- * @ingroup grid
- * @author Wolfgang Bangerth, 1998
- */
- template <>
- class TriaLevel<2> : public TriaLevel<0>
- {
- public:
- /**
- * The object containing the data on quads and
- * related functions
- */
- TriaObjects<Quad> quads;
-
- public:
- /**
- * Determine an estimate for the
- * memory consumption (in bytes)
- * of this object.
+ /**
+ * Exception
*/
- unsigned int memory_consumption () const;
- };
-
-
-
-/**
- * Store all information which belongs to one level of the multilevel hierarchy.
- *
- * In 3D this contains the hexahedra on this levels,
- *
- * @ingroup grid
- * @author Wolfgang Bangerth, 1998, 2003
- */
- template <>
- class TriaLevel<3> : public TriaLevel<0>
- {
- public:
- /**
- * The object containing the data on hexes and
- * related functions
- */
- TriaObjectsHex hexes;
-
- public:
- /**
- * Determine an estimate for the
- * memory consumption (in bytes)
- * of this object.
+ DeclException3 (ExcMemoryWasted,
+ char*, int, int,
+ << "The container " << arg1 << " contains "
+ << arg2 << " elements, but it`s capacity is "
+ << arg3 << ".");
+ /**
+ * Exception
*/
- unsigned int memory_consumption () const;
+ DeclException2 (ExcMemoryInexact,
+ int, int,
+ << "The containers have sizes " << arg1 << " and "
+ << arg2 << ", which is not as expected.");
};
+
+
}
}
+
+
DEAL_II_NAMESPACE_CLOSE
#endif
* @ingroup grid
*/
- class TriaObjectsHex: public TriaObjects<Hexahedron>
+ class TriaObjectsHex: public TriaObjects<TriaObject<3> >
{
public:
// reserve enough space
levels.push_back (new internal::Triangulation::TriaLevel<dim>);
- levels[0]->internal::Triangulation::TriaLevel<0>
- ::reserve_space (cells.size(), dim);
- levels[0]->lines.reserve_space (cells.size());
+ levels[0]->reserve_space (cells.size(), dim);
+ levels[0]->cells.reserve_space (cells.size());
// make up cells
raw_line_iterator next_free_line = begin_raw_line ();
// reserve enough space
levels.push_back (new internal::Triangulation::TriaLevel<dim>);
faces = new internal::Triangulation::TriaFaces<dim>;
- levels[0]->internal::Triangulation::TriaLevel<0>
- ::reserve_space (cells.size(), dim);
+ levels[0]->reserve_space (cells.size(), dim);
faces->lines.reserve_space (needed_lines.size());
- levels[0]->quads.reserve_space (cells.size());
+ levels[0]->cells.reserve_space (cells.size());
// make up lines
if (true)
// reserve enough space
levels.push_back (new internal::Triangulation::TriaLevel<dim>);
faces = new internal::Triangulation::TriaFaces<dim>;
- levels[0]->internal::Triangulation::TriaLevel<0>
- ::reserve_space (cells.size(), dim);
+ levels[0]->reserve_space (cells.size(), dim);
faces->lines.reserve_space (needed_lines.size());
// make up lines
/////////////////////////////////
// finally create the cells
- levels[0]->hexes.reserve_space (cells.size());
+ levels[0]->cells.reserve_space (cells.size());
// store for each quad index the
// adjacent cells
void Triangulation<1>::clear_user_data ()
{
for (unsigned int level=0;level<levels.size();++level)
- levels[level]->lines.clear_user_data();
+ levels[level]->cells.clear_user_data();
}
void Triangulation<2>::clear_user_data ()
{
for (unsigned int level=0;level<levels.size();++level)
- levels[level]->quads.clear_user_data();
+ levels[level]->cells.clear_user_data();
faces->lines.clear_user_data();
}
void Triangulation<3>::clear_user_data ()
{
for (unsigned int level=0;level<levels.size();++level)
- levels[level]->hexes.clear_user_data();
+ levels[level]->cells.clear_user_data();
faces->quads.clear_user_data();
faces->lines.clear_user_data();
}
{
Assert (level<levels.size(), ExcInvalidLevel(level));
- if (levels[level]->lines.cells.size() == 0)
+ if (levels[level]->cells.cells.size() == 0)
return end_line ();
return raw_line_iterator (const_cast<Triangulation<1>*>(this),
{
Assert (level<levels.size(), ExcInvalidLevel(level));
- if (levels[level]->quads.cells.size() == 0)
+ if (levels[level]->cells.cells.size() == 0)
return end_quad();
return raw_quad_iterator (const_cast<Triangulation<2>*>(this),
{
Assert (level<levels.size(), ExcInvalidLevel(level));
- if (levels[level]->hexes.cells.size() == 0)
+ if (levels[level]->cells.cells.size() == 0)
return end_hex();
return raw_hex_iterator (const_cast<Triangulation<dim>*>(this),
Triangulation<1>::last_raw_line (const unsigned int level) const
{
Assert (level<levels.size(), ExcInvalidLevel(level));
- Assert (levels[level]->lines.cells.size() != 0,
+ Assert (levels[level]->cells.cells.size() != 0,
ExcEmptyLevel (level));
return raw_line_iterator (const_cast<Triangulation<1>*>(this),
level,
- levels[level]->lines.cells.size()-1);
+ levels[level]->cells.cells.size()-1);
}
#endif
{
Assert (level<levels.size(),
ExcInvalidLevel(level));
- Assert (levels[level]->quads.cells.size() != 0,
+ Assert (levels[level]->cells.cells.size() != 0,
ExcEmptyLevel (level));
return raw_quad_iterator (const_cast<Triangulation<2>*>(this),
level,
- levels[level]->quads.cells.size()-1);
+ levels[level]->cells.cells.size()-1);
}
#endif
{
Assert (level<levels.size(),
ExcInvalidLevel(level));
- Assert (levels[level]->hexes.cells.size() != 0,
+ Assert (levels[level]->cells.cells.size() != 0,
ExcEmptyLevel (level));
return raw_hex_iterator (const_cast<Triangulation<dim>*>(this),
level,
- levels[level]->hexes.cells.size()-1);
+ levels[level]->cells.cells.size()-1);
}
unsigned int Triangulation<1>::n_raw_lines (const unsigned int level) const
{
Assert(level < n_levels(), ExcIndexRange(level,0,n_levels()));
- return levels[level]->lines.cells.size();
+ return levels[level]->cells.cells.size();
}
unsigned int Triangulation<2>::n_raw_quads (const unsigned int level) const
{
Assert(level < n_levels(), ExcIndexRange(level,0,n_levels()));
- return levels[level]->quads.cells.size();
+ return levels[level]->cells.cells.size();
}
#endif
unsigned int Triangulation<dim>::n_raw_hexs (const unsigned int level) const
{
Assert(level < n_levels(), ExcIndexRange(level,0,n_levels()));
- return levels[level]->hexes.cells.size();
+ return levels[level]->cells.cells.size();
}
// count number of used cells
// on the next higher level
const unsigned int used_cells
- = std::count_if (levels[level+1]->lines.used.begin(),
- levels[level+1]->lines.used.end(),
+ = std::count_if (levels[level+1]->cells.used.begin(),
+ levels[level+1]->cells.used.end(),
std::bind2nd (std::equal_to<bool>(), true));
// reserve space for the
// level as well as for the
// 2*flagged_cells that will be
// created on that level
- levels[level+1]->
- internal::Triangulation::TriaLevel<0>
- ::reserve_space (used_cells+
- GeometryInfo<1>::children_per_cell *
- flagged_cells, 1);
+ levels[level+1]->reserve_space(
+ used_cells+
+ GeometryInfo<1>::children_per_cell * flagged_cells, 1);
// reserve space for
// 2*flagged_cells new lines on
// the next higher level
- levels[level+1]->lines.
+ levels[level+1]->cells.
reserve_space (GeometryInfo<1>::children_per_cell*flagged_cells);
needed_vertices += flagged_cells;
#ifdef DEBUG
for (unsigned int level=0; level<levels.size(); ++level)
- levels[level]->lines.monitor_memory (1);
+ levels[level]->cells.monitor_memory (1);
// check whether really all
// refinement flags are reset (also
// count number of used cells
// on the next higher level
const unsigned int used_cells
- = std::count_if (levels[level+1]->quads.used.begin(),
- levels[level+1]->quads.used.end(),
+ = std::count_if (levels[level+1]->cells.used.begin(),
+ levels[level+1]->cells.used.end(),
std::bind2nd (std::equal_to<bool>(), true));
// level as well as for the
// 4*flagged_cells that will be
// created on that level
- levels[level+1]->
- internal::Triangulation::TriaLevel<0>
- ::reserve_space (used_cells+4*flagged_cells, 2);
+ levels[level+1]->reserve_space (used_cells+4*flagged_cells, 2);
// reserve space for
// 4*flagged_cells
// new quads on the next higher
// level
- levels[level+1]->quads.
+ levels[level+1]->cells.
reserve_space (4*flagged_cells);
}
#ifdef DEBUG
for (unsigned int level=0; level<levels.size(); ++level)
- levels[level]->quads.monitor_memory (2);
+ levels[level]->cells.monitor_memory (2);
// check whether really all
// refinement flags are reset (also
// count number of used cells on
// the next higher level
const unsigned int used_cells
- = std::count_if (levels[level+1]->hexes.used.begin(),
- levels[level+1]->hexes.used.end(),
+ = std::count_if (levels[level+1]->cells.used.begin(),
+ levels[level+1]->cells.used.end(),
std::bind2nd (std::equal_to<bool>(), true));
// level as well as for the
// 8*flagged_cells that will be
// created on that level
- levels[level+1]->
- internal::Triangulation::TriaLevel<0>
- ::reserve_space (used_cells+8*flagged_cells, 3);
+ levels[level+1]->reserve_space (used_cells+8*flagged_cells, 3);
// reserve space for
// 8*flagged_cells
// new hexes on the next higher
// level
- levels[level+1]->hexes.
- reserve_space (8*flagged_cells);
+ levels[level+1]->cells.reserve_space (8*flagged_cells);
}
// now count the quads and
#ifdef DEBUG
for (unsigned int level=0; level<levels.size(); ++level)
- levels[level]->hexes.monitor_memory (3);
+ levels[level]->cells.monitor_memory (3);
// check whether really all
// refinement flags are reset (also
{
// count lines on this level
number_cache.n_lines_level[level] = 0;
- if (levels[level]->lines.cells.size() != 0)
+ if (levels[level]->cells.cells.size() != 0)
{
line_iterator line = begin_line (level),
endc = (level == levels.size()-1 ?
{
// count lines on this level
number_cache.n_active_lines_level[level] = 0;
- if (levels[level]->lines.cells.size() != 0)
+ if (levels[level]->cells.cells.size() != 0)
{
active_line_iterator line = begin_active_line (level),
endc = end_active_line (level);
{
// count quads on this level
number_cache.n_quads_level[level] = 0;
- if (levels[level]->quads.cells.size() != 0)
+ if (levels[level]->cells.cells.size() != 0)
{
quad_iterator quad = begin_quad (level),
endc = (level == levels.size()-1 ?
{
// count quads on this level
number_cache.n_active_quads_level[level] = 0;
- if (levels[level]->quads.cells.size() != 0)
+ if (levels[level]->cells.cells.size() != 0)
{
active_quad_iterator quad = begin_active_quad (level),
endc = end_active_quad (level);
{
// count hexes on this level
number_cache.n_hexes_level[level] = 0;
- if (levels[level]->hexes.cells.size() != 0)
+ if (levels[level]->cells.cells.size() != 0)
{
hex_iterator hex = begin_hex (level),
endc = (level == levels.size()-1 ?
{
// count hexes on this level
number_cache.n_active_hexes_level[level] = 0;
- if (levels[level]->hexes.cells.size() != 0)
+ if (levels[level]->cells.cells.size() != 0)
{
active_hex_iterator hex = begin_active_hex (level),
endc = end_active_hex (level);
TriaObjectAccessor<3, 3>::set (const internal::Triangulation::Hexahedron &hex) const
{
this->tria->levels[this->present_level]
- ->hexes.cells[this->present_index] = hex;
+ ->cells.cells[this->present_index] = hex;
}
#endif
{
Assert (this->state() == IteratorState::valid,
TriaAccessorExceptions::ExcDereferenceInvalidObject());
- this->tria->levels[this->present_level]->hexes.used[this->present_index] = true;
+ this->tria->levels[this->present_level]->cells.used[this->present_index] = true;
}
{
Assert (this->state() == IteratorState::valid,
TriaAccessorExceptions::ExcDereferenceInvalidObject());
- this->tria->levels[this->present_level]->hexes.used[this->present_index] = false;
+ this->tria->levels[this->present_level]->cells.used[this->present_index] = false;
}
#endif
void TriaObjectAccessor<3, 3>::set_user_pointer (void *p) const
{
Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
- this->tria->levels[this->present_level]->hexes.user_pointer(this->present_index) = p;
+ this->tria->levels[this->present_level]->cells.user_pointer(this->present_index) = p;
}
void TriaObjectAccessor<3, 3>::clear_user_pointer () const
{
Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
- this->tria->levels[this->present_level]->hexes.user_pointer(this->present_index) = 0;
+ this->tria->levels[this->present_level]->cells.user_pointer(this->present_index) = 0;
}
void * TriaObjectAccessor<3, 3>::user_pointer () const
{
Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
- return this->tria->levels[this->present_level]->hexes.user_pointer(this->present_index);
+ return this->tria->levels[this->present_level]->cells.user_pointer(this->present_index);
}
void TriaObjectAccessor<3, 3>::set_user_index (unsigned int p) const
{
Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
- this->tria->levels[this->present_level]->hexes.user_index(this->present_index) = p;
+ this->tria->levels[this->present_level]->cells.user_index(this->present_index) = p;
}
void TriaObjectAccessor<3, 3>::clear_user_index () const
{
Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
- this->tria->levels[this->present_level]->hexes.user_index(this->present_index) = 0;
+ this->tria->levels[this->present_level]->cells.user_index(this->present_index) = 0;
}
unsigned int TriaObjectAccessor<3, 3>::user_index () const
{
Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
- return this->tria->levels[this->present_level]->hexes.user_index(this->present_index);
+ return this->tria->levels[this->present_level]->cells.user_index(this->present_index);
}
#endif
(!has_children() && (index>=0)),
TriaAccessorExceptions::ExcCantSetChildren(index));
- this->tria->levels[this->present_level]->hexes.children[this->present_index] = index;
+ this->tria->levels[this->present_level]->cells.children[this->present_index] = index;
}
#endif
ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell));
Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face
< this->tria->levels[this->present_level]
- ->hexes.face_orientations.size(),
+ ->cells.face_orientations.size(),
ExcInternalError());
this->tria->levels[this->present_level]
- ->hexes.face_orientations[this->present_index *
+ ->cells.face_orientations[this->present_index *
GeometryInfo<3>::faces_per_cell
+
face] = orientation;
ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell));
Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face
< this->tria->levels[this->present_level]
- ->hexes.face_flips.size(),
+ ->cells.face_flips.size(),
ExcInternalError());
this->tria->levels[this->present_level]
- ->hexes.face_flips[this->present_index *
+ ->cells.face_flips[this->present_index *
GeometryInfo<3>::faces_per_cell
+
face] = flip;
ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell));
Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face
< this->tria->levels[this->present_level]
- ->hexes.face_rotations.size(),
+ ->cells.face_rotations.size(),
ExcInternalError());
this->tria->levels[this->present_level]
- ->hexes.face_rotations[this->present_index *
+ ->cells.face_rotations[this->present_index *
GeometryInfo<3>::faces_per_cell
+
face] = rotation;
unsigned char CellAccessor<3>::material_id () const
{
Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
- return this->tria->levels[this->present_level]->hexes.material_id[this->present_index];
+ return this->tria->levels[this->present_level]->cells.material_id[this->present_index];
}
template <>
void CellAccessor<3>::set_material_id (const unsigned char mat_id) const
{
Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
- this->tria->levels[this->present_level]->hexes.material_id[this->present_index]
+ this->tria->levels[this->present_level]->cells.material_id[this->present_index]
= mat_id;
}
// $Id$
// Version: $Name$
//
-// Copyright (C) 2006 by the deal.II authors
+// Copyright (C) 2006, 2007 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
{
namespace Triangulation
{
-
- void
- TriaLevel<0>::reserve_space (const unsigned int total_cells,
- const unsigned int dimension)
- {
- // we need space for total_cells
- // cells. Maybe we have more already
- // with those cells which are unused,
- // so only allocate new space if needed.
- //
- // note that all arrays should have equal
- // sizes (checked by @p{monitor_memory}
- if (total_cells > refine_flags.size())
- {
- refine_flags.reserve (total_cells);
- refine_flags.insert (refine_flags.end(),
- total_cells - refine_flags.size(),
- false);
-
- coarsen_flags.reserve (total_cells);
- coarsen_flags.insert (coarsen_flags.end(),
- total_cells - coarsen_flags.size(),
- false);
-
- subdomain_ids.reserve (total_cells);
- subdomain_ids.insert (subdomain_ids.end(),
- total_cells - subdomain_ids.size(),
- 0);
-
- neighbors.reserve (total_cells*(2*dimension));
- neighbors.insert (neighbors.end(),
- total_cells*(2*dimension) - neighbors.size(),
- std::make_pair(-1,-1));
- };
- }
-
-
-
- void
- TriaLevel<0>::monitor_memory (const unsigned int true_dimension) const
- {
- // check that we have not allocated
- // too much memory. note that bool
- // vectors allocate their memory in
- // chunks of whole integers, so
- // they may over-allocate by up to
- // as many elements as an integer
- // has bits
- Assert (refine_flags.size() <= refine_flags.capacity() + sizeof(int)*8 ||
- refine_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
- ExcMemoryWasted ("refine_flags",
- refine_flags.size(), refine_flags.capacity()));
- Assert (coarsen_flags.size() <= coarsen_flags.capacity() + sizeof(int)*8 ||
- coarsen_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
- ExcMemoryWasted ("coarsen_flags",
- coarsen_flags.size(), coarsen_flags.capacity()));
- Assert (neighbors.size() == neighbors.capacity() ||
- neighbors.size()<DEAL_II_MIN_VECTOR_CAPACITY,
- ExcMemoryWasted ("neighbors",
- neighbors.size(), neighbors.capacity()));
- Assert (subdomain_ids.size() == subdomain_ids.capacity() ||
- subdomain_ids.size()<DEAL_II_MIN_VECTOR_CAPACITY,
- ExcMemoryWasted ("subdomain_ids",
- subdomain_ids.size(), subdomain_ids.capacity()));
- Assert (2*true_dimension*refine_flags.size() == neighbors.size(),
- ExcMemoryInexact (refine_flags.size(), neighbors.size()));
- Assert (2*true_dimension*coarsen_flags.size() == neighbors.size(),
- ExcMemoryInexact (coarsen_flags.size(), neighbors.size()));
- }
-
-
-
- unsigned int
- TriaLevel<0>::memory_consumption () const
- {
- return (MemoryConsumption::memory_consumption (refine_flags) +
- MemoryConsumption::memory_consumption (coarsen_flags) +
- MemoryConsumption::memory_consumption (neighbors));
- }
-
+
}
}
// $Id$
// Version: $Name$
//
-// Copyright (C) 2006 by the deal.II authors
+// Copyright (C) 2006, 2007 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
{
namespace Triangulation
{
+ template <int dim>
+ void
+ TriaLevel<dim>::reserve_space (const unsigned int total_cells,
+ const unsigned int dimension)
+ {
+ // we need space for total_cells
+ // cells. Maybe we have more already
+ // with those cells which are unused,
+ // so only allocate new space if needed.
+ //
+ // note that all arrays should have equal
+ // sizes (checked by @p{monitor_memory}
+ if (total_cells > refine_flags.size())
+ {
+ refine_flags.reserve (total_cells);
+ refine_flags.insert (refine_flags.end(),
+ total_cells - refine_flags.size(),
+ false);
+
+ coarsen_flags.reserve (total_cells);
+ coarsen_flags.insert (coarsen_flags.end(),
+ total_cells - coarsen_flags.size(),
+ false);
+
+ subdomain_ids.reserve (total_cells);
+ subdomain_ids.insert (subdomain_ids.end(),
+ total_cells - subdomain_ids.size(),
+ 0);
+
+ neighbors.reserve (total_cells*(2*dimension));
+ neighbors.insert (neighbors.end(),
+ total_cells*(2*dimension) - neighbors.size(),
+ std::make_pair(-1,-1));
+ };
+ }
-#if deal_II_dimension == 1
- unsigned int
- TriaLevel<1>::memory_consumption () const
+ template <int dim>
+ void
+ TriaLevel<dim>::monitor_memory (const unsigned int true_dimension) const
{
- return (TriaLevel<0>::memory_consumption() +
- MemoryConsumption::memory_consumption (lines));
+ // check that we have not allocated
+ // too much memory. note that bool
+ // vectors allocate their memory in
+ // chunks of whole integers, so
+ // they may over-allocate by up to
+ // as many elements as an integer
+ // has bits
+ Assert (refine_flags.size() <= refine_flags.capacity() + sizeof(int)*8 ||
+ refine_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
+ ExcMemoryWasted ("refine_flags",
+ refine_flags.size(), refine_flags.capacity()));
+ Assert (coarsen_flags.size() <= coarsen_flags.capacity() + sizeof(int)*8 ||
+ coarsen_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
+ ExcMemoryWasted ("coarsen_flags",
+ coarsen_flags.size(), coarsen_flags.capacity()));
+ Assert (neighbors.size() == neighbors.capacity() ||
+ neighbors.size()<DEAL_II_MIN_VECTOR_CAPACITY,
+ ExcMemoryWasted ("neighbors",
+ neighbors.size(), neighbors.capacity()));
+ Assert (subdomain_ids.size() == subdomain_ids.capacity() ||
+ subdomain_ids.size()<DEAL_II_MIN_VECTOR_CAPACITY,
+ ExcMemoryWasted ("subdomain_ids",
+ subdomain_ids.size(), subdomain_ids.capacity()));
+ Assert (2*true_dimension*refine_flags.size() == neighbors.size(),
+ ExcMemoryInexact (refine_flags.size(), neighbors.size()));
+ Assert (2*true_dimension*coarsen_flags.size() == neighbors.size(),
+ ExcMemoryInexact (coarsen_flags.size(), neighbors.size()));
}
-#endif
-
-#if deal_II_dimension == 2
+ template <int dim>
unsigned int
- TriaLevel<2>::memory_consumption () const
+ TriaLevel<dim>::memory_consumption () const
{
- return (TriaLevel<0>::memory_consumption() +
- MemoryConsumption::memory_consumption (quads));
+ return (MemoryConsumption::memory_consumption (refine_flags) +
+ MemoryConsumption::memory_consumption (coarsen_flags) +
+ MemoryConsumption::memory_consumption (neighbors) +
+ MemoryConsumption::memory_consumption (cells));
}
-#endif
-
+// This specialization should be only temporary, until the TriaObjects
+// classes are straightened out.
+
#if deal_II_dimension == 3
+ void
+ TriaLevel<3>::reserve_space (const unsigned int total_cells,
+ const unsigned int dimension)
+ {
+ // we need space for total_cells
+ // cells. Maybe we have more already
+ // with those cells which are unused,
+ // so only allocate new space if needed.
+ //
+ // note that all arrays should have equal
+ // sizes (checked by @p{monitor_memory}
+ if (total_cells > refine_flags.size())
+ {
+ refine_flags.reserve (total_cells);
+ refine_flags.insert (refine_flags.end(),
+ total_cells - refine_flags.size(),
+ false);
+
+ coarsen_flags.reserve (total_cells);
+ coarsen_flags.insert (coarsen_flags.end(),
+ total_cells - coarsen_flags.size(),
+ false);
+
+ subdomain_ids.reserve (total_cells);
+ subdomain_ids.insert (subdomain_ids.end(),
+ total_cells - subdomain_ids.size(),
+ 0);
+
+ neighbors.reserve (total_cells*(2*dimension));
+ neighbors.insert (neighbors.end(),
+ total_cells*(2*dimension) - neighbors.size(),
+ std::make_pair(-1,-1));
+ };
+ }
+
+
+ void
+ TriaLevel<3>::monitor_memory (const unsigned int true_dimension) const
+ {
+ // check that we have not allocated
+ // too much memory. note that bool
+ // vectors allocate their memory in
+ // chunks of whole integers, so
+ // they may over-allocate by up to
+ // as many elements as an integer
+ // has bits
+ Assert (refine_flags.size() <= refine_flags.capacity() + sizeof(int)*8 ||
+ refine_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
+ ExcMemoryWasted ("refine_flags",
+ refine_flags.size(), refine_flags.capacity()));
+ Assert (coarsen_flags.size() <= coarsen_flags.capacity() + sizeof(int)*8 ||
+ coarsen_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
+ ExcMemoryWasted ("coarsen_flags",
+ coarsen_flags.size(), coarsen_flags.capacity()));
+ Assert (neighbors.size() == neighbors.capacity() ||
+ neighbors.size()<DEAL_II_MIN_VECTOR_CAPACITY,
+ ExcMemoryWasted ("neighbors",
+ neighbors.size(), neighbors.capacity()));
+ Assert (subdomain_ids.size() == subdomain_ids.capacity() ||
+ subdomain_ids.size()<DEAL_II_MIN_VECTOR_CAPACITY,
+ ExcMemoryWasted ("subdomain_ids",
+ subdomain_ids.size(), subdomain_ids.capacity()));
+ Assert (2*true_dimension*refine_flags.size() == neighbors.size(),
+ ExcMemoryInexact (refine_flags.size(), neighbors.size()));
+ Assert (2*true_dimension*coarsen_flags.size() == neighbors.size(),
+ ExcMemoryInexact (coarsen_flags.size(), neighbors.size()));
+ }
+
unsigned int
TriaLevel<3>::memory_consumption () const
{
- return (TriaLevel<0>::memory_consumption() +
- MemoryConsumption::memory_consumption (hexes));
+ return (MemoryConsumption::memory_consumption (refine_flags) +
+ MemoryConsumption::memory_consumption (coarsen_flags) +
+ MemoryConsumption::memory_consumption (neighbors) +
+ MemoryConsumption::memory_consumption (cells));
}
#endif
-
+
}
}
+
+template class internal::Triangulation::TriaLevel<deal_II_dimension>;
+
+
DEAL_II_NAMESPACE_CLOSE
new std::vector<bool> (lines_on_level);
// Check for each cell, if it has children.
- transform (tria.levels[i]->lines.children.begin (),
- tria.levels[i]->lines.children.end (),
+ transform (tria.levels[i]->cells.children.begin (),
+ tria.levels[i]->cells.children.end (),
has_children_level->begin (),
std::bind2nd (std::not_equal_to<int>(), -1));
new std::vector<bool> (quads_on_level);
// Check for each cell, if it has children.
- std::transform (tria.levels[i]->quads.children.begin (),
- tria.levels[i]->quads.children.end (),
+ std::transform (tria.levels[i]->cells.children.begin (),
+ tria.levels[i]->cells.children.end (),
has_children_level->begin (),
std::bind2nd (std::not_equal_to<int>(), -1));
// Check for each cell, if it
// has children.
- transform (tria.levels[i]->hexes.children.begin (),
- tria.levels[i]->hexes.children.end (),
+ transform (tria.levels[i]->cells.children.begin (),
+ tria.levels[i]->cells.children.end (),
has_children_level->begin (),
std::bind2nd (std::not_equal_to<int>(), -1));