From 6252438ea69f090879930e1d0be86072b5b21bab Mon Sep 17 00:00:00 2001
From: Oliver Sander <oliver.sander@tu-dresden.de>
Date: Tue, 2 May 2023 12:03:06 +0200
Subject: [PATCH] A test for EmbeddedGlobalGFEFunction

---
 test/CMakeLists.txt                   |  1 +
 test/embeddedglobalgfefunctiontest.cc | 51 +++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100644 test/embeddedglobalgfefunctiontest.cc

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 8f62323c..5b79db23 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -4,6 +4,7 @@ set(TESTS
   averagedistanceassemblertest
   cosseratenergytest
   cosseratrodenergytest
+  embeddedglobalgfefunctiontest
   harmonicenergytest
   localgeodesicfefunctiontest
   localgfetestfunctiontest
diff --git a/test/embeddedglobalgfefunctiontest.cc b/test/embeddedglobalgfefunctiontest.cc
new file mode 100644
index 00000000..ca9be834
--- /dev/null
+++ b/test/embeddedglobalgfefunctiontest.cc
@@ -0,0 +1,51 @@
+// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+// vi: set et ts=4 sw=2 sts=2:
+
+#include "config.h"
+
+#include <dune/grid/yaspgrid.hh>
+
+#include <dune/functions/functionspacebases/lagrangebasis.hh>
+#include <dune/functions/gridfunctions/gridviewfunction.hh>
+
+#include <dune/gfe/embeddedglobalgfefunction.hh>
+#include <dune/gfe/localgeodesicfefunction.hh>
+#include <dune/gfe/localprojectedfefunction.hh>
+#include <dune/gfe/unitvector.hh>
+
+using namespace Dune;
+
+int main(int argc, char** argv)
+{
+  MPIHelper::instance(argc, argv);
+
+  // Make a test grid
+  const int dim = 2;
+  YaspGrid<dim> grid({1,1}, {5,5});
+
+  auto gridView = grid.leafGridView();
+
+  // Make a test basis
+  using namespace Functions::BasisFactory;
+  auto basis = Functions::BasisFactory::makeBasis(gridView, lagrange<2>());
+
+  // Make a test coefficient set
+  using TargetSpace = UnitVector<double,3>;
+
+  std::vector<TargetSpace> coefficients(basis.size());
+  std::fill(coefficients.begin(), coefficients.end(), FieldVector<double,3>({1,0,0}));
+
+  using GeodesicInterpolationRule  = LocalGeodesicFEFunction<dim, double, decltype(basis)::LocalView::Tree::FiniteElement, TargetSpace>;
+  GFE::EmbeddedGlobalGFEFunction<decltype(basis),GeodesicInterpolationRule,TargetSpace> testFunction(basis, coefficients);
+
+  // Evaluate the function at the element centers
+  auto localGFEFunction = localFunction(testFunction);
+  for (auto&& element : elements(gridView))
+  {
+    localGFEFunction.bind(element);
+    std::cout << localGFEFunction({0.5, 0.5}) << std::endl;
+  }
+
+  // Can we use EmbeddedGlobalGFEFunction within the type erasure wrapper?
+  auto typeErasure = Functions::makeGridViewFunction(testFunction, gridView);
+};
-- 
GitLab