From: young Date: Thu, 13 May 2010 07:07:11 +0000 (+0000) Subject: Error checking in SparseDirectMUMPS; and a final tweak to the compilation documentation. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3fe2de11b233ec7b37f39f232962c9d861ea31b1;p=dealii-svn.git Error checking in SparseDirectMUMPS; and a final tweak to the compilation documentation. git-svn-id: https://svn.dealii.org/trunk@21126 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/external-libs/mumps.html b/deal.II/doc/external-libs/mumps.html index 468f2f8674..2dacf0de03 100644 --- a/deal.II/doc/external-libs/mumps.html +++ b/deal.II/doc/external-libs/mumps.html @@ -24,10 +24,11 @@ straightforward is we would like, however, it is not so difficult that we can not talk about it. That said, we cannot discuss every possible choice of parameters, because this is too - involved and we would much rather be doing something productive - with the interface in deal.II. Thus we give - only a short walk-through mentioning the most important - parameters needed for successful compliation and linking. + involved (and we would probably much rather be doing something + productive with the interface and + deal.II). Thus we give only a short + walk-through mentioning the most important parameters needed for + successful compliation and linking.

The compilation scheme involves repeating the same three steps @@ -269,12 +270,15 @@ INTFACE of BLACS' own Bmake.inc. If you are using OpenMPI this should be the - value -DAdd_. Further we have to add to all + value -DAdd_. + + +

  • Finally we add the flag -fPIC to the three compiler flag variables OPTF, - OPTC, and OPTL the flag - -fPIC. Without adding this last flag it will - not be possible to link deal.II with MUMPS as a shared - library. + OPTC, and OPTL which follow + imediately after the above. Without adding this last flag it + will not be possible to link deal.II with + MUMPS as a shared library.
  • @@ -291,12 +295,25 @@ configure deal.II with the following additional options:
    -	--with-mumps=path/to/mumps
    -	  --with-blacs=path/to/blacs
    -	  --with-scalapack=path/to/scalpack
    +	
    +          --with-mumps=path/to/mumps
    +          --with-blacs=path/to/blacs
    +          --with-scalapack=path/to/scalpack
     	
           

    +

    + Note: Throughout this description of the compilation process + of MUMPS we have emphasised adding the + compiler flag -fPIC. This is a definate requirement + if we are compiling deal.II with shared + libraries (which is the default). If we had preferred to be + compiling deal.II without shared libraries, + that's ok too; in that case we would do exactly the same thing + as described above, but this time omitting + the -fPIC flag from the scheme. +

    + diff --git a/deal.II/lac/include/lac/sparse_direct.h b/deal.II/lac/include/lac/sparse_direct.h index f3792bbc56..ad4b4b887e 100644 --- a/deal.II/lac/include/lac/sparse_direct.h +++ b/deal.II/lac/include/lac/sparse_direct.h @@ -358,18 +358,17 @@ class SparseDirectMA27 : public Subscriptor * Exception */ DeclException0 (ExcInitializeAlreadyCalled); - /** - * Exception - */ - DeclException0 (ExcInitializeNotCalled); + /** * Exception */ DeclException0 (ExcFactorizeNotCalled); + /** * Exception */ DeclException0 (ExcDifferentSparsityPatterns); + /** * Exception */ @@ -829,14 +828,17 @@ class SparseDirectMA47 : public Subscriptor * Exception */ DeclException0 (ExcInitializeAlreadyCalled); + /** * Exception */ DeclException0 (ExcFactorizeNotCalled); + /** * Exception */ DeclException0 (ExcCantFactorizeAgain); + /** * Exception */ @@ -1295,9 +1297,8 @@ class SparseDirectMUMPS DMUMPS_STRUC_C id; - double *a; - double *rhs; - + double *a; + double *rhs; unsigned int *irn; unsigned int *jcn; unsigned int n; @@ -1311,7 +1312,7 @@ class SparseDirectMUMPS bool initialize_called; public: - + /** * Constructor */ @@ -1321,6 +1322,11 @@ class SparseDirectMUMPS * Destructor */ ~SparseDirectMUMPS (); + + /** + * Exception + */ + DeclException0 (ExcInitializeAlreadyCalled); /** * This function initializes a MUMPS instance diff --git a/deal.II/lac/source/sparse_direct.cc b/deal.II/lac/source/sparse_direct.cc index 813ca5f1ac..bbe582ff2d 100644 --- a/deal.II/lac/source/sparse_direct.cc +++ b/deal.II/lac/source/sparse_direct.cc @@ -454,6 +454,7 @@ SparseDirectMA27::initialize (const SparsityPattern &sp) // stdin pipe(detached_mode_data->server_client_pipe); pipe(detached_mode_data->client_server_pipe); + // fflush(NULL) is said to be a // good idea before fork() std::fflush(NULL); @@ -462,7 +463,7 @@ SparseDirectMA27::initialize (const SparsityPattern &sp) // process detached_mode_data->child_pid = fork(); if (detached_mode_data->child_pid == 0) - // child process starts here + // child process starts here { // copy read end of input // pipe to stdin, and @@ -1879,6 +1880,8 @@ SparseDirectUMFPACK::Tvmult_add ( #ifdef DEAL_II_USE_MUMPS SparseDirectMUMPS::SparseDirectMUMPS () + : + initialize_called (false) {} SparseDirectMUMPS::~SparseDirectMUMPS () @@ -1888,6 +1891,8 @@ template void SparseDirectMUMPS::initialize (const SparseMatrix& matrix, const Vector & vector) { + // Check we haven't been here before: + Assert (initialize_called == false, ExcInitializeAlreadyCalled()); // Initialize MUMPS instance: id.job = -1; @@ -1914,9 +1919,9 @@ void SparseDirectMUMPS::initialize (const SparseMatrix& matrix, a = new double[nz]; // matrix indices pointing to the row and - // column dimensions of the matrix - // respectively: iw. a[k] is the matrix - // element (irn[k],jcn[k]) + // column dimensions respectively of the + // matrix representation above (a): ie. a[k] + // is the matrix element (irn[k], jcn[k]) irn = new unsigned int[nz]; jcn = new unsigned int[nz]; @@ -1957,11 +1962,17 @@ void SparseDirectMUMPS::initialize (const SparseMatrix& matrix, void SparseDirectMUMPS::solve (Vector& vector) { + // Check that the solver has been initialized + // by the routine above: + Assert (initialize_called == true, ExcNotInitialized()); + + // and that the matrix has at least one + // nonzero element: + Assert (nz != 0, ExcNotInitialized()); // Start solver id.job = 6; dmumps_c (&id); - id.job = -2; dmumps_c (&id); @@ -2011,8 +2022,8 @@ InstantiateUMFPACK(SparseMatrix); InstantiateUMFPACK(BlockSparseMatrix); InstantiateUMFPACK(BlockSparseMatrix); -#ifdef DEAL_II_USE_MUMPS // explicit instantiations for SparseDirectMUMPS +#ifdef DEAL_II_USE_MUMPS template void SparseDirectMUMPS::initialize (const SparseMatrix& matrix, const Vector & vector);