From 5c33fc4f7d2c21082758f5f4bb19e51f6c80e354 Mon Sep 17 00:00:00 2001 From: guido Date: Tue, 8 Jul 2003 21:40:00 +0000 Subject: [PATCH] multigrid with grouped components and MGTransferSelect git-svn-id: https://svn.dealii.org/trunk@7861 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/include/dofs/dof_renumbering.h | 3 +- .../deal.II/include/multigrid/mg_smoother.h | 8 +- .../deal.II/include/multigrid/mg_transfer.h | 52 +++++++------ .../include/multigrid/mg_transfer.templates.h | 6 +- .../deal.II/source/multigrid/mg_dof_tools.cc | 5 +- .../source/multigrid/mg_transfer_block.cc | 74 +++++++++++++------ 6 files changed, 88 insertions(+), 60 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_renumbering.h b/deal.II/deal.II/include/dofs/dof_renumbering.h index d3fa5741a2..dbff2d8893 100644 --- a/deal.II/deal.II/include/dofs/dof_renumbering.h +++ b/deal.II/deal.II/include/dofs/dof_renumbering.h @@ -317,7 +317,8 @@ class DoFRenumbering template static void component_wise (DoFHandler &dof_handler, - const std::vector &target_component = std::vector()); + const std::vector &target_component + = std::vector()); /** * Sort the degrees of freedom by diff --git a/deal.II/deal.II/include/multigrid/mg_smoother.h b/deal.II/deal.II/include/multigrid/mg_smoother.h index b6899fa323..5a1583fc28 100644 --- a/deal.II/deal.II/include/multigrid/mg_smoother.h +++ b/deal.II/deal.II/include/multigrid/mg_smoother.h @@ -532,18 +532,12 @@ MGSmootherRelaxation::smooth( if (symmetric && (steps2 % 2 == 0)) T = false; // cerr << 'S' << level; +// cerr << '(' << matrices[level]->m() << ',' << matrices[level]->n() << ')'; for (unsigned int i=0; isadd(-1.,1.,rhs); diff --git a/deal.II/deal.II/include/multigrid/mg_transfer.h b/deal.II/deal.II/include/multigrid/mg_transfer.h index 5add525f41..3d405e64c3 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.h @@ -270,22 +270,27 @@ class MGTransferBlockBase * default, all matrices are * built. * - * The last argument - * @p{target_component} allows - * grouping of components the - * same way as in - * @p{DoFRenumbering::component_wise}. + * This function is only called + * by derived classes. These can + * also set the member variable + * @p{target_component} for + * re-ordering and grouping of + * components. */ template void build_matrices (const MGDoFHandler& mg_dof, - const std::vector& selected, - const std::vector& target_component); + const std::vector& selected); /** * Flag of selected components. */ std::vector selected; + /** + * Target component if renumbering is required. + */ + std::vector target_component; + /** * Sizes of the multi-level vectors. */ @@ -372,13 +377,21 @@ class MGTransferBlock : public MGTransferBase >, * default, all matrices are * built. * + * The last argument + * @p{target_component} allows + * grouping of components the + * same way as in + * @p{DoFRenumbering::component_wise}. + * * This function is a front-end * for the same function in * @ref{MGTransferBlockBase}. */ template void build_matrices (const MGDoFHandler &mg_dof, - std::vector selected = std::vector()); + std::vector selected = std::vector(), + const std::vector& target_component + =std::vector()); /** * Prolongate a vector from level @@ -541,25 +554,15 @@ class MGTransferSelect : public MGTransferBase >, */ virtual ~MGTransferSelect (); - /** - * Actually build the prolongation - * matrices for each level. - * - * Select the component you want - * to apply multigrid to. - * - * This function is a front-end - * for the same function in - * @ref{MGTransferBlockBase}. - */ - template - void build_matrices (const MGDoFHandler &mg_dof, - unsigned int selected); - /** * Actually build the prolongation * matrices for grouped components. * + * @p{selected} is the number of + * the component for which the + * transfer matrices should be + * built. + * * The argument * @p{target_component} * corresponds to the grouping @@ -577,7 +580,8 @@ class MGTransferSelect : public MGTransferBase >, template void build_matrices (const MGDoFHandler &mg_dof, unsigned int selected, - const std::vector& target_component); + const std::vector& target_component + = std::vector()); /** * Prolongate a vector from 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 eee2a98470..828e0865a0 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.templates.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.templates.h @@ -365,7 +365,7 @@ copy_to_mg (const MGDoFHandler &mg_dof_handler, // into the level-wise one for (unsigned int i=0; i &mg_dof_handler, // copy level-wise data to // global vector for (unsigned int i=0; i &mg_dof_handler, // copy level-wise data to // global vector for (unsigned int i=0; i void MGTransferBlockBase::build_matrices ( const MGDoFHandler& mg_dof, - const std::vector& select, - const std::vector& /*target_component*/) + const std::vector& select) { + if (target_component.size() == 0) + { + target_component.resize(mg_dof.get_fe().n_components()); + for (unsigned int i=0;i& fe = mg_dof.get_fe(); const unsigned int n_components = fe.n_components(); const unsigned int dofs_per_cell = fe.dofs_per_cell; @@ -44,7 +62,7 @@ void MGTransferBlockBase::build_matrices ( ExcDimensionMismatch(selected.size(), n_components)) sizes.resize(n_levels); - MGTools::count_dofs_per_component(mg_dof, sizes); + MGTools::count_dofs_per_component(mg_dof, sizes, target_component); // reset the size of the array of // matrices. call resize(0) first, @@ -158,9 +176,11 @@ void MGTransferBlockBase::build_matrices ( for (unsigned int j=0; jadd(dof_indices_child[i], dof_indices_parent[j]); }; @@ -196,7 +216,7 @@ void MGTransferBlockBase::build_matrices ( { const unsigned int icomp = fe.system_to_component_index(i).first; const unsigned int jcomp = fe.system_to_component_index(j).first; - if ((icomp==jcomp) && selected[icomp]) + if ((icomp==jcomp) && selected[target_component[icomp]]) prolongation_matrices[level]->set(dof_indices_child[i], dof_indices_parent[j], prolongation(i,j)); @@ -249,15 +269,15 @@ template template void MGTransferBlock::build_matrices ( const MGDoFHandler &mg_dof, - std::vector select) + std::vector select, + const std::vector& t_component) { if (select.size() == 0) select = std::vector (mg_dof.get_fe().n_components(), true); - std::vector target_component(mg_dof.get_fe().n_components()); - for (unsigned int i=0;i template void MGTransferSelect::build_matrices ( const MGDoFHandler &mg_dof, - unsigned int select) + unsigned int select, + const std::vector& t_component) { + unsigned int ncomp = mg_dof.get_fe().n_components(); + selected = select; - std::vector s(mg_dof.get_fe().n_components(), false); + std::vector s(ncomp, false); s[select] = true; - std::vector target_component(mg_dof.get_fe().n_components()); - for (unsigned int i=0;i::build_matrices ( template void MGTransferBlock::build_matrices (const MGDoFHandler &mg_dof, - std::vector); + std::vector, const std::vector&); template void MGTransferSelect::build_matrices (const MGDoFHandler &mg_dof, - unsigned int); + unsigned int, const std::vector&); template void MGTransferBlock::build_matrices (const MGDoFHandler &mg_dof, - std::vector); + std::vector, const std::vector&); template void MGTransferSelect::build_matrices (const MGDoFHandler &mg_dof, - unsigned int); + unsigned int, const std::vector&); template void -- 2.39.5