]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Bugfix: Add overload for linear_operator that takes a LinearOperator exemplar
authorMatthias Maier <tamiko@43-1.org>
Fri, 14 Jul 2017 21:56:51 +0000 (16:56 -0500)
committerMatthias Maier <tamiko@43-1.org>
Sun, 16 Jul 2017 16:54:13 +0000 (11:54 -0500)
This allows to copy the reinit functions from a LinearOperator directly.

include/deal.II/lac/linear_operator.h

index 22d37c2fbc9e0ac9470d4d1af05bac894cb51b20..7f00ad0020fcb5d3f3d9c504a422694b0e976b8a 100644 (file)
@@ -1291,6 +1291,45 @@ linear_operator(const OperatorExemplar &operator_exemplar, const Matrix &matrix)
 }
 
 
+
+/**
+ * @relates LinearOperator
+ *
+ * Variant of above function that takes a LinearOperator @p
+ * operator_exemplar as an additional reference.
+ * The reinit_domain_vector and reinit_range_vector function are copied
+ * from the @p operator_exemplar object.
+ *
+ * The reference @p matrix is used to construct vmult, Tvmult, etc.
+ *
+ * This variant can, for example, be used to encapsulate preconditioners (that
+ * typically do not expose any information about the underlying matrix).
+ *
+ * @author Matthias Maier, 2017
+ *
+ * @ingroup LAOperators
+ */
+template <typename Range,
+          typename Domain,
+          typename Payload,
+          typename Matrix>
+LinearOperator<Range, Domain, Payload>
+linear_operator(const LinearOperator<Range, Domain, Payload> &operator_exemplar,
+                const Matrix &matrix)
+{
+  // Initialise the payload based on the LinearOperator exemplar
+  auto return_op = operator_exemplar;
+
+  typename std::conditional<
+  has_vmult_add_and_Tvmult_add<Range, Domain, Matrix>::type::value,
+                               MatrixInterfaceWithVmultAdd<Range, Domain, Payload>,
+                               MatrixInterfaceWithoutVmultAdd<Range, Domain, Payload>>::type().
+                               operator()(return_op, matrix);
+
+  return return_op;
+}
+
+
 //@}
 
 

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.