]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
fix test
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 31 Jul 2013 15:01:48 +0000 (15:01 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 31 Jul 2013 15:01:48 +0000 (15:01 +0000)
git-svn-id: https://svn.dealii.org/trunk@30199 0785d39b-7218-0410-832d-ea1e28bc413d

tests/gla/block_mat_03.cc

index 4f9987e331e85da242b1ed994f66bf251211e8df..8a46835da2b193ea414b8e8536e7294563005326 100644 (file)
@@ -84,16 +84,21 @@ void test ()
   locally_owned_partitioning.push_back (locally_owned_dofs.get_view(0, dofs_per_block[0]));
   locally_owned_partitioning.push_back (locally_owned_dofs.get_view(dofs_per_block[0], dofs_per_block[0] + dofs_per_block[1]));
 
+  deallog << "owned: ";
+  locally_owned_dofs.print(deallog);
+  deallog << "relevant: ";
+  locally_relevant_dofs.print(deallog);
+  
+  
   ConstraintMatrix constraints(locally_relevant_dofs);
   constraints.close();
 
-  BlockCompressedSimpleSparsityPattern bcsp (locally_owned_partitioning);
+  BlockCompressedSimpleSparsityPattern bcsp (locally_relevant_partitioning);
   DoFTools::make_sparsity_pattern (dof_handler, bcsp, constraints, false);
-  SparsityTools::distribute_sparsity_pattern (bcsp, dof_handler.n_locally_owned_dofs_per_processor (), MPI_COMM_WORLD, locally_relevant_dofs);
+  SparsityTools::distribute_sparsity_pattern (bcsp, dof_handler.locally_owned_dofs_per_processor (), MPI_COMM_WORLD, locally_relevant_dofs);
 
   typename LA::MPI::BlockSparseMatrix A;
   A.reinit(locally_owned_partitioning, bcsp, MPI_COMM_WORLD);
-  A.print(deallog.get_file_stream());
 
   QGauss<3> quadrature (3);
   FEValues<3> fe_values (fe, quadrature, update_values);
@@ -101,7 +106,6 @@ void test ()
   std::vector<types::global_dof_index> local_dof_indices (fe.dofs_per_cell);
   FullMatrix<double> local_matrix(fe.dofs_per_cell, fe.dofs_per_cell);
 
-  if (1)
   for (DoFHandler<3>::active_cell_iterator cell = dof_handler.begin_active (); cell != dof_handler.end (); ++cell)
     if (cell->is_locally_owned ())
     {
@@ -116,16 +120,102 @@ void test ()
             local_matrix (i, j) += fe_values.shape_value(i, q_point) * fe_values.shape_value(j, q_point); 
         }
       }
+      
+      cell->get_dof_indices (local_dof_indices);
+      constraints.distribute_local_to_global (local_matrix, local_dof_indices, A);
+    }
+
+  A.compress(VectorOperation::add);
+  A.print(deallog.get_file_stream());
+
+  if (myid==0)
+    deallog << "OK" << std::endl;
+}
+
+template <int dim>
+void test_alt()
+{
+    typedef LA_Trilinos LA;
+  unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD);
+  unsigned int numproc = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD);
+
+  if (myid==0)
+    deallog << "numproc=" << numproc << std::endl;
+
+  parallel::distributed::Triangulation<3> triangulation(MPI_COMM_WORLD);
+  GridGenerator::hyper_cube (triangulation, -1.0, 1.0);
+  triangulation.refine_global(2);
+
+  FESystem<3> fe(FE_Q<3> (1), 2);
+  DoFHandler<3> dof_handler(triangulation);
+  dof_handler.distribute_dofs(fe);
+  DoFRenumbering::block_wise(dof_handler);
+
+  std::vector<types::global_dof_index> dofs_per_block (fe.n_blocks());
+  std::vector<unsigned int> sub_blocks (fe.n_blocks(), 0); sub_blocks[1] = 1;
+  DoFTools::count_dofs_per_block (dof_handler, dofs_per_block, sub_blocks);
+
+  deallog << "size: " << dofs_per_block[0] << " " << dofs_per_block[1] << std::endl;
+  
+  std::vector<IndexSet> locally_relevant_partitioning;
+  std::vector<IndexSet> locally_owned_partitioning;
 
+  IndexSet locally_relevant_dofs;
+  DoFTools::extract_locally_relevant_dofs (dof_handler, locally_relevant_dofs);
+  locally_relevant_partitioning.push_back (locally_relevant_dofs.get_view (0, dofs_per_block[0]));
+  locally_relevant_partitioning.push_back (locally_relevant_dofs.get_view (dofs_per_block[0], dofs_per_block[0] + dofs_per_block[1]));
+
+  IndexSet locally_owned_dofs = dof_handler.locally_owned_dofs ();
+  locally_owned_partitioning.push_back (locally_owned_dofs.get_view(0, dofs_per_block[0]));
+  locally_owned_partitioning.push_back (locally_owned_dofs.get_view(dofs_per_block[0], dofs_per_block[0] + dofs_per_block[1]));
+
+  deallog << "owned: ";
+  locally_owned_dofs.print(deallog);
+  deallog << "relevant: ";
+  locally_relevant_dofs.print(deallog);
+  
+  
+  ConstraintMatrix constraints(locally_relevant_dofs);
+  constraints.close();
+
+  TrilinosWrappers::BlockSparsityPattern sp (locally_owned_partitioning,
+                                            MPI_COMM_WORLD);
+  DoFTools::make_sparsity_pattern (dof_handler, sp,
+                                     constraints, false,
+                                     Utilities::MPI::
+                                     this_mpi_process(MPI_COMM_WORLD));
+    sp.compress();
+  typename LA::MPI::BlockSparseMatrix A;
+A.reinit(sp);
+
+  QGauss<3> quadrature (3);
+  FEValues<3> fe_values (fe, quadrature, update_values);
+
+  std::vector<types::global_dof_index> local_dof_indices (fe.dofs_per_cell);
+  FullMatrix<double> local_matrix(fe.dofs_per_cell, fe.dofs_per_cell);
+
+  for (DoFHandler<3>::active_cell_iterator cell = dof_handler.begin_active (); cell != dof_handler.end (); ++cell)
+    if (cell->is_locally_owned ())
+    {
+      fe_values.reinit (cell);
+      local_matrix = 0.0;
+
+      for (unsigned int q_point = 0; q_point < fe_values.n_quadrature_points; ++q_point)
+      {
+        for (unsigned int i = 0; i < fe.dofs_per_cell; ++i)
+        {
+          for (unsigned int j = 0; j < fe.dofs_per_cell; ++j)
+            local_matrix (i, j) += fe_values.shape_value(i, q_point) * fe_values.shape_value(j, q_point); 
+        }
+      }
+      
       cell->get_dof_indices (local_dof_indices);
-       for (unsigned int i = 0; i < fe.dofs_per_cell; ++i)
-        deallog << local_dof_indices[i] << " ";
-       deallog << std::endl;
-       
       constraints.distribute_local_to_global (local_matrix, local_dof_indices, A);
     }
 
   A.compress(VectorOperation::add);
+  //A.print(deallog.get_file_stream());
+
   if (myid==0)
     deallog << "OK" << std::endl;
 }
@@ -134,7 +224,7 @@ void test ()
 int main (int argc, char **argv)
 {
   Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
-  MPILogInitAll log(__FILE__, true);
+  MPILogInitAll log(__FILE__);
 
   {
     deallog.push("PETSc");
@@ -143,6 +233,9 @@ int main (int argc, char **argv)
     deallog.push("Trilinos");
     test<LA_Trilinos,3>();
     deallog.pop();
+    deallog.push("Trilinos_alt");
+    test_alt<3>();
+    deallog.pop();
   }
 
   // compile, don't run

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.