]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Partial merge from the parallel_mg branch: Introduce a distribute_local_to_global...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 5 Nov 2012 00:56:21 +0000 (00:56 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 5 Nov 2012 00:56:21 +0000 (00:56 +0000)
git-svn-id: https://svn.dealii.org/trunk@27381 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/constraint_matrix.h

index a79738f20e351ab81372272b1df5c9b5a941e334..6baf697998d2fd45dfa2773996c4bee1c6528fad 100644 (file)
@@ -1055,7 +1055,16 @@ class ConstraintMatrix : public Subscriptor
                                 VectorType                      &global_vector,
                                 const FullMatrix<double>        &local_matrix) const;
 
-
+                                    /**
+                                     * Enter a single value into a
+                                     * result vector, obeying constraints.
+                                     */
+    template <class VectorType>
+    void
+    distribute_local_to_global (unsigned int index,
+                               double value,
+                               VectorType        &global_vector) const;
+   
                                      /**
                                       * This function takes a pointer to a
                                       * vector of local contributions (@p
@@ -1983,30 +1992,36 @@ ConstraintMatrix::can_store_line (unsigned int line_index) const
 
 
 
-template <class InVector, class OutVector>
+template <class VectorType>
 inline
-void
-ConstraintMatrix::
-distribute_local_to_global (const InVector                  &local_vector,
-                            const std::vector<unsigned int> &local_dof_indices,
-                            OutVector                       &global_vector) const
+void ConstraintMatrix::distribute_local_to_global (
+  unsigned int index,
+  double value,
+  VectorType        &global_vector) const
 {
-  Assert (local_vector.size() == local_dof_indices.size(),
-          ExcDimensionMismatch(local_vector.size(), local_dof_indices.size()));
-  distribute_local_to_global (local_vector.begin(), local_vector.end(),
-                              local_dof_indices.begin(), global_vector);
+  Assert (sorted == true, ExcMatrixNotClosed());
+  
+  if (is_constrained(index) == false)
+    global_vector(index) += value;
+  else
+    {
+      const ConstraintLine& position =
+       lines[lines_cache[calculate_line_index(index)]];
+      for (unsigned int j=0; j<position.entries.size(); ++j)
+       global_vector(position.entries[j].first)
+         += value * position.entries[j].second;
+    }
 }
 
 
-
 template <typename ForwardIteratorVec, typename ForwardIteratorInd,
           class VectorType>
 inline
-void ConstraintMatrix::
-  distribute_local_to_global (ForwardIteratorVec local_vector_begin,
-                              ForwardIteratorVec local_vector_end,
-                              ForwardIteratorInd local_indices_begin,
-                              VectorType        &global_vector) const
+void ConstraintMatrix::distribute_local_to_global (
+  ForwardIteratorVec local_vector_begin,
+  ForwardIteratorVec local_vector_end,
+  ForwardIteratorInd local_indices_begin,
+  VectorType        &global_vector) const
 {
   Assert (sorted == true, ExcMatrixNotClosed());
   for ( ; local_vector_begin != local_vector_end;
@@ -2026,6 +2041,21 @@ void ConstraintMatrix::
 }
 
 
+template <class InVector, class OutVector>
+inline
+void
+ConstraintMatrix::distribute_local_to_global (
+  const InVector                  &local_vector,
+  const std::vector<unsigned int> &local_dof_indices,
+  OutVector                       &global_vector) const
+{
+  Assert (local_vector.size() == local_dof_indices.size(),
+          ExcDimensionMismatch(local_vector.size(), local_dof_indices.size()));
+  distribute_local_to_global (local_vector.begin(), local_vector.end(),
+                              local_dof_indices.begin(), global_vector);
+}
+
+
 
 template <typename ForwardIteratorVec, typename ForwardIteratorInd,
           class VectorType>

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.