]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added diagnostic functions for AffineConstraints.
authorMarc Fehling <mafehling.git@gmail.com>
Wed, 4 Aug 2021 23:18:09 +0000 (17:18 -0600)
committerMarc Fehling <mafehling.git@gmail.com>
Thu, 5 Aug 2021 00:23:17 +0000 (18:23 -0600)
doc/news/changes/minor/20210804Fehling [new file with mode: 0644]
include/deal.II/lac/affine_constraints.h

diff --git a/doc/news/changes/minor/20210804Fehling b/doc/news/changes/minor/20210804Fehling
new file mode 100644 (file)
index 0000000..ce52954
--- /dev/null
@@ -0,0 +1,4 @@
+New: Diagnostic functions AffineConstraints::n_identities() and
+AffineConstraints::n_inhomogeneities() to analyse your constraints.
+<br>
+(Marc Fehling, 2021/08/04)
index 5baafd9eb0a774e8f8669a99318e919c3caffadf..cc981012022339fbac90187c005321f908f80044 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <boost/range/iterator_range.hpp>
 
+#include <algorithm>
 #include <set>
 #include <type_traits>
 #include <utility>
@@ -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<number>::n_constraints() const
   return lines.size();
 }
 
+template <typename number>
+inline types::global_dof_index
+AffineConstraints<number>::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 <typename number>
+inline types::global_dof_index
+AffineConstraints<number>::n_inhomogeneities() const
+{
+  return std::count_if(lines.begin(),
+                       lines.end(),
+                       [](const ConstraintLine &line) {
+                         return (line.inhomogeneity != number(0.));
+                       });
+}
+
 template <typename number>
 inline bool
 AffineConstraints<number>::is_constrained(const size_type index) const
@@ -2150,7 +2189,7 @@ AffineConstraints<number>::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.));
     }
 }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.