]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add additional access method to the underlying shared ptr
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 13 Jan 2017 17:47:02 +0000 (18:47 +0100)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 13 Jan 2017 20:14:54 +0000 (21:14 +0100)
include/deal.II/matrix_free/operators.h

index 81eb0e137cf71c5aec293ef94a6f5db33d57b0e8..4e4d63e15cf1418b7f89ba718f5ab0b5e7eb90ed 100644 (file)
@@ -159,6 +159,12 @@ namespace MatrixFreeOperators
      */
     virtual void compute_diagonal () = 0;
 
+    /**
+     * Get read access to the MatrixFree object stored with this operator.
+     */
+    std_cxx11::shared_ptr<const MatrixFree<dim,Number> >
+    get_matrix_free () const;
+
     /**
      * Get read access to the inverse diagonal of this operator.
      */
@@ -690,7 +696,6 @@ namespace MatrixFreeOperators
   Base<dim,Number>::Base ()
     :
     Subscriptor(),
-    data(NULL),
     have_interface_matrices(false)
   {
   }
@@ -701,7 +706,7 @@ namespace MatrixFreeOperators
   typename Base<dim,Number>::size_type
   Base<dim,Number>::m () const
   {
-    Assert(data != NULL,
+    Assert(data.get() != NULL,
            ExcNotInitialized());
     return data->get_vector_partitioner()->size();
   }
@@ -721,7 +726,7 @@ namespace MatrixFreeOperators
   void
   Base<dim,Number>::clear ()
   {
-    data = NULL;
+    data.reset();
     inverse_diagonal_entries.reset();
   }
 
@@ -745,7 +750,7 @@ namespace MatrixFreeOperators
   void
   Base<dim,Number>::initialize_dof_vector (LinearAlgebra::distributed::Vector<Number> &vec) const
   {
-    Assert(data != NULL,
+    Assert(data.get() != NULL,
            ExcNotInitialized());
     if (!vec.partitioners_are_compatible(*data->get_dof_info(0).vector_partitioner))
       data->initialize_dof_vector(vec);
@@ -1010,6 +1015,15 @@ namespace MatrixFreeOperators
 
 
 
+  template <int dim, typename Number>
+  std_cxx11::shared_ptr<const MatrixFree<dim,Number> >
+  Base<dim,Number>::get_matrix_free() const
+  {
+    return data;
+  }
+
+
+
   template <int dim, typename Number>
   const std_cxx11::shared_ptr<DiagonalMatrix<LinearAlgebra::distributed::Vector<Number> > > &
   Base<dim,Number>::get_matrix_diagonal_inverse() const
@@ -1117,7 +1131,7 @@ namespace MatrixFreeOperators
   MassOperator<dim, fe_degree, n_q_points_1d, n_components, Number>::
   compute_diagonal()
   {
-    Assert((Base<dim, Number>::data != NULL), ExcNotInitialized());
+    Assert((Base<dim, Number>::data.get() != NULL), ExcNotInitialized());
 
     this->inverse_diagonal_entries.
     reset(new DiagonalMatrix<LinearAlgebra::distributed::Vector<Number> >());
@@ -1224,7 +1238,7 @@ namespace MatrixFreeOperators
   LaplaceOperator<dim, fe_degree, n_q_points_1d, n_components, Number>::
   compute_diagonal()
   {
-    Assert((Base<dim, Number>::data != NULL), ExcNotInitialized());
+    Assert((Base<dim, Number>::data.get() != NULL), ExcNotInitialized());
 
     unsigned int dummy = 0;
     this->inverse_diagonal_entries.

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.