]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add a function which we can ask whether a certain DoF is constrained
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 1 Feb 2000 17:57:28 +0000 (17:57 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 1 Feb 2000 17:57:28 +0000 (17:57 +0000)
or not.

git-svn-id: https://svn.dealii.org/trunk@2308 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/dofs/dof_constraints.h
deal.II/deal.II/source/dofs/dof_constraints.cc

index 4b4500ed1b29f685b7c3f45cc092ae3b1b2492d8..740cb204316abcc98aa0b45ee5bb614f64d1137f 100644 (file)
@@ -154,6 +154,24 @@ class ConstraintMatrix : public Subscriptor
                                      */
     unsigned int n_constraints () const;
 
+                                    /**
+                                     * Return whether the degree of
+                                     * freedom with number #index# is
+                                     * a constrained one.
+                                     *
+                                     * Note that if #close# was
+                                     * called before, then this
+                                     * function is significantly
+                                     * faster, since then the
+                                     * constrained degrees of freedom
+                                     * are sorted and we can do a
+                                     * binary search, while before
+                                     * #close# was called, we have to
+                                     * perform a linear search
+                                     * through all entries.
+                                     */
+    bool is_constrained (const unsigned int index) const;
+    
                                     /**
                                      * Condense a given sparsity pattern. This
                                      * function assumes the uncondensed
index b07515369a849282838259e5a32e13594eb46f0b..9e1cf51df23d484747f75fbc966f1b0a8e8cc24a 100644 (file)
@@ -12,7 +12,9 @@
 
 
 
-bool ConstraintMatrix::ConstraintLine::operator < (const ConstraintMatrix::ConstraintLine &a) const
+inline
+bool
+ConstraintMatrix::ConstraintLine::operator < (const ConstraintLine &a) const
 {
   return line < a.line;
 };
@@ -308,12 +310,38 @@ void ConstraintMatrix::condense (SparsityPattern &sparsity) const {
 
 
 
-unsigned int ConstraintMatrix::n_constraints () const {
+unsigned int ConstraintMatrix::n_constraints () const
+{
   return lines.size();
 };
 
 
 
+bool ConstraintMatrix::is_constrained (const unsigned int index) const 
+{
+  if (sorted == true)
+    {
+      
+      ConstraintLine index_comparison;
+      index_comparison.line = index;
+      
+      return binary_search (lines.begin (),
+                           lines.end (),
+                           index_comparison);
+    }
+  else
+    {
+      for (vector<ConstraintLine>::const_iterator i=lines.begin();
+          i!=lines.end(); ++i)
+       if (i->line == index)
+         return true;
+
+      return false;
+    };
+};
+
+
+
 void ConstraintMatrix::print (ostream &out) const {
   for (unsigned int i=0; i!=lines.size(); ++i)
     for (unsigned int j=0; j!=lines[i].entries.size(); ++j)

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.