]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add add_entries function.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 26 Oct 2000 15:49:17 +0000 (15:49 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 26 Oct 2000 15:49:17 +0000 (15:49 +0000)
git-svn-id: https://svn.dealii.org/trunk@3462 0785d39b-7218-0410-832d-ea1e28bc413d

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

index a44c9bcd1452b22e020bc2590c1da43513cc78a9..25edb18ca909dd82c78292b15a58c8a8ff6978d0 100644 (file)
@@ -130,6 +130,18 @@ class ConstraintMatrix : public Subscriptor
                    const unsigned int column,
                    const double value);
 
+                                    /**
+                                     * Add a whole series of entries,
+                                     * denoted by pairs of column
+                                     * indices and values, to a line
+                                     * of constraints. This function
+                                     * is equivalent to calling the
+                                     * preceeding function more
+                                     * several times, but is faster.
+                                     */
+    void add_entries (const unsigned int                        line,
+                     const vector<pair<unsigned int,double> > &col_val_pairs);
+
                                     /**
                                      * Close the filling of entries. Since the
                                      * lines of a matrix of this type are
index 28d7b2a07502a85149d27e7cb0c525aff18be6f4..54593af88630669a7d3cf2547babfc27315fbedf 100644 (file)
@@ -101,6 +101,55 @@ void ConstraintMatrix::add_entry (const unsigned int line,
 
 
 
+void ConstraintMatrix::add_entries (const unsigned int                        line,
+                                   const vector<pair<unsigned int,double> > &col_val_pairs)
+{
+  Assert (sorted==false, ExcMatrixIsClosed());
+
+  vector<ConstraintLine>::iterator line_ptr;
+  const vector<ConstraintLine>::const_iterator start=lines.begin();
+                                  // the usual case is that the line where
+                                  // a value is entered is the one we
+                                  // added last, so we search backward
+  for (line_ptr=&lines.back(); line_ptr!=start; --line_ptr)
+    if (line_ptr->line == line)
+      break;
+
+                                  // if the loop didn't break, then
+                                  // line_ptr must be begin().
+                                  // we have an error if that doesn't
+                                  // point to 'line' then
+  Assert (line_ptr->line==line, ExcLineInexistant(line));
+
+                                  // if in debug mode, check whether an
+                                  // entry for this column already
+                                  // exists and if its the same as
+                                  // the one entered at present
+                                  //
+                                  // in any case: skip this entry if
+                                  // an entry for this column already
+                                  // exists, since we don't want to
+                                  // enter it twice
+  for (vector<pair<unsigned int,double> >::const_iterator col_val_pair = col_val_pairs.begin();
+       col_val_pair!=col_val_pairs.end(); ++col_val_pair)
+    {
+      for (vector<pair<unsigned int,double> >::const_iterator p=line_ptr->entries.begin();
+          p != line_ptr->entries.end(); ++p)
+       if (p->first == col_val_pair->first)
+         {
+                                            // entry exists, break
+                                            // innermost loop
+           Assert (p->second == col_val_pair->second,
+                   ExcEntryAlreadyExists(line, column, p->second, value));
+           break;
+         };
+      
+      line_ptr->entries.push_back (*col_val_pair);
+    };
+};
+
+
+
 void ConstraintMatrix::close ()
 {
   Assert (sorted==false, ExcMatrixIsClosed());

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.