]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add parallel MappingQEulerian test 3032/head
authorTimo Heister <timo.heister@gmail.com>
Mon, 29 Aug 2016 19:25:57 +0000 (15:25 -0400)
committerTimo Heister <timo.heister@gmail.com>
Mon, 29 Aug 2016 19:26:50 +0000 (15:26 -0400)
fixes #3014

tests/mappings/mapping_q_eulerian_07.cc [new file with mode: 0644]
tests/mappings/mapping_q_eulerian_07.with_petsc=true.mpirun=3.output [new file with mode: 0644]

diff --git a/tests/mappings/mapping_q_eulerian_07.cc b/tests/mappings/mapping_q_eulerian_07.cc
new file mode 100644 (file)
index 0000000..61ceac1
--- /dev/null
@@ -0,0 +1,148 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2003 - 2016 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.
+//
+// ---------------------------------------------------------------------
+
+
+// test that MappingQEulerian works in parallel.
+//
+// this is a variant of _02
+
+#include "../tests.h"
+
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/identity_matrix.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/thread_management.h>
+#include <deal.II/base/function.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/vector_memory.h>
+#include <deal.II/lac/filtered_matrix.h>
+#include <deal.II/lac/precondition.h>
+#include <deal.II/lac/solver_cg.h>
+#include <deal.II/lac/sparse_matrix.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_reordering.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/distributed/tria.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/lac/constraint_matrix.h>
+#include <deal.II/lac/petsc_parallel_vector.h>
+#include <deal.II/fe/mapping_q1.h>
+#include <deal.II/fe/mapping_q_eulerian.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/numerics/vector_tools.h>
+#include <deal.II/numerics/data_out.h>
+#include <deal.II/base/multithread_info.h>
+#include <fstream>
+#include <cmath>
+#include <iostream>
+#include <vector>
+
+
+
+
+
+
+using namespace dealii;
+
+
+template <int dim>
+class Displacement : public Function<dim>
+{
+public:
+  Displacement() :
+    Function<dim>(dim)
+  {}
+
+  double value (const Point<dim> &p,
+                const unsigned int component) const
+  {
+    return p[component]*p[0]/2;
+  }
+
+  void vector_value (const Point<dim> &p,
+                     Vector<double> &v) const
+  {
+    for (unsigned int i=0; i<dim; ++i)
+      v(i) = p[i]*p[0]/2;
+  }
+};
+
+
+template <int dim>
+void test ()
+{
+  deallog << "dim=" << dim << std::endl;
+  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<dim>
+  triangulation (MPI_COMM_WORLD,
+                 typename Triangulation<dim>::MeshSmoothing
+                 (Triangulation<dim>::smoothing_on_refinement |
+                  Triangulation<dim>::smoothing_on_coarsening));
+  GridGenerator::hyper_cube (triangulation, -1, 1);
+  triangulation.refine_global(2);
+
+  FESystem<dim> fe(FE_Q<dim>(2), dim);
+  DoFHandler<dim> dof_handler(triangulation);
+  dof_handler.distribute_dofs(fe);
+
+  IndexSet locally_owned_dofs = dof_handler.locally_owned_dofs ();
+  IndexSet locally_relevant_dofs;
+  DoFTools::extract_locally_relevant_dofs (dof_handler,locally_relevant_dofs);
+
+  PETScWrappers::MPI::Vector x(locally_owned_dofs, MPI_COMM_WORLD);
+  PETScWrappers::MPI::Vector x_relevant(locally_owned_dofs,locally_relevant_dofs, MPI_COMM_WORLD);
+
+  VectorTools::interpolate (dof_handler,
+                            Displacement<dim>(),
+                            x);
+  x_relevant = x;
+
+  MappingQEulerian<dim, PETScWrappers::MPI::Vector> euler(2, dof_handler, x_relevant);
+
+  // now the actual test
+  DataOut<dim> data_out;
+  data_out.attach_dof_handler(dof_handler);
+  data_out.add_data_vector(x_relevant, "displacement");
+
+  // output with all cells curved
+  data_out.build_patches(euler, 1, DataOut<dim>::curved_inner_cells);
+  data_out.write_gnuplot(deallog.get_file_stream());
+}
+
+
+
+int main (int argc, char *argv[])
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, 1);
+  MPILogInitAll log;
+
+  test<2> ();
+}
+
+
diff --git a/tests/mappings/mapping_q_eulerian_07.with_petsc=true.mpirun=3.output b/tests/mappings/mapping_q_eulerian_07.with_petsc=true.mpirun=3.output
new file mode 100644 (file)
index 0000000..86ba71e
--- /dev/null
@@ -0,0 +1,142 @@
+
+DEAL:0::dim=2
+DEAL:0::numproc=3
+# This file was generated by the deal.II library.
+
+
+#
+# For a description of the GNUPLOT format see the GNUPLOT manual.
+#
+# <x> <y> <displacement_0> <displacement_1> 
+-0.500000 -0.500000 0.500000 0.500000 
+-0.375000 -0.750000 0.125000 0.250000 
+
+-0.500000 -0.250000 0.500000 0.250000 
+-0.375000 -0.375000 0.125000 0.125000 
+
+
+-0.375000 -0.750000 0.125000 0.250000 
+0.00000 -1.00000 0.00000 0.00000 
+
+-0.375000 -0.375000 0.125000 0.125000 
+0.00000 -0.500000 0.00000 0.00000 
+
+
+-0.500000 -0.250000 0.500000 0.250000 
+-0.375000 -0.375000 0.125000 0.125000 
+
+-0.500000 0.00000 0.500000 0.00000 
+-0.375000 0.00000 0.125000 0.00000 
+
+
+-0.375000 -0.375000 0.125000 0.125000 
+0.00000 -0.500000 0.00000 0.00000 
+
+-0.375000 0.00000 0.125000 0.00000 
+0.00000 0.00000 0.00000 0.00000 
+
+
+
+DEAL:1::dim=2
+# This file was generated by the deal.II library.
+
+
+#
+# For a description of the GNUPLOT format see the GNUPLOT manual.
+#
+# <x> <y> <displacement_0> <displacement_1> 
+0.00000 -1.00000 0.00000 0.00000 
+0.625000 -1.25000 0.125000 -0.250000 
+
+0.00000 -0.500000 0.00000 0.00000 
+0.625000 -0.625000 0.125000 -0.125000 
+
+
+0.625000 -1.25000 0.125000 -0.250000 
+1.50000 -1.50000 0.500000 -0.500000 
+
+0.625000 -0.625000 0.125000 -0.125000 
+1.50000 -0.750000 0.500000 -0.250000 
+
+
+0.00000 -0.500000 0.00000 0.00000 
+0.625000 -0.625000 0.125000 -0.125000 
+
+0.00000 0.00000 0.00000 0.00000 
+0.625000 0.00000 0.125000 0.00000 
+
+
+0.625000 -0.625000 0.125000 -0.125000 
+1.50000 -0.750000 0.500000 -0.250000 
+
+0.625000 0.00000 0.125000 0.00000 
+1.50000 0.00000 0.500000 0.00000 
+
+
+-0.500000 0.00000 0.500000 0.00000 
+-0.375000 0.00000 0.125000 0.00000 
+
+-0.500000 0.250000 0.500000 -0.250000 
+-0.375000 0.375000 0.125000 -0.125000 
+
+
+-0.375000 0.00000 0.125000 0.00000 
+0.00000 0.00000 0.00000 0.00000 
+
+-0.375000 0.375000 0.125000 -0.125000 
+0.00000 0.500000 0.00000 0.00000 
+
+
+-0.500000 0.250000 0.500000 -0.250000 
+-0.375000 0.375000 0.125000 -0.125000 
+
+-0.500000 0.500000 0.500000 -0.500000 
+-0.375000 0.750000 0.125000 -0.250000 
+
+
+-0.375000 0.375000 0.125000 -0.125000 
+0.00000 0.500000 0.00000 0.00000 
+
+-0.375000 0.750000 0.125000 -0.250000 
+0.00000 1.00000 0.00000 0.00000 
+
+
+
+
+DEAL:2::dim=2
+# This file was generated by the deal.II library.
+
+
+#
+# For a description of the GNUPLOT format see the GNUPLOT manual.
+#
+# <x> <y> <displacement_0> <displacement_1> 
+0.00000 0.00000 0.00000 0.00000 
+0.625000 0.00000 0.125000 0.00000 
+
+0.00000 0.500000 0.00000 0.00000 
+0.625000 0.625000 0.125000 0.125000 
+
+
+0.625000 0.00000 0.125000 0.00000 
+1.50000 0.00000 0.500000 0.00000 
+
+0.625000 0.625000 0.125000 0.125000 
+1.50000 0.750000 0.500000 0.250000 
+
+
+0.00000 0.500000 0.00000 0.00000 
+0.625000 0.625000 0.125000 0.125000 
+
+0.00000 1.00000 0.00000 0.00000 
+0.625000 1.25000 0.125000 0.250000 
+
+
+0.625000 0.625000 0.125000 0.125000 
+1.50000 0.750000 0.500000 0.250000 
+
+0.625000 1.25000 0.125000 0.250000 
+1.50000 1.50000 0.500000 0.500000 
+
+
+

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.