#include <grid/tria_accessor.h>
#include <grid/tria_iterator.h>
#include <grid/tria.h>
+#include <grid/geometry_info.h>
#include <fe/fe.h>
#include <lac/dsmatrix.h>
#include <map>
unsigned int next_free_dof) {
// distribute dofs of vertices
- for (unsigned int v=0; v<2; ++v)
+ for (unsigned int v=0; v<GeometryInfo<1>::vertices_per_cell; ++v)
{
cell_iterator neighbor = cell->neighbor(v);
unsigned int next_free_dof) {
if (selected_fe->dofs_per_vertex > 0)
// number dofs on vertices
- for (unsigned int vertex=0; vertex<4; ++vertex)
+ for (unsigned int vertex=0; vertex<GeometryInfo<2>::vertices_per_cell; ++vertex)
// check whether dofs for this
// vertex have been distributed
// (only check the first dof)
cell->set_vertex_dof_index (vertex, d, next_free_dof++);
// for the four sides
- for (unsigned int side=0; side<4; ++side)
+ for (unsigned int side=0; side<GeometryInfo<2>::faces_per_cell; ++side)
{
line_iterator line = cell->line(side);
int dof_number=0;
// fill dof indices on vertices
- for (unsigned int vertex=0; vertex<4; ++vertex)
+ for (unsigned int vertex=0; vertex<GeometryInfo<2>::vertices_per_cell; ++vertex)
for (unsigned int d=0; d<selected_fe->dofs_per_vertex; ++d)
dofs_on_this_cell[dof_number++] = cell->vertex_dof_index (vertex,d);
- for (unsigned int line=0; line<4; ++line)
+ for (unsigned int line=0; line<GeometryInfo<2>::faces_per_cell; ++line)
for (unsigned int d=0; d<selected_fe->dofs_per_line; ++d)
dofs_on_this_cell[dof_number++] = cell->line(line)->dof_index (d);
// assert for once at the beginning the
// the matrices have the correct sizes
#ifdef DEBUG
- for (unsigned int c=0; c<(1<<dim); ++c)
+ for (unsigned int c=0; c<GeometryInfo<dim>::children_per_cell; ++c)
{
Assert (selected_fe->prolongate(c).m() == selected_fe->total_dofs,
ExcMatrixHasWrongSize(selected_fe->prolongate(c).m()));
dSMatrixStruct &transfer_pattern) const {
if (!new_cell->active() && !old_cell->active())
// both cells have children; go deeper
- for (unsigned int child=0; child<(1<<dim); ++child)
+ for (unsigned int child=0; child<GeometryInfo<dim>::children_per_cell; ++child)
transfer_cell (old_cell->child(child), new_cell->child(child),
transfer_pattern);
else
if (!new_cell->active() && old_cell->active())
// new cell has children, old one has not
{
- cell_iterator child[1<<dim];
- for (unsigned int c=0; c<(1<<dim); ++c)
+ cell_iterator child[GeometryInfo<dim>::children_per_cell];
+ for (unsigned int c=0; c<GeometryInfo<dim>::children_per_cell; ++c)
{
child[c] = new_cell->child(c);
Assert (child[c]->active(),
Assert (old_dof_indices.size() == selected_fe->total_dofs,
ExcInternalError ());
- for (unsigned int c=0; c<(1<<dim); ++c)
+ for (unsigned int c=0; c<GeometryInfo<dim>::children_per_cell; ++c)
{
// numbers of child dofs
vector<int> child_dof_indices;
};
} else {
// old cell has children, new one has not
- cell_iterator child[1<<dim];
- for (unsigned int c=0; c<(1<<dim); ++c)
+ cell_iterator child[GeometryInfo<dim>::children_per_cell];
+ for (unsigned int c=0; c<GeometryInfo<dim>::children_per_cell; ++c)
{
child[c] = old_cell->child(c);
Assert (child[c]->active(),
Assert (new_dof_indices.size() == selected_fe->total_dofs,
ExcInternalError ());
- for (unsigned int c=0; c<(1<<dim); ++c)
+ for (unsigned int c=0; c<GeometryInfo<dim>::children_per_cell; ++c)
{
// numbers of child dofs
vector<int> child_dof_indices;
dSMatrix &transfer_matrix) const {
if (!new_cell->active() && !old_cell->active())
// both cells have children; go deeper
- for (unsigned int child=0; child<(1<<dim); ++child)
+ for (unsigned int child=0; child<GeometryInfo<dim>::children_per_cell; ++child)
transfer_cell (old_cell->child(child), new_cell->child(child),
transfer_matrix);
else
if (!new_cell->active() && old_cell->active())
// new cell has children, old one has not
{
- cell_iterator child[1<<dim];
- for (unsigned int c=0; c<(1<<dim); ++c)
+ cell_iterator child[GeometryInfo<dim>::children_per_cell];
+ for (unsigned int c=0; c<GeometryInfo<dim>::children_per_cell; ++c)
{
child[c] = new_cell->child(c);
Assert (child[c]->active(),
Assert (old_dof_indices.size() == selected_fe->total_dofs,
ExcInternalError ());
- for (unsigned int c=0; c<(1<<dim); ++c)
+ for (unsigned int c=0; c<GeometryInfo<dim>::children_per_cell; ++c)
{
// numbers of child dofs
vector<int> child_dof_indices;
};
} else {
// old cell has children, new one has not
- cell_iterator child[1<<dim];
- for (unsigned int c=0; c<(1<<dim); ++c)
+ cell_iterator child[GeometryInfo<dim>::children_per_cell];
+ for (unsigned int c=0; c<GeometryInfo<dim>::children_per_cell; ++c)
{
child[c] = old_cell->child(c);
Assert (child[c]->active(),
Assert (new_dof_indices.size() == selected_fe->total_dofs,
ExcInternalError ());
- for (unsigned int c=0; c<(1<<dim); ++c)
+ for (unsigned int c=0; c<GeometryInfo<dim>::children_per_cell; ++c)
{
// numbers of child dofs
vector<int> child_dof_indices;
#include <grid/tria_boundary.h>
#include <grid/tria_iterator.h>
#include <grid/tria.h>
+#include <grid/geometry_info.h>
#include <basic/magic_numbers.h>
#include <basic/data_io.h>
#include <lac/dvector.h>
// for all lines
for (; line!=end(); ++line)
// for each of the two vertices
- for (unsigned int vertex=0; vertex<(1<<dim); ++vertex)
+ for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell; ++vertex)
// if first cell adjacent to this
// vertex is the present one, then
// the neighbor is the second adjacent
swap (cells[cell].vertices[0], cells[cell].vertices[2]);
swap (cells[cell].vertices[1], cells[cell].vertices[3]);
// remake lines
- line_vertices[0] = make_pair (cells[cell].vertices[0], cells[cell].vertices[1]);
- line_vertices[1] = make_pair (cells[cell].vertices[1], cells[cell].vertices[2]);
- line_vertices[2] = make_pair (cells[cell].vertices[0], cells[cell].vertices[3]);
- line_vertices[3] = make_pair (cells[cell].vertices[3], cells[cell].vertices[2]);
+ line_vertices[0]
+ = make_pair (cells[cell].vertices[0], cells[cell].vertices[1]);
+ line_vertices[1]
+ = make_pair (cells[cell].vertices[1], cells[cell].vertices[2]);
+ line_vertices[2]
+ = make_pair (cells[cell].vertices[0], cells[cell].vertices[3]);
+ line_vertices[3]
+ = make_pair (cells[cell].vertices[3], cells[cell].vertices[2]);
// allow for only one such
// rotation
break;
// used on level 0
unsigned int max_vertex_index = 0;
for (; cell!=endc; ++cell)
- for (unsigned vertex=0; vertex<(1<<dim); ++vertex)
+ for (unsigned vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell; ++vertex)
if (cell->vertex_index(vertex) > (signed int)max_vertex_index)
max_vertex_index = cell->vertex_index(vertex);
// touch a vertex's usage count everytime
// we find an adjacent element
for (cell=begin(); cell!=endc; ++cell)
- for (unsigned vertex=0; vertex<(1<<dim); ++vertex)
+ for (unsigned vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell; ++vertex)
++usage_count[cell->vertex_index(vertex)];
- return max (static_cast<unsigned int>(1<<dim),
+ return max (GeometryInfo<dim>::vertices_per_cell,
static_cast<unsigned int>(*(max_element (usage_count.begin(),
usage_count.end()))));
};
void Triangulation<1>::print_gnuplot (ostream &out,
- const TriaDimensionInfo<1>::active_cell_iterator & cell) const {
+ const active_cell_iterator & cell) const {
out << cell->vertex(0) << " " << cell->level() << endl
<< cell->vertex(1) << " " << cell->level() << endl
<< endl;
void Triangulation<2>::print_gnuplot (ostream &out,
- const TriaDimensionInfo<2>::active_cell_iterator & cell) const {
+ const active_cell_iterator & cell) const {
out << cell->vertex(0) << " " << cell->level() << endl
<< cell->vertex(1) << " " << cell->level() << endl
<< cell->vertex(2) << " " << cell->level() << endl
// 2*flagged_cells that will be created
// on that level
levels[level+1]->
- TriangulationLevel<0>::reserve_space (used_cells+2*flagged_cells, 1);
+ TriangulationLevel<0>::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]->
- TriangulationLevel<1>::reserve_space (2*flagged_cells);
+ TriangulationLevel<1>::reserve_space (GeometryInfo<1>::children_per_cell*flagged_cells);
needed_vertices += flagged_cells;
};
for (; cell != endc; --cell)
if (cell->refine_flag_set() == true)
// loop over neighbors of cell
- for (unsigned int i=0; i<(2*dim); ++i)
+ for (unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
if (cell->neighbor(i).state() == valid)
if ((cell->neighbor_level(i) == cell->level()-1)
&&
#include <grid/tria_iterator.h>
#include <grid/tria_accessor.h>
#include <grid/tria_iterator.templates.h>
+#include <grid/geometry_info.h>
/* Note: explicit instantiations at the end of the different sections! */
template <int dim>
int CellAccessor<dim>::neighbor_index (const unsigned int i) const {
- Assert (i<2*dim,
+ Assert (i<GeometryInfo<dim>::faces_per_cell,
typename TriaSubstructAccessor<dim>::ExcInvalidNeighbor(i));
- return tria->levels[present_level]->neighbors[present_index*2*dim+i].second;
+ 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<2*dim,
+ Assert (i<GeometryInfo<dim>::faces_per_cell,
typename TriaSubstructAccessor<dim>::ExcInvalidNeighbor(i));
- return tria->levels[present_level]->neighbors[present_index*2*dim+i].first;
+ 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 {
- Assert (i<2*dim, typename TriaSubstructAccessor<dim>::ExcInvalidNeighbor(i));
- tria->levels[present_level]->neighbors[present_index*2*dim+i].first
+ Assert (i<GeometryInfo<dim>::faces_per_cell,
+ typename TriaSubstructAccessor<dim>::ExcInvalidNeighbor(i));
+ tria->levels[present_level]->
+ neighbors[present_index*GeometryInfo<dim>::faces_per_cell+i].first
= pointer.accessor.present_level;
- tria->levels[present_level]->neighbors[present_index*2*dim+i].second
+ tria->levels[present_level]->
+ neighbors[present_index*GeometryInfo<dim>::faces_per_cell+i].second
= pointer.accessor.present_index;
};
template <int dim>
bool CellAccessor<dim>::at_boundary (const unsigned int i) const {
Assert (used(), typename TriaSubstructAccessor<dim>::ExcCellNotUsed());
- Assert (i<2*dim,
- typename TriaSubstructAccessor<dim>::ExcInvalidIndex (i,0,2*dim-1));
+ Assert (i<GeometryInfo<dim>::faces_per_cell,
+ typename TriaSubstructAccessor<dim>::
+ ExcInvalidIndex (i,0,GeometryInfo<dim>::faces_per_cell-1));
return (neighbor_index(i) == -1);
};
#include <grid/dof_accessor.h>
#include <grid/tria_iterator.h>
#include <grid/tria.h>
+#include <grid/geometry_info.h>
#include <fe/fe.h>
#include <map>
{
// allocate and read indices
cells.push_back (CellData<dim>());
- for (unsigned int i=0; i<(1<<dim); ++i)
+ for (unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
in >> cells.back().vertices[i];
cells.back().material_id = material_id;
// transform from ucd to
// consecutive numbering
- for (unsigned int i=0; i<(1<<dim); ++i)
+ for (unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
if (vertex_indices.find (cells.back().vertices[i]) != vertex_indices.end())
// vertex with this index exists
cells.back().vertices[i] = vertex_indices[cells.back().vertices[i]];
// use
vector<bool> is_vertex_dof (dofs->n_dofs(), false);
for (cell=dofs->begin_active(); cell!=endc; ++cell)
- for (unsigned int vertex=0; vertex<(1<<dim); ++vertex)
+ for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
+ ++vertex)
is_vertex_dof[cell->vertex_dof_index(vertex,0)] = true;
n_vertex_dofs = 0;
vector<bool> already_written (dofs->n_dofs(), false);
// write vertices
for (cell=dofs->begin_active(); cell!=endc; ++cell)
- for (unsigned int vertex=0; vertex<(1<<dim); ++vertex)
+ for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
+ ++vertex)
if (already_written[cell->vertex_dof_index(vertex,0)]==false)
{
out << cell->vertex_dof_index(vertex,0) // vertex index
default:
Assert (false, ExcNotImplemented());
};
- for (unsigned int vertex=0; vertex<(1<<dim); ++vertex)
+ for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
+ ++vertex)
out << cell->vertex_dof_index(vertex,0) << ' ';
out << endl;
};
vector<bool> already_written (dofs->n_dofs(), false);
// write vertices
for (cell=dofs->begin_active(); cell!=endc; ++cell)
- for (unsigned int vertex=0; vertex<(1<<dim); ++vertex)
+ for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_cell;
+ ++vertex)
if (already_written[cell->vertex_dof_index(vertex,0)]==false)
{
out << cell->vertex_dof_index(vertex,0) // vertex index
default:
Assert (false, ExcNotImplemented());
};
- for (unsigned int vertex=0; vertex<(1<<(dim-1)); ++vertex)
+ for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_face; ++vertex)
out << face->vertex_dof_index(vertex,0) << ' ';
out << endl;