]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added simple non local FE.
authorLuca Heltai <luca.heltai@sissa.it>
Thu, 16 Jul 2020 18:03:26 +0000 (20:03 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Thu, 30 Jul 2020 05:26:56 +0000 (07:26 +0200)
tests/non_local/CMakeLists.txt [new file with mode: 0644]
tests/non_local/fe_q1_nonlocal.h [new file with mode: 0644]
tests/non_local/fe_q1_nonlocal_01.cc [new file with mode: 0644]
tests/non_local/fe_q1_nonlocal_01.output [new file with mode: 0644]
tests/non_local/fe_q1_nonlocal_02.cc [new file with mode: 0644]
tests/non_local/fe_q1_nonlocal_02.output [new file with mode: 0644]
tests/non_local/fe_q1_nonlocal_03.cc [new file with mode: 0644]
tests/non_local/fe_q1_nonlocal_03.output [new file with mode: 0644]

diff --git a/tests/non_local/CMakeLists.txt b/tests/non_local/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d33eafa
--- /dev/null
@@ -0,0 +1,4 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
+INCLUDE(../setup_testsubproject.cmake)
+PROJECT(testsuite CXX)
+DEAL_II_PICKUP_TESTS()
diff --git a/tests/non_local/fe_q1_nonlocal.h b/tests/non_local/fe_q1_nonlocal.h
new file mode 100644 (file)
index 0000000..0e1a518
--- /dev/null
@@ -0,0 +1,68 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2020 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// Define an FE_Q1_Nonlocal finite element, where dofs are not distributed
+// on vertices (with dpo[0]=1) but on cells (with dpo[dim+2]=vertices_per_cell)
+// and the non-local dof numeration is based on the vertex id
+
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/tensor_product_polynomials.h>
+
+#include <deal.II/fe/fe_q_base.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+template <int dim>
+std::vector<unsigned int>
+get_dpo_vector()
+{
+  std::vector<unsigned int> dpo(dim + 2, 0.0);
+  dpo[dim + 1] = GeometryInfo<dim>::vertices_per_cell;
+  return dpo;
+}
+
+template <int dim>
+class FE_Q1_Nonlocal : public FE_Q_Base<TensorProductPolynomials<dim>, dim, dim>
+{
+public:
+  FE_Q1_Nonlocal()
+    : FE_Q_Base<TensorProductPolynomials<dim>, dim, dim>(
+        TensorProductPolynomials<dim>(
+          Polynomials::generate_complete_Lagrange_basis(
+            QGaussLobatto<1>(2).get_points())),
+        FiniteElementData<dim>(get_dpo_vector<dim>(),
+                               1,
+                               1,
+                               FiniteElementData<dim>::H1),
+        std::vector<bool>(1, false))
+  {
+    this->unit_support_points = QTrapez<dim>().get_points();
+  }
+
+  virtual std::unique_ptr<FiniteElement<dim>>
+  clone() const override
+  {
+    return std::make_unique<FE_Q1_Nonlocal<dim>>();
+  }
+
+  virtual std::string
+  get_name() const override
+  {
+    return "FE_Q_Nonlocal<dim>";
+  }
+};
diff --git a/tests/non_local/fe_q1_nonlocal_01.cc b/tests/non_local/fe_q1_nonlocal_01.cc
new file mode 100644 (file)
index 0000000..5633da7
--- /dev/null
@@ -0,0 +1,49 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 1998 - 2018 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+// build an FE_Q1_Nonlocal finite element, where dofs are not distributed
+// on vertices (with dpo[0]=1) but on cells (with dpo[dim+2]=vertices_per_cell)
+
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/tensor_product_polynomials.h>
+
+#include <deal.II/fe/fe_q_base.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+#include "../non_local/fe_q1_nonlocal.h"
+
+template <int dim>
+void
+test()
+{
+  FE_Q1_Nonlocal<dim> fe;
+  if (fe.n_dofs_per_cell() != GeometryInfo<dim>::vertices_per_cell)
+    deallog << "Not OK" << std::endl;
+  else
+    deallog << "OK" << std::endl;
+}
+
+int
+main()
+{
+  initlog();
+
+  test<1>();
+  test<2>();
+  test<3>();
+}
diff --git a/tests/non_local/fe_q1_nonlocal_01.output b/tests/non_local/fe_q1_nonlocal_01.output
new file mode 100644 (file)
index 0000000..fb71de2
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL::OK
+DEAL::OK
+DEAL::OK
diff --git a/tests/non_local/fe_q1_nonlocal_02.cc b/tests/non_local/fe_q1_nonlocal_02.cc
new file mode 100644 (file)
index 0000000..a490caa
--- /dev/null
@@ -0,0 +1,58 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 1998 - 2018 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+// build an FE_Q1_Nonlocal finite element, and check identities.
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+#include "../non_local/fe_q1_nonlocal.h"
+
+template <int dim>
+void
+test()
+{
+  deallog << "DIM: " << dim << std::endl << std::endl;
+  FE_Q1_Nonlocal<dim> fe;
+  // Check that the basis functions are what we expect
+  const auto &quad = fe.get_unit_support_points();
+
+  for (unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
+    {
+      deallog << "Shape[" << i << "]: ";
+      for (unsigned int q = 0; q < quad.size(); ++q)
+        {
+          const auto p = quad[q];
+          deallog << int(fe.shape_value(i, p)) << " ";
+        }
+      deallog << std::endl;
+    }
+}
+
+int
+main()
+{
+  initlog();
+
+  test<1>();
+  test<2>();
+  test<3>();
+}
diff --git a/tests/non_local/fe_q1_nonlocal_02.output b/tests/non_local/fe_q1_nonlocal_02.output
new file mode 100644 (file)
index 0000000..01dc4da
--- /dev/null
@@ -0,0 +1,21 @@
+
+DEAL::DIM: 1
+DEAL::
+DEAL::Shape[0]: 1 0 
+DEAL::Shape[1]: 0 1 
+DEAL::DIM: 2
+DEAL::
+DEAL::Shape[0]: 1 0 0 0 
+DEAL::Shape[1]: 0 1 0 0 
+DEAL::Shape[2]: 0 0 1 0 
+DEAL::Shape[3]: 0 0 0 1 
+DEAL::DIM: 3
+DEAL::
+DEAL::Shape[0]: 1 0 0 0 0 0 0 0 
+DEAL::Shape[1]: 0 1 0 0 0 0 0 0 
+DEAL::Shape[2]: 0 0 1 0 0 0 0 0 
+DEAL::Shape[3]: 0 0 0 1 0 0 0 0 
+DEAL::Shape[4]: 0 0 0 0 1 0 0 0 
+DEAL::Shape[5]: 0 0 0 0 0 1 0 0 
+DEAL::Shape[6]: 0 0 0 0 0 0 1 0 
+DEAL::Shape[7]: 0 0 0 0 0 0 0 1 
diff --git a/tests/non_local/fe_q1_nonlocal_03.cc b/tests/non_local/fe_q1_nonlocal_03.cc
new file mode 100644 (file)
index 0000000..5746bba
--- /dev/null
@@ -0,0 +1,55 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 1998 - 2018 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.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+// build an FE_Q1_Nonlocal finite element, and distribute dofs on a simple
+// Triangulation.
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+#include "../non_local/fe_q1_nonlocal.h"
+
+template <int dim>
+void
+test()
+{
+  FE_Q1_Nonlocal<dim> fe;
+  Triangulation<dim>  tria;
+  GridGenerator::hyper_cube(tria);
+  tria.refine_global(1);
+  DoFHandler<dim> dh(tria);
+  dh.distribute_dofs(fe);
+
+  if (dh.n_dofs() != tria.n_vertices())
+    deallog << "Not OK" << std::endl;
+  else
+    deallog << "OK" << std::endl;
+}
+
+int
+main()
+{
+  initlog();
+
+  test<1>();
+  test<2>();
+  test<3>();
+}
diff --git a/tests/non_local/fe_q1_nonlocal_03.output b/tests/non_local/fe_q1_nonlocal_03.output
new file mode 100644 (file)
index 0000000..e69de29

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.