From: Denis Davydov Date: Sun, 28 Feb 2016 10:32:58 +0000 (+0100) Subject: adjust functions in ConstraintMatrix to compile with complex algebra X-Git-Tag: v8.5.0-rc1~1276^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e72547d646cc31a8ac7cc22a8a7fcf561b8e8944;p=dealii.git adjust functions in ConstraintMatrix to compile with complex algebra modified condense(), set_matrix_digonals() and resolve_vector_entry() by swapping the order of multiplications. Instantiate distribute_local_to_global() and condense() for complex algebra. --- diff --git a/include/deal.II/lac/constraint_matrix.templates.h b/include/deal.II/lac/constraint_matrix.templates.h index a62c129803..543aa0a57b 100644 --- a/include/deal.II/lac/constraint_matrix.templates.h +++ b/include/deal.II/lac/constraint_matrix.templates.h @@ -136,7 +136,7 @@ ConstraintMatrix::condense (SparseMatrix &uncondensed, double average_diagonal = 0; for (size_type i=0; i &uncondensed, { for (size_type q=0; q!=lines[distribute[column]].entries.size(); ++q) - uncondensed.add (row, - lines[distribute[column]].entries[q].first, - entry->value() * - lines[distribute[column]].entries[q].second); + { + // need a temporary variable to avoid errors like + // no known conversion from 'complex::type>' to 'const complex' for 3rd argument + number v = static_cast(entry->value()); + v *=lines[distribute[column]].entries[q].second; + uncondensed.add (row, + lines[distribute[column]].entries[q].first, + v); + } // need to subtract this element from the // vector. this corresponds to an @@ -193,7 +198,7 @@ ConstraintMatrix::condense (SparseMatrix &uncondensed, // the matrix with Gauss elimination if (use_vectors == true) vec(row) -= - entry->value() * lines[distribute[column]].inhomogeneity; + static_cast(entry->value()) * lines[distribute[column]].inhomogeneity; // set old value to zero entry->value() = 0.; @@ -227,10 +232,15 @@ ConstraintMatrix::condense (SparseMatrix &uncondensed, { for (size_type q=0; q!=lines[distribute[row]].entries.size(); ++q) - uncondensed.add (lines[distribute[row]].entries[q].first, - column, - entry->value() * - lines[distribute[row]].entries[q].second); + { + // need a temporary variable to avoid errors like + // no known conversion from 'complex::type>' to 'const complex' for 3rd argument + number v = static_cast(entry->value()); + v *= lines[distribute[row]].entries[q].second; + uncondensed.add (lines[distribute[row]].entries[q].first, + column, + v); + } // set old entry to zero entry->value() = 0.; @@ -247,15 +257,20 @@ ConstraintMatrix::condense (SparseMatrix &uncondensed, { for (size_type q=0; q!=lines[distribute[column]].entries.size(); ++q) - uncondensed.add (lines[distribute[row]].entries[p].first, - lines[distribute[column]].entries[q].first, - entry->value() * - lines[distribute[row]].entries[p].second * - lines[distribute[column]].entries[q].second); + { + // need a temporary variable to avoid errors like + // no known conversion from 'complex::type>' to 'const complex' for 3rd argument + number v = static_cast(entry->value()); + v *= lines[distribute[row]].entries[p].second * + lines[distribute[column]].entries[q].second; + uncondensed.add (lines[distribute[row]].entries[p].first, + lines[distribute[column]].entries[q].first, + v); + } if (use_vectors == true) vec(lines[distribute[row]].entries[p].first) -= - entry->value() * lines[distribute[row]].entries[p].second * + static_cast(entry->value()) * lines[distribute[row]].entries[p].second * lines[distribute[column]].inhomogeneity; } @@ -1945,7 +1960,7 @@ add_this_index: // of fill in a zero in the ith components with an inhomogeneity, // we set those to: inhomogeneity(i)*global_matrix (i,i). if (use_inhomogeneities_for_rhs == true) - global_vector(global_row) += constraints.get_inhomogeneity(global_row) * new_diagonal; + global_vector(global_row) += new_diagonal * constraints.get_inhomogeneity(global_row); } } } @@ -2142,10 +2157,10 @@ resolve_vector_entry (const size_type i, { val = local_vector(loc_row); for (size_type i=0; i); MATRIX_FUNCTIONS(FullMatrix); MATRIX_FUNCTIONS(FullMatrix); MATRIX_FUNCTIONS(FullMatrix >); +MATRIX_FUNCTIONS(SparseMatrix >); +MATRIX_FUNCTIONS(SparseMatrix >); +MATRIX_FUNCTIONS(SparseMatrix >); BLOCK_MATRIX_FUNCTIONS(BlockSparseMatrix); BLOCK_MATRIX_FUNCTIONS(BlockSparseMatrix); diff --git a/source/lac/constraint_matrix.inst.in b/source/lac/constraint_matrix.inst.in index 4859a11632..6aaf41fcef 100644 --- a/source/lac/constraint_matrix.inst.in +++ b/source/lac/constraint_matrix.inst.in @@ -61,6 +61,11 @@ for (S1 : REAL_SCALARS; S2 : REAL_SCALARS) template void ConstraintMatrix::condense >(SparseMatrix&, Vector&) const; template void ConstraintMatrix::condense >(BlockSparseMatrix&, BlockVector&) const; } + +for (S1 : COMPLEX_SCALARS) + { + template void ConstraintMatrix::condense >(SparseMatrix&, Vector&) const; + } for (Vec : SERIAL_VECTORS)