From: Marc Fehling Date: Wed, 4 Aug 2021 23:18:09 +0000 (-0600) Subject: Added diagnostic functions for AffineConstraints. X-Git-Tag: v9.4.0-rc1~1107^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29f92c3f43cbce72054387eb2cc33ff30aadeb23;p=dealii.git Added diagnostic functions for AffineConstraints. --- diff --git a/doc/news/changes/minor/20210804Fehling b/doc/news/changes/minor/20210804Fehling new file mode 100644 index 0000000000..ce529549bc --- /dev/null +++ b/doc/news/changes/minor/20210804Fehling @@ -0,0 +1,4 @@ +New: Diagnostic functions AffineConstraints::n_identities() and +AffineConstraints::n_inhomogeneities() to analyse your constraints. +
+(Marc Fehling, 2021/08/04) diff --git a/include/deal.II/lac/affine_constraints.h b/include/deal.II/lac/affine_constraints.h index 5baafd9eb0..cc98101202 100644 --- a/include/deal.II/lac/affine_constraints.h +++ b/include/deal.II/lac/affine_constraints.h @@ -30,6 +30,7 @@ #include +#include #include #include #include @@ -843,6 +844,21 @@ public: size_type n_constraints() const; + /** + * Return number of constraints stored in this matrix that are identities, + * i.e., those constraints with only one degree of freedom and weight one. + */ + size_type + n_identities() const; + + /** + * Return number of constraints stored in this matrix that have an + * inhomogenity, i.e., those constraints with a non-trivial inhomogeneous + * value. + */ + size_type + n_inhomogeneities() const; + /** * Return whether the degree of freedom with number @p line_n is a * constrained one. @@ -2127,6 +2143,29 @@ AffineConstraints::n_constraints() const return lines.size(); } +template +inline types::global_dof_index +AffineConstraints::n_identities() const +{ + return std::count_if(lines.begin(), + lines.end(), + [](const ConstraintLine &line) { + return (line.entries.size() == 1) && + (line.entries[0].second == number(1.)); + }); +} + +template +inline types::global_dof_index +AffineConstraints::n_inhomogeneities() const +{ + return std::count_if(lines.begin(), + lines.end(), + [](const ConstraintLine &line) { + return (line.inhomogeneity != number(0.)); + }); +} + template inline bool AffineConstraints::is_constrained(const size_type index) const @@ -2150,7 +2189,7 @@ AffineConstraints::is_inhomogeneously_constrained( else { Assert(lines_cache[line_index] < lines.size(), ExcInternalError()); - return !(lines[lines_cache[line_index]].inhomogeneity == number(0.)); + return (lines[lines_cache[line_index]].inhomogeneity != number(0.)); } }