// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
/**
- * This is a constant vector-valued function, that is different from
- * zero only in one component.
- *
- * It is especially useful as a weight function for
- * <tt>VectorTools::integrate_difference</tt>, where it allows to integrate
- * only one component.
+ * This is a constant vector-valued function, in which one or more
+ * components of the vector have a constant value and all other
+ * components are zero. It is especially useful as a weight function
+ * for <tt>VectorTools::integrate_difference</tt>, where it allows to
+ * integrate only one or a few vector components, rather than the
+ * entire vector-valued solution. See the @ref step_20 "step-20"
+ * tutorial program for a detailed explanation.
*
* @ingroup functions
- * @author Guido Kanschat, 2000
+ * @author Guido Kanschat, 2000, Wolfgang Bangerth 2006
*/
template <int dim>
class ComponentSelectFunction : public ConstantFunction<dim>
{
public:
/**
- * Constructor. Arguments denote
- * the component selected, the
- * value for that component and
- * the total number of components.
+ * Constructor if only a single
+ * component shall be
+ * non-zero. Arguments denote the
+ * component selected, the value
+ * for that component and the
+ * total number of vector
+ * components.
*/
ComponentSelectFunction (const unsigned int selected,
const double value,
*/
ComponentSelectFunction (const unsigned int selected,
const unsigned int n_components);
+
+ /**
+ * Constructor if multiple
+ * components shall have
+ * non-zero, unit values
+ * (i.e. this should be a mask
+ * for multiple components). The
+ * first argument denotes a
+ * half-open interval of
+ * components (for example
+ * std::pair(0,dim) for the first
+ * dim components), and the
+ * second argument is the total
+ * number of vector components.
+ */
+ ComponentSelectFunction (const std::pair<unsigned int, unsigned int> &selected,
+ const unsigned int n_components);
/**
* Return the value of the function
protected:
/**
- * Index of the selected component.
+ * Half-open interval of the
+ * indices of selected
+ * components.
*/
- const unsigned int selected;
+ const std::pair<unsigned int,unsigned int> selected_components;
};
// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
const unsigned int n_components)
:
ConstantFunction<dim> (value, n_components),
- selected(selected)
+ selected_components(std::make_pair(selected,selected+1))
{}
const unsigned int n_components)
:
ConstantFunction<dim> (1., n_components),
- selected(selected)
+ selected_components(std::make_pair(selected,selected+1))
{}
+template <int dim>
+ComponentSelectFunction<dim>::
+ComponentSelectFunction (const std::pair<unsigned int,unsigned int> &selected,
+ const unsigned int n_components)
+ :
+ ConstantFunction<dim> (1., n_components),
+ selected_components(selected)
+{
+ Assert (selected_components.first < selected_components.second,
+ ExcMessage ("The upper bound of the interval must be larger than "
+ "the lower bound"));
+ Assert (selected_components.second <= n_components,
+ ExcMessage ("The upper bound of the interval must be less than "
+ "or equal to the total number of vector components"));
+}
+
+
+
template <int dim>
void ComponentSelectFunction<dim>::vector_value (const Point<dim> &,
Vector<double> &return_value) const
Assert (return_value.size() == this->n_components,
ExcDimensionMismatch (return_value.size(), this->n_components));
- std::fill (return_value.begin(), return_value.end(), 0.);
- return_value(selected) = this->function_value;
+ return_value = 0;
+ std::fill (return_value.begin()+selected_components.first,
+ return_value.begin()+selected_components.second,
+ this->function_value);
}
ExcDimensionMismatch(values.size(), points.size()));
for (unsigned int i=0; i<points.size(); ++i)
- {
- Assert (values[i].size() == this->n_components,
- ExcDimensionMismatch(values[i].size(), this->n_components));
- std::fill (values[i].begin(), values[i].end(), 0.);
- values[i](selected) = this->function_value;
- }
+ ComponentSelectFunction<dim>::vector_value (points[i],
+ values[i]);
}
<h3>base</h3>
<ol>
+ <li> <p>Improved: The <code class="class">ComponentSelect</code> class can
+ now also handle the case that one wants to select multiple vector
+ components at once, not only a single one.
+ <br>
+ (WB 2006/02/12)
+ </p>
- <li> <p>Improved: a new function <code class="class">TableBase</code>::<code
- class="member">fill</code>, filling the whole table with the same element has
- been introduced.
- <br>
- (GK 2006/01/18)
- </p>
+ <li> <p>Improved: A new function <code class="class">TableBase</code>::<code
+ class="member">fill</code>, filling the whole table with the same
+ element has been introduced.
+ <br>
+ (GK 2006/01/18)
+ </p>
<li> <p>Improved: <code class="class">DataOutBase</code> now writes binary
- files for OpenDX.
- <br>
- (GK 2006/01/18)
- </p>
+ files for OpenDX.
+ <br>
+ (GK 2006/01/18)
+ </p>
<li> <p>
New: There are now functions