From f711a135c6e04e563139b41984ef301d0515ca78 Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 1 Apr 2004 11:15:47 +0000 Subject: [PATCH] MGTransferPrebuilt for BlockVector, MGTransferSelect works with target_components, MGTransferBlock broken git-svn-id: https://svn.dealii.org/trunk@8935 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/common/scripts/status.pl | 9 +- deal.II/contrib/dx/single/scalar.cfg | 32 +- deal.II/contrib/dx/single/scalar.net | 68 +-- deal.II/deal.II/include/multigrid/mg_base.h | 82 ++-- .../deal.II/include/multigrid/mg_transfer.h | 394 ++++++++---------- .../include/multigrid/mg_transfer.templates.h | 83 ++-- deal.II/deal.II/include/multigrid/multigrid.h | 5 +- .../source/multigrid/mg_transfer_block.cc | 37 +- .../source/multigrid/mg_transfer_prebuilt.cc | 109 +++-- .../multigrid/multigrid.all_dimensions.cc | 38 +- tests/fe/transfer.cc | 4 +- tests/multigrid/transfer.cc | 141 +++++-- 12 files changed, 563 insertions(+), 439 deletions(-) diff --git a/deal.II/common/scripts/status.pl b/deal.II/common/scripts/status.pl index 991154c335..9b43f4075a 100644 --- a/deal.II/common/scripts/status.pl +++ b/deal.II/common/scripts/status.pl @@ -58,15 +58,16 @@ while() } else { $status = "$status $work $rep "; } - + + $tag =~ s/ .*//; $tag = '' if ($tag eq '(none)'); $date = '' if ($date eq '(none)'); $opt = '' if ($opt eq '(none)'); - $opt = '' if ($opt eq '-kk'); +# $opt = '' if ($opt eq '-kk'); my $stick = $tag . $date . $opt; - $stick = "Stick $stick" unless ($stick eq ''); + $stick = "$stick" unless ($stick eq ''); $status .= $stick; - printf "%-40s %-20s %s\n", $file, $status, + printf "%-40s %-30s %s\n", $file, $status, (($short) ? '' : $rep_file) unless ($compress && ($status eq 'OK ')); } diff --git a/deal.II/contrib/dx/single/scalar.cfg b/deal.II/contrib/dx/single/scalar.cfg index 80ac72710f..e29a67d660 100644 --- a/deal.II/contrib/dx/single/scalar.cfg +++ b/deal.II/contrib/dx/single/scalar.cfg @@ -1,40 +1,40 @@ // -// time: Mon Dec 10 11:19:00 2001 +// time: Sun Feb 22 22:08:26 2004 // -// version: 3.1.2 (format), 4.1.3 (DX) +// version: 3.1.2 (format), 4.2.0 (DX) // // Message Window: -// window: position = (0.5148,0.0039), size = 0.4781x0.2568 +// window: position = (0.5149,0.0038), size = 0.4780x0.2571 // -// panel[0]: position = (0.6203,0.5889), size = 0.3047x0.2666, startup = 1, devstyle = 1 +// panel[0]: position = (0.6202,0.5886), size = 0.3048x0.2667, startup = 1, devstyle = 1 // title: value = Control Panel // // workspace: width = 196, height = 145 // layout: snap = 1, width = 50, height = 50, align = NL // -// interactor FileSelector[1]: num_components = 1, value = NULL +// interactor FileSelector[1]: num_components = 1, value = "/home/kanschat/deal.II/gk/n/slug.04.dx" // instance: panel = 0, x = 0, y = 6, style = FileSelector, vertical = 1, size = 196x57 // filter = *.dx // -// interactor Integer[1]: num_components = 1, value = 11 -// component[0]: minimum = 0, maximum = 14, global increment = 1, decimal = 0, global continuous = 0 +// interactor Integer[1]: num_components = 1, value = 2 +// component[0]: minimum = 0, maximum = 4, global increment = 1, decimal = 0, global continuous = 0 // instance: panel = 0, x = 0, y = 89, style = Stepper, vertical = 1, size = 118x56 // label: value = Component: // local continuous: value = 1, mode = local // local increment[0]: value = 1, mode = global // // node Image[1]: -// depth: value = 8 -// window: position = (0.0000,0.1338), size = 0.5195x0.6553 +// depth: value = 24 +// window: position = (0.0000,0.1333), size = 0.5196x0.6552 // input[1]: defaulting = 0, value = "Image_1" // input[4]: defaulting = 0, value = 1 -// input[5]: defaulting = 0, value = [0 0 0] -// input[6]: defaulting = 0, value = [0 0 5.55279] -// input[7]: defaulting = 0, value = 2.97574 -// input[8]: defaulting = 0, value = 651 -// input[9]: defaulting = 0, value = 0.963902 +// input[5]: defaulting = 0, value = [0.5 1 0] +// input[6]: defaulting = 0, value = [0.5 1 7.10757] +// input[7]: defaulting = 0, value = 3.80895 +// input[8]: defaulting = 0, value = 859 +// input[9]: defaulting = 0, value = 0.75 // input[10]: defaulting = 0, value = [0 1 0] -// input[11]: defaulting = 1, value = 30.0001 +// input[11]: defaulting = 0, value = 30.0001 // input[12]: defaulting = 0, value = 0 // input[14]: defaulting = 0, value = 1 // input[15]: defaulting = 1, value = "none" @@ -44,7 +44,7 @@ // input[19]: defaulting = 0, value = 0 // input[22]: defaulting = 0, value = "white" // input[26]: defaulting = 0, value = "eps color dpi=65 orient=landscape" -// input[29]: defaulting = 0, value = 1 +// input[29]: defaulting = 0, value = 0 // input[30]: defaulting = 0, value = {"x", "y", "z"} // input[33]: defaulting = 0, value = 0 // input[36]: defaulting = 0, value = 0 diff --git a/deal.II/contrib/dx/single/scalar.net b/deal.II/contrib/dx/single/scalar.net index fea9b89b14..b26967831e 100644 --- a/deal.II/contrib/dx/single/scalar.net +++ b/deal.II/contrib/dx/single/scalar.net @@ -1,14 +1,14 @@ // -// time: Mon Dec 10 11:19:00 2001 +// time: Sun Feb 22 22:08:26 2004 // -// version: 3.1.2 (format), 4.1.3 (DX) +// version: 3.1.2 (format), 4.2.0 (DX) // // // MODULE main -// page assignment: Color order=2, windowed=0, showing=1 -// page assignment: Display order=3, windowed=0, showing=0 -// page assignment: Input order=1, windowed=0, showing=0 -// workspace: width = 500, height = 551 +// page assignment: Color order=3, windowed=0, showing=1 +// page assignment: Display order=4, windowed=0, showing=0 +// page assignment: Input order=2, windowed=0, showing=0 +// workspace: width = 435, height = 551 // layout: snap = 1, width = 50, height = 80, align = CC // macro main( @@ -16,8 +16,8 @@ macro main( ) { // // node FileSelector[1]: x = 331, y = 9, inputs = 0, label = FileSelector - // output[1]: visible = 1, type = 32, value = NULL - // output[2]: visible = 1, type = 32, value = NULL + // output[1]: visible = 1, type = 32, value = "/home/kanschat/deal.II/gk/n/slug.04.dx" + // output[2]: visible = 1, type = 32, value = "slug.04.dx" // page group: Input // // @@ -57,15 +57,15 @@ main_Inquire_1_out_1 = // // node Integer[1]: x = 141, y = 329, inputs = 11, label = Integer // input[1]: defaulting = 0, visible = 0, type = 32, value = "Integer_1" - // input[3]: defaulting = 0, visible = 0, type = 1, value = 11 + // input[3]: defaulting = 0, visible = 0, type = 1, value = 2 // input[4]: visible = 1 // input[5]: defaulting = 0, visible = 1, type = 1, value = 0 - // input[6]: defaulting = 1, visible = 1, type = 1, value = 14 + // input[6]: defaulting = 1, visible = 1, type = 1, value = 4 // input[7]: defaulting = 1, visible = 1, type = 5, value = 1.0 // input[8]: visible = 1 // input[9]: defaulting = 1, visible = 0, type = 1, value = 0 // input[11]: defaulting = 1, visible = 1, type = 32, value = "Component select" - // output[1]: visible = 1, type = 1, value = 11 + // output[1]: visible = 1, type = 1, value = 2 // page group: Input // main_Integer_1_out_1[cache: 2] = @@ -289,23 +289,23 @@ main_Collect_2_out_1 = // node Image[1]: x = 239, y = 329, inputs = 49, label = Image // input[1]: defaulting = 0, visible = 0, type = 67108863, value = "Image_1" // input[4]: defaulting = 0, visible = 0, type = 1, value = 1 - // input[5]: defaulting = 0, visible = 0, type = 8, value = [0 0 0] - // input[6]: defaulting = 0, visible = 0, type = 8, value = [0 0 5.55279] - // input[7]: defaulting = 0, visible = 0, type = 5, value = 2.97574 - // input[8]: defaulting = 0, visible = 0, type = 1, value = 651 - // input[9]: defaulting = 0, visible = 0, type = 5, value = 0.963902 + // input[5]: defaulting = 0, visible = 0, type = 8, value = [0.5 1 0] + // input[6]: defaulting = 0, visible = 0, type = 8, value = [0.5 1 7.10757] + // input[7]: defaulting = 0, visible = 0, type = 5, value = 3.80895 + // input[8]: defaulting = 0, visible = 0, type = 1, value = 859 + // input[9]: defaulting = 0, visible = 0, type = 5, value = 0.75 // input[10]: defaulting = 0, visible = 0, type = 8, value = [0 1 0] - // input[11]: defaulting = 1, visible = 0, type = 5, value = 30.0001 + // input[11]: defaulting = 0, visible = 0, type = 5, value = 30.0001 // input[12]: defaulting = 0, visible = 0, type = 1, value = 0 // input[14]: defaulting = 0, visible = 0, type = 1, value = 1 // input[15]: defaulting = 1, visible = 0, type = 32, value = "none" // input[16]: defaulting = 1, visible = 0, type = 32, value = "none" // input[17]: defaulting = 1, visible = 0, type = 1, value = 1 // input[18]: defaulting = 1, visible = 0, type = 1, value = 1 - // input[19]: defaulting = 0, visible = 0, type = 3, value = 0 + // input[19]: defaulting = 0, visible = 0, type = 1, value = 0 // input[22]: defaulting = 0, visible = 0, type = 32, value = "white" // input[26]: defaulting = 0, visible = 0, type = 32, value = "eps color dpi=65 orient=landscape" - // input[29]: defaulting = 0, visible = 0, type = 3, value = 1 + // input[29]: defaulting = 0, visible = 0, type = 3, value = 0 // input[30]: defaulting = 0, visible = 0, type = 16777248, value = {"x", "y", "z"} // input[33]: defaulting = 0, visible = 0, type = 3, value = 0 // input[36]: defaulting = 0, visible = 0, type = 3, value = 0 @@ -314,8 +314,8 @@ main_Collect_2_out_1 = // input[39]: defaulting = 0, visible = 0, type = 5, value = 0.5 // input[41]: defaulting = 0, visible = 0, type = 32, value = "none" // page group: Display - // depth: value = 8 - // window: position = (0.0000,0.1338), size = 0.5195x0.6553 + // depth: value = 24 + // window: position = (0.0000,0.1333), size = 0.5196x0.6552 // internal caching: 1 // main_Image_1_out_1[cache: 0], @@ -375,8 +375,8 @@ main_Image_1_out_3[cache: 0] = // network: end of macro body CacheScene(main_Image_1_in_1, main_Image_1_out_1, main_Image_1_out_2); } -main_FileSelector_1_out_1 = NULL; -main_FileSelector_1_out_2 = NULL; +main_FileSelector_1_out_1 = "/home/kanschat/deal.II/gk/n/slug.04.dx"; +main_FileSelector_1_out_2 = "slug.04.dx"; main_Import_1_in_2 = NULL; main_Import_1_in_3 = NULL; main_Import_1_in_4 = NULL; @@ -390,7 +390,7 @@ main_Inquire_1_in_3 = NULL; main_Inquire_1_out_1 = NULL; main_Integer_1_in_1 = "Integer_1"; main_Integer_1_in_2 = NULL; -main_Integer_1_in_3 = 11 ; +main_Integer_1_in_3 = 2; main_Integer_1_in_4 = NULL; main_Integer_1_in_5 = 0; main_Integer_1_in_7 = NULL; @@ -398,7 +398,7 @@ main_Integer_1_in_8 = NULL; main_Integer_1_in_9 = NULL; main_Integer_1_in_10 = NULL; main_Integer_1_in_11 = NULL; -main_Integer_1_out_1 = 11 ; +main_Integer_1_out_1 = 2; main_Compute_1_in_1 = "select($0,$1)"; main_Compute_1_out_1 = NULL; main_Transmitter_1_out_1 = NULL; @@ -777,15 +777,15 @@ macro Image( RECformat) [instance: 2, cache: 1]; } main_Image_1_in_1 = "Image_1"; -main_Image_1_in_3 = "X8,,"; +main_Image_1_in_3 = "X24,,"; main_Image_1_in_4 = 1; -main_Image_1_in_5 = [0 0 0]; -main_Image_1_in_6 = [0 0 5.55279]; -main_Image_1_in_7 = 2.97574; -main_Image_1_in_8 = 651; -main_Image_1_in_9 = 0.963902; +main_Image_1_in_5 = [0.5 1 0]; +main_Image_1_in_6 = [0.5 1 7.10757]; +main_Image_1_in_7 = 3.80895; +main_Image_1_in_8 = 859; +main_Image_1_in_9 = 0.75; main_Image_1_in_10 = [0 1 0]; -main_Image_1_in_11 = NULL; +main_Image_1_in_11 = 30.0001; main_Image_1_in_12 = 0; main_Image_1_in_13 = NULL; main_Image_1_in_14 = 1; @@ -802,7 +802,7 @@ main_Image_1_in_25 = NULL; main_Image_1_in_26 = "eps color dpi=65 orient=landscape"; main_Image_1_in_27 = NULL; main_Image_1_in_28 = NULL; -main_Image_1_in_29 = 1; +main_Image_1_in_29 = 0; main_Image_1_in_30 = {"x", "y", "z"}; main_Image_1_in_31 = NULL; main_Image_1_in_32 = NULL; @@ -823,6 +823,6 @@ main_Image_1_in_46 = NULL; main_Image_1_in_47 = NULL; main_Image_1_in_48 = NULL; main_Image_1_in_49 = NULL; -Executive("product version 4 1 3"); +Executive("product version 4 2 0"); $sync main(); diff --git a/deal.II/deal.II/include/multigrid/mg_base.h b/deal.II/deal.II/include/multigrid/mg_base.h index bc0859e92f..80bcedc2bd 100644 --- a/deal.II/deal.II/include/multigrid/mg_base.h +++ b/deal.II/deal.II/include/multigrid/mg_base.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -32,8 +32,8 @@ * multilevel algorithms. It has no relation to the actual matrix type * and takes the vector class as only template argument. * - * Usually, the derived class @ref{MGMatrix}, operating on an - * @ref{MGLevelObject} of matrices will be sufficient for applications. + * Usually, the derived class MGMatrix, operating on an + * MGLevelObject of matrices will be sufficient for applications. * * @author Guido Kanschat, 2002 */ @@ -107,25 +107,26 @@ class MGCoarseGridBase : public Subscriptor /** * Base class used to declare the operations needed by a concrete class * implementing prolongation and restriction of vectors in the multigrid - * context. This class is an abstract one and has no implementations of - * possible algorithms for these operations. + * context. This class is abstract and has no implementation of + * these operations. * * There are several derived classes, reflecting the fact that vector * types and numbering of the fine-grid discretization and of the * multi-level implementation are independent. * * If you use multigrid for your complete system of equations, you - * will use @ref{MGTransferPrebuilt} together with Multigrid for - * Vector objects. The fine-grid vectors may still be of type - * BlockVector. + * will use MGTransferPrebuilt together with Multigrid. The vector + * types used on the fine grid as well as for the multilevel + * operations may be Vector or BlockVector. In both cases, + * MGTransferPrebuilt will operate on all components of the solution. * * For mixed systems, it may be required to do multigrid only for a * single component or for some components. The classes - * @ref{MGTransferSelect} and @ref{MGTransferBlock} handle these cases. + * MGTransferSelect and MGTransferBlock handle these cases. * - * MGTransferSelect is used if you use mutligrid (on Vector oblects) + * MGTransferSelect is used if you use mutligrid (on Vector objects) * for a single component, possibly grouped using - * @p{mg_target_component}. + * mg_target_component. * * The class MGTransferBlock handles the case where your multigrid * method operates on BlockVector objects. These can contain all or a @@ -148,18 +149,19 @@ class MGCoarseGridBase : public Subscriptor /** * Prolongate a vector from level - * @p{to_level-1} to level - * @p{to_level}. The previous - * content of @p{dst} is + * to_level-1 to level + * to_level. The previous + * content of dst is * overwritten. * - * @p{src} is assumed to be a vector with - * as many elements as there are degrees - * of freedom on the coarser level of - * the two involved levels, while @p{src} - * shall have as many elements as there - * are degrees of freedom on the finer - * level. + * @arg src is a vector with as + * many elements as there are + * degrees of freedom on the + * coarser level involved. + * + * @arg dst has as many elements + * as there are degrees of + * freedom on the finer level. */ virtual void prolongate (const unsigned int to_level, VECTOR& dst, @@ -167,26 +169,30 @@ class MGCoarseGridBase : public Subscriptor /** * Restrict a vector from level - * @p{from_level} to level - * @p{from_level-1} and add this - * restriction to - * @p{dst}. Obviously, if the - * refined region on level - * @p{from_level} is smaller than - * that on level @p{from_level-1}, - * some degrees of freedom in - * @p{dst} are not covered and will - * not be altered. For the other - * degress of freedom, the result - * of the restriction is added. + * from_level to level + * from_level-1 and add + * this restriction to + * dst. If the region + * covered by cells on level + * from_level is smaller + * than that of level + * from_level-1 (local + * refinement), then some degrees + * of freedom in dst are + * active and will not be + * altered. For the other degress + * of freedom, the result of the + * restriction is added. * - * @p{src} is assumed to be a vector with - * as many elements as there are degrees - * of freedom on the finer level of - * the two involved levels, while @p{src} - * shall have as many elements as there + * @arg src is a vector with as + * many elements as there are + * degrees of freedom on the + * finer level + * + * @arg dst has as many elements as there * are degrees of freedom on the coarser * level. + * */ virtual void restrict_and_add (const unsigned int from_level, VECTOR& dst, diff --git a/deal.II/deal.II/include/multigrid/mg_transfer.h b/deal.II/deal.II/include/multigrid/mg_transfer.h index 8c0200dc18..1f2f62ff53 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.h @@ -13,6 +13,7 @@ #ifndef __deal2__mg_transfer_h #define __deal2__mg_transfer_h +#include #include #ifdef DEAL_PREFER_MATRIX_EZ @@ -35,19 +36,19 @@ template class MGDoFHandler; */ /** - * Implementation of the @p{MGTransferBase} interface for which the transfer + * Implementation of the MGTransferBase interface for which the transfer * operations are prebuilt upon construction of the object of this class as * matrices. This is the fast way, since it only needs to build the operation * once by looping over all cells and storing the result in a matrix for * each level, but requires additional memory. * - * See @ref{MGTransferBase} to find out which of the transfer classes + * See MGTransferBase to find out which of the transfer classes * is best for your needs. * - * @author Wolfgang Bangerth, Guido Kanschat, 1999-2003 + * @author Wolfgang Bangerth, Guido Kanschat, 1999-2004 */ -template -class MGTransferPrebuilt : public MGTransferBase > +template +class MGTransferPrebuilt : public MGTransferBase { public: /** @@ -62,51 +63,13 @@ class MGTransferPrebuilt : public MGTransferBase > template void build_matrices (const MGDoFHandler &mg_dof); - /** - * Prolongate a vector from level - * @p{to_level-1} to level - * @p{to_level}. The previous - * content of @p{dst} is - * overwritten. - * - * @p{src} is assumed to be a vector with - * as many elements as there are degrees - * of freedom on the coarser level of - * the two involved levels, while @p{src} - * shall have as many elements as there - * are degrees of freedom on the finer - * level. - */ virtual void prolongate (const unsigned int to_level, - Vector &dst, - const Vector &src) const; + VECTOR &dst, + const VECTOR &src) const; - /** - * Restrict a vector from level - * @p{from_level} to level - * @p{from_level-1} and add this - * restriction to - * @p{dst}. Obviously, if the - * refined region on level - * @p{from_level} is smaller than - * that on level @p{from_level-1}, - * some degrees of freedom in - * @p{dst} are not covered and will - * not be altered. For the other - * degress of freedom, the result - * of the restriction is added. - * - * @p{src} is assumed to be a vector with - * as many elements as there are degrees - * of freedom on the finer level of - * the two involved levels, while @p{src} - * shall have as many elements as there - * are degrees of freedom on the coarser - * level. - */ virtual void restrict_and_add (const unsigned int from_level, - Vector &dst, - const Vector &src) const; + VECTOR &dst, + const VECTOR &src) const; /** * Transfer from a vector on the @@ -116,9 +79,9 @@ class MGTransferPrebuilt : public MGTransferBase > */ template void - copy_to_mg (const MGDoFHandler &mg_dof, - MGLevelObject > &dst, - const InVector &src) const; + copy_to_mg (const MGDoFHandler& mg_dof, + MGLevelObject& dst, + const InVector& src) const; /** * Transfer from multi-level vector to @@ -136,7 +99,7 @@ class MGTransferPrebuilt : public MGTransferBase > void copy_from_mg (const MGDoFHandler &mg_dof, OutVector &dst, - const MGLevelObject > &src) const; + const MGLevelObject &src) const; /** * Add a multi-level vector to a @@ -150,7 +113,7 @@ class MGTransferPrebuilt : public MGTransferBase > void copy_from_mg_add (const MGDoFHandler &mg_dof, OutVector &dst, - const MGLevelObject > &src) const; + const MGLevelObject &src) const; /** * Finite element does not @@ -220,7 +183,7 @@ class MGTransferPrebuilt : public MGTransferBase > /** * Implementation of the - * @p{copy_to_mg} function for + * copy_to_mg() function for * 1d. We have to resort to some * template trickery because we * can't specialize template @@ -238,7 +201,7 @@ class MGTransferPrebuilt : public MGTransferBase > template void copy_to_mg (const MGDoFHandler &mg_dof, - MGLevelObject > &dst, + MGLevelObject &dst, const InVector &src, const is_1d &) const; @@ -249,15 +212,15 @@ class MGTransferPrebuilt : public MGTransferBase > template void copy_to_mg (const MGDoFHandler &mg_dof, - MGLevelObject > &dst, + MGLevelObject &dst, const InVector &src, const is_1d &) const; }; /** - * Implementation of matrix generation for @ref{MGTransferBlock} and - * @p{MGTransferSelect}. + * Implementation of matrix generation for MGTransferBlock and + * MGTransferSelect. * * @author Guido Kanschat, 2001-2003 */ @@ -283,8 +246,9 @@ class MGTransferBlockBase * * This function is only called * by derived classes. These can - * also set the member variable - * @p{target_component} for + * also set the member variables + * #target_component and + * #mg_target_component for * re-ordering and grouping of * components. */ @@ -294,11 +258,34 @@ class MGTransferBlockBase /** * Flag of selected components. + * + * The transfer operators only act + * on the components having a + * true entry here. If + * renumbering by + * #target_component is used, + * this refers to the + * renumbered components. */ std::vector selected; + /** + * Flag of selected components. + * + * The transfer operators only act + * on the components having a + * true entry here. If + * renumbering by + * #mg_target_component is used, + * this refers to the + * renumbered components. + */ + std::vector mg_selected; + /** - * Target component if renumbering is required. + * Target component of the + * fine-level vector if + * renumbering is required. */ std::vector target_component; @@ -326,7 +313,7 @@ class MGTransferBlockBase std::vector > mg_component_start; /** - * Call @p{build_matrices} + * Call build_matrices() * function first. */ DeclException0(ExcMatricesNotBuilt); @@ -364,7 +351,7 @@ class MGTransferBlockBase //TODO:[GK] Update this class /** - * Implementation of the @p{MGTransferBase} interface for block + * Implementation of the MGTransferBase interface for block * matrices and block vectors. * * Warning! Due to additional requirements on MGTransferSelect, the @@ -398,22 +385,34 @@ class MGTransferBlock : public MGTransferBase >, /** * Build the prolongation * matrices for each level. - * - * If a field selected is given, - * only matrices for these - * 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}. * * This function is a front-end * for the same function in - * @ref{MGTransferBlockBase}. + * MGTransferBlockBase. + * + * @arg selected: Opional + * argument indicating that only + * matrices for these components + * are to be built. By default, + * all matrices are built. + * + * If mg_target_component is + * present, this refers to the + * renumbered components. + * + * @arg target_component: this + * argument allows grouping and + * renumbering of components in + * the fine-level vector (see + * DoFRenumbering::component_wise). + * + * @arg mg_target_component: this + * argument allows grouping and + * renumbering of components in + * the level vectors (see + * DoFRenumbering::component_wise). It + * also affects the behavior of + * the selected argument */ template void build_matrices (const MGDoFHandler &mg_dof, @@ -423,57 +422,35 @@ class MGTransferBlock : public MGTransferBase >, const std::vector& mg_target_component =std::vector()); - /** - * Prolongate a vector from level - * @p{to_level-1} to level - * @p{to_level}. The previous - * content of @p{dst} is - * overwritten. - * - * @p{src} is assumed to be a vector with - * as many elements as there are degrees - * of freedom on the coarser level of - * the two involved levels, while @p{src} - * shall have as many elements as there - * are degrees of freedom on the finer - * level. - */ virtual void prolongate (const unsigned int to_level, BlockVector &dst, const BlockVector &src) const; - /** - * Restrict a vector from level - * @p{from_level} to level - * @p{from_level-1} and add this - * restriction to - * @p{dst}. Obviously, if the - * refined region on level - * @p{from_level} is smaller than - * that on level @p{from_level-1}, - * some degrees of freedom in - * @p{dst} are not covered and will - * not be altered. For the other - * degress of freedom, the result - * of the restriction is added. - * - * @p{src} is assumed to be a vector with - * as many elements as there are degrees - * of freedom on the finer level of - * the two involved levels, while @p{src} - * shall have as many elements as there - * are degrees of freedom on the coarser - * level. - */ virtual void restrict_and_add (const unsigned int from_level, BlockVector &dst, const BlockVector &src) const; /** * Transfer from a vector on the - * global grid to vectors defined - * on each of the levels - * separately, i.a. an @p{MGVector}. + * global grid to a multilevel + * vector. + * + * The action for discontinuous + * elements is as follows: on an + * active mesh cell, the global + * vector entries are simply + * copied to the corresponding + * entries of the level + * vector. Then, these values are + * restricted down to the + * coarsest level. + * + * If the arguments + * target_component and + * mg_target_component + * was used in build_matrices(), + * then the blocks are shuffled + * around accordingly. */ template void @@ -486,12 +463,16 @@ class MGTransferBlock : public MGTransferBase >, * normal vector. * * Copies data from active - * portions of an MGVector into - * the respective positions of a - * @p{Vector}. In order to - * keep the result consistent, - * constrained degrees of freedom - * are set to zero. + * portions of a multilevel + * vector into the respective + * positions of a global vector. + * + * If the arguments + * target_component and + * mg_target_component + * was used in build_matrices(), + * then the blocks are shuffled + * around accordingly. */ template void @@ -569,13 +550,13 @@ class MGTransferBlock : public MGTransferBase >, //TODO:[GK] Update documentation for copy_* functions /** - * Implementation of the @p{MGTransferBase} interface for block - * matrices and simple vectors. This class uses @ref{MGTransferBlockBase} + * Implementation of the MGTransferBase interface for block + * matrices and simple vectors. This class uses MGTransferBlockBase * selecting a single component or grouping several components into a * single block. The transfer operators themselves are implemented for * Vector and BlockVector objects. * - * See @ref{MGTransferBase} to find out which of the transfer classes + * See MGTransferBase to find out which of the transfer classes * is best for your needs. * * @author Guido Kanschat, 2001, 2002, 2003 @@ -594,29 +575,39 @@ class MGTransferSelect : public MGTransferBase >, * Actually build the prolongation * matrices for grouped components. * - * @p{selected} tells the copy - * functions operating on single - * vectors, which component this - * vector belongs to. + * This function is a front-end + * for the same function in + * MGTransferBlockBase. + * + * @arg selected: Number of the + * component of the global vector + * to be copied from and to the + * multilevel vector. This number + * refers to the renumbering by + * target_component. * - * @p{mg_selected} is the number + * @arg mg_selected: Number * of the component for which the * transfer matrices should be * built. * - * 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. + * If mg_target_component is + * present, this refers to the + * renumbered components. * - * This function is a front-end - * for the same function in - * @ref{MGTransferBlockBase}. + * @arg target_component: this + * argument allows grouping and + * renumbering of components in + * the fine-level vector (see + * DoFRenumbering::component_wise). + * + * @arg mg_target_component: this + * argument allows grouping and + * renumbering of components in + * the level vectors (see + * DoFRenumbering::component_wise). It + * also affects the behavior of + * the selected argument */ template void build_matrices (const MGDoFHandler &mg_dof, @@ -631,50 +622,13 @@ class MGTransferSelect : public MGTransferBase >, * Change selected * component. Handle with care! */ - void select (const unsigned int component); + void select (const unsigned int component, + const unsigned int mg_component = deal_II_numbers::invalid_unsigned_int); - /** - * Prolongate a vector from level - * @p{to_level-1} to level - * @p{to_level}. The previous - * content of @p{dst} is - * overwritten. - * - * @p{src} is assumed to be a vector with - * as many elements as there are degrees - * of freedom on the coarser level of - * the two involved levels, while @p{src} - * shall have as many elements as there - * are degrees of freedom on the finer - * level. - */ virtual void prolongate (const unsigned int to_level, Vector &dst, const Vector &src) const; - /** - * Restrict a vector from level - * @p{from_level} to level - * @p{from_level-1} and add this - * restriction to - * @p{dst}. Obviously, if the - * refined region on level - * @p{from_level} is smaller than - * that on level @p{from_level-1}, - * some degrees of freedom in - * @p{dst} are not covered and will - * not be altered. For the other - * degress of freedom, the result - * of the restriction is added. - * - * @p{src} is assumed to be a vector with - * as many elements as there are degrees - * of freedom on the finer level of - * the two involved levels, while @p{src} - * shall have as many elements as there - * are degrees of freedom on the coarser - * level. - */ virtual void restrict_and_add (const unsigned int from_level, Vector &dst, const Vector &src) const; @@ -682,21 +636,19 @@ class MGTransferSelect : public MGTransferBase >, /** * Structure that is used to * disambiguate calls to - * @p{copy_to_mg} for 1d and + * copy_to_mg() for 1d and * non-1d. We provide two - * functions of @p{copy_to_mg}, + * functions of copy_to_mg(), * where the 1d function takes an * argument of type - * @p{is_1d} and the other - * one of type @p{is_1d}. + * is_1d and the other + * one of type 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}. + * global grid to a multilevel vector. */ template void @@ -705,16 +657,13 @@ class MGTransferSelect : public MGTransferBase >, const Vector &src) const; /** - * Transfer from multi-level vector to + * Transfer from multilevel vector to * normal vector. * * Copies data from active - * portions of an MGVector into - * the respective positions of a - * @p{Vector}. In order to - * keep the result consistent, - * constrained degrees of freedom - * are set to zero. + * portions of an multilevel + * vector into the respective + * positions of a Vector. */ template void @@ -738,9 +687,7 @@ class MGTransferSelect : public MGTransferBase >, /** * Transfer from a vector on the - * global grid to vectors defined - * on each of the levels - * separately, i.a. an @p{MGVector}. + * global grid to multilevel vectors. */ template void @@ -749,16 +696,14 @@ class MGTransferSelect : public MGTransferBase >, const BlockVector &src) const; /** - * Transfer from multi-level vector to + * Transfer from multilevel vector to * normal vector. * * Copies data from active - * portions of an MGVector into - * the respective positions of a - * @p{Vector}. In order to - * keep the result consistent, - * constrained degrees of freedom - * are set to zero. + * portions of a multilevel + * vector into the respective + * positions of a global + * BlockVector. */ template void @@ -787,16 +732,8 @@ class MGTransferSelect : public MGTransferBase >, private: /** - * Transfer from multi-level vector to - * normal vector. - * - * Copies data from active - * portions of an MGVector into - * the respective positions of a - * @p{Vector}. In order to - * keep the result consistent, - * constrained degrees of freedom - * are set to zero. + * Implementation of the public + * function. */ template void @@ -806,12 +743,8 @@ class MGTransferSelect : public MGTransferBase >, const unsigned int offset) const; /** - * Add a multi-level vector to a - * normal vector. - * - * Works as the previous - * function, but probably not for - * continuous elements. + * Implementation of the public + * function. */ template void @@ -822,7 +755,7 @@ class MGTransferSelect : public MGTransferBase >, /** * Implementation of the - * @p{copy_to_mg} function for + * copy_to_mg() function for * 1d. We have to resort to some * template trickery because we * can't specialize template @@ -846,8 +779,9 @@ class MGTransferSelect : public MGTransferBase >, const is_1d &) const; /** - * Same for all other space - * dimensions. + * Implementation of the + * copy_to_mg() function for + * higher dimensions. */ template void @@ -858,17 +792,25 @@ class MGTransferSelect : public MGTransferBase >, const is_1d &) const; /** - * Selected component. + * Selected component of global vector. */ unsigned int selected_component; + /** + * Selected component inside multigrid. + */ + unsigned int mg_selected_component; }; //----------------------------------------------------------------------// template inline void -MGTransferSelect::select(const unsigned int component) +MGTransferSelect::select(const unsigned int component, + const unsigned int mg_component) { selected_component = component; + mg_selected_component = (mg_component == deal_II_numbers::invalid_unsigned_int) + ? component + : mg_component; } 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 f2e6a3b213..fcc48e3cd0 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.templates.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.templates.h @@ -30,12 +30,12 @@ -template +template template void -MGTransferPrebuilt::copy_to_mg ( +MGTransferPrebuilt::copy_to_mg ( const MGDoFHandler &mg_dof_handler, - MGLevelObject > &dst, + MGLevelObject &dst, const InVector &src) const { // forward to the correct @@ -44,12 +44,12 @@ MGTransferPrebuilt::copy_to_mg ( } -template +template template void -MGTransferPrebuilt::copy_to_mg ( +MGTransferPrebuilt::copy_to_mg ( const MGDoFHandler &, - MGLevelObject > &, + MGLevelObject &, const InVector &, const is_1d &) const { @@ -57,14 +57,14 @@ MGTransferPrebuilt::copy_to_mg ( } -template +template template void -MGTransferPrebuilt::copy_to_mg ( - const MGDoFHandler &mg_dof_handler, - MGLevelObject > &dst, - const InVector &src, - const is_1d &) 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; @@ -81,8 +81,8 @@ MGTransferPrebuilt::copy_to_mg ( Assert(sizes.size()==mg_dof_handler.get_tria().n_levels(), ExcMatricesNotBuilt()); - for (unsigned int l=minlevel;l<=maxlevel;++l) - dst[l].reinit(sizes[l]); +// for (unsigned int l=minlevel;l<=maxlevel;++l) +// dst[l].reinit(sizes[l]); std::vector global_dof_indices (dofs_per_cell); std::vector level_dof_indices (dofs_per_cell); @@ -158,13 +158,13 @@ MGTransferPrebuilt::copy_to_mg ( -template +template template void -MGTransferPrebuilt::copy_from_mg( - const MGDoFHandler &mg_dof_handler, - OutVector &dst, - const MGLevelObject > &src) const +MGTransferPrebuilt::copy_from_mg( + const MGDoFHandler& mg_dof_handler, + OutVector& dst, + const MGLevelObject& src) const { const unsigned int dofs_per_cell = mg_dof_handler.get_fe().dofs_per_cell; @@ -206,13 +206,13 @@ MGTransferPrebuilt::copy_from_mg( -template +template template void -MGTransferPrebuilt::copy_from_mg_add ( +MGTransferPrebuilt::copy_from_mg_add ( const MGDoFHandler &mg_dof_handler, OutVector &dst, - const MGLevelObject > &src) const + const MGLevelObject &src) const { const unsigned int dofs_per_cell = mg_dof_handler.get_fe().dofs_per_cell; @@ -255,9 +255,9 @@ MGTransferPrebuilt::copy_from_mg_add ( } -template +template unsigned int -MGTransferPrebuilt::memory_consumption () const +MGTransferPrebuilt::memory_consumption () const { unsigned int result = sizeof(*this); result += sizeof(unsigned int) * sizes.size(); @@ -288,7 +288,9 @@ MGTransferSelect::copy_to_mg ( { // forward to the correct // specialization - do_copy_to_mg (mg_dof_handler, dst, src, 0, is_1d<(dim==1)>()); + do_copy_to_mg (mg_dof_handler, dst, src, + 0, //component_start[selected_component], + is_1d<(dim==1)>()); } @@ -353,7 +355,8 @@ MGTransferSelect::do_copy_to_mg ( Assert(sizes.size()==mg_dof_handler.get_tria().n_levels(), ExcMatricesNotBuilt()); - MGTools::reinit_vector(mg_dof_handler, dst, selected, mg_target_component); + MGTools::reinit_vector(mg_dof_handler, dst, + mg_selected, mg_target_component); std::vector global_dof_indices (dofs_per_cell); std::vector level_dof_indices (dofs_per_cell); @@ -399,7 +402,7 @@ MGTransferSelect::do_copy_to_mg ( { const unsigned int component = mg_target_component[fe.system_to_component_index(i).first]; - if (selected[component]) + if (mg_selected[component]) { const unsigned int level_start = mg_component_start[level][component]; @@ -409,13 +412,13 @@ MGTransferSelect::do_copy_to_mg ( } } - for (unsigned int face_n=0; face_n::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); +// for (unsigned int face_n=0; face_n::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, @@ -423,9 +426,9 @@ MGTransferSelect::do_copy_to_mg ( // for (unsigned int i=0; i::do_copy_from_mg ( { const unsigned int component = mg_target_component[fe.system_to_component_index(i).first]; - if (selected[component]) + if (mg_selected[component]) { const unsigned int level_start = mg_component_start[level][component]; @@ -602,7 +605,7 @@ MGTransferSelect::do_copy_from_mg_add ( { const unsigned int component = mg_target_component[fe.system_to_component_index(i).first]; - if (selected[component]) + if (mg_selected[component]) { const unsigned int level_start = mg_component_start[level][component]; @@ -682,7 +685,7 @@ MGTransferBlock::copy_to_mg ( dst.clear(); - MGTools::reinit_vector(mg_dof_handler, dst, selected, mg_target_component); + MGTools::reinit_vector(mg_dof_handler, dst, mg_selected, mg_target_component); std::vector global_dof_indices (dofs_per_cell); std::vector level_dof_indices (dofs_per_cell); diff --git a/deal.II/deal.II/include/multigrid/multigrid.h b/deal.II/deal.II/include/multigrid/multigrid.h index 0f5baed13a..1479067d35 100644 --- a/deal.II/deal.II/include/multigrid/multigrid.h +++ b/deal.II/deal.II/include/multigrid/multigrid.h @@ -34,7 +34,10 @@ * Implementation of the multigrid method. * * Warning: multigrid on locally refined meshes only works with - * discontinuous finite elements. + * discontinuous finite elements right now. It is not clear, + * whether the paradigm of local smoothing we use is applicable to + * continuous elements with hanging nodes; in fact, most people you + * meet on conferences seem to deny this. * * The function actually performing a multi-level cycle, * @p{level_mgstep}, as well as the function @p{vcycle}, calling it, diff --git a/deal.II/deal.II/source/multigrid/mg_transfer_block.cc b/deal.II/deal.II/source/multigrid/mg_transfer_block.cc index 99ef32d7d4..0125fdbfe5 100644 --- a/deal.II/deal.II/source/multigrid/mg_transfer_block.cc +++ b/deal.II/deal.II/source/multigrid/mg_transfer_block.cc @@ -61,7 +61,7 @@ void MGTransferBlockBase::build_matrices ( { mg_target_component.resize(mg_dof.get_fe().n_components()); for (unsigned int i=0;iadd(dof_indices_child[i], dof_indices_parent[j]); }; @@ -278,7 +278,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[mg_target_component[icomp]]) + if ((icomp==jcomp) && mg_selected[mg_target_component[icomp]]) prolongation_matrices[level]->set(dof_indices_child[i], dof_indices_parent[j], prolongation(i,j)); @@ -351,14 +351,29 @@ void MGTransferSelect::build_matrices ( { unsigned int ncomp = mg_dof.get_fe().n_components(); - selected_component = select; - std::vector s(ncomp, false); - s[mg_select] = true; -//TODO:[GK] Assert that select and mg_select access the same component -// or figure out how to use different components target_component = t_component; mg_target_component = mg_t_component; + selected_component = select; + mg_selected_component = mg_select; + selected.resize(ncomp, false); + selected[select] = true; + // If components are renumbered, + // find the first original + // component corresponding to the + // target component. + for (unsigned int i=0;i s(ncomp, false); + s[mg_select] = true; + MGTransferBlockBase::build_matrices (mg_dof, s); } diff --git a/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc b/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc index 3720c4b34c..c754f2936c 100644 --- a/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc +++ b/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc @@ -169,82 +169,141 @@ void MGTransferPrebuilt::build_matrices ( template -void MGTransferPrebuilt::build_matrices +void MGTransferPrebuilt >::build_matrices (const MGDoFHandler &mg_dof); template -void MGTransferPrebuilt::build_matrices +void MGTransferPrebuilt >::build_matrices +(const MGDoFHandler &mg_dof); + +template +void MGTransferPrebuilt >::build_matrices +(const MGDoFHandler &mg_dof); + +template +void MGTransferPrebuilt >::build_matrices (const MGDoFHandler &mg_dof); template void -MGTransferPrebuilt::copy_to_mg ( +MGTransferPrebuilt >::copy_to_mg ( const MGDoFHandler&, MGLevelObject >&, const Vector&) const; template void -MGTransferPrebuilt::copy_to_mg ( +MGTransferPrebuilt >::copy_to_mg ( const MGDoFHandler&, MGLevelObject >&, const BlockVector&) const; template void -MGTransferPrebuilt::copy_to_mg ( +MGTransferPrebuilt >::copy_from_mg ( const MGDoFHandler&, - MGLevelObject >&, - const Vector&) const; + Vector&, + const MGLevelObject >&) const; template void -MGTransferPrebuilt::copy_to_mg ( +MGTransferPrebuilt >::copy_from_mg ( const MGDoFHandler&, - MGLevelObject >&, - const BlockVector&) const; + BlockVector&, + const MGLevelObject >&) const; template void -MGTransferPrebuilt::copy_from_mg ( +MGTransferPrebuilt >::copy_from_mg_add ( const MGDoFHandler&, Vector&, const MGLevelObject >&) const; template void -MGTransferPrebuilt::copy_from_mg ( +MGTransferPrebuilt >::copy_from_mg_add ( const MGDoFHandler&, BlockVector&, const MGLevelObject >&) const; + template void -MGTransferPrebuilt::copy_from_mg ( +MGTransferPrebuilt >::copy_to_mg ( const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; + MGLevelObject >&, + const Vector&) const; template void -MGTransferPrebuilt::copy_from_mg ( +MGTransferPrebuilt >::copy_to_mg ( const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferPrebuilt >::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; template void -MGTransferPrebuilt::copy_to_mg ( +MGTransferPrebuilt >::copy_to_mg ( const MGDoFHandler&, MGLevelObject >&, const Vector&) const; template void -MGTransferPrebuilt::copy_to_mg ( +MGTransferPrebuilt >::copy_to_mg ( const MGDoFHandler&, MGLevelObject >&, const BlockVector&) const; template void -MGTransferPrebuilt::copy_from_mg ( +MGTransferPrebuilt >::copy_from_mg ( const MGDoFHandler&, Vector&, const MGLevelObject >&) const; template void -MGTransferPrebuilt::copy_from_mg ( +MGTransferPrebuilt >::copy_from_mg ( const MGDoFHandler&, BlockVector&, const MGLevelObject >&) const; - template void -MGTransferPrebuilt::copy_from_mg_add ( +MGTransferPrebuilt >::copy_from_mg_add ( const MGDoFHandler&, Vector&, const MGLevelObject >&) const; template void -MGTransferPrebuilt::copy_from_mg_add ( +MGTransferPrebuilt >::copy_from_mg_add ( const MGDoFHandler&, BlockVector&, const MGLevelObject >&) const; + +template void +MGTransferPrebuilt >::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferPrebuilt >::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferPrebuilt >::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; diff --git a/deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc b/deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc index 70ba223c79..18528d514f 100644 --- a/deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc +++ b/deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -90,16 +90,16 @@ Multigrid::print_vector (const unsigned int level, -template -MGTransferPrebuilt::~MGTransferPrebuilt () +template +MGTransferPrebuilt::~MGTransferPrebuilt () {} -template -void MGTransferPrebuilt::prolongate ( - const unsigned int to_level, - Vector &dst, - const Vector &src) const +template +void MGTransferPrebuilt::prolongate ( + const unsigned int to_level, + VECTOR& dst, + const VECTOR& src) const { Assert ((to_level >= 1) && (to_level<=prolongation_matrices.size()), ExcIndexRange (to_level, 1, prolongation_matrices.size()+1)); @@ -108,11 +108,11 @@ void MGTransferPrebuilt::prolongate ( } -template -void MGTransferPrebuilt::restrict_and_add ( +template +void MGTransferPrebuilt::restrict_and_add ( const unsigned int from_level, - Vector &dst, - const Vector &src) const + VECTOR &dst, + const VECTOR &src) const { Assert ((from_level >= 1) && (from_level<=prolongation_matrices.size()), ExcIndexRange (from_level, 1, prolongation_matrices.size()+1)); @@ -185,8 +185,8 @@ void MGTransferSelect::prolongate ( Assert ((to_level >= 1) && (to_level<=prolongation_matrices.size()), ExcIndexRange (to_level, 1, prolongation_matrices.size()+1)); - prolongation_matrices[to_level-1]->block(selected_component, - selected_component) + prolongation_matrices[to_level-1]->block(mg_selected_component, + mg_selected_component) .vmult (dst, src); } @@ -200,8 +200,8 @@ void MGTransferSelect::restrict_and_add ( Assert ((from_level >= 1) && (from_level<=prolongation_matrices.size()), ExcIndexRange (from_level, 1, prolongation_matrices.size()+1)); - prolongation_matrices[from_level-1]->block(selected_component, - selected_component) + prolongation_matrices[from_level-1]->block(mg_selected_component, + mg_selected_component) .Tvmult_add (dst, src); } @@ -213,8 +213,10 @@ template class Multigrid >; template class Multigrid >; template class Multigrid >; -template class MGTransferPrebuilt; -template class MGTransferPrebuilt; +template class MGTransferPrebuilt >; +template class MGTransferPrebuilt >; +template class MGTransferPrebuilt >; +template class MGTransferPrebuilt >; template class MGTransferBlock; template class MGTransferBlock; template class MGTransferSelect; diff --git a/tests/fe/transfer.cc b/tests/fe/transfer.cc index dc8798d19c..1248c9a294 100644 --- a/tests/fe/transfer.cc +++ b/tests/fe/transfer.cc @@ -2,7 +2,7 @@ // transfer.cc,v 1.4 2003/04/09 15:49:55 wolf Exp // Version: // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -51,7 +51,7 @@ print_matrix(std::ostream& of, MGDoFHandler dof(tr); dof.distribute_dofs(finel); - MGTransferPrebuilt transfer; + MGTransferPrebuilt > transfer; transfer.build_matrices(dof); unsigned int n_coarse = dof.n_dofs(level-1); diff --git a/tests/multigrid/transfer.cc b/tests/multigrid/transfer.cc index 6eba0bc4ff..fd7a3ad312 100644 --- a/tests/multigrid/transfer.cc +++ b/tests/multigrid/transfer.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -33,6 +33,7 @@ #include #include +using namespace std; template void check_simple(const FiniteElement& fe) @@ -46,7 +47,7 @@ void check_simple(const FiniteElement& fe) MGDoFHandler mgdof(tr); mgdof.distribute_dofs(fe); - MGTransferPrebuilt transfer; + MGTransferPrebuilt > transfer; transfer.build_matrices(mgdof); Vector u2(mgdof.n_dofs(2)); @@ -71,8 +72,86 @@ void check_simple(const FiniteElement& fe) template void check_select(const FiniteElement& fe, unsigned int selected, + unsigned int mg_selected, std::vector target_component, std::vector mg_target_component) +{ + deallog << fe.get_name() + << " select " << selected + << " (global) and " << mg_selected + << " (mg)" << std::endl; + + Triangulation tr; + GridGenerator::hyper_cube(tr); + tr.refine_global(2); + + MGDoFHandler mgdof(tr); + mgdof.distribute_dofs(fe); + DoFRenumbering::component_wise(mgdof, target_component); + vector ndofs(fe.n_components()); + DoFTools::count_dofs_per_component(mgdof, ndofs, target_component); + + for (unsigned int l=0;l > mg_ndofs(mgdof.get_tria().n_levels()); MGTools::count_dofs_per_component(mgdof, mg_ndofs, mg_target_component); + + deallog << "Global dofs:"; + for (unsigned int i=0;i transfer; + transfer.build_matrices(mgdof, selected, mg_selected, + target_component, mg_target_component); + + Vector u2(mg_ndofs[2][mg_selected]); + Vector u1(mg_ndofs[1][mg_selected]); + Vector u0(mg_ndofs[0][mg_selected]); + + u0 = 1; + transfer.prolongate(1,u1,u0); + transfer.prolongate(2,u2,u1); + deallog << "u0 " << u0*u0 + << "\tu1 " << u1*u1 + << "\tu2 " << u2*u2; + u1 = 0.; + u0 = 0.; + transfer.restrict_and_add(2,u1,u2); + transfer.restrict_and_add(1,u0,u1); + deallog << "\tu1 " << u1*u1 + << "\tu0 " << u0*u0 + << std::endl; + + // Check copy to mg and back + BlockVector u; + u.reinit (ndofs); + for (unsigned int i=0;i > v; + v.resize(2,2); + v[2].reinit(mg_ndofs[2][mg_selected]); + + transfer.copy_to_mg(mgdof, v, u); + for (unsigned int i=0; i +void check_block(const FiniteElement& fe, + const vector& selected, + const vector& mg_selected, + std::vector target_component, + std::vector mg_target_component) { deallog << fe.get_name() << std::endl; @@ -97,26 +176,26 @@ void check_select(const FiniteElement& fe, } - MGTransferSelect transfer; - transfer.build_matrices(mgdof, selected, selected, + MGTransferBlock transfer; + transfer.build_matrices(mgdof, selected, mg_selected, target_component, mg_target_component); - Vector u2(mg_ndofs[2][0]); - Vector u1(mg_ndofs[1][0]); - Vector u0(mg_ndofs[0][0]); + BlockVector u2(mg_ndofs[2]); + BlockVector u1(mg_ndofs[1]); + BlockVector u0(mg_ndofs[0]); u0 = 1; transfer.prolongate(1,u1,u0); transfer.prolongate(2,u2,u1); - deallog << "u0 " << u0.l2_norm() - << "\tu1 " << u1.l2_norm() - << "\tu2 " << u2.l2_norm(); + deallog << "u0 " << u0*u0 + << "\tu1 " << u1*u1 + << "\tu2 " << u2*u2; u1 = 0.; u0 = 0.; transfer.restrict_and_add(2,u1,u2); transfer.restrict_and_add(1,u0,u1); - deallog << "\tu1 " << u1.l2_norm() - << "\tu0 " << u0.l2_norm() + deallog << "\tu1 " << u1*u1 + << "\tu0 " << u0*u0 << std::endl; // Check copy to mg and back @@ -129,7 +208,7 @@ void check_select(const FiniteElement& fe, MGLevelObject > v; v.resize(2,2); - v[2].reinit(mg_ndofs[2][selected]); + v[2].reinit(mg_ndofs[2][mg_selected]); transfer.copy_to_mg(mgdof, v, u); for (unsigned int i=0; i(0)); // check_simple (FE_DGP<2>(1)); @@ -151,6 +230,8 @@ int main() // check_simple (FE_Q<2>(1)); // check_simple (FE_Q<2>(2)); + std::cerr << "Select" << std::endl; + std::vector v1(4); std::vector v2(4); std::vector v3(4); @@ -158,17 +239,29 @@ int main() { v1[i] = i; v2[i] = 0; - v3[i] = i/2; + v3[i] = i; } - - check_select (FESystem<2>(FE_DGQ<2>(1), 4), 0, v1, v1); - check_select (FESystem<2>(FE_DGQ<2>(1), 4), 1, v1, v1); - check_select (FESystem<2>(FE_DGQ<2>(1), 4), 0, v2, v2); - check_select (FESystem<2>(FE_DGQ<2>(1), 4), 0, v3, v3); - check_select (FESystem<2>(FE_DGQ<2>(1), 4), 1, v3, v3); - check_select (FESystem<2>(FE_DGQ<2>(1), 4), 0, v1, v3); - check_select (FESystem<2>(FE_DGQ<2>(1), 4), 1, v1, v3); -} + v3[0] = 0; + v3[1] = 1; + v3[2] = 1; + v3[3] = 2; + FESystem<2> fe1(FE_DGQ<2>(1), 4); + + check_select (fe1, 0, 0, v1, v1); + check_select (fe1, 1, 1, v1, v1); + check_select (fe1, 1, 2, v1, v1); + check_select (fe1, 2, 1, v1, v1); + check_select (fe1, 0, 0, v2, v2); + check_select (fe1, 0, 0, v3, v3); + check_select (fe1, 1, 1, v3, v3); + check_select (fe1, 0, 0, v1, v3); + check_select (fe1, 1, 1, v1, v3); + check_select (fe1, 2, 1, v1, v3); + check_select (fe1, 0, 1, v1, v3); + check_select (fe1, 0, 0, v1, v2); +// vector s1(4, true); +// check_block(fe1, s1, s1, v1, v1); +} -- 2.39.5