From 5c2516145d9e2aab2b0b68aad338c5ae62d7ffc3 Mon Sep 17 00:00:00 2001
From: Simon Praetorius <simon.praetorius@tu-dresden.de>
Date: Wed, 17 Apr 2024 23:26:33 +0200
Subject: [PATCH] Replace BlockTraits by FieldTraits

---
 dune/istl/bcrsmatrix.hh   |  2 +-
 dune/istl/bdmatrix.hh     |  3 ++-
 dune/istl/btdmatrix.hh    |  3 ++-
 dune/istl/bvector.hh      | 37 +++++++++----------------------------
 dune/istl/matrix.hh       |  4 ++--
 dune/istl/matrixmarket.hh |  5 +++--
 dune/istl/vbvector.hh     |  2 +-
 7 files changed, 20 insertions(+), 36 deletions(-)

diff --git a/dune/istl/bcrsmatrix.hh b/dune/istl/bcrsmatrix.hh
index 3806a813b..7cecddb39 100644
--- a/dune/istl/bcrsmatrix.hh
+++ b/dune/istl/bcrsmatrix.hh
@@ -485,7 +485,7 @@ namespace Dune {
     //===== type definitions and constants
 
     //! export the type representing the field
-    using field_type = typename Imp::BlockTraits<B>::field_type;
+    using field_type = typename FieldTraits<B>::field_type;
 
     //! export the type representing the components
     typedef B block_type;
diff --git a/dune/istl/bdmatrix.hh b/dune/istl/bdmatrix.hh
index 19ed0f36c..ce268ddb3 100644
--- a/dune/istl/bdmatrix.hh
+++ b/dune/istl/bdmatrix.hh
@@ -7,6 +7,7 @@
 
 #include <memory>
 
+#include <dune/common/ftraits.hh>
 #include <dune/common/rangeutilities.hh>
 #include <dune/common/scalarmatrixview.hh>
 
@@ -36,7 +37,7 @@ namespace Dune {
     //===== type definitions and constants
 
     //! export the type representing the field
-    using field_type = typename Imp::BlockTraits<B>::field_type;
+    using field_type = typename FieldTraits<B>::field_type;
 
     //! export the type representing the components
     typedef B block_type;
diff --git a/dune/istl/btdmatrix.hh b/dune/istl/btdmatrix.hh
index 2bd2a6ea1..f4dc981a8 100644
--- a/dune/istl/btdmatrix.hh
+++ b/dune/istl/btdmatrix.hh
@@ -6,6 +6,7 @@
 #define DUNE_ISTL_BTDMATRIX_HH
 
 #include <dune/common/fmatrix.hh>
+#include <dune/common/ftraits.hh>
 #include <dune/common/scalarvectorview.hh>
 #include <dune/common/scalarmatrixview.hh>
 #include <dune/istl/bcrsmatrix.hh>
@@ -34,7 +35,7 @@ namespace Dune {
     //===== type definitions and constants
 
     //! export the type representing the field
-    using field_type = typename Imp::BlockTraits<B>::field_type;
+    using field_type = typename FieldTraits<B>::field_type;
 
     //! export the type representing the components
     typedef B block_type;
diff --git a/dune/istl/bvector.hh b/dune/istl/bvector.hh
index 7b5a951e4..6aa358273 100644
--- a/dune/istl/bvector.hh
+++ b/dune/istl/bvector.hh
@@ -40,30 +40,11 @@ namespace Dune {
 /** \brief Everything in this namespace is internal to dune-istl, and may change without warning */
 namespace Imp {
 
-  /** \brief Define some derived types transparently for number types and dune-istl vector types
-   *
-   * This is the actual implementation.  Calling code should use BlockTraits instead.
-   * \tparam isNumber Whether B is a number type (true) or a dune-istl matrix or vector type (false)
-   */
-  template <class B, bool isNumber>
-  class BlockTraitsImp;
-
-  template <class B>
-  class BlockTraitsImp<B,true>
-  {
-  public:
-    using field_type = B;
-  };
-
-  template <class B>
-  class BlockTraitsImp<B,false>
-    : public Dune::FieldTraits<B>
-  {};
-
   /** \brief Define some derived types transparently for number types and dune-istl matrix/vector types
+   * \deprecated
    */
   template <class B>
-  using BlockTraits = BlockTraitsImp<B,IsNumber<B>::value>;
+  using BlockTraits [[deprecated("Use FieldTraits instead.")]] = FieldTraits<B>;
 
   /**
       \brief An unmanaged vector of blocks.
@@ -84,7 +65,7 @@ namespace Imp {
   public:
 
     //===== type definitions and constants
-    using field_type = typename Imp::BlockTraits<B>::field_type;
+    using field_type = typename FieldTraits<B>::field_type;
 
     //! export the type representing the components
     typedef B block_type;
@@ -175,7 +156,7 @@ namespace Imp {
     template<class OtherB, class OtherST>
     auto operator* (const block_vector_unmanaged<OtherB,OtherST>& y) const
     {
-      typedef typename PromotionTraits<field_type,typename BlockTraits<OtherB>::field_type>::PromotedType PromotedType;
+      typedef typename PromotionTraits<field_type,typename FieldTraits<OtherB>::field_type>::PromotedType PromotedType;
       PromotedType sum(0);
 #ifdef DUNE_ISTL_WITH_CHECKING
       if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
@@ -196,7 +177,7 @@ namespace Imp {
     template<class OtherB, class OtherST>
     auto dot(const block_vector_unmanaged<OtherB,OtherST>& y) const
     {
-      typedef typename PromotionTraits<field_type,typename BlockTraits<OtherB>::field_type>::PromotedType PromotedType;
+      typedef typename PromotionTraits<field_type,typename FieldTraits<OtherB>::field_type>::PromotedType PromotedType;
       PromotedType sum(0);
 #ifdef DUNE_ISTL_WITH_CHECKING
       if (this->n!=y.N()) DUNE_THROW(ISTLError,"vector size mismatch");
@@ -393,7 +374,7 @@ namespace Imp {
     //===== type definitions and constants
 
     //! export the type representing the field
-    using field_type = typename Imp::BlockTraits<B>::field_type;
+    using field_type = typename FieldTraits<B>::field_type;
 
     //! export the type representing the components
     typedef B block_type;
@@ -621,7 +602,7 @@ namespace Imp {
     //===== type definitions and constants
 
     //! export the type representing the field
-    using field_type = typename Imp::BlockTraits<B>::field_type;
+    using field_type = typename FieldTraits<B>::field_type;
 
     //! export the type representing the components
     typedef B block_type;
@@ -744,7 +725,7 @@ namespace Imp {
     //===== type definitions and constants
 
     //! export the type representing the field
-    using field_type = typename Imp::BlockTraits<B>::field_type;
+    using field_type = typename FieldTraits<B>::field_type;
 
     //! export the type representing the components
     typedef B block_type;
@@ -995,7 +976,7 @@ namespace Imp {
     //===== type definitions and constants
 
     //! export the type representing the field
-    using field_type = typename Imp::BlockTraits<B>::field_type;
+    using field_type = typename FieldTraits<B>::field_type;
 
     //! export the type representing the components
     typedef B block_type;
diff --git a/dune/istl/matrix.hh b/dune/istl/matrix.hh
index 2aff17648..dc86fb100 100644
--- a/dune/istl/matrix.hh
+++ b/dune/istl/matrix.hh
@@ -47,7 +47,7 @@ namespace MatrixImp
     //===== type definitions and constants
 
     //! export the type representing the field
-    using field_type = typename Imp::BlockTraits<B>::field_type;
+    using field_type = typename FieldTraits<B>::field_type;
 
     //! export the allocator type
     typedef A allocator_type;
@@ -562,7 +562,7 @@ namespace MatrixImp
   public:
 
     /** \brief Export the type representing the underlying field */
-    using field_type = typename Imp::BlockTraits<T>::field_type;
+    using field_type = typename FieldTraits<T>::field_type;
 
     /** \brief Export the type representing the components */
     typedef T block_type;
diff --git a/dune/istl/matrixmarket.hh b/dune/istl/matrixmarket.hh
index 5c2d78255..05289d58c 100644
--- a/dune/istl/matrixmarket.hh
+++ b/dune/istl/matrixmarket.hh
@@ -23,6 +23,7 @@
 
 #include <dune/common/exceptions.hh>
 #include <dune/common/fmatrix.hh>
+#include <dune/common/ftraits.hh>
 #include <dune/common/fvector.hh>
 #include <dune/common/hybridutilities.hh>
 #include <dune/common/stdstreams.hh>
@@ -179,7 +180,7 @@ namespace Dune
       static void print(std::ostream& os)
       {
         os<<"%%MatrixMarket matrix coordinate ";
-        os<<mm_numeric_type<Simd::Scalar<typename Imp::BlockTraits<T>::field_type>>::str()<<" general"<<std::endl;
+        os<<mm_numeric_type<Simd::Scalar<typename FieldTraits<T>::field_type>>::str()<<" general"<<std::endl;
       }
     };
 
@@ -189,7 +190,7 @@ namespace Dune
       static void print(std::ostream& os)
       {
         os<<"%%MatrixMarket matrix array ";
-        os<<mm_numeric_type<Simd::Scalar<typename Imp::BlockTraits<B>::field_type>>::str()<<" general"<<std::endl;
+        os<<mm_numeric_type<Simd::Scalar<typename FieldTraits<B>::field_type>>::str()<<" general"<<std::endl;
       }
     };
 
diff --git a/dune/istl/vbvector.hh b/dune/istl/vbvector.hh
index 681df8c85..89dd0962e 100644
--- a/dune/istl/vbvector.hh
+++ b/dune/istl/vbvector.hh
@@ -53,7 +53,7 @@ namespace Dune {
     //===== type definitions and constants
 
     //! export the type representing the field
-    using field_type = typename Imp::BlockTraits<B>::field_type;
+    using field_type = typename FieldTraits<B>::field_type;
 
     //! export the allocator type
     typedef A allocator_type;
-- 
GitLab