From: kanschat Date: Mon, 1 Nov 2010 03:38:39 +0000 (+0000) Subject: check in temporary functions in BlockList X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96fa2ead67c80818c65a6844494ea24bdb61e3f3;p=dealii-svn.git check in temporary functions in BlockList git-svn-id: https://svn.dealii.org/trunk@22563 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/lac/block_list.h b/deal.II/include/deal.II/lac/block_list.h index d5276b3e80..92fdafe785 100644 --- a/deal.II/include/deal.II/lac/block_list.h +++ b/deal.II/include/deal.II/lac/block_list.h @@ -15,6 +15,7 @@ #include #include +#include #include @@ -47,6 +48,26 @@ class BlockList : typedef std::vector block_container; /// The iterator for individual indices typedef block_container::const_iterator const_iterator; + + /** + * Add the indices in + * indices to block + * block, eliminating + * repeated indices. + */ + void add(unsigned int block, const std::vector& indices); + + /** + * Add the indices in + * indices to block + * block, eliminating + * repeated indices. Only add + * those indices for which + * selected_indices is true. + */ + void add(unsigned int block, + const std::vector& indices, + const std::vector& selected_indices); /** * Set up all index sets using an @@ -69,6 +90,9 @@ class BlockList : const typename identity::type end); /** + * @deprecated This function will + * move to DoFTools. + * * Set up all index sets using an * DoF iterator range. This * function will call @@ -89,6 +113,9 @@ class BlockList : const typename identity::type end); /** + * @deprecated This function will + * move to DoFTools. + * * Set up all index sets using an * DoF iterator range. This * function will call @@ -123,6 +150,9 @@ class BlockList : const std::vector& selected_dofs, unsigned int offset = 0); /** + * @deprecated This function will + * move to DoFTools. + * * Set up all index sets using an * DoF iterator range. This * function will call @@ -157,6 +187,46 @@ class BlockList : const std::vector& selected_dofs, unsigned int offset = 0); + /** + * @deprecated This function will + * move to DoFTools. + * + * Same as initialize_mg(), but + * instead of gathering the + * degrees of freedom of a single + * cell into a block, gather all + * degrees of freedom of a patch + * around a vertex. + */ + template + void initialize_vertex_patches_mg(unsigned int n_blocks, + const ITERATOR begin, + const typename identity::type end, + const std::vector& selected_dofs = std::vector(), + unsigned int offset = 0); + + /** + * @deprecated This function will + * move to DoFTools. + * + * Auxiliary function, counting + * the patches around vertices. + */ + template + unsigned int count_vertex_patches( + const ITERATOR begin, + const typename identity::type end, + bool same_level_only) const; + + /** + * @deprecated This function will + * move to DoFTools. + * + */ + template + bool cell_generates_vertex_patch(const ITERATOR cell, + bool same_level_only) const; + /** * The number of blocks. */ @@ -192,6 +262,46 @@ class BlockList : }; +inline +void +BlockList::add(const unsigned int block, const std::vector& indices) +{ + AssertIndexRange(block, index_sets.size()); + + for (unsigned int i=0;i& indices, + const std::vector& selected) +{ + AssertIndexRange(block, index_sets.size()); + AssertDimension(indices.size(), selected.size()); + + for (unsigned int i=0;i inline void @@ -204,10 +314,7 @@ BlockList::initialize(unsigned int n_blocks, const ITERATOR begin, const typenam { indices.resize(cell->get_fe().dofs_per_cell); cell->get_dof_indices(indices); - - for (std::vector::const_iterator i=indices.begin(); - i != indices.end(); ++i) - index_sets[k].push_back(*i); + add(k, indices); } } @@ -224,10 +331,7 @@ BlockList::initialize_mg(unsigned int n_blocks, const ITERATOR begin, const type { indices.resize(cell->get_fe().dofs_per_cell); cell->get_mg_dof_indices(indices); - - for (std::vector::const_iterator i=indices.begin(); - i != indices.end(); ++i) - index_sets[k].push_back(*i); + add(k, indices); } } @@ -251,10 +355,7 @@ BlockList::initialize( AssertDimension(selected_dofs.size(), cell->get_fe().dofs_per_cell); cell->get_dof_indices(indices); - - for (unsigned int i=0; iget_fe().dofs_per_cell); cell->get_mg_dof_indices(indices); - - for (unsigned int i=0; i +inline +bool +BlockList::cell_generates_vertex_patch( + const ITERATOR cell, + bool same_level_only) const +{ + switch(dim) + { + case 3: + if (cell->at_boundary(4)) break; + if (same_level_only && cell->neighbor(4)->level() != cell->level()) break; + if (cell->neighbor(4)->at_boundary(0)) break; + if (same_level_only && cell->neighbor(4)->neighbor(0)->level() != cell->level()) break; + if (cell->neighbor(4)->at_boundary(2)) break; + if (same_level_only && cell->neighbor(4)->neighbor(2)->level() != cell->level()) break; + if (cell->neighbor(4)->neighbor(0)->at_boundary(2)) break; + if (same_level_only && cell->neighbor(4)->neighbor(0)->neighbor(2)->level() != cell->level()) break; + // No break here + case 2: + if (cell->at_boundary(2)) break; + if (same_level_only && cell->neighbor(2)->level() != cell->level()) break; + if (cell->neighbor(2)->at_boundary(0)) break; + if (same_level_only && cell->neighbor(2)->neighbor(0)->level() != cell->level()) break; + case 1: + if (cell->at_boundary(0)) break; + if (same_level_only && cell->neighbor(0)->level() != cell->level()) break; + return true; + break; + default: + Assert(false, ExcNotImplemented()); + break; + } + return false; +} + + +template +inline +unsigned int +BlockList::count_vertex_patches( + const ITERATOR begin, + const typename identity::type end, + bool same_level_only) const +{ + unsigned int count = 0; + for (ITERATOR cell = begin; cell != end; ++cell) + if (cell_generates_vertex_patch(cell, same_level_only)) + ++count; + return count; +} + + +template +inline +void +BlockList::initialize_vertex_patches_mg( + unsigned int n_blocks, + const ITERATOR begin, + const typename identity::type end, + const std::vector& selected_dofs, + unsigned int offset) +{ + Assert(selected_dofs.size() == 0, ExcNotImplemented()); + Assert(offset==0, ExcNotImplemented()); + const FiniteElement& fe = begin->get_fe(); + Assert(fe.dofs_per_vertex == 0, ExcNotImplemented()); + + index_sets.resize(n_blocks); + std::vector indices; + unsigned int k = 0; + for (ITERATOR cell = begin; cell != end; ++cell) + { + if (cell_generates_vertex_patch(cell, true)) + { + indices.resize(cell->get_fe().dofs_per_cell); + + switch(dim) + { + case 3: + cell->neighbor(4)->get_mg_dof_indices(indices); + for (unsigned int i=0;ineighbor(4)->neighbor(0)->get_mg_dof_indices(indices); + for (unsigned int i=0;ineighbor(4)->neighbor(2)->get_mg_dof_indices(indices); + for (unsigned int i=0;ineighbor(4)->neighbor(2)->neighbor(0)->get_mg_dof_indices(indices); + for (unsigned int i=0;ineighbor(2)->get_mg_dof_indices(indices); + for (unsigned int i=0;i2) + indices[fe.face_to_cell_index(i,5)] = numbers::invalid_unsigned_int; + } + add(k, indices); + cell->neighbor(2)->neighbor(0)->get_mg_dof_indices(indices); + for (unsigned int i=0;i2) + indices[fe.face_to_cell_index(i,5)] = numbers::invalid_unsigned_int; + } + add(k, indices); + // no break here + case 1: + cell->get_mg_dof_indices(indices); + for (unsigned int i=0;i1) + indices[fe.face_to_cell_index(i,3)] = numbers::invalid_unsigned_int; + if (dim>2) + indices[fe.face_to_cell_index(i,5)] = numbers::invalid_unsigned_int; + } + add(k, indices); + cell->neighbor(0)->get_mg_dof_indices(indices); + for (unsigned int i=0;i1) + indices[fe.face_to_cell_index(i,3)] = numbers::invalid_unsigned_int; + if (dim>2) + indices[fe.face_to_cell_index(i,5)] = numbers::invalid_unsigned_int; + } + add(k, indices); + break; + default: + Assert(false, ExcNotImplemented()); + break; + } + ++k; + } } }