Specifically, remove the functions that actually create a shrunk linear system, rather than zeroing out rows and columns in an existing linear system. These functions were a bad idea when they were introduced in 1998, and they still are today. We've never used them in anything and they are not used in any of the tutorials or tests.
It is true that I've only deprecated one of the functions yesterday or the day before and remove it today. On the other hand, anyone who would have used that function to shrink a sparsity pattern (which was not previously deprecated) would also have had to use the corresponding function on their matrix (which was already deprecated).
- SparseMatrixIterators::Accessor and SparseMatrixIterators::Iterator
constructors.
- SparseMatrix::raw_entry and SparseMatrix::global_entry.
+ - The ConstraintMatrix functions that transform a matrix, vector, or
+ linear system into a smaller by not just setting the corresponding
+ rows and columns to zero, but actually shrinking the size of the
+ linear system.
<br>
<em>With headers in <code>deal.II/deal.II/</code>:</em>
* @{
*/
- /**
- * Condense a given sparsity pattern. This function assumes the uncondensed
- * matrix struct to be compressed and the one to be filled to be empty. The
- * condensed structure is compressed afterwards.
- *
- * The constraint matrix object must be closed to call this function.
- *
- * @note The hanging nodes are completely eliminated from the linear system
- * referring to <tt>condensed</tt>. Therefore, the dimension of
- * <tt>condensed</tt> is the dimension of <tt>uncondensed</tt> minus the
- * number of constrained degrees of freedom.
- *
- * @deprecated The functions converting an uncondensed matrix into its
- * condensed form are deprecated. Use the functions doing the in-place
- * condensation leaving the size of the linear system unchanged.
- */
- void condense (const SparsityPattern &uncondensed,
- SparsityPattern &condensed) const DEAL_II_DEPRECATED;
-
/**
* Condense a sparsity pattern. The name of the function mimics the
*/
void condense (BlockCompressedSimpleSparsityPattern &sparsity) const;
-
- /**
- * Condense a given matrix. The associated matrix struct should be condensed
- * and compressed. It is the user's responsibility to guarantee that all
- * entries in the @p condensed matrix be zero!
- *
- * The constraint matrix object must be closed to call this function.
- *
- * @deprecated The functions converting an uncondensed matrix into its
- * condensed form are deprecated. Use the functions doing the in-place
- * condensation leaving the size of the linear system unchanged.
- */
- template<typename number>
- void condense (const SparseMatrix<number> &uncondensed,
- SparseMatrix<number> &condensed) const DEAL_II_DEPRECATED;
-
/**
* Condense a given matrix, i.e., eliminate the rows and columns of
* the matrix that correspond to constrained degrees of freedom.
void condense (const VectorType &vec_ghosted,
VectorType &output) const;
- /**
- * Condense a given matrix and a given vector by eliminating rows
- * and columns of the linear system that correspond to constrained
- * degrees of freedom. The sparsity pattern associated with the
- * matrix needs to be condensed and compressed. This function is
- * the appropriate choice for applying inhomogeneous constraints.
- *
- * The constraint matrix object must be closed to call this function.
- *
- * See the general documentation of this
- * class for more detailed information.
- *
- * @deprecated The functions converting an uncondensed matrix into its
- * condensed form are deprecated. Use the functions doing the in-place
- * condensation leaving the size of the linear system unchanged.
- */
- template<typename number, class VectorType>
- void condense (const SparseMatrix<number> &uncondensed_matrix,
- const VectorType &uncondensed_vector,
- SparseMatrix<number> &condensed_matrix,
- VectorType &condensed_vector) const DEAL_II_DEPRECATED;
-
/**
* Condense a given matrix and a given vector by eliminating rows
* and columns of the linear system that correspond to constrained
DEAL_II_NAMESPACE_OPEN
-template<typename number>
-void
-ConstraintMatrix::condense (const SparseMatrix<number> &uncondensed,
- SparseMatrix<number> &condensed) const
-{
- // create two dummy vectors and enter the
- // other function
- Vector<number> dummy (0);
- condense (uncondensed, dummy, condensed, dummy);
-}
-
-
-
template<typename number>
void
ConstraintMatrix::condense (SparseMatrix<number> &uncondensed) const
-template<typename number, class VectorType>
-void
-ConstraintMatrix::condense (const SparseMatrix<number> &uncondensed,
- const VectorType &uncondensed_vector,
- SparseMatrix<number> &condensed,
- VectorType &condensed_vector) const
-{
- // check whether we work on real vectors
- // or we just used a dummy when calling
- // the other function above.
- const bool use_vectors = (uncondensed_vector.size() == 0 &&
- condensed_vector.size() == 0) ? false : true;
-
- const SparsityPattern &uncondensed_struct = uncondensed.get_sparsity_pattern ();
-
- Assert (sorted == true, ExcMatrixNotClosed());
- Assert (uncondensed_struct.is_compressed() == true, ExcMatrixNotClosed());
- Assert (condensed.get_sparsity_pattern().is_compressed() == true, ExcMatrixNotClosed());
- Assert (uncondensed_struct.n_rows() == uncondensed_struct.n_cols(),
- ExcNotQuadratic());
- Assert (condensed.n() == condensed.m(),
- ExcNotQuadratic());
- AssertDimension (condensed.n()+n_constraints(), uncondensed.n());
- if (use_vectors == true)
- {
- AssertDimension (condensed_vector.size()+n_constraints(),
- uncondensed_vector.size());
- AssertDimension (condensed_vector.size(), condensed.m());
- }
-
- // store for each line of the matrix
- // its new line number
- // after compression. If the shift is
- // -1, this line will be condensed away
- std::vector<int> new_line;
-
- new_line.reserve (uncondensed_struct.n_rows());
-
- std::vector<ConstraintLine>::const_iterator next_constraint = lines.begin();
- size_type shift = 0;
- const size_type n_rows = uncondensed_struct.n_rows();
-
- if (next_constraint == lines.end())
- // if no constraint is to be handled
- for (size_type row=0; row!=n_rows; ++row)
- new_line.push_back (row);
- else
- for (size_type row=0; row!=n_rows; ++row)
- if (row == next_constraint->line)
- {
- // this line is constrained
- new_line.push_back (-1);
- // note that @p lines is ordered
- ++shift;
- ++next_constraint;
- if (next_constraint == lines.end())
- // nothing more to do; finish rest
- // of loop
- {
- for (size_type i=row+1; i<n_rows; ++i)
- new_line.push_back (i-shift);
- break;
- };
- }
- else
- new_line.push_back (row-shift);
-
-
- next_constraint = lines.begin();
-
- // note: in this loop we need not check
- // whether @p next_constraint is a valid
- // iterator, since @p next_constraint is
- // only evaluated so often as there are
- // entries in new_line[*] which tells us
- // which constraints exist
- for (size_type row=0; row<uncondensed_struct.n_rows(); ++row)
- if (new_line[row] != -1)
- {
- // line not constrained
- // copy entries if column will not
- // be condensed away, distribute
- // otherwise
- for (typename SparseMatrix<number>::const_iterator
- p = uncondensed.begin(row);
- p != uncondensed.end(row); ++p)
- if (new_line[p->column()] != -1)
- condensed.add (new_line[row],
- new_line[p->column()],
- p->value());
- else
- {
- // let c point to the
- // constraint of this column
- std::vector<ConstraintLine>::const_iterator c = lines.begin();
- while (c->line != p->column())
- ++c;
-
- for (size_type q=0; q!=c->entries.size(); ++q)
- // distribute to rows with
- // appropriate weight
- condensed.add (new_line[row], new_line[c->entries[q].first],
- p->value() * c->entries[q].second);
-
- // take care of inhomogeneity:
- // need to subtract this element from the
- // vector. this corresponds to an
- // explicit elimination in the respective
- // row of the inhomogeneous constraint in
- // the matrix with Gauss elimination
- if (use_vectors == true)
- condensed_vector(new_line[row]) -= p->value() *
- c->inhomogeneity;
- }
-
- if (use_vectors == true)
- condensed_vector(new_line[row]) += uncondensed_vector(row);
- }
- else
- // line must be distributed
- {
- for (typename SparseMatrix<number>::const_iterator
- p = uncondensed.begin(row);
- p != uncondensed.end(row); ++p)
- // for each column: distribute
- if (new_line[p->column()] != -1)
- // column is not constrained
- for (size_type q=0; q!=next_constraint->entries.size(); ++q)
- condensed.add (new_line[next_constraint->entries[q].first],
- new_line[p->column()],
- p->value() *
- next_constraint->entries[q].second);
-
- else
- // not only this line but
- // also this col is constrained
- {
- // let c point to the constraint
- // of this column
- std::vector<ConstraintLine>::const_iterator c = lines.begin();
- while (c->line != p->column())
- ++c;
-
- for (size_type r=0; r!=c->entries.size(); ++r)
- for (size_type q=0; q!=next_constraint->entries.size(); ++q)
- condensed.add (new_line[next_constraint->entries[q].first],
- new_line[c->entries[r].first],
- p->value() *
- next_constraint->entries[r].second *
- c->entries[r].second);
-
- if (use_vectors == true)
- for (size_type q=0; q!=next_constraint->entries.size(); ++q)
- condensed_vector (new_line[next_constraint->entries[q].first])
- -= p->value() *
- next_constraint->entries[q].second *
- c->inhomogeneity;
- }
-
- // condense the vector
- if (use_vectors == true)
- for (size_type q=0; q!=next_constraint->entries.size(); ++q)
- condensed_vector(new_line[next_constraint->entries[q].first])
- +=
- uncondensed_vector(row) * next_constraint->entries[q].second;
-
- ++next_constraint;
- };
-}
-
-
-
template<typename number, class VectorType>
void
ConstraintMatrix::condense (SparseMatrix<number> &uncondensed,
-void ConstraintMatrix::condense (const SparsityPattern &uncondensed,
- SparsityPattern &condensed) const
-{
- Assert (sorted == true, ExcMatrixNotClosed());
- Assert (uncondensed.is_compressed() == true, ExcMatrixNotClosed());
- Assert (uncondensed.n_rows() == uncondensed.n_cols(), ExcNotQuadratic());
-
- // store for each line of the matrix its new line number after
- // compression. If the shift is -1, this line will be condensed away
-#ifndef DEAL_II_WITH_64BIT_INDICES
- std::vector<int> new_line;
-#else
- std::vector<long long int> new_line;
-#endif
-
- new_line.reserve (uncondensed.n_rows());
-
- std::vector<ConstraintLine>::const_iterator next_constraint = lines.begin();
- size_type shift = 0;
- size_type n_rows = uncondensed.n_rows();
-
- if (next_constraint == lines.end())
- // if no constraint is to be handled
- for (size_type row=0; row!=n_rows; ++row)
- new_line.push_back (row);
- else
- for (size_type row=0; row!=n_rows; ++row)
- if (row == next_constraint->line)
- {
- // this line is constrained
- new_line.push_back (-1);
- // note that @p{lines} is ordered
- ++shift;
- ++next_constraint;
- if (next_constraint == lines.end())
- // nothing more to do; finish rest of loop
- {
- for (size_type i=row+1; i<n_rows; ++i)
- new_line.push_back (i-shift);
- break;
- };
- }
- else
- new_line.push_back (row-shift);
-
-
- next_constraint = lines.begin();
- // note: in this loop we need not check whether @p{next_constraint} is a
- // valid iterator, since @p{next_constraint} is only evaluated so often as
- // there are entries in new_line[*] which tells us which constraints exist
- for (size_type row=0; row<uncondensed.n_rows(); ++row)
- if (new_line[row] != -1)
- // line not constrained copy entries if column will not be condensed
- // away, distribute otherwise
- for (SparsityPattern::iterator j=uncondensed.begin(row);
- j<uncondensed.end(row); ++j)
- if (new_line[j->column()])
- condensed.add (new_line[row], new_line[j->column()]);
- else
- {
- // let c point to the constraint of this column
- std::vector<ConstraintLine>::const_iterator c = lines.begin();
- while (c->line != j->column())
- ++c;
-
- for (size_type q=0; q!=c->entries.size(); ++q)
- condensed.add (new_line[row], new_line[c->entries[q].first]);
- }
- else
- // line must be distributed
- {
- for (SparsityPattern::iterator j=uncondensed.begin(row);
- j<uncondensed.end(row); ++j)
- // for each entry: distribute
- if (new_line[j->column()] != -1)
- // column is not constrained
- for (size_type q=0; q!=next_constraint->entries.size(); ++q)
- condensed.add (new_line[next_constraint->entries[q].first],
- new_line[j->column()]);
-
- else
- // not only this line but
- // also this col is constrained
- {
- // let c point to the constraint
- // of this column
- std::vector<ConstraintLine>::const_iterator c = lines.begin();
- while (c->line != j->column()) ++c;
-
- for (size_type p=0; p!=c->entries.size(); ++p)
- for (size_type q=0; q!=next_constraint->entries.size(); ++q)
- condensed.add (new_line[next_constraint->entries[q].first],
- new_line[c->entries[p].first]);
- };
-
- ++next_constraint;
- };
-
- condensed.compress();
-}
-
-
-
void ConstraintMatrix::condense (SparsityPattern &sparsity) const
{
Assert (sorted == true, ExcMatrixNotClosed());
template void ConstraintMatrix::condense<VectorType >(const VectorType &uncondensed,\
VectorType &condensed) const;\
template void ConstraintMatrix::condense<VectorType >(VectorType &vec) const;\
- template void ConstraintMatrix::condense<float,VectorType >(const SparseMatrix<float> &uncondensed, \
- const VectorType &uncondensed_vector, \
- SparseMatrix<float> &condensed, \
- VectorType &condensed_vector) const; \
- template void ConstraintMatrix::condense<double,VectorType >(const SparseMatrix<double> &uncondensed, \
- const VectorType &uncondensed_vector, \
- SparseMatrix<double> &condensed, \
- VectorType &condensed_vector) const; \
template void ConstraintMatrix:: \
distribute_local_to_global<VectorType > (const Vector<double> &, \
const std::vector<ConstraintMatrix::size_type> &, \
for (S : REAL_SCALARS)
{
- template void ConstraintMatrix::condense<S>(const SparseMatrix<S>&, SparseMatrix<S> &) const;
template void ConstraintMatrix::condense<S>(SparseMatrix<S>&) const;
template void ConstraintMatrix::condense<S>(BlockSparseMatrix<S>&) const;
}
{
template void ConstraintMatrix::condense<S1,Vector<S2> >(SparseMatrix<S1>&, Vector<S2>&) const;
template void ConstraintMatrix::condense<S1,BlockVector<S2> >(BlockSparseMatrix<S1>&, BlockVector<S2>&) const;
- template void ConstraintMatrix::condense<S1,Vector<S2> >(
- const SparseMatrix<S1>&, const Vector<S2>&, SparseMatrix<S1> &, Vector<S2>&) const;
- template void ConstraintMatrix::condense<S1,BlockVector<S2> >(
- const SparseMatrix<S1>&, const BlockVector<S2>&, SparseMatrix<S1> &, BlockVector<S2>&) const;
}