]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Patch by Daniel Arndt: add is_local_range() to all vector classes. Use it in the...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 14 Jan 2013 14:10:11 +0000 (14:10 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 14 Jan 2013 14:10:11 +0000 (14:10 +0000)
git-svn-id: https://svn.dealii.org/trunk@28047 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/lac/block_vector_base.h
deal.II/include/deal.II/lac/constraint_matrix.templates.h
deal.II/include/deal.II/lac/vector.h

index 635f13388b7db6ddd106c0d9a6353a404d092a26..e3c0fcd829fe3d0fb1d89a05f1aa62f6089aea23 100644 (file)
@@ -177,6 +177,11 @@ DoFHandler, in particular removal of specializations.
 <h3>Specific improvements</h3>
 
 <ol>
+<li> New: All vector classes should now have a in_local_range()
+function indicating whether a given index is locally stored or not.
+<br>
+(Daniel Arndt, 2013/01/14)
+
 <li> Fixed: The one-argument version of ConstraintMatrix::condense was
 not prepared to deal with parallel vectors. This is now fixed.
 <br>
index a36f8daf8c4a9e98ff1595787c56e4066eb20cc5..2de013528804daacd235193da464c08935da253f 100644 (file)
@@ -957,6 +957,13 @@ public:
    */
   real_type linfty_norm () const;
 
+  /**
+   * Returns true if the given global index is
+   * in the local range of this processor.
+   * Asks the corresponding block.
+   */
+  bool in_local_range (const types::global_dof_index global_index) const;
+
   /**
    * Return whether the vector contains only
    * elements with value zero. This function
@@ -1866,6 +1873,18 @@ BlockVectorBase<VectorType>::end() const
 }
 
 
+template <class VectorType>
+inline
+bool
+BlockVectorBase<VectorType>::in_local_range
+(const types::global_dof_index global_index) const
+{
+  const std::pair<unsigned int,unsigned int> local_index
+  = block_indices.global_to_local (global_index);
+  
+  return components[local_index.first].in_local_range (global_index);
+}
+
 
 template <class VectorType>
 bool
index 587e4fc30b31d2c4eb7b57a6beb18803ceffe734..aea9d0c6c0b39c376e98b900aedb3f42ad04fa4f 100644 (file)
@@ -160,10 +160,11 @@ ConstraintMatrix::condense (VectorType &vec) const
 
       const typename VectorType::value_type old_value = vec(constraint_line->line);
       for (unsigned int q=0; q!=constraint_line->entries.size(); ++q)
-        vec(constraint_line->entries[q].first)
-        += (static_cast<typename VectorType::value_type>
-            (old_value) *
-            constraint_line->entries[q].second);
+        if (vec.in_local_range(constraint_line->entries[q].first) == true) 
+          vec(constraint_line->entries[q].first)
+          += (static_cast<typename VectorType::value_type>
+              (old_value) *
+              constraint_line->entries[q].second);
     }
 
   vec.compress();
@@ -171,7 +172,8 @@ ConstraintMatrix::condense (VectorType &vec) const
   for (std::vector<ConstraintLine>::const_iterator
         constraint_line = lines.begin();
        constraint_line!=lines.end(); ++constraint_line)
-    vec(constraint_line->line) = 0.;
+    if (vec.in_local_range(constraint_line->line) == true) 
+      vec(constraint_line->line) = 0.;
 }
 
 
@@ -2875,3 +2877,4 @@ add_entries_local_to_global (const std::vector<unsigned int> &local_dof_indices,
 DEAL_II_NAMESPACE_CLOSE
 
 #endif
+
index ca8980b1240e8a49f4c3e19b64ae2ad6118bd683..97058d77887419478cfa5086a018bff4535ba965 100644 (file)
@@ -579,6 +579,14 @@ public:
    */
   real_type linfty_norm () const;
 
+  /**
+   * Returns true if the given global index is
+   * in the local range of this processor.
+   * Since this is not a distributed
+   * vector the method always returns true.
+   */
+  bool in_local_range (const types::global_dof_index global_index) const;
+
   /**
    * Return dimension of the vector.
    */
@@ -1189,6 +1197,15 @@ unsigned int Vector<Number>::size () const
 }
 
 
+template <typename Number>
+inline
+bool Vector<Number>::in_local_range
+(const types::global_dof_index global_index) const
+{
+  return true;
+}
+
+
 
 template <typename Number>
 inline

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.