* a second step.
*
* @ingroup dofs
- * @author Wolfgang Bangerth, 1998, 2004, 2008
+ * @author Wolfgang Bangerth, Martin Kronbichler, 1998, 2004, 2008, 2009
*/
class ConstraintMatrix : public Subscriptor
{
void add_entries (const unsigned int line,
const std::vector<std::pair<unsigned int,double> > &col_val_pairs);
+ /**
+ * Set an imhomogeneity to the
+ * constraint line <i>i</i>,
+ * according to the discussion in
+ * the general class description.
+ */
+ void set_inhomogeneity (const unsigned int line,
+ const double value);
+
/**
* Close the filling of
* entries. Since the lines of a
/**
* Delete hanging nodes in a
- * vector. Sets all hanging node
+ * vector. Sets all hanging node
* values to zero. The @p
* VectorType may be a
* Vector<float>, Vector<double>,
*/
std::vector<std::pair<unsigned int,double> > entries;
+ /**
+ * Value of the inhomogeneity.
+ */
+ double inhomogeneity;
+
/**
* This operator is a bit
* weird and unintuitive: it
// list
lines.push_back (ConstraintLine());
lines.back().line = line;
+ lines.back().inhomogeneity = 0.;
}
+inline
+void
+ConstraintMatrix::set_inhomogeneity (const unsigned int line,
+ const double value)
+{
+ std::vector<ConstraintLine>::iterator line_ptr;
+ const std::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.end()-1); 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));
+ // second check: the respective
+ // flag in the
+ // constraint_line_exists field
+ // must exist
+ Assert (line < constraint_line_exists.size(), ExcInternalError());
+ Assert (constraint_line_exists[line] == true, ExcInternalError());
+
+ line_ptr->inhomogeneity = value;
+}
+
+
+
inline
bool
ConstraintMatrix::is_constrained (const unsigned int index) const
// line was condensed away,
// create it newly. first set
// it to zero
- uncondensed(line) = 0.;
+ uncondensed(line) = next_constraint->inhomogeneity;
// then add the different
// contributions
for (unsigned int i=0; i<next_constraint->entries.size(); ++i)
// fill entry in line
// next_constraint.line by adding the
// different contributions
- double new_value = 0;
+ double new_value = next_constraint->inhomogeneity;
for (unsigned int i=0; i<next_constraint->entries.size(); ++i)
new_value += (vec(next_constraint->entries[i].first) *
next_constraint->entries[i].second);