]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Error checking in SparseDirectMUMPS; and a final tweak to the compilation documentation.
authoryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 13 May 2010 07:07:11 +0000 (07:07 +0000)
committeryoung <young@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 13 May 2010 07:07:11 +0000 (07:07 +0000)
git-svn-id: https://svn.dealii.org/trunk@21126 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/external-libs/mumps.html
deal.II/lac/include/lac/sparse_direct.h
deal.II/lac/source/sparse_direct.cc

index 468f2f8674c4a198aafa8cd159064fcd409d2944..2dacf0de0387fe40ca043b29b00b4dcddfdcff24 100644 (file)
       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 <acronym>deal.II</acronym>. 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
+      <acronym>deal.II</acronym>). Thus we give only a short
+      walk-through mentioning the most important parameters needed for
+      successful compliation and linking.
     </p>
     
     <p> The compilation scheme involves repeating the same three steps
          <code>INTFACE</code> of 
          <acronym>BLACS</acronym>' own <code>Bmake.inc</code>. If you
          are using OpenMPI this should be the
-         value <code>-DAdd_</code>. Further we have to add to all
+         value <code>-DAdd_</code>. 
+       </li>
+
+       <li> Finally we add the flag <code>-fPIC</code> to the
          three compiler flag variables <code>OPTF</code>,
-         <code>OPTC</code>, and <code>OPTL</code> the flag
-         <code>-fPIC</code>. Without adding this last flag it will
-         not be possible to link deal.II with MUMPS as a shared
-         library.
+         <code>OPTC</code>, and <code>OPTL</code> which follow
+         imediately after the above. Without adding this last flag it
+         will not be possible to link <acronym>deal.II</acronym> with
+         <acronym>MUMPS</acronym> as a shared library.
        </li>
       </ul>
     </p>
       configure <acronym>deal.II</acronym> with the following
       additional options:
       <pre>
-       <code>--with-mumps=path/to/mumps
-         --with-blacs=path/to/blacs
-         --with-scalapack=path/to/scalpack
+       <code>
+          --with-mumps=path/to/mumps
+          --with-blacs=path/to/blacs
+          --with-scalapack=path/to/scalpack
        </code>
       </pre>
     </p>
     
+    <p>
+      Note: Throughout this description of the compilation process
+      of <acronym>MUMPS</acronym> we have emphasised adding the
+      compiler flag <code>-fPIC</code>. This is a definate requirement
+      if we are compiling <acronym>deal.II</acronym> with shared
+      libraries (which is the default). If we had preferred to be
+      compiling <acronym>deal.II</acronym> 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 <code>-fPIC</code> flag from the scheme.
+    </p>
+
   </body>
 </html>
index f3792bbc5661133d664a2e7f1a7dd5714f33f36f..ad4b4b887ea37ec1db3945230ed5947a93003bbf 100644 (file)
@@ -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
index 813ca5f1acc5b93fff62d8bf1e2b30c3537821af..bbe582ff2d03307c7a62fd17da63a5b5609291c0 100644 (file)
@@ -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 <class Matrix>
 void SparseDirectMUMPS::initialize (const SparseMatrix<double>& matrix, 
                                    const Vector<double>      & 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<double>& 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<double>& matrix,
 
 void SparseDirectMUMPS::solve (Vector<double>& 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<float>);
 InstantiateUMFPACK(BlockSparseMatrix<double>);
 InstantiateUMFPACK(BlockSparseMatrix<float>);
 
-#ifdef DEAL_II_USE_MUMPS
 // explicit instantiations for SparseDirectMUMPS
+#ifdef DEAL_II_USE_MUMPS
 template <class Matrix>
 void SparseDirectMUMPS::initialize (const SparseMatrix<double>& matrix, 
                                    const Vector<double>      & vector);

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.