From 1cff434d504fce621f0b7a03e4afa72e8c8051e1 Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Sun, 29 Jan 2006 15:00:32 +0000 Subject: [PATCH] MGTransfer simplified for DG only git-svn-id: https://svn.dealii.org/trunk@12201 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/include/multigrid/mg_transfer.h | 193 ++---------------- .../include/multigrid/mg_transfer.templates.h | 178 +++------------- 2 files changed, 49 insertions(+), 322 deletions(-) diff --git a/deal.II/deal.II/include/multigrid/mg_transfer.h b/deal.II/deal.II/include/multigrid/mg_transfer.h index b39a342e53..3be072a0f3 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -90,7 +90,7 @@ class MGTransferPrebuilt : public MGTransferBase void copy_to_mg (const MGDoFHandler& mg_dof, MGLevelObject& dst, - const InVector& src) const; + const InVector& src) const; /** * Transfer from multi-level vector to @@ -106,8 +106,8 @@ class MGTransferPrebuilt : public MGTransferBase */ template void - copy_from_mg (const MGDoFHandler &mg_dof, - OutVector &dst, + copy_from_mg (const MGDoFHandler& mg_dof, + OutVector& dst, const MGLevelObject &src) const; /** @@ -120,9 +120,9 @@ class MGTransferPrebuilt : public MGTransferBase */ template void - copy_from_mg_add (const MGDoFHandler &mg_dof, - OutVector &dst, - const MGLevelObject &src) const; + copy_from_mg_add (const MGDoFHandler& mg_dof, + OutVector& dst, + const MGLevelObject& src) const; /** * Finite element does not @@ -149,17 +149,6 @@ class MGTransferPrebuilt : public MGTransferBase */ std::vector sizes; -#ifdef DEAL_PREFER_MATRIX_EZ - /** - * The actual prolongation matrix. - * column indices belong to the - * dof indices of the mother cell, - * i.e. the coarse level. - * while row indices belong to the - * child cell, i.e. the fine level. - */ - std::vector > > prolongation_matrices; -#else /** * Sparsity patterns for transfer * matrices. @@ -174,56 +163,7 @@ class MGTransferPrebuilt : public MGTransferBase * while row indices belong to the * child cell, i.e. the fine level. */ - std::vector > > prolongation_matrices; -#endif - - /** - * Structure that is used to - * disambiguate calls to - * @p copy_to_mg for 1d and - * non-1d. We provide two - * functions of @p copy_to_mg, - * where the 1d function takes an - * argument of type - * is_1d and the other - * one of type is_1d. - */ - template struct is_1d {}; - - /** - * Implementation of the - * copy_to_mg() function for - * 1d. We have to resort to some - * template trickery because we - * can't specialize template - * functions on the (outer) - * template of the class, without - * also fully specializing the - * inner (member function) - * template parameters. However, - * it can be done by adding the - * additional argument that - * converts template - * specialization into function - * overloading. - */ - template - void - copy_to_mg (const MGDoFHandler &mg_dof, - MGLevelObject &dst, - const InVector &src, - const is_1d &) const; - - /** - * Same for all other space - * dimensions. - */ - template - void - copy_to_mg (const MGDoFHandler &mg_dof, - MGLevelObject &dst, - const InVector &src, - const is_1d &) const; + std::vector > > prolongation_matrices; }; @@ -324,25 +264,12 @@ class MGTransferBlockBase * function first. */ DeclException0(ExcMatricesNotBuilt); - -#ifdef DEAL_PREFER_MATRIX_EZ - protected: - - /** - * The actual prolongation matrix. - * column indices belong to the - * dof indices of the mother cell, - * i.e. the coarse level. - * while row indices belong to the - * child cell, i.e. the fine level. - */ - std::vector > > prolongation_matrices; -#else + private: std::vector > prolongation_sparsities; - + protected: - + /** * The actual prolongation matrix. * column indices belong to the @@ -352,8 +279,7 @@ class MGTransferBlockBase * child cell, i.e. the fine level. */ std::vector > > prolongation_matrices; -#endif - + /** * Unused now, but intended to * hold the mapping for the @@ -520,54 +446,6 @@ class MGTransferBlock : public MGTransferBase >, MGTransferBlockBase::memory_consumption; private: - /** - * Structure that is used to - * disambiguate calls to - * @p copy_to_mg for 1d and - * non-1d. We provide two - * functions of @p copy_to_mg, - * where the 1d function takes an - * argument of type - * is_1d and the other - * one of type is_1d. - */ - template struct is_1d {}; - - /** - * Implementation of the - * @p copy_to_mg function for - * 1d. We have to resort to some - * template trickery because we - * can't specialize template - * functions on the (outer) - * template of the class, without - * also fully specializing the - * inner (member function) - * template parameters. However, - * it can be done by adding the - * additional argument that - * converts template - * specialization into function - * overloading. - */ - template - void - copy_to_mg (const MGDoFHandler &mg_dof, - MGLevelObject > &dst, - const InVector &src, - const is_1d &) const; - - /** - * Same for all other space - * dimensions. - */ - template - void - copy_to_mg (const MGDoFHandler &mg_dof, - MGLevelObject > &dst, - const InVector &src, - const is_1d &) const; - /** * Optional multiplication * factors for each @@ -671,19 +549,6 @@ class MGTransferSelect : public MGTransferBase >, virtual void restrict_and_add (const unsigned int from_level, Vector &dst, const Vector &src) const; - - /** - * Structure that is used to - * disambiguate calls to - * copy_to_mg() for 1d and - * non-1d. We provide two - * functions of copy_to_mg(), - * where the 1d function takes an - * argument of type - * is_1d and the other - * one of type is_1d}. - */ - template struct is_1d {}; /** * Transfer from a vector on the @@ -793,43 +658,15 @@ class MGTransferSelect : public MGTransferBase >, const unsigned int offset) const; /** - * Implementation of the - * copy_to_mg() function for - * 1d. We have to resort to some - * template trickery because we - * can't specialize template - * functions on the (outer) - * template of the class, without - * also fully specializing the - * inner (member function) - * template parameters. However, - * it can be done by adding the - * additional argument that - * converts template - * specialization into function - * overloading. + * Actual implementation of + * copy_to_mg(). */ template void do_copy_to_mg (const MGDoFHandler &mg_dof, MGLevelObject > &dst, const InVector &src, - const unsigned int offset, - const is_1d &) const; - - /** - * Implementation of the - * copy_to_mg() function for - * higher dimensions. - */ - template - void - do_copy_to_mg (const MGDoFHandler &mg_dof, - MGLevelObject > &dst, - const InVector &src, - const unsigned int offset, - const is_1d &) const; - + const unsigned int offset) const; /** * Selected component of global vector. */ 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 6931906f31..100b9d00d2 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.templates.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.templates.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004, 2005 by the deal.II authors +// Copyright (C) 2003, 2004, 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -38,40 +38,11 @@ MGTransferPrebuilt::copy_to_mg ( MGLevelObject &dst, const InVector &src) const { - // forward to the correct - // specialization - copy_to_mg (mg_dof_handler, dst, src, is_1d<(dim==1)>()); -} - - -template -template -void -MGTransferPrebuilt::copy_to_mg ( - const MGDoFHandler &, - MGLevelObject &, - const InVector &, - const is_1d &) const -{ - Assert(false, ExcNotImplemented()); -} - - -template -template -void -MGTransferPrebuilt::copy_to_mg ( - const MGDoFHandler& mg_dof_handler, - MGLevelObject& dst, - const InVector& src, - const is_1d&) const -{ - // Make src a real finite element function -// InVector src = osrc; -// constraints->distribute(src); - const unsigned int dofs_per_cell = mg_dof_handler.get_fe().dofs_per_cell; - const unsigned int dofs_per_face = mg_dof_handler.get_fe().dofs_per_face; - + const FiniteElement& fe = mg_dof_handler.get_fe(); + Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0)); + + const unsigned int dofs_per_cell = fe.dofs_per_cell; + // set the elements of the vectors // on all levels to zero unsigned int minlevel = dst.get_minlevel(); @@ -86,8 +57,7 @@ MGTransferPrebuilt::copy_to_mg ( std::vector global_dof_indices (dofs_per_cell); std::vector level_dof_indices (dofs_per_cell); - std::vector level_face_indices (dofs_per_face); - + // traverse the grid top-down // (i.e. starting with the most // refined grid). this way, we can @@ -105,10 +75,6 @@ MGTransferPrebuilt::copy_to_mg ( const typename MGDoFHandler::active_cell_iterator level_end = mg_dof_handler.end_active(level); -//TODO:[?] Treat hanging nodes properly -// The single-level vector is not an FE-function, because the values at -// hanging nodes are set to zero. This should be treated before the restriction. - // Compute coarse level right hand side // by restricting from fine level. for (; level_cell!=level_end; ++level_cell) @@ -125,24 +91,7 @@ MGTransferPrebuilt::copy_to_mg ( // into the level-wise one for (unsigned int i=0; i::faces_per_cell; ++face_n) - { - const typename MGDoFHandler::face_iterator - face = level_cell->face(face_n); - if (face->has_children()) - { - face->get_mg_dof_indices(level_face_indices); - - - // Delete values on refinement edge, - // since restriction will add them again. - for (unsigned int i=0; i::copy_to_mg ( { restrict_and_add (level+1, dst[level], dst[level+1]); } - }; + } } @@ -165,8 +114,10 @@ MGTransferPrebuilt::copy_from_mg( OutVector& dst, const MGLevelObject& src) const { - const unsigned int dofs_per_cell = mg_dof_handler.get_fe().dofs_per_cell; - + const FiniteElement& fe = mg_dof_handler.get_fe(); + Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0)); + + const unsigned int dofs_per_cell = fe.dofs_per_cell; std::vector global_dof_indices (dofs_per_cell); std::vector level_dof_indices (dofs_per_cell); @@ -212,8 +163,10 @@ MGTransferPrebuilt::copy_from_mg_add ( OutVector &dst, const MGLevelObject &src) const { - const unsigned int dofs_per_cell = mg_dof_handler.get_fe().dofs_per_cell; - + const FiniteElement& fe = mg_dof_handler.get_fe(); + Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0)); + + const unsigned int dofs_per_cell = fe.dofs_per_cell; std::vector global_dof_indices (dofs_per_cell); std::vector level_dof_indices (dofs_per_cell); @@ -283,11 +236,7 @@ MGTransferSelect::copy_to_mg ( MGLevelObject > &dst, const BlockVector &src) const { - // forward to the correct - // specialization - do_copy_to_mg (mg_dof_handler, dst, src, - 0, //component_start[selected_component], - is_1d<(dim==1)>()); + do_copy_to_mg (mg_dof_handler, dst, src, 0); } @@ -300,26 +249,7 @@ MGTransferSelect::copy_to_mg ( MGLevelObject > &dst, const Vector &src) const { - // forward to the correct - // specialization - do_copy_to_mg (mg_dof_handler, dst, src, - component_start[selected_component], - is_1d<(dim==1)>()); -} - - - -template -template -void -MGTransferSelect::do_copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const InVector&, - const unsigned int, - const is_1d&) const -{ - Assert(false, ExcNotImplemented()); + do_copy_to_mg (mg_dof_handler, dst, src, component_start[selected_component]); } @@ -331,17 +261,13 @@ MGTransferSelect::do_copy_to_mg ( const MGDoFHandler& mg_dof_handler, MGLevelObject >& dst, const InVector& src, - const unsigned int offset, - const is_1d&) const + const unsigned int offset) const { - // Make src a real finite element function -// InVector src = osrc; -// constraints->distribute(src); - const FiniteElement& fe = mg_dof_handler.get_fe(); + Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0)); + const unsigned int dofs_per_cell = fe.dofs_per_cell; - const unsigned int dofs_per_face = fe.dofs_per_face; - + // set the elements of the vectors // on all levels to zero unsigned int minlevel = dst.get_minlevel(); @@ -357,8 +283,7 @@ MGTransferSelect::do_copy_to_mg ( std::vector global_dof_indices (dofs_per_cell); std::vector level_dof_indices (dofs_per_cell); - std::vector level_face_indices (dofs_per_face); - + // Build a vector of the selected // indices, since traversing all // indices on each cell is too @@ -498,10 +423,10 @@ MGTransferSelect::do_copy_from_mg ( const MGLevelObject > &src, const unsigned int offset) const { - const FiniteElement& fe = mg_dof_handler.get_fe(); + Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0)); + const unsigned int dofs_per_cell = fe.dofs_per_cell; - std::vector global_dof_indices (dofs_per_cell); std::vector level_dof_indices (dofs_per_cell); @@ -558,8 +483,8 @@ MGTransferSelect::do_copy_from_mg_add ( const MGLevelObject > &src, const unsigned int offset) const { - const FiniteElement& fe = mg_dof_handler.get_fe(); + Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0)); const unsigned int dofs_per_cell = fe.dofs_per_cell; std::vector global_dof_indices (dofs_per_cell); @@ -629,44 +554,10 @@ MGTransferBlock::copy_to_mg ( MGLevelObject > &dst, const InVector &src) const { - // forward to the correct - // specialization - copy_to_mg (mg_dof_handler, dst, src, is_1d<(dim==1)>()); -} - - - -template -template -void -MGTransferBlock::copy_to_mg ( - const MGDoFHandler &, - MGLevelObject > &, - const InVector &, - const is_1d &) const -{ - Assert(false, ExcNotImplemented()); -} - - - -template -template -void -MGTransferBlock::copy_to_mg ( - const MGDoFHandler &mg_dof_handler, - MGLevelObject > &dst, - const InVector &src, - const is_1d &) const -{ - // Make src a real finite element - // function -// InVector src = osrc; -// constraints->distribute(src); - const FiniteElement& fe = mg_dof_handler.get_fe(); + Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0)); + const unsigned int dofs_per_cell = fe.dofs_per_cell; - const unsigned int dofs_per_face = fe.dofs_per_face; // set the elements of the vectors // on all levels to zero @@ -679,8 +570,7 @@ MGTransferBlock::copy_to_mg ( std::vector global_dof_indices (dofs_per_cell); std::vector level_dof_indices (dofs_per_cell); - std::vector level_face_indices (dofs_per_face); - + // traverse the grid top-down // (i.e. starting with the most // refined grid). this way, we can @@ -718,7 +608,6 @@ MGTransferBlock::copy_to_mg ( dst[level](level_dof_indices[i]) = src(global_dof_indices[i]); } -//TODO: Special treatment of faces? Copy from MGTransferPrebuilt when done there. } // for that part of the level // which is further refined: @@ -743,10 +632,10 @@ MGTransferBlock::copy_from_mg ( OutVector &dst, const MGLevelObject > &src) const { - const FiniteElement& fe = mg_dof_handler.get_fe(); + Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0)); + const unsigned int dofs_per_cell = fe.dofs_per_cell; - std::vector global_dof_indices (dofs_per_cell); std::vector level_dof_indices (dofs_per_cell); @@ -790,8 +679,9 @@ MGTransferBlock::copy_from_mg_add ( const MGLevelObject > &src) const { const FiniteElement& fe = mg_dof_handler.get_fe(); + Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0)); + const unsigned int dofs_per_cell = fe.dofs_per_cell; - std::vector global_dof_indices (dofs_per_cell); std::vector level_dof_indices (dofs_per_cell); -- 2.39.5