]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Use default template parameters extensively for Solver*, Precondition*, and MG* class...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 25 Nov 1999 12:18:46 +0000 (12:18 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 25 Nov 1999 12:18:46 +0000 (12:18 +0000)
git-svn-id: https://svn.dealii.org/trunk@1946 0785d39b-7218-0410-832d-ea1e28bc413d

24 files changed:
deal.II/common/scripts/forward_declarations.pl
deal.II/deal.II/include/multigrid/mg_base.h
deal.II/deal.II/source/numerics/base.cc
deal.II/deal.II/source/numerics/vectors.cc
deal.II/lac/include/lac/mgbase.h
deal.II/lac/include/lac/precondition.h
deal.II/lac/include/lac/precondition_block.h
deal.II/lac/include/lac/precondition_selector.h
deal.II/lac/include/lac/solver.h
deal.II/lac/include/lac/solver_bicgstab.h
deal.II/lac/include/lac/solver_cg.h
deal.II/lac/include/lac/solver_gmres.h
deal.II/lac/include/lac/solver_qmrs.h
deal.II/lac/include/lac/solver_richardson.h
deal.II/lac/include/lac/solver_selector.h
deal.II/lac/include/lac/vector_memory.h
tests/deal.II/mg.cc
tests/deal.II/mglocal.cc
tests/deal.II/wave-test-3.cc
tests/lac/mg.cc
tests/lac/solver.cc
tests/lac/solver.checked
tests/lac/testmatrix.cc
tests/lac/testmatrix.h

index 25703b19dc10bdc470150d3fa85c8855c02ad65c..3e9c05597187a72aef02011fed5e7406f0b2a55b 100644 (file)
@@ -40,16 +40,39 @@ sub parse_class_declarations {
     
     open (FILE, $filename);
     while (<FILE>) {
-
        # if the lines contains a "template" at the 
        # beginning and no semicolon at the end: join it
        # with the next line.
        if ( /^\s*template/ && !/;\s*$/ ) {
+           # if this is a multiline template, then join following lines as well
+           # find out by looking at the last char of the line
+           while ( ! />\s*$/ ) {
+               # more concise check: find out whether the number of '<' is
+               # not equal to the number of '>'
+               my ( $tmp1, $tmp2 ) = ($_, $_);
+               $tmp1 =~ s/[^<]//g;
+               $tmp2 =~ s/[^>]//g;
+               if ( length ($tmp1) ==  length ($tmp2) ) {
+                   last;
+               }
+               else
+               {
+                   s/\n//;
+                   $_ = $_ . " " . <FILE>;
+                   s/ \s+/ /g;
+               }
+           }
            s/\n//;
+           s/ \s+/ /g;
            $_ = $_ . " " . <FILE>;
        }
 
-       if ( /^\s*((template\s*<(([-\w,_\s]|<([-\w_,+\s])+>)+)>\s*)?(class|struct))(.*)/ ) {
+       if ( /^\s*((template\s*<
+                     (
+                        ([-\w,_=\s]   |
+                         <([-\w_,=\s])+>  )+ 
+                     )>\s*)?
+                   (class|struct))(.*)/x ) {
            # this is the declaration of a class, possibly a template
            $basepart = $1;
            $rest     = $7;
@@ -58,7 +81,7 @@ sub parse_class_declarations {
            # $rest contains the name of the class and what comes after that
            #
            # first extract the name of the class
-           $rest =~ /([\w_]+(\s*<(([-\w,_\s]|<([-\w,+\s])+>)+)>)?)(.*)/;
+           $rest =~ /([\w_]+(\s*<(([-\w,_\s]|<([-\w,\s])+>)+)>)?)(.*)/;
 
            $name = $1;
            $rest = $6;
@@ -75,6 +98,10 @@ sub parse_class_declarations {
                $declaration =~ s/^\s+//g;
                $declaration =~ s/\s+$//g;
 
+               # strip default template parameters
+               while ( $declaration =~ s/<(.*)=\s[-\w,_\s]+(<[^.]*>)?(.*)>/<$1 $3 > / ) {
+               }
+
                # impose a negativ-list of names we do not want to
                # have in this file. this is due to a compiler bug in
                # egcs 1.1.2, which does not gracefully handle local
index 270eb9e5d6f51d0658148909b16d99de65d01269..77ab520edfc5da29f015998d26f3f7ec9224403e 100644 (file)
@@ -253,7 +253,7 @@ class MGVector : public Subscriptor
  * with a subscriptor for smart pointers.
  * @author Guido Kanschat, 1999
  */
-template<class MATRIX>
+template<class MATRIX = SparseMatrix<double> >
 class MGMatrix : public Subscriptor,
                 public vector<MATRIX>
 {
index 4d1d23afee79b895eac4164107b1a9f5468914f9..53f7fe8fa2f9d9b724c51fa6b72f02d6544e1227 100644 (file)
@@ -144,11 +144,11 @@ void ProblemBase<dim>::solve ()
 {
   Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected());
   
-  SolverControl                    control(4000, 1e-16);
-  PrimitiveVectorMemory<Vector<double> >   memory;
-  SolverCG<SparseMatrix<double>,Vector<double> >       cg(control,memory);
+  SolverControl           control(4000, 1e-16);
+  PrimitiveVectorMemory<> memory;
+  SolverCG<>              cg(control,memory);
 
-  PreconditionRelaxation<SparseMatrix<double>, Vector<double> >
+  PreconditionRelaxation<>
     prec(system_matrix,
         &SparseMatrix<double>::template precondition_SSOR<double>,
         1.2);
index 5332e93e737ff8e7c9b0bdf3196744a037e95f00..041ab2d6349fdd426a6c4303c77f3054962d2235 100644 (file)
@@ -412,11 +412,11 @@ void VectorTools<dim>::project (const DoFHandler<dim>    &dof,
     MatrixTools<dim>::apply_boundary_values (boundary_values,
                                             mass_matrix, vec, tmp);
 
-  SolverControl                    control(1000,1e-16);
-  PrimitiveVectorMemory<Vector<double> >   memory;
-  SolverCG<SparseMatrix<double>,Vector<double> >       cg(control,memory);
+  SolverControl           control(1000,1e-16);
+  PrimitiveVectorMemory<> memory;
+  SolverCG<>              cg(control,memory);
 
-  PreconditionRelaxation<SparseMatrix<double>, Vector<double> >
+  PreconditionRelaxation<>
     prec(mass_matrix,
         &SparseMatrix<double>::template precondition_SSOR<double>,
         1.2);
@@ -684,11 +684,11 @@ VectorTools<dim>::project_boundary_values (const DoFHandler<dim>    &dof,
   
   Vector<double> boundary_projection (rhs.size());
 
-  SolverControl                    control(1000, 1e-16);
-  PrimitiveVectorMemory<Vector<double> >   memory;
-  SolverCG<SparseMatrix<double>,Vector<double> >       cg(control,memory);
+  SolverControl           control(1000, 1e-16);
+  PrimitiveVectorMemory<> memory;
+  SolverCG<>              cg(control,memory);
 
-  PreconditionRelaxation<SparseMatrix<double>, Vector<double> >
+  PreconditionRelaxation<>
     prec(mass_matrix,
         &SparseMatrix<double>::template precondition_SSOR<double>,
         1.2);
index 80ee32f174e34c19de71ffa5f4955215f5240857..3044152cb619f0a7a87bc9c877d175c82600f44e 100644 (file)
@@ -253,7 +253,7 @@ class MGVector : public Subscriptor
  * with a subscriptor for smart pointers.
  * @author Guido Kanschat, 1999
  */
-template<class MATRIX>
+template<class MATRIX = SparseMatrix<double> >
 class MGMatrix : public Subscriptor,
                 public vector<MATRIX>
 {
index 8ad05245a3ef4de078c8e7bb9adea17a7fe79276..6897d521cf37ea4924d0f0852600e4c7f3173161 100644 (file)
@@ -59,7 +59,8 @@ class PreconditionIdentity
  *
  * @author Guido Kanschat, Wolfgang Bangerth, 1999
  */
-template<class MATRIX, class VECTOR>
+template<class MATRIX = SparseMatrix<double>,
+         class VECTOR = Vector<double> >
 class PreconditionUseMatrix
 {
   public:
@@ -131,7 +132,8 @@ class PreconditionUseMatrix
  *
  * @author Guido Kanschat, Wolfgang Bangerth, 1999
  */
-template<class MATRIX, class VECTOR>
+template<class MATRIX = SparseMatrix<double>,
+         class VECTOR = Vector<double> >
 class PreconditionRelaxation
 {
   public:
@@ -194,7 +196,9 @@ class PreconditionRelaxation
  *
  * @author Guido Kanschat, 1999
  */
-template<class SOLVER, class MATRIX, class PRECONDITION>
+template<class SOLVER,
+         class MATRIX       = SparseMatrix<double>,
+         class PRECONDITION = PreconditionIdentity>
 class PreconditionLACSolver
 {
   public:
index 8eb6353cc013dc876fc60a0581e0a86780398b7a..ee42d8f4166f12876a141975c7d5d299a9d79869 100644 (file)
@@ -43,7 +43,8 @@
  * store the inverted blocks with less accuracy than the original matrix;
  * for example, #number==double, inverse_type=float# might be a viable choice.
  */
-template<typename number, typename inverse_type>
+template<typename number,
+         typename inverse_type = number>
 class PreconditionBlock: public Subscriptor
 {
   public:
@@ -197,7 +198,8 @@ class PreconditionBlock: public Subscriptor
  * (of arbitray structure) below the diagonal blocks are used
  * in the #operator ()# function of this class.
  */
-template<typename number, typename inverse_type>
+template<typename number,
+         typename inverse_type = number>
 class PreconditionBlockSOR : public PreconditionBlock<number, inverse_type>
 {
   public:
index 6e113e90c19febb3d0030dd14dbe68bd1dddc7e4..72c08e56b3758847cae71977d798539d6ad31f55 100644 (file)
@@ -70,7 +70,8 @@
  *
  * @author Ralf Hartmann, 1999
  */
-template <class Matrix, class Vector>
+template <class Matrix = SparseMatrix<double>,
+          class Vector = Vector<double> >
 class PreconditionSelector
 {
   public:
index 73d868cf271e3944bd2398118122055a9f11bee3..35e8e73bf5a8000eacfede1ee0a6049514116480 100644 (file)
@@ -6,16 +6,14 @@
 
 
 
-// forward declaration
-class SolverControl;
-template <class Vector> class VectorMemory;
+#include <lac/forward-declarations.h>
 
 
 
 /**
  * Base class for iterative solvers.
  *
- * HAS TO BE UPDATED!
+//TODO: * HAS TO BE UPDATED!
  *
  * This class defines possible
  * return states of linear solvers and provides interfaces to a memory
@@ -124,7 +122,8 @@ template <class Vector> class VectorMemory;
  *
  * @author Wolfgang Bangerth, Guido Kanschat, Ralf Hartmann, 1997, 1998, 1999
  */
-template <class Matrix, class Vector>
+template <class Matrix = SparseMatrix<double>,
+          class Vector = Vector<double> >
 class Solver
 {
   public:
index a291ac19b6d926c7ebbc510ad1361e060a0a2d88..55ea11569a134928c3ea23d07765bbe70a793540 100644 (file)
@@ -26,7 +26,8 @@
  * has a default argument, so you may call it without the additional
  * parameter.
  */
-template<class Matrix, class Vector>
+template <class Matrix = SparseMatrix<double>,
+          class Vector = Vector<double> >
 class SolverBicgstab : public Solver<Matrix,Vector>
 {
   public:
index 7a3c383a3f846777069fc6088c2943313dedb386..e71d5026915b36ee4b2b2f5e3010c00b1c196165 100644 (file)
@@ -36,7 +36,8 @@
  *
  * @author Original implementation by G. Kanschat, R. Becker and F.-T. Suttmeier, reworking and  documentation by Wolfgang Bangerth
  */
-template<class Matrix, class Vector>
+template <class Matrix = SparseMatrix<double>,
+          class Vector = Vector<double> >
 class SolverCG : public Solver<Matrix,Vector>
 {
   public:
index c192016029b3d8d7ac9873c0636c289c31c73665..3d3508231021eb01d0a7d9a9b9bf8922b210c2a3 100644 (file)
@@ -60,8 +60,9 @@
  *
  * @author Wolfgang Bangerth
  */
-template<class Matrix, class VECTOR>
-class SolverGMRES : public Solver<Matrix, VECTOR>
+template <class MATRIX = SparseMatrix<double>,
+          class VECTOR = Vector<double> >
+class SolverGMRES : public Solver<MATRIX, VECTOR>
 {
   public:
                                     /**
@@ -98,7 +99,7 @@ class SolverGMRES : public Solver<Matrix, VECTOR>
                                      * Solver method.
                                      */
     template<class Preconditioner>
-    typename Solver<Matrix,VECTOR>::ReturnState solve (const Matrix &A,
+    typename Solver<MATRIX,VECTOR>::ReturnState solve (const MATRIX &A,
                                                       VECTOR       &x,
                                                       const VECTOR &b,
                                                       const Preconditioner& precondition);
@@ -139,11 +140,11 @@ class SolverGMRES : public Solver<Matrix, VECTOR>
 /* --------------------- Inline and template functions ------------------- */
 
 
-template <class Matrix, class VECTOR>
-SolverGMRES<Matrix,VECTOR>::SolverGMRES (SolverControl        &cn,
+template <class MATRIX, class VECTOR>
+SolverGMRES<MATRIX,VECTOR>::SolverGMRES (SolverControl        &cn,
                                         VectorMemory<VECTOR> &mem,
                                         const AdditionalData &data) :
-               Solver<Matrix,VECTOR> (cn,mem),
+               Solver<MATRIX,VECTOR> (cn,mem),
                additional_data(data)
 {
   Assert (additional_data.max_n_tmp_vectors >= 10, 
@@ -152,10 +153,10 @@ SolverGMRES<Matrix,VECTOR>::SolverGMRES (SolverControl        &cn,
 
 
 
-template <class Matrix, class VECTOR>
+template <class MATRIX, class VECTOR>
 inline
 void
-SolverGMRES<Matrix,VECTOR>::givens_rotation (Vector<double> &h,
+SolverGMRES<MATRIX,VECTOR>::givens_rotation (Vector<double> &h,
                                             Vector<double> &b,
                                             Vector<double> &ci,
                                             Vector<double> &si, 
@@ -181,10 +182,10 @@ SolverGMRES<Matrix,VECTOR>::givens_rotation (Vector<double> &h,
 
 
 
-template<class Matrix, class VECTOR>
+template<class MATRIX, class VECTOR>
 template<class Preconditioner>
-typename Solver<Matrix,VECTOR>::ReturnState
-SolverGMRES<Matrix,VECTOR>::solve (const Matrix& A,
+typename Solver<MATRIX,VECTOR>::ReturnState
+SolverGMRES<MATRIX,VECTOR>::solve (const MATRIX& A,
                                   VECTOR      & x,
                                   const VECTOR& b,
                                   const Preconditioner& precondition)
@@ -396,9 +397,9 @@ SolverGMRES<Matrix,VECTOR>::solve (const Matrix& A,
   
 
 
-template<class Matrix, class VECTOR>
+template<class MATRIX, class VECTOR>
 double
-SolverGMRES<Matrix,VECTOR>::criterion () 
+SolverGMRES<MATRIX,VECTOR>::criterion () 
 {
                                   // dummy implementation. this function is
                                   // not needed for the present implementation
index 79cbaf0afd37dd6317fab245ca28cacee4c86b4b..1dcda2651e0a8450bca56724f4d25f26c0887041 100644 (file)
@@ -41,7 +41,8 @@
  *
  * @author Guido Kanschat, 1999
  */
-template<class Matrix, class Vector>
+template <class Matrix = SparseMatrix<double>,
+          class Vector = Vector<double> >
 class SolverQMRS : public Solver<Matrix,Vector>
 {
   public:
index 8a529775d74ea1c98235ff84966d18721dcd3652..c1db38f4bf67098848f2f2deba6d4aa9eb98db28 100644 (file)
@@ -31,7 +31,8 @@
  *
  * @author Ralf Hartmann
  */
-template<class Matrix, class Vector>
+template <class Matrix = SparseMatrix<double>,
+          class Vector = Vector<double> >
 class SolverRichardson : public Solver<Matrix, Vector>
 {
   public:
index 000f2507632e5b2edb8fa7933eecdaf2fc1398a7..0f7855dc7e558be74805de77b1018c5427cc2f50 100644 (file)
@@ -77,7 +77,8 @@
  * 
  * @author Ralf Hartmann, 1999
  */
-template <class Matrix, class Vector>
+template <class Matrix = SparseMatrix<double>,
+          class Vector = Vector<double> >
 class SolverSelector
 {
   public:
index 6a909b07209714dd74615005f9483bcf14b2492d..aab9e728c5a9c777665b3464bbea251312e81e9c 100644 (file)
@@ -24,7 +24,7 @@
  * sophisticated management of vectors. One of these has to be
  * applied by the user according to his needs.
  */
-template<class Vector>
+template<class Vector = Vector<double> >
 class VectorMemory : public Subscriptor
 {
   public:
@@ -67,7 +67,7 @@ class VectorMemory : public Subscriptor
  * vectors as needed from the global heap, i.e. performs no
  * specially adapted actions to the purpose of this class.
  */
-template<class Vector>
+template<class Vector = Vector<double> >
 class PrimitiveVectorMemory : public VectorMemory<Vector>
 {
   public:
@@ -103,8 +103,7 @@ class PrimitiveVectorMemory : public VectorMemory<Vector>
  * 
  * @author Guido Kanschat, 1999
  */
-
-template<class Vector>
+template<class Vector = Vector<double> >
 class GrowingVectorMemory : public VectorMemory<Vector>
 {
   public:
@@ -115,6 +114,7 @@ class GrowingVectorMemory : public VectorMemory<Vector>
                                      * of vectors.
                                      */
     GrowingVectorMemory(unsigned int initial_size = 0);
+
                                     /**
                                      * Destructor.
                                      * Release all vectors.
@@ -127,6 +127,7 @@ class GrowingVectorMemory : public VectorMemory<Vector>
                                      * are allocated vectors left.
                                      */
     ~GrowingVectorMemory();
+    
                                     /**
                                      * Return new vector from the pool.
                                      */
@@ -146,19 +147,25 @@ class GrowingVectorMemory : public VectorMemory<Vector>
                                      * vector itself.
                                      */
     typedef pair<bool, Vector* > entry_type;
+
                                     /**
                                      * Array of allocated vectors.
                                      */
     vector<entry_type> pool;
+    
                                     /**
                                      * Overall number of allocations.
                                      */
     unsigned int n_alloc;
 };
 
+
+
+/* --------------------- inline functions ---------------------- */
+
+
 template<typename Vector>
-GrowingVectorMemory<Vector>::GrowingVectorMemory(unsigned int
-                                                initial_size)
+GrowingVectorMemory<Vector>::GrowingVectorMemory(const unsigned int initial_size)
                : pool(initial_size)
 {
   for (vector<entry_type>::iterator i=pool.begin();i != pool.end()
@@ -170,6 +177,8 @@ GrowingVectorMemory<Vector>::GrowingVectorMemory(unsigned int
   n_alloc = 0;
 }
 
+
+
 template<typename Vector>
 GrowingVectorMemory<Vector>::~GrowingVectorMemory()
 {
index b170f615453a104c02a977e3ef6f5048733ba348..79805a5ad984f97750692f946cd82ae64d86ea52 100644 (file)
@@ -100,9 +100,9 @@ int main()
          
          Vector<double> u;
          u.reinit(f);
-         PrimitiveVectorMemory<Vector<double> > mem;
+         PrimitiveVectorMemory<> mem;
          SolverControl control(100, 1.e-12);
-         SolverCG<SparseMatrix<double>, Vector<double> >solver(control, mem);
+         SolverCG<>    solver(control, mem);
          
          PreconditionIdentity precondition;
          solver.solve(A,u,f,precondition);
@@ -122,11 +122,10 @@ int main()
          equation.build_mgmatrix(mgA, mgdof, quadrature);
          
          SolverControl cgcontrol(10,0., false, false);
-         PrimitiveVectorMemory<Vector<double> > cgmem;
-         SolverCG<SparseMatrix<double>, Vector<double> > cgsolver(cgcontrol, cgmem);
+         PrimitiveVectorMemory<> cgmem;
+         SolverCG<> cgsolver(cgcontrol, cgmem);
          PreconditionIdentity cgprec;
-         MGCoarseGridLACIteration<SolverCG<SparseMatrix<double>, Vector<double> >,
-           SparseMatrix<double>, PreconditionIdentity>
+         MGCoarseGridLACIteration<SolverCG<>, SparseMatrix<double>, PreconditionIdentity>
            coarse(cgsolver, mgA[0], cgprec);
          
          MGSmootherLAC smoother(mgA);
@@ -135,7 +134,7 @@ int main()
          
          
          MG<2> multigrid(mgdof, hanging_nodes, mgA, transfer);
-         PreconditionMG<MG<2>, Vector<double> >
+         PreconditionMG<MG<2> >
            mgprecondition(multigrid, smoother, smoother, coarse);
          
          solver.solve(A, u, f, mgprecondition);
@@ -163,9 +162,9 @@ MGSmootherLAC::smooth (const unsigned int level,
                       const Vector<double> &rhs) const
 {
   SolverControl control(2,1.e-300,false,false);
-  PrimitiveVectorMemory<Vector<double> > mem;
-  SolverRichardson<SparseMatrix<double> , Vector<double>  > rich(control, mem);
-  PreconditionRelaxation<SparseMatrix<double> , Vector<double> >
+  PrimitiveVectorMemory<> mem;
+  SolverRichardson<> rich(control, mem);
+  PreconditionRelaxation<>
     prec((*matrices)[level], &SparseMatrix<double> ::template precondition_SSOR<double>, 1.);
 
   rich.solve((*matrices)[level], u, rhs, prec);
index f5bfdda87d5ec4164c67bb52a9ba3eac4435188d..7664abf5cd8624a9dce87657457e5a76193a7a4d 100644 (file)
@@ -116,9 +116,9 @@ int main()
 
          Vector<double> u;
          u.reinit(f);
-         PrimitiveVectorMemory<Vector<double> > mem;
+         PrimitiveVectorMemory<> mem;
          SolverControl control(20, 1.e-12, true);
-         SolverRichardson<SparseMatrix<double>, Vector<double> >solver(control, mem);
+         SolverRichardson<solver(control, mem);
          
          vector<SparseMatrixStruct> mgstruct(tr.n_levels());
          MGMatrix<SparseMatrix<double> > mgA(0,tr.n_levels()-1);
@@ -134,11 +134,10 @@ int main()
          equation.build_mgmatrix(mgA, mgdof, quadrature);
          
          SolverControl cgcontrol(20,0., false, false);
-         PrimitiveVectorMemory<Vector<double> > cgmem;
-         SolverCG<SparseMatrix<double>, Vector<double> > cgsolver(cgcontrol, cgmem);
+         PrimitiveVectorMemory<> cgmem;
+         SolverCG<> cgsolver(cgcontrol, cgmem);
          PreconditionIdentity cgprec;
-         MGCoarseGridLACIteration<SolverCG<SparseMatrix<double>, Vector<double> >,
-           SparseMatrix<double>, PreconditionIdentity>
+         MGCoarseGridLACIteration<SolverCG<>, SparseMatrix<double>, PreconditionIdentity>
            coarse(cgsolver, mgA[tr.n_levels()-2], cgprec);
          
          MGSmootherRelaxation<double>
@@ -151,7 +150,7 @@ int main()
          
          
          MG<2> multigrid(mgdof, hanging_nodes, mgA, transfer, tr.n_levels()-2);
-         PreconditionMG<MG<2>, Vector<double> >
+         PreconditionMG<MG<2> >
            mgprecondition(multigrid, smoother, smoother, coarse);
 
           u = 0.;
index 0650686cceb547c1785be80c8f7e39c4b524317d..b9f69f252585e15504d4a02f40d925268fe45e66 100644 (file)
@@ -5478,13 +5478,13 @@ template <int dim>
 unsigned int TimeStep_Wave<dim>::solve (const UserMatrix       &matrix,
                                        Vector<double>         &solution,
                                        const Vector<double>   &rhs) const {
-  SolverControl                    control(2000, 1.e-12);
-  PrimitiveVectorMemory<Vector<double> >   memory;
-  SolverCG<UserMatrix,Vector<double> >     pcg(control,memory);
+  SolverControl            control(2000, 1.e-12);
+  PrimitiveVectorMemory<>  memory;
+  SolverCG<UserMatrix>     pcg(control,memory);
 
                                   // solve
   pcg.solve (matrix, solution, rhs,
-            PreconditionUseMatrix<UserMatrix,Vector<double> >
+            PreconditionUseMatrix<UserMatrix>
             (matrix,
              &UserMatrix::precondition));
                                   // distribute solution
index 3fc185677cd5d347dfbc00d1b065d3647e7c0669..23510ccf16f7895a5078cc77498395cd568ee12c 100644 (file)
@@ -74,10 +74,9 @@ class MGSmootherLAC
     
 };
 
-typedef MGCoarseGridLACIteration<SolverCG<SparseMatrix<double> , Vector<double>  >,
-SparseMatrix<double>, /*PreconditionRelaxation<SparseMatrix<double> ,*/
-  PreconditionIdentity >
-Coarse;
+typedef MGCoarseGridLACIteration<SolverCG<>,
+                                 SparseMatrix<double>,
+                                 PreconditionIdentity > Coarse;
 
 
 int main()
@@ -98,9 +97,9 @@ int main()
   FDMGTransfer transfer(maxsize, maxsize, maxlevel);
 
                                   // coarse grid solver
-  PrimitiveVectorMemory<Vector<double> > cgmem;
+  PrimitiveVectorMemory<> cgmem;
   ReductionControl cgcontrol(100, 1.e-30, 1.e-2, false, false);
-  SolverCG<SparseMatrix<double> , Vector<double> > cgcg(cgcontrol,cgmem);
+  SolverCG<> cgcg(cgcontrol,cgmem);
 
   
   for (unsigned int level = 0; level <= maxlevel; ++level)
@@ -132,7 +131,7 @@ int main()
       
       FDMG multigrid(level, A, transfer);
 
-//      PreconditionRelaxation<SparseMatrix<double> , Vector<double> >
+//      PreconditionRelaxation<>
       PreconditionIdentity
        cgprec;//(A[minlevel], &SparseMatrix<double> ::template precondition_SSOR<double>, 1.2);
       
@@ -166,8 +165,8 @@ FDMG::FDMG(unsigned int maxlevel, MGMatrix<SparseMatrix<double> >& matrices,
 {
   for (unsigned int level = minlevel; level<=maxlevel ; ++level)
     {
-      s[level].reinit(matrices[level].m());
-      d[level].reinit(matrices[level].m());
+      solution[level].reinit(matrices[level].m());
+      defect[level].reinit(matrices[level].m());
     }
 }
 
@@ -184,13 +183,13 @@ FDMG::level_vmult (unsigned int level,
 void
 FDMG::copy_to_mg(const Vector<TYPE>& v)
 {
-  d[maxlevel] = v;
+  defect[maxlevel] = v;
 }
 
 void
 FDMG::copy_from_mg(Vector<TYPE>& v)
 {
-  v = s[maxlevel];
+  v = solution[maxlevel];
 }
 
 
@@ -206,9 +205,9 @@ MGSmootherLAC::smooth (const unsigned int level,
                       const Vector<double> &rhs) const
 {
   SolverControl control(1,1.e-300,false,false);
-  PrimitiveVectorMemory<Vector<double> > mem;
-  SolverRichardson<SparseMatrix<double> , Vector<double>  > rich(control, mem);
-  PreconditionRelaxation<SparseMatrix<double> , Vector<double> >
+  PrimitiveVectorMemory<> mem;
+  SolverRichardson<> rich(control, mem);
+  PreconditionRelaxation<>
     prec((*matrices)[level], &SparseMatrix<double> ::template precondition_SSOR<double>, 1.);
 
   rich.solve((*matrices)[level], u, rhs, prec);
index 8b61521f15db03436f1a563457a5e4a96c32af2a..eb6e0d4f48dfaae481aa1dd488851c60a3435b36 100644 (file)
@@ -34,14 +34,14 @@ int main()
   deallog.attach(logfile);
   deallog.depth_console(0);
   
-  GrowingVectorMemory<Vector<double>  > mem;
+  GrowingVectorMemory<> mem;
   SolverControl control(100, 1.e-5);
   SolverControl verbose_control(100, 1.e-5, true);
-  SolverCG<SparseMatrix<float> , Vector<double>  > cg(control, mem);
-  SolverGMRES<SparseMatrix<float> , Vector<double>  > gmres(control, mem,20);
-  SolverBicgstab<SparseMatrix<float> , Vector<double>  > bicgstab(control, mem);
-  SolverRichardson<SparseMatrix<float> , Vector<double>  > rich(control, mem);
-  SolverQMRS<SparseMatrix<float> , Vector<double>  > qmrs(control, mem);
+  SolverCG<> cg(control, mem);
+  SolverGMRES<> gmres(control, mem,20);
+  SolverBicgstab<> bicgstab(control, mem);
+  SolverRichardson<> rich(control, mem);
+  SolverQMRS<> qmrs(control, mem);
 
   for (unsigned int size=4; size <= 40; size *= 3)
     {
@@ -54,15 +54,15 @@ int main()
       SparseMatrixStruct structure(dim, dim, 5);
       testproblem.build_structure(structure);
       structure.compress();
-      SparseMatrix<float>  A(structure);
+      SparseMatrix<double>  A(structure);
       testproblem.laplacian(A);
 
       PreconditionIdentity
        prec_no;
-      PreconditionRelaxation<SparseMatrix<float> , Vector<double> >
-       prec_sor(A, &SparseMatrix<float> ::template precondition_SOR<double>, 1.2);
-      PreconditionRelaxation<SparseMatrix<float> , Vector<double> >
-       prec_ssor(A, &SparseMatrix<float> ::template precondition_SSOR<double>, 1.2);
+      PreconditionRelaxation<>
+       prec_sor(A, &SparseMatrix<double>::template precondition_SOR<double>, 1.2);
+      PreconditionRelaxation<>
+       prec_ssor(A, &SparseMatrix<double>::template precondition_SSOR<double>, 1.2);
       
       Vector<double>  f(dim);
       Vector<double>  u(dim);
index 01317a3f9cfc59d7d2a8883f044e46f73a0a681e..4def8b6bdfa0f6997eb55be8dbfadf8d54ea773b 100644 (file)
@@ -77,7 +77,7 @@ DEAL:no:cg::Starting
 DEAL:no:cg::Starting 
 DEAL:no:cg::Convergence step 58 
 DEAL:no:Bicgstab::Starting 
-DEAL:no:Bicgstab::Convergence step 45 
+DEAL:no:Bicgstab::Convergence step 44 
 DEAL:no:GMRES::Starting 
 DEAL:no:GMRES::Starting 
 DEAL:no:GMRES::Failure step 100 
index ac7840fb1a0280014f5fccac058b7e03fd121db6..94502617382512c978c470202a6a0018251fd43e 100644 (file)
@@ -221,9 +221,9 @@ FDMGTransfer::prolongate (const unsigned int   to_level,
 
 
 void
-FDMGTransfer::restrict (const unsigned int   from_level,
-                       Vector<double>       &dst,
-                       const Vector<double> &src) const
+FDMGTransfer::restrict_and_add (const unsigned int   from_level,
+                               Vector<double>       &dst,
+                               const Vector<double> &src) const
 {
   Assert((from_level>0) && (from_level<=matrices.size()),
         ExcIndexRange(from_level, 0, matrices.size()+1));
index 13e9ebf7beda7b833e2d889f6b85e4960e91f19a..885e6db18bd9eacf21de3ab48173fc467066d3a0 100644 (file)
@@ -73,9 +73,9 @@ class FDMGTransfer
                                      * Implementation of abstract
                                      * function in #MGTranferBase#.
                                      */
-    virtual void restrict (const unsigned int   from_level,
-                          Vector<double>       &dst,
-                          const Vector<double> &src) const;
+    virtual void restrict_and_add (const unsigned int   from_level,
+                                  Vector<double>       &dst,
+                                  const Vector<double> &src) const;
 
                                     /**
                                      * Exception.

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.