From e8ec743ea692d4b4b6a63237cc121786dd7dc59b Mon Sep 17 00:00:00 2001 From: Joscha Gedicke Date: Sun, 6 Mar 2016 15:47:02 +0100 Subject: [PATCH] distribute_local_to_global for assembly of an inhomogeneous vector with two (possibly) different index sets for row and column of the local matrix. --- include/deal.II/lac/constraint_matrix.h | 8 +++++ .../deal.II/lac/constraint_matrix.templates.h | 32 +++++++++++++------ source/lac/constraint_matrix.cc | 13 +++++++- source/lac/constraint_matrix.inst.in | 6 ++++ 4 files changed, 48 insertions(+), 11 deletions(-) diff --git a/include/deal.II/lac/constraint_matrix.h b/include/deal.II/lac/constraint_matrix.h index e413a6b033..591e706675 100644 --- a/include/deal.II/lac/constraint_matrix.h +++ b/include/deal.II/lac/constraint_matrix.h @@ -740,6 +740,14 @@ public: VectorType &global_vector, const FullMatrix &local_matrix) const; + template + void + distribute_local_to_global (const Vector &local_vector, + const std::vector &local_dof_indices_row, + const std::vector &local_dof_indices_col, + VectorType &global_vector, + const FullMatrix &local_matrix) const; + /** * Enter a single value into a result vector, obeying constraints. */ diff --git a/include/deal.II/lac/constraint_matrix.templates.h b/include/deal.II/lac/constraint_matrix.templates.h index 543aa0a57b..2d00c80a9d 100644 --- a/include/deal.II/lac/constraint_matrix.templates.h +++ b/include/deal.II/lac/constraint_matrix.templates.h @@ -623,15 +623,27 @@ distribute_local_to_global (const Vector &local_vector, const std::vector &local_dof_indices, VectorType &global_vector, const FullMatrix &local_matrix) const +{ + distribute_local_to_global(local_vector,local_dof_indices,local_dof_indices, global_vector, local_matrix); +} + +template +void +ConstraintMatrix:: +distribute_local_to_global (const Vector &local_vector, + const std::vector &local_dof_indices_row, + const std::vector &local_dof_indices_col, + VectorType &global_vector, + const FullMatrix &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 &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 &local_vector, if (val != 0) for (size_type j=0; j &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 &indices template void ConstraintMatrix::condense(VectorType &vec) const;\ template void ConstraintMatrix:: \ distribute_local_to_global (const Vector &, \ + const std::vector &, \ + VectorType &, \ + const FullMatrix &) const;\ + template void ConstraintMatrix:: \ + distribute_local_to_global (const Vector &, \ + const std::vector &, \ const std::vector &, \ VectorType &, \ const FullMatrix &) const - #define PARALLEL_VECTOR_FUNCTIONS(VectorType) \ template void ConstraintMatrix:: \ distribute_local_to_global (const Vector &, \ + const std::vector &, \ + VectorType &, \ + const FullMatrix &) const;\ + template void ConstraintMatrix:: \ + distribute_local_to_global (const Vector &, \ + const std::vector &, \ const std::vector &, \ VectorType &, \ const FullMatrix &) const diff --git a/source/lac/constraint_matrix.inst.in b/source/lac/constraint_matrix.inst.in index 22a4f147f0..8e3e3486be 100644 --- a/source/lac/constraint_matrix.inst.in +++ b/source/lac/constraint_matrix.inst.in @@ -19,6 +19,8 @@ for (S: REAL_SCALARS; T : DEAL_II_VEC_TEMPLATES) template void ConstraintMatrix::condense >(T &vec) const; template void ConstraintMatrix::distribute_local_to_global > ( const Vector&, const std::vector &, T &, const FullMatrix&) const; + template void ConstraintMatrix::distribute_local_to_global > ( + const Vector&, const std::vector &, const std::vector &, T &, const FullMatrix&) const; template void ConstraintMatrix::set_zero >(T &) const; } @@ -29,6 +31,8 @@ for (S: REAL_SCALARS; T : DEAL_II_VEC_TEMPLATES) template void ConstraintMatrix::condense >(parallel::distributed::T &vec) const; template void ConstraintMatrix::distribute_local_to_global > ( const Vector&, const std::vector &, parallel::distributed::T &, const FullMatrix&) const; + template void ConstraintMatrix::distribute_local_to_global > ( + const Vector&, const std::vector &, const std::vector &, parallel::distributed::T &, const FullMatrix&) const; template void ConstraintMatrix::set_zero >(parallel::distributed::T &) const; } @@ -39,6 +43,8 @@ for (V: EXTERNAL_SEQUENTIAL_VECTORS) template void ConstraintMatrix::condense(V&vec) const; template void ConstraintMatrix::distribute_local_to_global ( const Vector&, const std::vector &, V&, const FullMatrix&) const; + template void ConstraintMatrix::distribute_local_to_global ( + const Vector&, const std::vector &, const std::vector &, V&, const FullMatrix&) const; template void ConstraintMatrix::set_zero(V&) const; } -- 2.39.5