]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Clean up the declaration of make_nvector_view(). 13741/head
authorDavid Wells <drwells@email.unc.edu>
Mon, 16 May 2022 02:44:45 +0000 (22:44 -0400)
committerDavid Wells <drwells@email.unc.edu>
Tue, 17 May 2022 13:01:02 +0000 (09:01 -0400)
include/deal.II/sundials/n_vector.h
include/deal.II/sundials/n_vector.templates.h

index 2fb2b03ff963ebb48591674431f9efd00218a128..def025dd2229879c38555f958623720d7d9a3dbc 100644 (file)
@@ -41,6 +41,7 @@ namespace SUNDIALS
 {
   namespace internal
   {
+#  if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
     /**
      * Create a NVectorView of the given @p vector.
      *
@@ -56,22 +57,48 @@ namespace SUNDIALS
      * @tparam VectorType Type of the viewed vector. This parameter can be
      *   deduced automatically and will respect a potential const-qualifier.
      * @param vector The vector to view.
-#  if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
      * @param nvector_context A SUNDIALS context object to be used for the
      *   operations we want to do on this vector.
-#  endif
      * @return A NVectorView of the @p vector.
      *
      * @related NVectorView
+     *
+     * @note Versions of this function prior to SUNDIALS 6.0 did not take a
+     * SUNContext argument.
      */
     template <typename VectorType>
     NVectorView<VectorType>
-    make_nvector_view(VectorType &vector
-#  if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
-                      ,
-                      SUNContext nvector_context
+    make_nvector_view(VectorType &vector, SUNContext nvector_context);
+#  else
+    /**
+     * Create a NVectorView of the given @p vector.
+     *
+     * This call is intended to be used as
+     *
+     * @code
+     *   auto view = make_nvector_view(vector);
+     * @endcode
+     *
+     * The resulting object `view` must be kept around as long as any other
+     * object will use the internally viewed N_Vector.
+     *
+     * @tparam VectorType Type of the viewed vector. This parameter can be
+     *   deduced automatically and will respect a potential const-qualifier.
+     * @param vector The vector to view.
+     * @param nvector_context A SUNDIALS context object to be used for the
+     *   operations we want to do on this vector.
+     * @return A NVectorView of the @p vector.
+     *
+     * @related NVectorView
+     *
+     * @note This version of make_nvector_view() is only for versions of
+     * SUNDIALS prior to 6.0 which did not need a SUNContext object to set up a
+     * vector.
+     */
+    template <typename VectorType>
+    NVectorView<VectorType>
+    make_nvector_view(VectorType &vector);
 #  endif
-    );
 
     /**
      * Retrieve the underlying vector attached to N_Vector @p v. This call will
@@ -135,15 +162,23 @@ namespace SUNDIALS
        */
       NVectorView() = default;
 
+#  if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
       /**
        * Constructor. Create view of @p vector.
+       *
+       * @note Versions of this function prior to SUNDIALS 6.0 did not take a
+       * SUNContext argument.
        */
-      NVectorView(VectorType &vector
-#  if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
-                  ,
-                  SUNContext nvector_context
+      NVectorView(VectorType &vector, SUNContext nvector_context);
+#  else
+      /**
+       * Constructor. Create view of @p vector.
+       *
+       * @note This constructor is only for versions of SUNDIALS prior to 6.0
+       * which do not need a SUNContext object to set up a vector.
+       */
+      NVectorView(VectorType &vector);
 #  endif
-      );
 
       /**
        * Move assignment.
index 0aec4c04708dd850c751644fd16e55a7dccd21c2..129d2db920dd2affc9f6aafca997b858f649888a 100644 (file)
@@ -363,22 +363,21 @@ namespace SUNDIALS
 
 
 
+#  if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
     template <typename VectorType>
     NVectorView<VectorType>
-    make_nvector_view(VectorType &vector
-#  if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
-                      ,
-                      SUNContext nvector_context
-#  endif
-    )
+    make_nvector_view(VectorType &vector, SUNContext nvector_context)
     {
-      return NVectorView<VectorType>(vector
-#  if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
-                                     ,
-                                     nvector_context
-#  endif
-      );
+      return NVectorView<VectorType>(vector, nvector_context);
     }
+#  else
+    template <typename VectorType>
+    NVectorView<VectorType>
+    make_nvector_view(VectorType &vector)
+    {
+      return NVectorView<VectorType>(vector);
+    }
+#  endif
 
 
 

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.