* This function exists because @p operator=() is explicitly
* disabled.
*/
+ template <typename other_number>
void
- copy_from(const AffineConstraints &other);
+ copy_from(const AffineConstraints<other_number> &other);
/**
* clear() the AffineConstraints object and supply an IndexSet with lines
*/
number inhomogeneity;
+ /**
+ * Default constructor.
+ */
+ ConstraintLine(const size_type &index = numbers::invalid_dof_index,
+ const Entries & entries = {},
+ const number & inhomogeneity = 0.0);
+
+ /**
+ * Copy constructor.
+ */
+ template <typename ConstraintLineType>
+ ConstraintLine(const ConstraintLineType &other);
+
+ /**
+ * Copy assignment.
+ */
+ template <typename ConstraintLineType>
+ ConstraintLine &
+ operator=(const ConstraintLineType &other);
+
/**
* This operator is a bit weird and unintuitive: it compares the line
* numbers of two lines. We need this to sort the lines; in fact we could
<< "that every processor who owns a DoF that constrains "
<< "another DoF also knows about this constraint?");
+ template <typename>
+ friend class AffineConstraints;
+
private:
/**
* Store the lines of the matrix. Entries are usually appended in an
} // namespace internal
+
+template <typename number>
+template <typename other_number>
+inline void
+AffineConstraints<number>::copy_from(
+ const AffineConstraints<other_number> &other)
+{
+ lines.clear();
+ lines.insert(lines.begin(), other.lines.begin(), other.lines.end());
+ lines_cache = other.lines_cache;
+ local_lines = other.local_lines;
+ sorted = other.sorted;
+}
+
+
+
template <typename number>
template <typename MatrixType>
inline void
SparsityPatternType>::value>());
}
+
+
+template <typename number>
+inline AffineConstraints<number>::ConstraintLine::ConstraintLine(
+ const size_type & index,
+ const typename AffineConstraints<number>::ConstraintLine::Entries &entries,
+ const number &inhomogeneity)
+ : index(index)
+ , entries(entries)
+ , inhomogeneity(inhomogeneity)
+{}
+
+
+
+template <typename number>
+template <typename ConstraintLineType>
+inline AffineConstraints<number>::ConstraintLine::ConstraintLine(
+ const ConstraintLineType &other)
+{
+ this->index = other.index;
+
+ entries.clear();
+ entries.insert(entries.begin(), other.entries.begin(), other.entries.end());
+
+ this->inhomogeneity = other.inhomogeneity;
+}
+
+
+
+template <typename number>
+template <typename ConstraintLineType>
+inline typename AffineConstraints<number>::ConstraintLine &
+AffineConstraints<number>::ConstraintLine::
+operator=(const ConstraintLineType &other)
+{
+ this->index = other.index;
+
+ entries.clear();
+ entries.insert(entries.begin(), other.entries.begin(), other.entries.end());
+
+ this->inhomogeneity = other.inhomogeneity;
+
+ return *this;
+}
+
DEAL_II_NAMESPACE_CLOSE
#endif
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2021 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+// Test AffineConstraints::copy_from() for different types (float, double).
+
+#include <deal.II/lac/affine_constraints.h>
+
+#include <vector>
+
+#include "../tests.h"
+
+template <typename T1, typename T2>
+void
+test()
+{
+ AffineConstraints<T1> constraints;
+
+ constraints.add_line(1);
+ constraints.add_entry(1, 2, 1.);
+ constraints.add_entry(1, 3, 1.);
+
+ constraints.add_line(3);
+ constraints.add_entry(3, 4, 1.);
+ constraints.add_entry(3, 5, 1.);
+
+ constraints.add_line(5);
+ constraints.add_entry(5, 0, 1.);
+
+ constraints.close();
+
+ AffineConstraints<T2> constraints_float;
+
+ constraints_float.copy_from(constraints);
+
+ constraints.print(deallog.get_file_stream());
+ deallog << std::endl;
+ constraints_float.print(deallog.get_file_stream());
+ deallog << std::endl;
+}
+
+int
+main()
+{
+ initlog();
+ deallog << std::setprecision(2);
+
+ test<double, double>();
+ test<float, double>();
+ test<double, float>();
+ test<float, float>();
+}