]> https://gitweb.dealii.org/ - dealii.git/commitdiff
distribute_local_to_global for assembly of an inhomogeneous vector with two (possibly...
authorJoscha Gedicke <joscha.gedicke@iwr.uni-heidelberg.de>
Sun, 6 Mar 2016 14:47:02 +0000 (15:47 +0100)
committerJoscha Gedicke <joscha.gedicke@iwr.uni-heidelberg.de>
Sun, 6 Mar 2016 14:47:02 +0000 (15:47 +0100)
include/deal.II/lac/constraint_matrix.h
include/deal.II/lac/constraint_matrix.templates.h
source/lac/constraint_matrix.cc
source/lac/constraint_matrix.inst.in

index e413a6b033b5b102924f3a97aa1d20d164a3a7f9..591e7066759f4b2fb7ee6c0329560cb331ed79a0 100644 (file)
@@ -740,6 +740,14 @@ public:
                               VectorType                   &global_vector,
                               const FullMatrix<LocalType>  &local_matrix) const;
 
+  template <typename VectorType, typename LocalType>
+  void
+  distribute_local_to_global (const Vector<LocalType>      &local_vector,
+                              const std::vector<size_type> &local_dof_indices_row,
+                              const std::vector<size_type> &local_dof_indices_col,
+                              VectorType                   &global_vector,
+                              const FullMatrix<LocalType>  &local_matrix) const;
+
   /**
    * Enter a single value into a result vector, obeying constraints.
    */
index 543aa0a57bd4282d7425c1927ef3178bdde9e4d1..2d00c80a9dd06cb3d9b0c558eec3fd380f020625 100644 (file)
@@ -623,15 +623,27 @@ distribute_local_to_global (const Vector<LocalType>      &local_vector,
                             const std::vector<size_type> &local_dof_indices,
                             VectorType                   &global_vector,
                             const FullMatrix<LocalType>  &local_matrix) const
+{
+  distribute_local_to_global(local_vector,local_dof_indices,local_dof_indices, global_vector, local_matrix);
+}
+
+template <typename VectorType, typename LocalType>
+void
+ConstraintMatrix::
+distribute_local_to_global (const Vector<LocalType>      &local_vector,
+                            const std::vector<size_type> &local_dof_indices_row,
+                            const std::vector<size_type> &local_dof_indices_col,
+                            VectorType                   &global_vector,
+                            const FullMatrix<LocalType>  &local_matrix) const
 {
   Assert (sorted == true, ExcMatrixNotClosed());
-  AssertDimension (local_vector.size(), local_dof_indices.size());
-  AssertDimension (local_matrix.m(), local_dof_indices.size());
-  AssertDimension (local_matrix.n(), local_dof_indices.size());
+  AssertDimension (local_vector.size(), local_dof_indices_col.size());
+  AssertDimension (local_matrix.m(), local_dof_indices_row.size());
+  AssertDimension (local_matrix.n(), local_dof_indices_col.size());
 
   const size_type n_local_dofs = local_vector.size();
   if (lines.empty())
-    global_vector.add(local_dof_indices, local_vector);
+    global_vector.add(local_dof_indices_col, local_vector);
   else
     for (size_type i=0; i<n_local_dofs; ++i)
       {
@@ -639,15 +651,15 @@ distribute_local_to_global (const Vector<LocalType>      &local_vector,
         // constrained. if not, just write the entry
         // into the vector. otherwise, need to resolve
         // the constraint
-        if (is_constrained(local_dof_indices[i]) == false)
+        if (is_constrained(local_dof_indices_col[i]) == false)
           {
-            global_vector(local_dof_indices[i]) += local_vector(i);
+            global_vector(local_dof_indices_col[i]) += local_vector(i);
             continue;
           }
 
         // find the constraint line to the given
         // global dof index
-        const size_type line_index = calculate_line_index (local_dof_indices[i]);
+        const size_type line_index = calculate_line_index (local_dof_indices_col[i]);
         const ConstraintLine *position =
           lines_cache.size() <= line_index ? 0 : &lines[lines_cache[line_index]];
 
@@ -658,9 +670,9 @@ distribute_local_to_global (const Vector<LocalType>      &local_vector,
         if (val != 0)
           for (size_type j=0; j<n_local_dofs; ++j)
             {
-              if (is_constrained(local_dof_indices[j]) == false)
+              if (is_constrained(local_dof_indices_row[j]) == false)
                 {
-                  global_vector(local_dof_indices[j]) -= val * local_matrix(j,i);
+                  global_vector(local_dof_indices_row[j]) -= val * local_matrix(j,i);
                   continue;
                 }
 
@@ -670,7 +682,7 @@ distribute_local_to_global (const Vector<LocalType>      &local_vector,
                 continue;
 
               const ConstraintLine &position_j =
-                lines[lines_cache[calculate_line_index(local_dof_indices[j])]];
+                lines[lines_cache[calculate_line_index(local_dof_indices_row[j])]];
 
               for (size_type q=0; q<position_j.entries.size(); ++q)
                 {
index 8855c85d3c5ec8698b36e39ac5c2d409601509cb..45247f81924cc564eddda76f492fb4eae83de43a 100644 (file)
@@ -1223,14 +1223,25 @@ ConstraintMatrix::resolve_indices (std::vector<types::global_dof_index> &indices
   template void ConstraintMatrix::condense<VectorType >(VectorType &vec) const;\
   template void ConstraintMatrix:: \
   distribute_local_to_global<VectorType > (const Vector<VectorType::value_type>            &, \
+                                           const std::vector<ConstraintMatrix::size_type>  &, \
+                                           VectorType                      &, \
+                                           const FullMatrix<VectorType::value_type>        &) const;\
+  template void ConstraintMatrix:: \
+  distribute_local_to_global<VectorType > (const Vector<VectorType::value_type>            &, \
+                                           const std::vector<ConstraintMatrix::size_type>  &, \
                                            const std::vector<ConstraintMatrix::size_type>  &, \
                                            VectorType                      &, \
                                            const FullMatrix<VectorType::value_type>        &) const
 
-
 #define PARALLEL_VECTOR_FUNCTIONS(VectorType) \
   template void ConstraintMatrix:: \
   distribute_local_to_global<VectorType > (const Vector<VectorType::value_type>            &, \
+                                           const std::vector<ConstraintMatrix::size_type>  &, \
+                                           VectorType                      &, \
+                                           const FullMatrix<VectorType::value_type>        &) const;\
+  template void ConstraintMatrix:: \
+  distribute_local_to_global<VectorType > (const Vector<VectorType::value_type>            &, \
+                                           const std::vector<ConstraintMatrix::size_type>  &, \
                                            const std::vector<ConstraintMatrix::size_type>  &, \
                                            VectorType                      &, \
                                            const FullMatrix<VectorType::value_type>        &) const
index 22a4f147f0185b611774453aa13f5f569343c9d3..8e3e3486be2dfeeca2243d106ca0b15ad4dcb2e0 100644 (file)
@@ -19,6 +19,8 @@ for (S: REAL_SCALARS; T : DEAL_II_VEC_TEMPLATES)
     template void ConstraintMatrix::condense<T<S> >(T<S> &vec) const;
     template void ConstraintMatrix::distribute_local_to_global<T<S> > (
       const Vector<S>&, const std::vector<types::global_dof_index> &, T<S> &, const FullMatrix<S>&) const;  
+    template void ConstraintMatrix::distribute_local_to_global<T<S> > (
+      const Vector<S>&, const std::vector<types::global_dof_index> &, const std::vector<types::global_dof_index> &, T<S> &, const FullMatrix<S>&) const;
     template void ConstraintMatrix::set_zero<T<S> >(T<S> &) const;
   }
 
@@ -29,6 +31,8 @@ for (S: REAL_SCALARS; T : DEAL_II_VEC_TEMPLATES)
     template void ConstraintMatrix::condense<parallel::distributed::T<S> >(parallel::distributed::T<S> &vec) const;
     template void ConstraintMatrix::distribute_local_to_global<parallel::distributed::T<S> > (
       const Vector<S>&, const std::vector<types::global_dof_index> &, parallel::distributed::T<S> &, const FullMatrix<S>&) const;
+    template void ConstraintMatrix::distribute_local_to_global<parallel::distributed::T<S> > (
+      const Vector<S>&, const std::vector<types::global_dof_index> &, const std::vector<types::global_dof_index> &, parallel::distributed::T<S> &, const FullMatrix<S>&) const;
     template void ConstraintMatrix::set_zero<parallel::distributed::T<S> >(parallel::distributed::T<S> &) const;
   }
 
@@ -39,6 +43,8 @@ for (V: EXTERNAL_SEQUENTIAL_VECTORS)
     template void ConstraintMatrix::condense<V >(V&vec) const;
     template void ConstraintMatrix::distribute_local_to_global<V > (
       const Vector<V::value_type>&, const std::vector<types::global_dof_index> &, V&, const FullMatrix<V::value_type>&) const;
+    template void ConstraintMatrix::distribute_local_to_global<V > (
+      const Vector<V::value_type>&, const std::vector<types::global_dof_index> &, const std::vector<types::global_dof_index> &, V&, const FullMatrix<V::value_type>&) const;
     template void ConstraintMatrix::set_zero<V >(V&) const;
   }
 

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.