From: Guido Kanschat Date: Tue, 8 Jul 2003 10:56:42 +0000 (+0000) Subject: introduce component renumbering and grouping X-Git-Tag: v8.0.0~16359 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4404e63d3f4d48ef6a8851a01ce0dbddf45a932b;p=dealii.git introduce component renumbering and grouping git-svn-id: https://svn.dealii.org/trunk@7851 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/dofs/dof_renumbering.h b/deal.II/deal.II/include/dofs/dof_renumbering.h index da9735c5cb..d3fa5741a2 100644 --- a/deal.II/deal.II/include/dofs/dof_renumbering.h +++ b/deal.II/deal.II/include/dofs/dof_renumbering.h @@ -279,7 +279,7 @@ class DoFRenumbering * different way than suggested * by the @p{FESystem} object you * use. To this end, Set up the - * vector @p{component_order} + * vector @p{target_component} * such that the entry at index * @p{i} denotes the number of * the target component for dofs @@ -317,13 +317,27 @@ class DoFRenumbering template static void component_wise (DoFHandler &dof_handler, - const std::vector &component_order = std::vector()); + const std::vector &target_component = std::vector()); + + /** + * Sort the degrees of freedom by + * component. It does the same + * thing as the above function, + * only that it does this for one + * level of a multi-level + * discretization. + */ + template + static void + component_wise (MGDoFHandler& dof_handler, + unsigned int level, + const std::vector& target_component = std::vector()); /** * Computes the renumbering * vector needed by the * @p{component_wise} - * function. Does not perform the + * functions. Does not perform the * renumbering on the * @p{DoFHandler} dofs but * returns the renumbering @@ -334,22 +348,8 @@ class DoFRenumbering compute_component_wise (std::vector& new_index, ITERATOR& start, const ENDITERATOR& end, - const std::vector &component_order = std::vector()); + const std::vector &target_component); - /** - * Sort the degrees of freedom by - * component. It does the same - * thing as the above function, - * only that it does this for one - * level of a multi-level - * discretization. - */ - template - static void - component_wise (MGDoFHandler& dof_handler, - unsigned int level, - const std::vector& component_order = std::vector()); - /** * Cell-wise renumbering for DG * elements. This function takes diff --git a/deal.II/deal.II/include/dofs/dof_tools.h b/deal.II/deal.II/include/dofs/dof_tools.h index fd128f4390..924f5ccb8a 100644 --- a/deal.II/deal.II/include/dofs/dof_tools.h +++ b/deal.II/deal.II/include/dofs/dof_tools.h @@ -775,7 +775,7 @@ class DoFTools * Count how many degrees of * freedom out of the total * number belong to each - * components. If the number of + * component. If the number of * components the finite element * has is one (i.e. you only have * one scalar variable), then the @@ -804,13 +804,26 @@ class DoFTools * than the total number of * degrees of freedom. * - * The result is returned in the - * last argument. + * The additional optional + * argument @p{target_component} + * allows for a re-sorting and + * grouping of components. To + * this end, it contains for each + * component the component number + * it shall be counted as. Having + * the same number entered + * several times sums up several + * components as the same. + * + * The result is returned in + * @p{dofs_per_component}. */ template static void - count_dofs_per_component (const DoFHandler &dof_handler, - std::vector &dofs_per_component); + count_dofs_per_component (const DoFHandler& dof_handler, + std::vector& dofs_per_component, + std::vector target_component + =std::vector()); /** * This function can be used when diff --git a/deal.II/deal.II/include/multigrid/mg_dof_tools.h b/deal.II/deal.II/include/multigrid/mg_dof_tools.h index 57edad521e..738b96204d 100644 --- a/deal.II/deal.II/include/multigrid/mg_dof_tools.h +++ b/deal.II/deal.II/include/multigrid/mg_dof_tools.h @@ -36,7 +36,7 @@ template class FullMatrix; * All member functions are static, so there is no need to create an * object of class @p{MGTools}. * - * @author Wolfgang Bangerth, Guido Kanschat, 1999, 2000 + * @author Wolfgang Bangerth, Guido Kanschat, 1999-2003 */ class MGTools { @@ -126,7 +126,9 @@ class MGTools */ template static void count_dofs_per_component (const MGDoFHandler& mg_dof, - std::vector >& result); + std::vector >& result, + std::vector target_component + = std::vector()); /** diff --git a/deal.II/deal.II/include/multigrid/mg_transfer.h b/deal.II/deal.II/include/multigrid/mg_transfer.h index ad9c487871..5add525f41 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.h @@ -41,7 +41,7 @@ template class MGDoFHandler; * once by looping over all cells and storing the result in a matrix for * each level, but requires additional memory. * - * @author Wolfgang Bangerth, Guido Kanschat, 1999, 2000, 2001, 2002 + * @author Wolfgang Bangerth, Guido Kanschat, 1999-2003 */ template class MGTransferPrebuilt : public MGTransferBase > @@ -255,7 +255,7 @@ class MGTransferPrebuilt : public MGTransferBase > * Implementation of matrix generation for @ref{MGTransferBlock} and * @p{MGTransferSelected}. * - * @author Guido Kanschat, 2001 + * @author Guido Kanschat, 2001-2003 */ class MGTransferBlockBase { @@ -269,10 +269,17 @@ class MGTransferBlockBase * components are to be built. By * default, all matrices are * built. + * + * The last argument + * @p{target_component} allows + * grouping of components the + * same way as in + * @p{DoFRenumbering::component_wise}. */ template - void build_matrices (const MGDoFHandler &mg_dof, - std::vector selected); + void build_matrices (const MGDoFHandler& mg_dof, + const std::vector& selected, + const std::vector& target_component); /** * Flag of selected components. @@ -518,10 +525,11 @@ class MGTransferBlock : public MGTransferBase >, /** * Implementation of the @p{MGTransferBase} interface for block * matrices and simple vectors. This class uses @ref{MGTransferBlock} - * selecting a single component. The transfer operators themselves are - * implemented for simple vectors again. + * selecting a single component or grouping several components into a + * single block. The transfer operators themselves are implemented for + * simple vectors again. * - * @author Guido Kanschat, 2001, 2002 + * @author Guido Kanschat, 2001, 2002, 2003 */ template class MGTransferSelect : public MGTransferBase >, @@ -548,6 +556,29 @@ class MGTransferSelect : public MGTransferBase >, void build_matrices (const MGDoFHandler &mg_dof, unsigned int selected); + /** + * Actually build the prolongation + * matrices for grouped components. + * + * The argument + * @p{target_component} + * corresponds to the grouping + * mechanism of + * @p{DoFRenumbering::component_wise(...)}, + * which should be used to create + * the corresponding block + * structure in matrices and + * vectors. + * + * This function is a front-end + * for the same function in + * @ref{MGTransferBlockBase}. + */ + template + void build_matrices (const MGDoFHandler &mg_dof, + unsigned int selected, + const std::vector& target_component); + /** * Prolongate a vector from level * @p{to_level-1} to level diff --git a/deal.II/deal.II/include/multigrid/mg_transfer.templates.h b/deal.II/deal.II/include/multigrid/mg_transfer.templates.h index 0f384aa958..eee2a98470 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.templates.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.templates.h @@ -26,8 +26,6 @@ #include -//TODO:[GK] This file is included from nowhere. It should either go away entirely, or be included at least from some .h or .cc file - /* --------------------- MGTransferPrebuilt -------------- */ diff --git a/deal.II/deal.II/source/dofs/dof_tools.cc b/deal.II/deal.II/source/dofs/dof_tools.cc index a36065742a..9ae23dd559 100644 --- a/deal.II/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/deal.II/source/dofs/dof_tools.cc @@ -1674,11 +1674,26 @@ DoFTools::extract_subdomain_dofs (const DoFHandler &dof_handler, template void DoFTools:: -count_dofs_per_component (const DoFHandler &dof_handler, - std::vector &dofs_per_component) +count_dofs_per_component (const DoFHandler& dof_handler, + std::vector& dofs_per_component, + std::vector target_component) { const unsigned int n_components = dof_handler.get_fe().n_components(); dofs_per_component.resize (n_components); + fill (dofs_per_component.begin(), dofs_per_component.end(), 0U); + + // If the empty vector was given as + // default argument, set up this + // vector as identity. + if (target_component.size()==0) + { + target_component.resize(n_components); + for (unsigned int i=0;i &dof_handler, // next count what we got for (unsigned int i=0; i -void MGTools::make_sparsity_pattern (const MGDoFHandler &dof, - SparsityPattern &sparsity, - const unsigned int level) +void MGTools::make_sparsity_pattern ( + const MGDoFHandler &dof, + SparsityPattern &sparsity, + const unsigned int level) { const unsigned int n_dofs = dof.n_dofs(level); @@ -65,9 +66,10 @@ void MGTools::make_sparsity_pattern (const MGDoFHandler &dof, template void -MGTools::make_flux_sparsity_pattern (const MGDoFHandler &dof, - SparsityPattern &sparsity, - const unsigned int level) +MGTools::make_flux_sparsity_pattern ( + const MGDoFHandler &dof, + SparsityPattern &sparsity, + const unsigned int level) { const unsigned int n_dofs = dof.n_dofs(level); @@ -121,9 +123,10 @@ MGTools::make_flux_sparsity_pattern (const MGDoFHandler &dof, template void -MGTools::make_flux_sparsity_pattern_edge (const MGDoFHandler &dof, - SparsityPattern &sparsity, - const unsigned int level) +MGTools::make_flux_sparsity_pattern_edge ( + const MGDoFHandler &dof, + SparsityPattern &sparsity, + const unsigned int level) { Assert ((level>=1) && (level &dof, -//TODO[GK]: Replace FullMatrix by Table<2,bool> +//TODO[GK]: Replace FullMatrix by Table<2,char> template void -MGTools::make_flux_sparsity_pattern (const MGDoFHandler &dof, - SparsityPattern &sparsity, - const unsigned int level, - const FullMatrix& int_mask, - const FullMatrix& flux_mask) +MGTools::make_flux_sparsity_pattern ( + const MGDoFHandler &dof, + SparsityPattern &sparsity, + const unsigned int level, + const FullMatrix& int_mask, + const FullMatrix& flux_mask) { const unsigned int n_dofs = dof.n_dofs(level); const unsigned int n_comp = dof.get_fe().n_components(); @@ -291,8 +295,10 @@ MGTools::make_flux_sparsity_pattern (const MGDoFHandler &dof, template void -MGTools::count_dofs_per_component (const MGDoFHandler& dof_handler, - std::vector >& result) +MGTools::count_dofs_per_component ( + const MGDoFHandler& dof_handler, + std::vector >& result, + std::vector target_component) { const unsigned int nlevels = dof_handler.get_tria().n_levels(); @@ -300,6 +306,17 @@ MGTools::count_dofs_per_component (const MGDoFHandler& dof_handler, ExcDimensionMismatch(result.size(), nlevels)); const unsigned int n_components = dof_handler.get_fe().n_components(); + + if (target_component.size() == 0) + { + target_component.resize(n_components); + for (unsigned int i=0;i& dof_handler, // next count what we got for (unsigned int i=0; i void MGTransferBlockBase::build_matrices ( - const MGDoFHandler &mg_dof, - std::vector select) + const MGDoFHandler& mg_dof, + const std::vector& select, + const std::vector& target_component) { const FiniteElement& fe = mg_dof.get_fe(); const unsigned int n_components = fe.n_components(); @@ -248,12 +249,15 @@ template template void MGTransferBlock::build_matrices ( const MGDoFHandler &mg_dof, - std::vector select) + std::vector select) { if (select.size() == 0) select = std::vector (mg_dof.get_fe().n_components(), true); - - MGTransferBlockBase::build_matrices (mg_dof, select); + std::vector target_component(mg_dof.get_fe().n_components()); + for (unsigned int i=0;i::build_matrices ( selected = select; std::vector s(mg_dof.get_fe().n_components(), false); s[select] = true; + std::vector target_component(mg_dof.get_fe().n_components()); + for (unsigned int i=0;i