]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
add test
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 25 Apr 2014 20:47:39 +0000 (20:47 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 25 Apr 2014 20:47:39 +0000 (20:47 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_sharedtria@32832 0785d39b-7218-0410-832d-ea1e28bc413d

tests/sharedtria/tria_01.cc [new file with mode: 0644]
tests/sharedtria/tria_01.mpirun=3.output [new file with mode: 0644]
tests/sharedtria/tria_01.output [new file with mode: 0644]

diff --git a/tests/sharedtria/tria_01.cc b/tests/sharedtria/tria_01.cc
new file mode 100644 (file)
index 0000000..017902b
--- /dev/null
@@ -0,0 +1,103 @@
+// ---------------------------------------------------------------------
+// $Id: 3d_refinement_01.cc 31349 2013-10-20 19:07:06Z maier $
+//
+// Copyright (C) 2008 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// create a shared tria mesh and refine it
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/tensor.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/distributed/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_out.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/numerics/data_out.h>
+
+#include <fstream>
+
+template <int dim, int spacedim>
+void write_mesh (const parallel::shared::Triangulation<dim,spacedim> &tria,
+                const char                                *filename_)
+{
+    DataOut<dim> data_out;
+    data_out.attach_triangulation (tria);
+    Vector<float> subdomain (tria.n_active_cells());
+    for (unsigned int i=0; i<subdomain.size(); ++i)
+      subdomain(i) = tria.locally_owned_subdomain();
+    data_out.add_data_vector (subdomain, "subdomain");
+
+    data_out.build_patches ();
+    const std::string filename = (filename_ +
+                                  Utilities::int_to_string
+                                  (tria.locally_owned_subdomain(), 4));
+    {
+      std::ofstream output ((filename + ".vtu").c_str());
+      data_out.write_vtu (output);
+    }
+
+    //cat_file((filename + ".vtu").c_str());
+}
+
+
+
+template<int dim>
+void test()
+{
+  parallel::shared::Triangulation<dim> tr(MPI_COMM_WORLD);
+
+
+  GridGenerator::hyper_cube(tr);
+  tr.begin_active()->set_refine_flag();
+  tr.execute_coarsening_and_refinement ();
+  if (tr.locally_owned_subdomain()==0)
+    tr.begin_active()->set_refine_flag();
+  tr.execute_coarsening_and_refinement ();
+
+  deallog
+    << " locally_owned_subdomain(): " << tr.locally_owned_subdomain() << "\n"
+    << " n_active_cells: " << tr.n_active_cells() << "\n"
+    << " n_levels: " << tr.n_levels() << "\n"
+    << " n_global_levels: " << tr.n_global_levels()  << "\n"
+    //<< " n_locally_owned_active_cells: " << tr.n_locally_owned_active_cells() << "\n"
+    //<< " n_global_active_cells: " << tr.n_global_active_cells() << "\n"
+    << std::endl;
+
+  /*deallog << "n_locally_owned_active_cells_per_processor: ";
+  std::vector<unsigned int> v = tr.n_locally_owned_active_cells_per_processor();
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << v[i] << " ";
+    deallog << std::endl;*/
+
+  write_mesh(tr, "mesh");
+}
+
+
+int main(int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+  MPILogInitAll all;
+
+  deallog.push("2d");
+  test<2>();
+  deallog.pop();
+  deallog.push("3d");
+  //test<3>();
+  deallog.pop();
+}
diff --git a/tests/sharedtria/tria_01.mpirun=3.output b/tests/sharedtria/tria_01.mpirun=3.output
new file mode 100644 (file)
index 0000000..2fd09c5
--- /dev/null
@@ -0,0 +1,20 @@
+
+DEAL:0:2d:: locally_owned_subdomain(): 0
+ n_active_cells: 7
+ n_levels: 3
+ n_global_levels: 3
+
+
+DEAL:1:2d:: locally_owned_subdomain(): 1
+ n_active_cells: 4
+ n_levels: 2
+ n_global_levels: 2
+
+
+
+DEAL:2:2d:: locally_owned_subdomain(): 2
+ n_active_cells: 4
+ n_levels: 2
+ n_global_levels: 2
+
+
diff --git a/tests/sharedtria/tria_01.output b/tests/sharedtria/tria_01.output
new file mode 100644 (file)
index 0000000..132c2cf
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL:0:2d:: locally_owned_subdomain(): 0
+ n_active_cells: 7
+ n_levels: 3
+ n_global_levels: 3
+

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.