From: Wolfgang Bangerth Date: Mon, 21 Aug 2023 22:46:48 +0000 (-0600) Subject: Add a default constructor to AffineConstraints. X-Git-Tag: relicensing~560^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dc9b70ee3e67aa1b230f19682f6c0db647b3446;p=dealii.git Add a default constructor to AffineConstraints. --- diff --git a/include/deal.II/lac/affine_constraints.h b/include/deal.II/lac/affine_constraints.h index f1cd91d159..9f0f61d7d7 100644 --- a/include/deal.II/lac/affine_constraints.h +++ b/include/deal.II/lac/affine_constraints.h @@ -547,24 +547,39 @@ public: right_object_wins }; + /** + * Default constructor. + * + * This constructor sets up an object that stores all constraints eventually + * given to it. (This is in contrast to the following constructor that + * restricts which degrees of freedom we should care about -- for example, + * in a parallel context one would typically only store constraints + * for the locally relevant DoFs, see + * @ref GlossLocallyRelevantDof .) + * Consequently, this constructor creates internal data structures for + * all possible + * indices will be created, leading to memory consumption on every + * processor that is proportional to the overall size of the + * problem, not just proportional to the size of the portion of the + * overall problem that is handled by the current processor. Calling + * this constructor in a parallel program is a common bug: Call the + * other one, with an index set, instead. + */ + AffineConstraints(); + /** * Constructor. The supplied IndexSet defines which indices might be * constrained inside this AffineConstraints container. In a calculation * with a DoFHandler object based on parallel::distributed::Triangulation * or parallel::shared::Triangulation, one should use the set of locally - * relevant dofs (see + * relevant DoFs (see * @ref GlossLocallyRelevantDof). * * The given IndexSet allows the AffineConstraints container to save * memory by just not caring about degrees of freedom that are not of - * importance to the current processor. Alternatively, if no such - * IndexSet is provided, internal data structures for all possible - * indices will be created, leading to memory consumption on every - * processor that is proportional to the overall size of the - * problem, not just proportional to the size of the portion of the - * overall problem that is handled by the current processor. + * importance to the current processor. */ - explicit AffineConstraints(const IndexSet &local_constraints = IndexSet()); + explicit AffineConstraints(const IndexSet &local_constraints); /** * Copy constructor @@ -2022,6 +2037,20 @@ private: /* ---------------- template and inline functions ----------------- */ +template +inline AffineConstraints::AffineConstraints() + : lines() + , local_lines() + , sorted(false) +{ + // make sure the IndexSet is compressed. Otherwise this can lead to crashes + // that are hard to find (only happen in release mode). + // see tests/mpi/affine_constraints_crash_01 + local_lines.compress(); +} + + + template inline AffineConstraints::AffineConstraints( const IndexSet &local_constraints) @@ -2035,6 +2064,8 @@ inline AffineConstraints::AffineConstraints( local_lines.compress(); } + + template inline AffineConstraints::AffineConstraints( const AffineConstraints &affine_constraints) @@ -2045,6 +2076,8 @@ inline AffineConstraints::AffineConstraints( , sorted(affine_constraints.sorted) {} + + template inline void AffineConstraints::add_line(const size_type line_n)