From bf054388f22b2d988d410dc7b7c71b4996d47a6d Mon Sep 17 00:00:00 2001
From: Simon Praetorius <simon.praetorius@tu-dresden.de>
Date: Sat, 20 Jan 2018 00:57:18 +0100
Subject: [PATCH] Some cleanup for intel compiler

---
 dune/amdis/ProblemStat.inc.hpp                | 12 ++---
 dune/amdis/common/FieldMatVec.hpp             | 11 +++++
 dune/amdis/common/Literals.hpp                |  8 +--
 .../gridfunctions/AnalyticGridFunction.hpp    | 49 ++++++++++---------
 .../gridfunctions/FunctorGridFunction.hpp     | 29 ++++++-----
 5 files changed, 67 insertions(+), 42 deletions(-)

diff --git a/dune/amdis/ProblemStat.inc.hpp b/dune/amdis/ProblemStat.inc.hpp
index df3b1f7e..b7e14680 100644
--- a/dune/amdis/ProblemStat.inc.hpp
+++ b/dune/amdis/ProblemStat.inc.hpp
@@ -137,9 +137,9 @@ void ProblemStat<Traits>::addMatrixOperator(
     RowTreePath row, ColTreePath col,
     double* factor, double* estFactor)
 {
-  static_assert( Concept::PreTreePath<RowTreePath>,
+  static_assert( Concepts::PreTreePath<RowTreePath>,
       "row must be a valid treepath, or an integer/index-constant");
-  static_assert( Concept::PreTreePath<ColTreePath>,
+  static_assert( Concepts::PreTreePath<ColTreePath>,
       "col must be a valid treepath, or an integer/index-constant");
 
   auto i = child(globalBasis->localView().tree(), makeTreePath(row));
@@ -161,9 +161,9 @@ void ProblemStat<Traits>::addMatrixOperator(
     RowTreePath row, ColTreePath col,
     double* factor, double* estFactor)
 {
-  static_assert( Concept::PreTreePath<RowTreePath>,
+  static_assert( Concepts::PreTreePath<RowTreePath>,
       "row must be a valid treepath, or an integer/index-constant");
-  static_assert( Concept::PreTreePath<ColTreePath>,
+  static_assert( Concepts::PreTreePath<ColTreePath>,
       "col must be a valid treepath, or an integer/index-constant");
 
   auto i = child(globalBasis->localView().tree(), makeTreePath(row));
@@ -185,7 +185,7 @@ void ProblemStat<Traits>::addVectorOperator(
     TreePath path,
     double* factor, double* estFactor)
 {
-  static_assert( Concept::PreTreePath<TreePath>,
+  static_assert( Concepts::PreTreePath<TreePath>,
       "path must be a valid treepath, or an integer/index-constant");
 
   auto i = child(globalBasis->localView().tree(), makeTreePath(path));
@@ -206,7 +206,7 @@ void ProblemStat<Traits>::addVectorOperator(
     TreePath path,
     double* factor, double* estFactor)
 {
-  static_assert( Concept::PreTreePath<TreePath>,
+  static_assert( Concepts::PreTreePath<TreePath>,
       "path must be a valid treepath, or an integer/index-constant");
 
   auto i = child(globalBasis->localView().tree(), makeTreePath(path));
diff --git a/dune/amdis/common/FieldMatVec.hpp b/dune/amdis/common/FieldMatVec.hpp
index 64690122..ffc8492f 100644
--- a/dune/amdis/common/FieldMatVec.hpp
+++ b/dune/amdis/common/FieldMatVec.hpp
@@ -338,4 +338,15 @@ namespace AMDiS
     return C;
   }
 
+  template <class T, int M, int N>
+  Dune::FieldMatrix<T,M,N>& multiplies_ABt(Dune::FieldMatrix<T, M, N> const& A,  Dune::DiagonalMatrix<T, N> const& B, Dune::FieldMatrix<T,M,N>& C)
+  {
+    for (int m = 0; m < M; ++m) {
+      for (int n = 0; n < N; ++n) {
+        C[m][n] = A[m][n] * B.diagonal(n);
+      }
+    }
+    return C;
+  }
+
 } // end namespace AMDiS
diff --git a/dune/amdis/common/Literals.hpp b/dune/amdis/common/Literals.hpp
index 72654b3a..ee08d32e 100644
--- a/dune/amdis/common/Literals.hpp
+++ b/dune/amdis/common/Literals.hpp
@@ -15,14 +15,16 @@ namespace AMDiS
       return unsigned(c) - unsigned('0');
     }
 
-    template <std::size_t N>
-    constexpr std::size_t string2num(const char (&arr)[N])
+    template <char... digits>
+    constexpr std::size_t string2num()
     {
+      const char arr[] = {digits...};
       assert(arr[0] != '-' && "Negative integral constant");
 
       std::size_t result = 0;
       std::size_t power  = 1;
 
+      const int N = sizeof...(digits);
       for (std::size_t i = 0; i < N; ++i) {
           char c = arr[N - 1 - i];
           result+= char2digit(c) * power;
@@ -38,7 +40,7 @@ namespace AMDiS
   template <char... digits>
   constexpr auto operator"" _c()
   {
-    return index_<Impl::string2num<sizeof...(digits)>({digits...})>;
+    return index_<Impl::string2num<digits...>()>;
   }
 
 } // end namespace AMDiS
diff --git a/dune/amdis/gridfunctions/AnalyticGridFunction.hpp b/dune/amdis/gridfunctions/AnalyticGridFunction.hpp
index e48ead94..e339b330 100644
--- a/dune/amdis/gridfunctions/AnalyticGridFunction.hpp
+++ b/dune/amdis/gridfunctions/AnalyticGridFunction.hpp
@@ -45,18 +45,6 @@ namespace AMDiS
       return fct_(geometry_.value().global(local));
     }
 
-    friend auto derivative(AnalyticLocalFunction const& lf)
-    {
-      static_assert(Concepts::HasPartial<Function>,
-        "No partial(_0,...) defined for Functor F of AnalyticLocalFunction.");
-
-      auto df = partial(lf.fct(), index_<0>);
-
-      using RawSignature = typename Dune::Functions::SignatureTraits<R(D)>::RawSignature;
-      using DerivativeSignature = typename Dune::Functions::DefaultDerivativeTraits<RawSignature>::Range(D);
-      return AnalyticLocalFunction<DerivativeSignature,LocalContext,decltype(df)>{df};
-    }
-
     Function const& fct() const
     {
       return fct_;
@@ -77,6 +65,20 @@ namespace AMDiS
   }
 
 
+  template <class R, class D, class LocalContext, class F>
+  auto derivative(AnalyticLocalFunction<R(D),LocalContext,F> const& lf)
+  {
+    static_assert(Concepts::HasPartial<F>,
+      "No partial(_0,...) defined for Functor F of AnalyticLocalFunction.");
+
+    auto df = partial(lf.fct(), index_<0>);
+
+    using RawSignature = typename Dune::Functions::SignatureTraits<R(D)>::RawSignature;
+    using DerivativeSignature = typename Dune::Functions::DefaultDerivativeTraits<RawSignature>::Range(D);
+    return AnalyticLocalFunction<DerivativeSignature,LocalContext,decltype(df)>{df};
+  }
+
+
   /// \class AnalyticGridFunction
   /// \brief A Gridfunction that evaluates a function with global coordinates.
   /**
@@ -121,16 +123,6 @@ namespace AMDiS
       return LocalFunction{gf.fct_};
     }
 
-    /// \brief Return a GridFunction representing the derivative of a functor.
-    // [expects: Functor f has free function derivative(f)]
-    friend auto derivative(AnalyticGridFunction const& gf)
-    {
-      static_assert(Concepts::HasPartial<Function>,
-        "No partial(_0,...) defined for Functor of AnalyticLocalFunction.");
-
-      auto df = partial(gf.fct(), index_<0>);
-      return AnalyticGridFunction<decltype(df), GridView>{df, gf.entitySet().gridView()};
-    }
 
     EntitySet const& entitySet() const
     {
@@ -146,6 +138,19 @@ namespace AMDiS
   };
 
 
+  /// \brief Return a GridFunction representing the derivative of a functor.
+  // [expects: Functor f has free function derivative(f)]
+  template <class F, class GV>
+  auto derivative(AnalyticGridFunction<F,GV> const& gf)
+  {
+    static_assert(Concepts::HasPartial<F>,
+      "No partial(_0,...) defined for Functor of AnalyticLocalFunction.");
+
+    auto df = partial(gf.fct(), index_<0>);
+    return AnalyticGridFunction<decltype(df), GV>{df, gf.entitySet().gridView()};
+  }
+
+
 #ifndef DOXYGEN
   // A pre-GridFunction that just stores the function
   template <class Function>
diff --git a/dune/amdis/gridfunctions/FunctorGridFunction.hpp b/dune/amdis/gridfunctions/FunctorGridFunction.hpp
index c8d65e8b..4fc04787 100644
--- a/dune/amdis/gridfunctions/FunctorGridFunction.hpp
+++ b/dune/amdis/gridfunctions/FunctorGridFunction.hpp
@@ -179,9 +179,10 @@ namespace AMDiS
 
     using RawRange = std::decay_t<Range>;
     using LocalDomain = typename EntitySet::LocalCoordinate;
-    using LocalFunction = FunctorLocalFunction<RawRange(LocalDomain), Functor, LocalFct<GridFunctions>...>;
 
   public:
+    using LocalFunction = FunctorLocalFunction<RawRange(LocalDomain), Functor, LocalFct<GridFunctions>...>;
+
     /// Constructor. Stores copies of the functor and gridfunctions.
     template <class... GridFcts>
     explicit FunctorGridFunction(Functor const& fct, GridFcts&&... gridFcts)
@@ -196,22 +197,15 @@ namespace AMDiS
         MakeSeq_t<sizeof...(GridFunctions)>{});
     }
 
-    /// \brief Creates a LocalFunction from the LocalFunctions of the GridFunctions. \relates FunctorLocalFunction
-    friend LocalFunction localFunction(FunctorGridFunction const& gf)
-    {
-      return Dune::Std::apply([&gf](auto const&... gridFcts)
-      {
-        return LocalFunction{gf.fct_, localFunction(gridFcts)...};
-      },
-      gf.gridFcts_);
-    }
-
     /// Return the stored \ref EntitySet of the first GridFunction
     EntitySet const& entitySet() const
     {
       return std::get<0>(gridFcts_).entitySet();
     }
 
+    auto const& fct() const { return fct_; }
+    auto const& gridFcts() const { return gridFcts_; }
+
   private:
     template <class Outer, class Inner, std::size_t... I>
     auto eval(Outer outer, Inner inner, Indices<I...>) const
@@ -225,6 +219,19 @@ namespace AMDiS
   };
 
 
+  /// \brief Creates a LocalFunction from the LocalFunctions of the GridFunctions. \relates FunctorLocalFunction
+  template <class F, class... GFs>
+  auto localFunction(FunctorGridFunction<F,GFs...> const& gf)
+  {
+    return Dune::Std::apply([&gf](auto const&... gridFcts)
+    {
+      using LocalFunction = typename FunctorGridFunction<F,GFs...>::LocalFunction;
+      return LocalFunction{gf.fct(), localFunction(gridFcts)...};
+    },
+    gf.gridFcts());
+  }
+
+
 #ifndef DOXYGEN
   // Generator function for FunctorGridFunction expressions
   template <class Functor, class... GridFcts>
-- 
GitLab