From b2047d8e271e4a10076915d633778a28c264ee51 Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 29 May 2003 19:44:49 +0000 Subject: [PATCH] Resolve some of the issues with using deal_II_dimension in header files, which is not allowed. Rename the file mg_tools.templates.h to mg_transfer.templates.h, which is really the right name. git-svn-id: https://svn.dealii.org/trunk@7682 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/include/multigrid/mg_transfer.h | 166 ++++++++++++++++-- ...ls.templates.h => mg_transfer.templates.h} | 87 ++++++--- 2 files changed, 216 insertions(+), 37 deletions(-) rename deal.II/deal.II/include/multigrid/{mg_tools.templates.h => mg_transfer.templates.h} (91%) diff --git a/deal.II/deal.II/include/multigrid/mg_transfer.h b/deal.II/deal.II/include/multigrid/mg_transfer.h index 98d58c34cd..d3a8d9268f 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.h @@ -43,7 +43,7 @@ template class MGDoFHandler; * * @author Wolfgang Bangerth, Guido Kanschat, 1999, 2000, 2001, 2002 */ -template +template class MGTransferPrebuilt : public MGTransferBase > { public: @@ -111,7 +111,7 @@ class MGTransferPrebuilt : public MGTransferBase > * on each of the levels * separately, i.a. an @p{MGVector}. */ - template + template void copy_to_mg (const MGDoFHandler &mg_dof, MGLevelObject > &dst, @@ -129,7 +129,7 @@ class MGTransferPrebuilt : public MGTransferBase > * constrained degrees of freedom * are set to zero. */ - template + template void copy_from_mg (const MGDoFHandler &mg_dof, OutVector &dst, @@ -143,7 +143,7 @@ class MGTransferPrebuilt : public MGTransferBase > * function, but probably not for * continuous elements. */ - template + template void copy_from_mg_add (const MGDoFHandler &mg_dof, OutVector &dst, @@ -200,6 +200,54 @@ class MGTransferPrebuilt : public MGTransferBase > */ 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 + * @p{is_1d} and the other + * one of type @p{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; }; @@ -377,7 +425,7 @@ class MGTransferBlock : public MGTransferBase >, * on each of the levels * separately, i.a. an @p{MGVector}. */ - template + template void copy_to_mg (const MGDoFHandler &mg_dof, MGLevelObject > &dst, @@ -395,7 +443,7 @@ class MGTransferBlock : public MGTransferBase >, * constrained degrees of freedom * are set to zero. */ - template + template void copy_from_mg (const MGDoFHandler &mg_dof, OutVector &dst, @@ -409,11 +457,60 @@ class MGTransferBlock : public MGTransferBase >, * function, but probably not for * continuous elements. */ - template + template void copy_from_mg_add (const MGDoFHandler &mg_dof, OutVector &dst, const MGLevelObject > &src) const; + + 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 + * @p{is_1d} and the other + * one of type @p{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; }; @@ -497,13 +594,26 @@ class MGTransferSelect : public MGTransferBase >, Vector &dst, const Vector &src) const; + /** + * 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 + * @p{is_1d} and the other + * one of type @p{is_1d}. + */ + template struct is_1d; + /** * Transfer from a vector on the * global grid to vectors defined * on each of the levels * separately, i.a. an @p{MGVector}. */ - template + template void copy_to_mg (const MGDoFHandler &mg_dof, MGLevelObject > &dst, @@ -521,7 +631,7 @@ class MGTransferSelect : public MGTransferBase >, * constrained degrees of freedom * are set to zero. */ - template + template void copy_from_mg (const MGDoFHandler &mg_dof, OutVector &dst, @@ -535,7 +645,7 @@ class MGTransferSelect : public MGTransferBase >, * function, but probably not for * continuous elements. */ - template + template void copy_from_mg_add (const MGDoFHandler &mg_dof, OutVector &dst, @@ -546,6 +656,42 @@ class MGTransferSelect : public MGTransferBase >, * Selected component. */ unsigned int selected; + + + /** + * 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; }; diff --git a/deal.II/deal.II/include/multigrid/mg_tools.templates.h b/deal.II/deal.II/include/multigrid/mg_transfer.templates.h similarity index 91% rename from deal.II/deal.II/include/multigrid/mg_tools.templates.h rename to deal.II/deal.II/include/multigrid/mg_transfer.templates.h index 136109baa0..589121da60 100644 --- a/deal.II/deal.II/include/multigrid/mg_tools.templates.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.templates.h @@ -11,8 +11,8 @@ // //---------------------------------------------------------------------------- -#ifndef __deal2__mg_tools_templates_h -#define __deal2__mg_tools_templates_h +#ifndef __deal2__mg_transfer_templates_h +#define __deal2__mg_transfer_templates_h #include #include @@ -28,33 +28,39 @@ /* --------------------- MGTransferPrebuilt -------------- */ -//TODO[GK]: this file must really be changed: it contains #if's for deal_II_dimension, but we can't use this in headers, since application programs might not use this way to select the dimension. the only way in header files is to have proper template specializations +template +template +void +MGTransferPrebuilt::copy_to_mg (const MGDoFHandler &mg_dof_handler, + MGLevelObject > &dst, + const InVector &src) const +{ + // forward to the correct + // specialization + copy_to_mg (mg_dof_handler, dst, src, is_1d()); +} -//TODO:[?] This function needs to be specially implemented, since in 2d mode we use faces -#if deal_II_dimension == 1 template template void -MGTransferPrebuilt::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const InVector&) const +MGTransferPrebuilt::copy_to_mg (const MGDoFHandler &, + MGLevelObject > &, + const InVector &, + const is_1d &) const { Assert(false, ExcNotImplemented()); } -#else - template template void -MGTransferPrebuilt::copy_to_mg ( - const MGDoFHandler& mg_dof_handler, - MGLevelObject >& dst, - const InVector& src) const +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; @@ -146,7 +152,6 @@ MGTransferPrebuilt::copy_to_mg ( }; } -#endif template @@ -250,8 +255,21 @@ copy_from_mg_add (const MGDoFHandler &mg_dof_handler, /* --------------------- MGTransferSelect -------------- */ -//TODO:[?] This function needs to be specially implemented, since in 2d mode we use faces -#if deal_II_dimension == 1 + +template +template +void +MGTransferSelect:: +copy_to_mg (const MGDoFHandler &mg_dof_handler, + MGLevelObject > &dst, + const InVector &src) const +{ + // forward to the correct + // specialization + copy_to_mg (mg_dof_handler, dst, src, is_1d()); +} + + template template @@ -259,12 +277,12 @@ void MGTransferSelect:: copy_to_mg (const MGDoFHandler &, MGLevelObject > &, - const InVector &) const + const InVector &, + const is_1d &) const { Assert(false, ExcNotImplemented()); } -#else template @@ -273,7 +291,8 @@ void MGTransferSelect:: copy_to_mg (const MGDoFHandler &mg_dof_handler, MGLevelObject > &dst, - const InVector &osrc) const + const InVector &osrc, + const is_1d &) const { // Make src a real finite element function InVector src = osrc; @@ -379,7 +398,6 @@ copy_to_mg (const MGDoFHandler &mg_dof_handler, }; } -#endif template @@ -507,7 +525,21 @@ copy_from_mg_add (const MGDoFHandler &mg_dof_handler, /* --------------------- MGTransferBlock -------------- */ -#if deal_II_dimension == 1 + +template +template +void +MGTransferBlock:: +copy_to_mg (const MGDoFHandler &mg_dof_handler, + MGLevelObject > &dst, + const InVector &src) const +{ + // forward to the correct + // specialization + copy_to_mg (mg_dof_handler, dst, src, is_1d()); +} + + template template @@ -515,12 +547,12 @@ void MGTransferBlock:: copy_to_mg (const MGDoFHandler &, MGLevelObject > &, - const InVector &) const + const InVector &, + const is_1d &) const { Assert(false, ExcNotImplemented()); } -#else template @@ -529,7 +561,8 @@ void MGTransferBlock:: copy_to_mg (const MGDoFHandler &mg_dof_handler, MGLevelObject > &dst, - const InVector &src) const + const InVector &src, + const is_1d &) const { // Make src a real finite element // function @@ -607,7 +640,7 @@ copy_to_mg (const MGDoFHandler &mg_dof_handler, }; } -#endif + template -- 2.39.5