From d5f16bef71bf17c7199e244bcd4bee7889ef8718 Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 13 Nov 2000 10:39:50 +0000 Subject: [PATCH] Allow to use finite elements with more than one component. git-svn-id: https://svn.dealii.org/trunk@3480 0785d39b-7218-0410-832d-ea1e28bc413d --- .../numerics/derivative_approximation.h | 33 ++++++++-- .../numerics/derivative_approximation.cc | 61 ++++++++++++++----- 2 files changed, 74 insertions(+), 20 deletions(-) diff --git a/deal.II/deal.II/include/numerics/derivative_approximation.h b/deal.II/deal.II/include/numerics/derivative_approximation.h index 5efe558ab3..c207ebcab8 100644 --- a/deal.II/deal.II/include/numerics/derivative_approximation.h +++ b/deal.II/deal.II/include/numerics/derivative_approximation.h @@ -173,12 +173,19 @@ class DerivativeApproximation * 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 static void approximate_gradient (const DoFHandler &dof, const Vector &solution, - Vector &derivative_norm); + Vector &derivative_norm, + const unsigned int component = 0); /** * This function is the analogue @@ -195,12 +202,19 @@ class DerivativeApproximation * 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 static void approximate_second_derivative (const DoFHandler &dof, const Vector &solution, - Vector &derivative_norm); + Vector &derivative_norm, + const unsigned int component); /** * Exception @@ -268,7 +282,8 @@ class DerivativeApproximation */ static ProjectedDerivative get_projected_derivative (const FEValues &fe_values, - const Vector &solution); + const Vector &solution, + const unsigned int component); /** * Return the norm of the @@ -347,7 +362,8 @@ class DerivativeApproximation */ static ProjectedDerivative get_projected_derivative (const FEValues &fe_values, - const Vector &solution); + const Vector &solution, + const unsigned int component); /** * Return the norm of the @@ -404,11 +420,17 @@ class DerivativeApproximation * 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 static void approximate_derivative (const DoFHandler &dof, const Vector &solution, + const unsigned int component, Vector &derivative_norm); /** @@ -421,8 +443,9 @@ class DerivativeApproximation static void approximate (const DoFHandler &dof, const Vector &solution, + const unsigned int component, const IndexInterval &index_interval, - Vector &derivative_norm); + Vector &derivative_norm); }; diff --git a/deal.II/deal.II/source/numerics/derivative_approximation.cc b/deal.II/deal.II/source/numerics/derivative_approximation.cc index 78433a828b..21185db451 100644 --- a/deal.II/deal.II/source/numerics/derivative_approximation.cc +++ b/deal.II/deal.II/source/numerics/derivative_approximation.cc @@ -42,11 +42,22 @@ inline typename DerivativeApproximation::Gradient::ProjectedDerivative DerivativeApproximation::Gradient:: get_projected_derivative (const FEValues &fe_values, - const Vector &solution) + const Vector &solution, + const unsigned int component) { - vector values (1); - fe_values.get_function_values (solution, values); - return values[0]; + if (fe_values.get_fe().n_components() == 1) + { + vector values (1); + fe_values.get_function_values (solution, values); + return values[0]; + } + else + { + vector > values + (1, Vector(fe_values.get_fe().n_components())); + fe_values.get_function_values (solution, values); + return values[0](component); + }; }; @@ -79,11 +90,22 @@ inline typename DerivativeApproximation::SecondDerivative::ProjectedDerivative DerivativeApproximation::SecondDerivative:: get_projected_derivative (const FEValues &fe_values, - const Vector &solution) + const Vector &solution, + const unsigned int component) { - vector values (1); - fe_values.get_function_grads (solution, values); - return values[0]; + if (fe_values.get_fe().n_components() == 1) + { + vector values (1); + fe_values.get_function_grads (solution, values); + return values[0]; + } + else + { + vector > values + (1, vector(fe_values.get_fe().n_components())); + fe_values.get_function_grads (solution, values); + return values[0][component]; + }; }; @@ -169,10 +191,12 @@ void DerivativeApproximation:: approximate_gradient (const DoFHandler &dof_handler, const Vector &solution, - Vector &derivative_norm) + Vector &derivative_norm, + const unsigned int component) { approximate_derivative,dim> (dof_handler, solution, + component, derivative_norm); }; @@ -183,10 +207,12 @@ void DerivativeApproximation:: approximate_second_derivative (const DoFHandler &dof_handler, const Vector &solution, - Vector &derivative_norm) + Vector &derivative_norm, + const unsigned int component) { approximate_derivative,dim> (dof_handler, solution, + component, derivative_norm); }; @@ -197,6 +223,7 @@ void DerivativeApproximation:: approximate_derivative (const DoFHandler &dof_handler, const Vector &solution, + const unsigned int component, Vector &derivative_norm) { Assert (derivative_norm.size() == dof_handler.get_tria().n_active_cells(), @@ -215,7 +242,7 @@ approximate_derivative (const DoFHandler &dof_handler, Threads::encapsulate (&DerivativeApproximation:: template approximate) - .collect_args (dof_handler, solution, + .collect_args (dof_handler, solution, component, index_intervals[i], derivative_norm)); thread_manager.wait (); @@ -227,6 +254,7 @@ template void DerivativeApproximation::approximate (const DoFHandler &dof_handler, const Vector &solution, + const unsigned int component, const IndexInterval &index_interval, Vector &derivative_norm) { @@ -278,7 +306,8 @@ DerivativeApproximation::approximate (const DoFHandler &dof_handler, 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 this_center = fe_midpoint_value.quadrature_point(0); @@ -364,7 +393,7 @@ DerivativeApproximation::approximate (const DoFHandler &dof_handler, 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 @@ -446,14 +475,16 @@ void DerivativeApproximation:: approximate_gradient (const DoFHandler &dof_handler, const Vector &solution, - Vector &derivative_norm); + Vector &derivative_norm, + const unsigned int component); template void DerivativeApproximation:: approximate_second_derivative (const DoFHandler &dof_handler, const Vector &solution, - Vector &derivative_norm); + Vector &derivative_norm, + const unsigned int component); -- 2.39.5