]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add MatrixFreeOperators::set_constrained_entries_to_one() and make clear() virtual
authorDenis Davydov <davydden@gmail.com>
Tue, 1 Nov 2016 15:28:00 +0000 (16:28 +0100)
committerDenis Davydov <davydden@gmail.com>
Tue, 1 Nov 2016 15:28:00 +0000 (16:28 +0100)
include/deal.II/matrix_free/operators.h

index f9287d5460d1ffb0289484cc4674dbb610356ba6..f621df09814c2b028b42fdcd508d61eaf9608079 100644 (file)
@@ -72,7 +72,7 @@ namespace MatrixFreeOperators
      * Release all memory and return to a state just like after having called
      * the default constructor.
      */
-    void clear();
+    virtual void clear();
 
     /**
      * Initialize operator on fine scale.
@@ -173,6 +173,12 @@ namespace MatrixFreeOperators
 
   protected:
 
+    /**
+     * Set constrained entries (both from hanging nodes and edge constraints)
+     * of @p dst to one.
+     */
+    void set_constrained_entries_to_one (LinearAlgebra::distributed::Vector<Number> &dst) const;
+
     /**
      * Apply operator to @p src and add result in @p dst.
      */
@@ -197,12 +203,13 @@ namespace MatrixFreeOperators
      */
     LinearAlgebra::distributed::Vector<Number> inverse_diagonal_entries;
 
+  private:
+
     /**
      * Indices of DoFs on edge in case the operator is used in GMG context.
      */
     std::vector<unsigned int> edge_constrained_indices;
 
-  private:
     /**
      * Auxiliary vector.
      */
@@ -557,6 +564,20 @@ namespace MatrixFreeOperators
 
 
 
+  template <int dim, typename Number>
+  void
+  Base<dim,Number>::set_constrained_entries_to_one (LinearAlgebra::distributed::Vector<Number> &dst) const
+  {
+    const std::vector<unsigned int> &
+    constrained_dofs = data->get_constrained_dofs();
+    for (unsigned int i=0; i<constrained_dofs.size(); ++i)
+      dst.local_element(constrained_dofs[i]) = 1.;
+    for (unsigned int i=0; i<edge_constrained_indices.size(); ++i)
+      dst.local_element(edge_constrained_indices[i]) = 1.;
+  }
+
+
+
   template <int dim, typename Number>
   void
   Base<dim,Number>::vmult (LinearAlgebra::distributed::Vector<Number>       &dst,

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.