From 0a6efbc27b751cc1a4e3fe5d75bf52cd43116206 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 2 May 2006 19:48:17 +0000 Subject: [PATCH] Implement distribute_dofs for 1d, 2d, 3d in the same way. git-svn-id: https://svn.dealii.org/trunk@12969 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/source/dofs/hp_dof_handler.cc | 222 ++++++++---------- 1 file changed, 103 insertions(+), 119 deletions(-) diff --git a/deal.II/deal.II/source/dofs/hp_dof_handler.cc b/deal.II/deal.II/source/dofs/hp_dof_handler.cc index 531b38539c..926ffa46e6 100644 --- a/deal.II/deal.II/source/dofs/hp_dof_handler.cc +++ b/deal.II/deal.II/source/dofs/hp_dof_handler.cc @@ -1557,6 +1557,7 @@ namespace hp } + template void DoFHandler::clear () { @@ -1575,52 +1576,33 @@ namespace hp DoFHandler<1>::distribute_dofs_on_cell (active_cell_iterator &cell, unsigned int next_free_dof) { -//TODO[WB]: this may be completely bogus -- look through it - // get the fe for this cell - const FiniteElement<1> &fe = cell->get_fe(); - - // distribute dofs of vertices - for (unsigned int v=0; v::vertices_per_cell; ++v) + const FiniteElement<2> &fe = cell->get_fe(); + const unsigned int fe_index = cell->active_fe_index (); + + // number dofs on vertices. to do + // so, check whether dofs for + // this vertex have been + // distributed and for the + // present fe (only check the + // first dof), and if this isn't + // the case distribute new ones + // there + if (fe.dofs_per_vertex > 0) + for (unsigned int vertex=0; vertex::vertices_per_cell; ++vertex) + if (cell->vertex_dof_index(vertex, 0, fe_index) == invalid_dof_index) + for (unsigned int d=0; dset_vertex_dof_index (vertex, d, next_free_dof, fe_index); + + // finally for the line. this one + // shouldn't be numbered yet + if (fe.dofs_per_line > 0) { - cell_iterator neighbor = cell->neighbor(v); - - if (neighbor.state() == IteratorState::valid) - { - // find true neighbor; may be its - // a child of @p{neighbor} - while (neighbor->has_children()) - neighbor = neighbor->child(v==0 ? 1 : 0); - - // has neighbor already been processed? - if (neighbor->user_flag_set()) - // copy dofs - { - if (v==0) - for (unsigned int d=0; dset_vertex_dof_index (0, d, - neighbor->vertex_dof_index (1, d), - cell->active_fe_index()); - else - for (unsigned int d=0; dset_vertex_dof_index (1, d, - neighbor->vertex_dof_index (0, d), - cell->active_fe_index()); - - // next neighbor - continue; - }; - }; - - // otherwise: create dofs newly - for (unsigned int d=0; dset_vertex_dof_index (v, d, next_free_dof++, - cell->active_fe_index()); - }; - - // dofs of line - for (unsigned int d=0; dset_dof_index (d, next_free_dof++, - cell->active_fe_index()); + Assert (cell->dof_index(0, fe_index) == invalid_dof_index, + ExcInternalError()); + + for (unsigned int d=0; dset_dof_index (d, next_free_dof, fe_index); + } // note that this cell has been processed cell->set_user_flag (); @@ -1638,46 +1620,49 @@ namespace hp DoFHandler<2>::distribute_dofs_on_cell (active_cell_iterator &cell, unsigned int next_free_dof) { -//TODO[WB]: Check for correctness - // get the fe for this cell - const FiniteElement<2> &fe = cell->get_fe(); - + const FiniteElement<2> &fe = cell->get_fe(); + const unsigned int fe_index = cell->active_fe_index (); + + // number dofs on vertices. to do + // so, check whether dofs for + // this vertex have been + // distributed and for the + // present fe (only check the + // first dof), and if this isn't + // the case distribute new ones + // there if (fe.dofs_per_vertex > 0) - // number dofs on vertices for (unsigned int vertex=0; vertex::vertices_per_cell; ++vertex) - // check whether dofs for this - // vertex have been distributed - // (only check the first dof) - if (cell->vertex_dof_index(vertex, 0, cell->active_fe_index()) - == invalid_dof_index) - for (unsigned int d=0; dset_vertex_dof_index (vertex, d, next_free_dof++, - cell->active_fe_index()); + if (cell->vertex_dof_index(vertex, 0, fe_index) == invalid_dof_index) + for (unsigned int d=0; dset_vertex_dof_index (vertex, d, next_free_dof, fe_index); - // for the four sides -//TODO[?] Does not work for continuous FEs + // next the sides. do the + // same as above: check whether + // the line is already numbered + // for the present fe_index, and + // if not do it if (fe.dofs_per_line > 0) - for (unsigned int side=0; side::faces_per_cell; ++side) + for (unsigned int l=0; l::lines_per_cell; ++l) { - line_iterator line = cell->line(side); + line_iterator line = cell->line(l); - // distribute dofs if necessary: - // check whether line dof is already - // numbered (check only first dof) - if (line->dof_index(0,cell->active_fe_index()) == invalid_dof_index) - // if not: distribute dofs - for (unsigned int d=0; dset_dof_index (d, next_free_dof++, - cell->active_fe_index()); - }; + if (line->dof_index(0,fe_index) == invalid_dof_index) + for (unsigned int d=0; dset_dof_index (d, next_free_dof, fe_index); + } - // dofs of quad + // finally for the quad. this one + // shouldn't be numbered yet if (fe.dofs_per_quad > 0) - for (unsigned int d=0; dset_dof_index (d, next_free_dof++, - cell->active_fe_index()); - + { + Assert (cell->dof_index(0, fe_index) == invalid_dof_index, + ExcInternalError()); + + for (unsigned int d=0; dset_dof_index (d, next_free_dof, fe_index); + } // note that this cell has been processed cell->set_user_flag (); @@ -1695,61 +1680,60 @@ namespace hp DoFHandler<3>::distribute_dofs_on_cell (active_cell_iterator &cell, unsigned int next_free_dof) { -//TODO[WB]: check for correctness - // get the fe for this cell - const FiniteElement<3> &fe = cell->get_fe(); - + const FiniteElement<2> &fe = cell->get_fe(); + const unsigned int fe_index = cell->active_fe_index (); + + // number dofs on vertices. to do + // so, check whether dofs for + // this vertex have been + // distributed and for the + // present fe (only check the + // first dof), and if this isn't + // the case distribute new ones + // there if (fe.dofs_per_vertex > 0) - // number dofs on vertices for (unsigned int vertex=0; vertex::vertices_per_cell; ++vertex) - // check whether dofs for this - // vertex have been distributed - // (only check the first dof) - if (cell->vertex_dof_index(vertex, 0,cell->active_fe_index()) - == invalid_dof_index) - for (unsigned int d=0; dset_vertex_dof_index (vertex, d, next_free_dof++, - cell->active_fe_index()); + if (cell->vertex_dof_index(vertex, 0, fe_index) == invalid_dof_index) + for (unsigned int d=0; dset_vertex_dof_index (vertex, d, next_free_dof, fe_index); - // for the lines + // next the four lines. do the + // same as above: check whether + // the line is already numbered + // for the present fe_index, and + // if not do it if (fe.dofs_per_line > 0) for (unsigned int l=0; l::lines_per_cell; ++l) { line_iterator line = cell->line(l); - - // distribute dofs if necessary: - // check whether line dof is already - // numbered (check only first dof) - if (line->dof_index(0, cell->active_fe_index()) == invalid_dof_index) - // if not: distribute dofs - for (unsigned int d=0; dset_dof_index (d, next_free_dof++, - cell->active_fe_index()); - }; - - // for the quads + + if (line->dof_index(0,fe_index) == invalid_dof_index) + for (unsigned int d=0; dset_dof_index (d, next_free_dof, fe_index); + } + + // same for quads if (fe.dofs_per_quad > 0) for (unsigned int q=0; q::quads_per_cell; ++q) { quad_iterator quad = cell->quad(q); - - // distribute dofs if necessary: - // check whether quad dof is already - // numbered (check only first dof) - if (quad->dof_index(0, cell->active_fe_index()) == invalid_dof_index) - // if not: distribute dofs - for (unsigned int d=0; dset_dof_index (d, next_free_dof++, - cell->active_fe_index()); - }; - - - // dofs of hex - if (fe.dofs_per_hex > 0) - for (unsigned int d=0; dset_dof_index (d, next_free_dof++, - cell->active_fe_index()); + if (quad->dof_index(0,fe_index) == invalid_dof_index) + for (unsigned int d=0; dset_dof_index (d, next_free_dof, fe_index); + } + + + // finally for the hex. this one + // shouldn't be numbered yet + if (fe.dofs_per_hex > 0) + { + Assert (cell->dof_index(0, fe_index) == invalid_dof_index, + ExcInternalError()); + + for (unsigned int d=0; dset_dof_index (d, next_free_dof, fe_index); + } // note that this cell has been processed cell->set_user_flag (); -- 2.39.5