From b8e035bda93c28f36e1c06da5ecee8835f776d92 Mon Sep 17 00:00:00 2001 From: guido Date: Wed, 5 May 1999 12:50:05 +0000 Subject: [PATCH] more types improved git-svn-id: https://svn.dealii.org/trunk@1276 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/multigrid/mg_base.h | 41 ++++++++--------- deal.II/deal.II/source/multigrid/mg_base.cc | 6 +-- deal.II/lac/include/lac/mgbase.h | 41 ++++++++--------- deal.II/lac/include/lac/solver.h | 45 ++----------------- deal.II/lac/include/lac/solver_cg.h | 9 ++-- deal.II/lac/include/lac/sparse_matrix.h | 4 +- .../lac/include/lac/sparse_matrix.templates.h | 4 +- deal.II/lac/source/mgbase.cc | 6 +-- deal.II/lac/source/sparse_matrix.double.cc | 8 ++-- deal.II/lac/source/sparse_matrix.float.cc | 8 ++-- .../lac/source/sparse_matrix.long_double.cc | 20 ++++----- 11 files changed, 75 insertions(+), 117 deletions(-) diff --git a/deal.II/deal.II/include/multigrid/mg_base.h b/deal.II/deal.II/include/multigrid/mg_base.h index 2a45a3a826..5f16cbf0e9 100644 --- a/deal.II/deal.II/include/multigrid/mg_base.h +++ b/deal.II/deal.II/include/multigrid/mg_base.h @@ -12,9 +12,6 @@ #include #include -#define FLOAT float - - /** * Abstract base class for coarse grid solvers. * The interface of a function call operator is defined to execute coarse @@ -41,8 +38,8 @@ class MGCoarseGridSolver * about the matrix is removed to * that class. */ - virtual void operator() (unsigned int level, Vector& dst, - const Vector& src) const = 0; + virtual void operator() (unsigned int level, Vector& dst, + const Vector& src) const = 0; }; @@ -75,8 +72,8 @@ class MGSmootherBase * things. */ virtual void smooth (const unsigned int level, - Vector &u, - const Vector &rhs) const = 0; + Vector &u, + const Vector &rhs) const = 0; }; @@ -94,8 +91,8 @@ class MGSmootherIdentity * This function does nothing. */ virtual void smooth (const unsigned int level, - Vector &u, - const Vector &rhs) const; + Vector &u, + const Vector &rhs) const; }; /** @@ -130,8 +127,8 @@ class MGTransferBase * level. */ virtual void prolongate (const unsigned int to_level, - Vector &dst, - const Vector &src) const = 0; + Vector &dst, + const Vector &src) const = 0; /** * Restrict a vector from level @@ -147,8 +144,8 @@ class MGTransferBase * level. */ virtual void restrict (const unsigned int from_level, - Vector &dst, - const Vector &src) const = 0; + Vector &dst, + const Vector &src) const = 0; }; /** @@ -246,8 +243,8 @@ class MGCoarseGridLACIteration * matrix, vectors and * preconditioner. */ - virtual void operator() (unsigned int level, Vector& dst, - const Vector& src) const; + virtual void operator() (unsigned int level, Vector& dst, + const Vector& src) const; private: /** * Reference to the solver. @@ -304,18 +301,18 @@ class MGBase /** * Auxiliary vector, defect. */ - MGVector > d; + MGVector > d; /** * Auxiliary vector, solution. */ - MGVector > s; + MGVector > s; private: /** * Auxiliary vector. */ - Vector t; + Vector t; /** * Prolongation and restriction object. @@ -345,9 +342,9 @@ class MGBase * derived class. */ virtual void level_residual(unsigned int level, - Vector& dst, - const Vector& src, - const Vector& rhs) = 0; + Vector& dst, + const Vector& src, + const Vector& rhs) = 0; public: @@ -443,7 +440,7 @@ MGCoarseGridLACIteration template void MGCoarseGridLACIteration::operator() -(unsigned int, Vector& dst, const Vector& src) const +(unsigned int, Vector& dst, const Vector& src) const { solver.solve(matrix, dst, src, precondition); } diff --git a/deal.II/deal.II/source/multigrid/mg_base.cc b/deal.II/deal.II/source/multigrid/mg_base.cc index b7e475a798..b08359efb4 100644 --- a/deal.II/deal.II/source/multigrid/mg_base.cc +++ b/deal.II/deal.II/source/multigrid/mg_base.cc @@ -13,7 +13,7 @@ void print_vector(ostream& s, const VECTOR& v) for (unsigned int i=0;i &, - const Vector &) const + Vector &, + const Vector &) const {} diff --git a/deal.II/lac/include/lac/mgbase.h b/deal.II/lac/include/lac/mgbase.h index 4192a16bd6..3e9396f8f0 100644 --- a/deal.II/lac/include/lac/mgbase.h +++ b/deal.II/lac/include/lac/mgbase.h @@ -12,9 +12,6 @@ #include #include -#define FLOAT float - - /** * Abstract base class for coarse grid solvers. * The interface of a function call operator is defined to execute coarse @@ -41,8 +38,8 @@ class MGCoarseGridSolver * about the matrix is removed to * that class. */ - virtual void operator() (unsigned int level, Vector& dst, - const Vector& src) const = 0; + virtual void operator() (unsigned int level, Vector& dst, + const Vector& src) const = 0; }; @@ -75,8 +72,8 @@ class MGSmootherBase * things. */ virtual void smooth (const unsigned int level, - Vector &u, - const Vector &rhs) const = 0; + Vector &u, + const Vector &rhs) const = 0; }; @@ -94,8 +91,8 @@ class MGSmootherIdentity * This function does nothing. */ virtual void smooth (const unsigned int level, - Vector &u, - const Vector &rhs) const; + Vector &u, + const Vector &rhs) const; }; /** @@ -130,8 +127,8 @@ class MGTransferBase * level. */ virtual void prolongate (const unsigned int to_level, - Vector &dst, - const Vector &src) const = 0; + Vector &dst, + const Vector &src) const = 0; /** * Restrict a vector from level @@ -147,8 +144,8 @@ class MGTransferBase * level. */ virtual void restrict (const unsigned int from_level, - Vector &dst, - const Vector &src) const = 0; + Vector &dst, + const Vector &src) const = 0; }; /** @@ -246,8 +243,8 @@ class MGCoarseGridLACIteration * matrix, vectors and * preconditioner. */ - virtual void operator() (unsigned int level, Vector& dst, - const Vector& src) const; + virtual void operator() (unsigned int level, Vector& dst, + const Vector& src) const; private: /** * Reference to the solver. @@ -304,18 +301,18 @@ class MGBase /** * Auxiliary vector, defect. */ - MGVector > d; + MGVector > d; /** * Auxiliary vector, solution. */ - MGVector > s; + MGVector > s; private: /** * Auxiliary vector. */ - Vector t; + Vector t; /** * Prolongation and restriction object. @@ -345,9 +342,9 @@ class MGBase * derived class. */ virtual void level_residual(unsigned int level, - Vector& dst, - const Vector& src, - const Vector& rhs) = 0; + Vector& dst, + const Vector& src, + const Vector& rhs) = 0; public: @@ -443,7 +440,7 @@ MGCoarseGridLACIteration template void MGCoarseGridLACIteration::operator() -(unsigned int, Vector& dst, const Vector& src) const +(unsigned int, Vector& dst, const Vector& src) const { solver.solve(matrix, dst, src, precondition); } diff --git a/deal.II/lac/include/lac/solver.h b/deal.II/lac/include/lac/solver.h index 7a3a6028ec..a7494f17a0 100644 --- a/deal.II/lac/include/lac/solver.h +++ b/deal.II/lac/include/lac/solver.h @@ -143,47 +143,12 @@ class Solver */ Solver (SolverControl &, VectorMemory &); - /** - * Solver procedure. This is in - * fact only a template for the - * solve-function to be - * implemented in derived classes - */ - template - ReturnState solve (const Matrix &A, - Vector &x, - const Vector &b, - const Preconditioner& precondition) const; - /** * Access to control object. */ SolverControl& control() const; protected: - /** - * Calculation of convergence - * criterion. To allow further - * flexibility in solvers, the - * convergence criterion can be - * implemented by the user. Each - * method has it's standard - * criterion (usually some kind of - * residual) already implemented. - */ - virtual double criterion() = 0; - - /** - * Additional entry point for - * examination. Allows access to - * internal variables of a solver - * at a given point dependent of - * the actual solver method. Does - * nothing by default and should - * only be implemented to test - * iterative methods. - */ - virtual void expert() {}; /** * Control structure. @@ -217,7 +182,7 @@ class SolverDual : public Solver * Solve the original problem * $Ax=b$. */ - virtual ReturnState solve (const Matrix &A, + ReturnState solve (const Matrix &A, Vector &x, const Vector &b) = 0; @@ -225,7 +190,7 @@ class SolverDual : public Solver * Solve the two problems * $Ax=b1$ and $A^Tz=b2$ simultanously. */ - virtual ReturnState solve (const Matrix &A, + ReturnState solve (const Matrix &A, Vector &x, const Vector &b1, Vector &z, @@ -241,7 +206,8 @@ class SolverDual : public Solver template inline -SolverControl & Solver::control() const { +SolverControl & Solver::control() const +{ return cntrl; }; @@ -255,9 +221,6 @@ Solver::Solver(SolverControl &cn, VectorMemory &mem) {}; - - - /*---------------------------- solver.h ---------------------------*/ /* end of #ifndef __solver_H */ #endif diff --git a/deal.II/lac/include/lac/solver_cg.h b/deal.II/lac/include/lac/solver_cg.h index a0000885a6..94a3a3398b 100644 --- a/deal.II/lac/include/lac/solver_cg.h +++ b/deal.II/lac/include/lac/solver_cg.h @@ -52,7 +52,7 @@ class SolverCG : public Solver * Implementation of the computation of * the norm of the residual. */ - virtual double criterion(); + virtual long double criterion(); /** * Temporary vectors, allocated through @@ -72,7 +72,7 @@ class SolverCG : public Solver * norm of the residual vector and thus * the square root of the #res2# value. */ - double res2; + long double res2; }; @@ -89,7 +89,8 @@ SolverCG::SolverCG(SolverControl &cn, template -double SolverCG::criterion() +long double +SolverCG::criterion() { return sqrt(res2); }; @@ -128,7 +129,7 @@ SolverCG::solve (const Matrix &A, // Implementation taken from the DEAL // library int it=0; - double res,gh,alpha,beta; + long double res,gh,alpha,beta; res = A.residual(g,x,b); conv = control().check(0,res); diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h index 23507bc94c..8c7da6c984 100644 --- a/deal.II/lac/include/lac/sparse_matrix.h +++ b/deal.II/lac/include/lac/sparse_matrix.h @@ -763,7 +763,7 @@ class SparseMatrix : public Subscriptor * for this operation. */ template - double matrix_norm (const Vector &v) const; + somenumber matrix_norm (const Vector &v) const; /** * Return the l1-norm of the matrix, i.e. @@ -801,7 +801,7 @@ class SparseMatrix : public Subscriptor * #dst#. */ template - double residual (Vector& dst, const Vector& x, + somenumber residual (Vector& dst, const Vector& x, const Vector& b) const; // template diff --git a/deal.II/lac/include/lac/sparse_matrix.templates.h b/deal.II/lac/include/lac/sparse_matrix.templates.h index a9bb565977..c20d302938 100644 --- a/deal.II/lac/include/lac/sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix.templates.h @@ -225,7 +225,7 @@ SparseMatrix::Tvmult (Vector& dst, const Vector& template template -double +somenumber SparseMatrix::matrix_norm (const Vector& v) const { Assert (cols != 0, ExcMatrixNotInitialized()); @@ -292,7 +292,7 @@ number SparseMatrix::linfty_norm () const template template -double +somenumber SparseMatrix::residual (Vector& dst, const Vector& u, const Vector& b) const diff --git a/deal.II/lac/source/mgbase.cc b/deal.II/lac/source/mgbase.cc index b7e475a798..b08359efb4 100644 --- a/deal.II/lac/source/mgbase.cc +++ b/deal.II/lac/source/mgbase.cc @@ -13,7 +13,7 @@ void print_vector(ostream& s, const VECTOR& v) for (unsigned int i=0;i &, - const Vector &) const + Vector &, + const Vector &) const {} diff --git a/deal.II/lac/source/sparse_matrix.double.cc b/deal.II/lac/source/sparse_matrix.double.cc index d3adea7812..3ad663c052 100644 --- a/deal.II/lac/source/sparse_matrix.double.cc +++ b/deal.II/lac/source/sparse_matrix.double.cc @@ -29,10 +29,10 @@ template void SparseMatrix::vmult (Vector &, template void SparseMatrix::Tvmult (Vector &, const Vector &) const; -template double +template TYPE2 SparseMatrix::matrix_norm (const Vector &) const; -template double SparseMatrix::residual (Vector &, +template TYPE2 SparseMatrix::residual (Vector &, const Vector &, const Vector &) const; @@ -65,10 +65,10 @@ template void SparseMatrix::vmult (Vector &, template void SparseMatrix::Tvmult (Vector &, const Vector &) const; -template double +template TYPE2 SparseMatrix::matrix_norm (const Vector &) const; -template double SparseMatrix::residual (Vector &, +template TYPE2 SparseMatrix::residual (Vector &, const Vector &, const Vector &) const; diff --git a/deal.II/lac/source/sparse_matrix.float.cc b/deal.II/lac/source/sparse_matrix.float.cc index 5be1b54c19..88c4460cf0 100644 --- a/deal.II/lac/source/sparse_matrix.float.cc +++ b/deal.II/lac/source/sparse_matrix.float.cc @@ -29,12 +29,12 @@ template void SparseMatrix::vmult (Vector &, template void SparseMatrix::Tvmult (Vector &, const Vector &) const; -template double +template TYPE2 SparseMatrix::matrix_norm (const Vector &) const; -template double SparseMatrix::residual (Vector &, - const Vector &, - const Vector &) const; +template TYPE2 SparseMatrix::residual (Vector &, + const Vector &, + const Vector &) const; template void SparseMatrix::precondition_SSOR (Vector &, const Vector &, diff --git a/deal.II/lac/source/sparse_matrix.long_double.cc b/deal.II/lac/source/sparse_matrix.long_double.cc index 6678c95d2f..7334d98cce 100644 --- a/deal.II/lac/source/sparse_matrix.long_double.cc +++ b/deal.II/lac/source/sparse_matrix.long_double.cc @@ -29,10 +29,10 @@ template void SparseMatrix::vmult (Vector &, template void SparseMatrix::Tvmult (Vector &, const Vector &) const; -template double +template TYPE2 SparseMatrix::matrix_norm (const Vector &) const; -template double SparseMatrix::residual (Vector &, +template TYPE2 SparseMatrix::residual (Vector &, const Vector &, const Vector &) const; @@ -65,10 +65,10 @@ template void SparseMatrix::vmult (Vector &, template void SparseMatrix::Tvmult (Vector &, const Vector &) const; -template double +template TYPE2 SparseMatrix::matrix_norm (const Vector &) const; -template double SparseMatrix::residual (Vector &, +template TYPE2 SparseMatrix::residual (Vector &, const Vector &, const Vector &) const; @@ -101,10 +101,10 @@ template void SparseMatrix::vmult (Vector &, template void SparseMatrix::Tvmult (Vector &, const Vector &) const; -template double +template TYPE2 SparseMatrix::matrix_norm (const Vector &) const; -template double SparseMatrix::residual (Vector &, +template TYPE2 SparseMatrix::residual (Vector &, const Vector &, const Vector &) const; @@ -137,10 +137,10 @@ template void SparseMatrix::vmult (Vector &, template void SparseMatrix::Tvmult (Vector &, const Vector &) const; -template double +template TYPE2 SparseMatrix::matrix_norm (const Vector &) const; -template double SparseMatrix::residual (Vector &, +template TYPE2 SparseMatrix::residual (Vector &, const Vector &, const Vector &) const; @@ -173,10 +173,10 @@ template void SparseMatrix::vmult (Vector &, template void SparseMatrix::Tvmult (Vector &, const Vector &) const; -template double +template TYPE2 SparseMatrix::matrix_norm (const Vector &) const; -template double SparseMatrix::residual (Vector &, +template TYPE2 SparseMatrix::residual (Vector &, const Vector &, const Vector &) const; -- 2.39.5