* receive the cell-wise
* Euclidian norm of the
* approximated gradient.
+ *
+ * The last parameter denotes the
+ * solution component, for which
+ * the gradient is to be
+ * computed. It defaults to the
+ * first component.
*/
template <int dim>
static void
approximate_gradient (const DoFHandler<dim> &dof,
const Vector<double> &solution,
- Vector<float> &derivative_norm);
+ Vector<float> &derivative_norm,
+ const unsigned int component = 0);
/**
* This function is the analogue
* derivatives. The spectral norm
* is the matrix norm associated
* to the $l_2$ vector norm.
+ *
+ * The last parameter denotes the
+ * solution component, for which
+ * the gradient is to be
+ * computed. It defaults to the
+ * first component.
*/
template <int dim>
static void
approximate_second_derivative (const DoFHandler<dim> &dof,
const Vector<double> &solution,
- Vector<float> &derivative_norm);
+ Vector<float> &derivative_norm,
+ const unsigned int component);
/**
* Exception
*/
static ProjectedDerivative
get_projected_derivative (const FEValues<dim> &fe_values,
- const Vector<double> &solution);
+ const Vector<double> &solution,
+ const unsigned int component);
/**
* Return the norm of the
*/
static ProjectedDerivative
get_projected_derivative (const FEValues<dim> &fe_values,
- const Vector<double> &solution);
+ const Vector<double> &solution,
+ const unsigned int component);
/**
* Return the norm of the
* administration that is
* independent of the actual
* derivative to be computed.
+ *
+ * The @p{component} argument
+ * denotes which component of the
+ * solution vector we are to work
+ * on.
*/
template <class DerivativeDescription, int dim>
static void
approximate_derivative (const DoFHandler<dim> &dof,
const Vector<double> &solution,
+ const unsigned int component,
Vector<float> &derivative_norm);
/**
static void
approximate (const DoFHandler<dim> &dof,
const Vector<double> &solution,
+ const unsigned int component,
const IndexInterval &index_interval,
- Vector<float> &derivative_norm);
+ Vector<float> &derivative_norm);
};
typename DerivativeApproximation::Gradient<dim>::ProjectedDerivative
DerivativeApproximation::Gradient<dim>::
get_projected_derivative (const FEValues<dim> &fe_values,
- const Vector<double> &solution)
+ const Vector<double> &solution,
+ const unsigned int component)
{
- vector<ProjectedDerivative> values (1);
- fe_values.get_function_values (solution, values);
- return values[0];
+ if (fe_values.get_fe().n_components() == 1)
+ {
+ vector<ProjectedDerivative> values (1);
+ fe_values.get_function_values (solution, values);
+ return values[0];
+ }
+ else
+ {
+ vector<Vector<double> > values
+ (1, Vector<double>(fe_values.get_fe().n_components()));
+ fe_values.get_function_values (solution, values);
+ return values[0](component);
+ };
};
typename DerivativeApproximation::SecondDerivative<dim>::ProjectedDerivative
DerivativeApproximation::SecondDerivative<dim>::
get_projected_derivative (const FEValues<dim> &fe_values,
- const Vector<double> &solution)
+ const Vector<double> &solution,
+ const unsigned int component)
{
- vector<ProjectedDerivative> values (1);
- fe_values.get_function_grads (solution, values);
- return values[0];
+ if (fe_values.get_fe().n_components() == 1)
+ {
+ vector<ProjectedDerivative> values (1);
+ fe_values.get_function_grads (solution, values);
+ return values[0];
+ }
+ else
+ {
+ vector<vector<ProjectedDerivative> > values
+ (1, vector<ProjectedDerivative>(fe_values.get_fe().n_components()));
+ fe_values.get_function_grads (solution, values);
+ return values[0][component];
+ };
};
DerivativeApproximation::
approximate_gradient (const DoFHandler<dim> &dof_handler,
const Vector<double> &solution,
- Vector<float> &derivative_norm)
+ Vector<float> &derivative_norm,
+ const unsigned int component)
{
approximate_derivative<Gradient<dim>,dim> (dof_handler,
solution,
+ component,
derivative_norm);
};
DerivativeApproximation::
approximate_second_derivative (const DoFHandler<dim> &dof_handler,
const Vector<double> &solution,
- Vector<float> &derivative_norm)
+ Vector<float> &derivative_norm,
+ const unsigned int component)
{
approximate_derivative<SecondDerivative<dim>,dim> (dof_handler,
solution,
+ component,
derivative_norm);
};
DerivativeApproximation::
approximate_derivative (const DoFHandler<dim> &dof_handler,
const Vector<double> &solution,
+ const unsigned int component,
Vector<float> &derivative_norm)
{
Assert (derivative_norm.size() == dof_handler.get_tria().n_active_cells(),
Threads::encapsulate
(&DerivativeApproximation::
template approximate<DerivativeDescription,dim>)
- .collect_args (dof_handler, solution,
+ .collect_args (dof_handler, solution, component,
index_intervals[i],
derivative_norm));
thread_manager.wait ();
void
DerivativeApproximation::approximate (const DoFHandler<dim> &dof_handler,
const Vector<double> &solution,
+ const unsigned int component,
const IndexInterval &index_interval,
Vector<float> &derivative_norm)
{
const typename DerivativeDescription::ProjectedDerivative
this_midpoint_value
= DerivativeDescription::get_projected_derivative (fe_midpoint_value,
- solution);
+ solution,
+ component);
// ...and the place where it lives
const Point<dim> this_center = fe_midpoint_value.quadrature_point(0);
const typename DerivativeDescription::ProjectedDerivative
neighbor_midpoint_value
= DerivativeDescription::get_projected_derivative (fe_midpoint_value,
- solution);
+ solution, component);
// ...and the place where it lives
const Point<dim>
DerivativeApproximation::
approximate_gradient (const DoFHandler<deal_II_dimension> &dof_handler,
const Vector<double> &solution,
- Vector<float> &derivative_norm);
+ Vector<float> &derivative_norm,
+ const unsigned int component);
template
void
DerivativeApproximation::
approximate_second_derivative (const DoFHandler<deal_II_dimension> &dof_handler,
const Vector<double> &solution,
- Vector<float> &derivative_norm);
+ Vector<float> &derivative_norm,
+ const unsigned int component);