]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fixed a problem in the setup of the null space in the ML preconditioner when run...
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 17 Sep 2008 14:49:15 +0000 (14:49 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 17 Sep 2008 14:49:15 +0000 (14:49 +0000)
git-svn-id: https://svn.dealii.org/trunk@16844 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/source/trilinos_precondition_amg.cc

index ea61218f94415c7e7e443b4f8e64881f26e02243..8a7a349edb376a2a89c09626e2af8cdaf50a236e 100755 (executable)
@@ -17,6 +17,7 @@
 #ifdef DEAL_II_USE_TRILINOS
 
 #include <Epetra_Map.h>
+#include <Epetra_MultiVector.h>
 #include <Epetra_Vector.h>
 #include <Teuchos_ParameterList.hpp>
 #include <ml_include.h>
@@ -78,27 +79,39 @@ namespace TrilinosWrappers
   
     if (higher_order_elements)
       parameter_list.set("aggregation: type", "MIS");
+
+    const Epetra_Map * domain_map = &(matrix.matrix->DomainMap());
     
-    std::vector<double> null_space_modes;
+    Epetra_MultiVector null_space_modes (*domain_map, null_space_dimension);
   
     if (null_space_dimension > 1)
       {
        Assert (n_rows == null_space[0].size(),
                ExcDimensionMismatch(n_rows,
                                     null_space[0].size()));
+       Assert (n_rows == (unsigned int)null_space_modes.GlobalLength(),
+               ExcDimensionMismatch(n_rows,
+                                    null_space_modes.GlobalLength()));
+
+       unsigned int my_size = domain_map->NumMyElements();
+       Assert (my_size == domain_map->MaxLID()+1,
+               ExcDimensionMismatch (my_size, domain_map->MaxLID()+1));
        
                                        // Reshape null space as a
                                        // contiguous vector of
                                        // doubles so that Trilinos
                                        // can read from it.
-       null_space_modes.resize (n_rows * null_space_dimension, 0.);
        for (unsigned int d=0; d<null_space_dimension; ++d)
-         for (unsigned int row=0; row<n_rows; ++row)
-           null_space_modes[d*n_rows + row] = (double)null_space[d][row];
+         for (unsigned int row=0; row<my_size; ++row)
+           {
+             int global_row_id = domain_map->GID(row);
+             null_space_modes.ReplaceMyValue(row, d, 
+                                (double)null_space[d][global_row_id]);
+           }
   
        parameter_list.set("null space: type", "pre-computed");
-       parameter_list.set("null space: dimension", int(null_space_dimension));
-       parameter_list.set("null space: vectors", &null_space_modes[0]);
+       parameter_list.set("null space: dimension", null_space_modes.NumVectors());
+       parameter_list.set("null space: vectors", null_space_modes.Values());
       }
 
     multigrid_operator = boost::shared_ptr<ML_Epetra::MultiLevelPreconditioner>

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.