From: hartmann Date: Tue, 27 Mar 2001 11:45:29 +0000 (+0000) Subject: Extend several functions to work on arbitrary Mappings. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=045ef579fc7ccb42f48395d1eb6ff0111d076b3d;p=dealii-svn.git Extend several functions to work on arbitrary Mappings. git-svn-id: https://svn.dealii.org/trunk@4296 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/numerics/vectors.h b/deal.II/deal.II/include/numerics/vectors.h index 0618f28b0a..8ccd50bcd3 100644 --- a/deal.II/deal.II/include/numerics/vectors.h +++ b/deal.II/deal.II/include/numerics/vectors.h @@ -20,6 +20,7 @@ template class QGauss2; template class Vector; template class FullMatrix; +template class Mapping; template class DoFHandler; class ConstraintMatrix; @@ -278,6 +279,17 @@ class VectorTools * class for further information. */ template + static void interpolate (const Mapping &mapping, + const DoFHandler &dof, + const Function &function, + Vector &vec); + + /** + * Calls the @p{interpolate} + * function, see above, with + * @p{mapping=MappingQ1()}. + */ + template static void interpolate (const DoFHandler &dof, const Function &function, Vector &vec); @@ -358,11 +370,23 @@ class VectorTools * class for further information. */ template - static void create_right_hand_side (const DoFHandler &dof, - const Quadrature &q, - const Function &rhs, - Vector &rhs_vector); + static void create_right_hand_side (const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &q, + const Function &rhs, + Vector &rhs_vector); + /** + * Calls the @p{create_right_hand_side} + * function, see above, with + * @p{mapping=MappingQ1()}. + */ + template + static void create_right_hand_side (const DoFHandler &dof, + const Quadrature &q, + const Function &rhs, + Vector &rhs_vector); + /** * Prepare Dirichlet boundary conditions. * Make up the list of nodes subject @@ -407,9 +431,22 @@ class VectorTools * information. */ template - static void interpolate_boundary_values (const DoFHandler &dof, - const unsigned char boundary_component, - const Function &boundary_function, + static void interpolate_boundary_values (const Mapping &mapping, + const DoFHandler &dof, + const unsigned char boundary_component, + const Function &boundary_function, + std::map &boundary_values, + const std::vector &component_mask = std::vector()); + + /** + * Calls the @p{interpolate_boundary_values} + * function, see above, with + * @p{mapping=MappingQ1()}. + */ + template + static void interpolate_boundary_values (const DoFHandler &dof, + const unsigned char boundary_component, + const Function &boundary_function, std::map &boundary_values, const std::vector &component_mask = std::vector()); @@ -491,13 +528,28 @@ class VectorTools * class for more information. */ template - static void integrate_difference (const DoFHandler &dof, - const Vector &fe_function, - const Function &exact_solution, - Vector &difference, - const Quadrature &q, - const NormType &norm, - const Function *weight=0); + static void integrate_difference (const Mapping &mapping, + const DoFHandler &dof, + const Vector &fe_function, + const Function &exact_solution, + Vector &difference, + const Quadrature &q, + const NormType &norm, + const Function *weight=0); + + /** + * Calls the @p{integrate_difference} + * function, see above, with + * @p{mapping=MappingQ1()}. + */ + template + static void integrate_difference (const DoFHandler &dof, + const Vector &fe_function, + const Function &exact_solution, + Vector &difference, + const Quadrature &q, + const NormType &norm, + const Function *weight=0); /** * Mean-value filter for Stokes. @@ -521,6 +573,7 @@ class VectorTools * be computed and later * subtracted. */ +// TODO: Implementation of subtract_mean_value is missing. static void subtract_mean_value(Vector &v, const std::vector &p_select); @@ -551,11 +604,23 @@ class VectorTools * boundaries for the velocities. */ template - static double compute_mean_value (const DoFHandler &dof, + static double compute_mean_value (const Mapping &mapping, + const DoFHandler &dof, const Quadrature &quadrature, Vector &v, - const unsigned int component); + const unsigned int component); + /** + * Calls the @p{integrate_difference} + * function, see above, with + * @p{mapping=MappingQ1()}. + */ + template + static double compute_mean_value (const DoFHandler &dof, + const Quadrature &quadrature, + Vector &v, + const unsigned int component); + /** * Exception */ diff --git a/deal.II/deal.II/source/numerics/vectors.cc b/deal.II/deal.II/source/numerics/vectors.cc index a71c8cab9b..95cb3a9f8a 100644 --- a/deal.II/deal.II/source/numerics/vectors.cc +++ b/deal.II/deal.II/source/numerics/vectors.cc @@ -66,7 +66,8 @@ inline double sqr_point (const Tensor<1,dim> &p) template -void VectorTools::interpolate (const DoFHandler &dof, +void VectorTools::interpolate (const Mapping &mapping, + const DoFHandler &dof, const Function &function, Vector &vec) { @@ -169,10 +170,9 @@ void VectorTools::interpolate (const DoFHandler &dof, // to feed it into FEValues Quadrature support_quadrature(unit_support_points, dummy_weights); -//TODO: Higher order mapping? // Transformed support points are computed by // FEValues - FEValues fe_values (mapping_q1, fe, support_quadrature, update_q_points); + FEValues fe_values (mapping, fe, support_quadrature, update_q_points); for (; cell!=endc; ++cell) { @@ -228,6 +228,16 @@ void VectorTools::interpolate (const DoFHandler &dof, } +template +void VectorTools::interpolate (const DoFHandler &dof, + const Function &function, + Vector &vec) +{ + static const MappingQ1 mapping; + interpolate(mapping, dof, function, vec); +} + + template void @@ -395,7 +405,7 @@ void VectorTools::project (const DoFHandler &dof, MatrixCreator::create_mass_matrix (dof, quadrature, mass_matrix); - VectorTools::create_right_hand_side (dof, quadrature, function, tmp); + VectorTools::create_right_hand_side (mapping_q1, dof, quadrature, function, tmp); constraints.condense (mass_matrix); constraints.condense (tmp); @@ -420,10 +430,11 @@ void VectorTools::project (const DoFHandler &dof, template -void VectorTools::create_right_hand_side (const DoFHandler &dof_handler, - const Quadrature &quadrature, - const Function &rhs_function, - Vector &rhs_vector) +void VectorTools::create_right_hand_side (const Mapping &mapping, + const DoFHandler &dof_handler, + const Quadrature &quadrature, + const Function &rhs_function, + Vector &rhs_vector) { const FiniteElement &fe = dof_handler.get_fe(); Assert (fe.n_components() == rhs_function.n_components, @@ -435,7 +446,7 @@ void VectorTools::create_right_hand_side (const DoFHandler &dof_handler, UpdateFlags update_flags = UpdateFlags(update_values | update_q_points | update_JxW_values); - FEValues fe_values (mapping_q1, fe, quadrature, update_flags); + FEValues fe_values (mapping, fe, quadrature, update_flags); const unsigned int dofs_per_cell = fe_values.dofs_per_cell, n_q_points = fe_values.n_quadrature_points, @@ -506,6 +517,17 @@ void VectorTools::create_right_hand_side (const DoFHandler &dof_handler, }; +template +void VectorTools::create_right_hand_side (const DoFHandler &dof_handler, + const Quadrature &quadrature, + const Function &rhs_function, + Vector &rhs_vector) +{ + static const MappingQ1 mapping; + create_right_hand_side(mapping, dof_handler, quadrature, + rhs_function, rhs_vector); +} + #if deal_II_dimension == 1 @@ -586,9 +608,10 @@ VectorTools::interpolate_boundary_values (const DoFHandler<1> &dof, template void -VectorTools::interpolate_boundary_values (const DoFHandler &dof, - const unsigned char boundary_component, - const Function &boundary_function, +VectorTools::interpolate_boundary_values (const Mapping &mapping, + const DoFHandler &dof, + const unsigned char boundary_component, + const Function &boundary_function, std::map &boundary_values, const std::vector &component_mask_) { @@ -641,7 +664,7 @@ VectorTools::interpolate_boundary_values (const DoFHandler &dof, std::vector dummy_weights (unit_support_points.size()); Quadrature aux_quad (unit_support_points, dummy_weights); - FEFaceValues fe_values (mapping_q1, fe, aux_quad, update_q_points); + FEFaceValues fe_values (mapping, fe, aux_quad, update_q_points); DoFHandler::active_cell_iterator cell = dof.begin_active(), endc = dof.end(); @@ -691,7 +714,21 @@ VectorTools::interpolate_boundary_values (const DoFHandler &dof, } - +template +void +VectorTools::interpolate_boundary_values (const DoFHandler &dof, + const unsigned char boundary_component, + const Function &boundary_function, + std::map &boundary_values, + const std::vector &component_mask) +{ + static const MappingQ1 mapping; + interpolate_boundary_values(mapping, dof, boundary_component, + boundary_function, boundary_values, component_mask); +} + + + template void VectorTools::project_boundary_values (const DoFHandler &dof, @@ -782,13 +819,14 @@ VectorTools::project_boundary_values (const DoFHandler &dof, template void -VectorTools::integrate_difference (const DoFHandler &dof, - const Vector &fe_function, - const Function &exact_solution, - Vector &difference, - const Quadrature &q, - const NormType &norm, - const Function *weight) +VectorTools::integrate_difference (const Mapping &mapping, + const DoFHandler &dof, + const Vector &fe_function, + const Function &exact_solution, + Vector &difference, + const Quadrature &q, + const NormType &norm, + const Function *weight) { const unsigned int n_q_points = q.n_quadrature_points; const FiniteElement &fe = dof.get_fe(); @@ -814,7 +852,7 @@ VectorTools::integrate_difference (const DoFHandler &dof, if ((norm==H1_seminorm) || (norm==H1_norm)) update_flags = UpdateFlags (update_flags | update_gradients); - FEValues fe_values(mapping_q1, fe, q, update_flags); + FEValues fe_values(mapping, fe, q, update_flags); std::vector< Vector > function_values (n_q_points, Vector(n_components)); @@ -1110,18 +1148,36 @@ VectorTools::integrate_difference (const DoFHandler &dof, }; +template +void +VectorTools::integrate_difference (const DoFHandler &dof, + const Vector &fe_function, + const Function &exact_solution, + Vector &difference, + const Quadrature &q, + const NormType &norm, + const Function *weight) +{ + static const MappingQ1 mapping; + integrate_difference(mapping, dof, fe_function, exact_solution, + difference, q, norm, weight); +} + + + template double -VectorTools::compute_mean_value (const DoFHandler &dof, +VectorTools::compute_mean_value (const Mapping &mapping, + const DoFHandler &dof, const Quadrature &quadrature, Vector &v, - const unsigned int component) + const unsigned int component) { Assert (component < dof.get_fe().n_components(), ExcIndexRange(component, 0, dof.get_fe().n_components())); - FEValues fe(mapping_q1, dof.get_fe(), quadrature, + FEValues fe(mapping, dof.get_fe(), quadrature, UpdateFlags(update_JxW_values | update_values)); @@ -1147,11 +1203,55 @@ VectorTools::compute_mean_value (const DoFHandler &dof, }; - +template +double +VectorTools::compute_mean_value (const DoFHandler &dof, + const Quadrature &quadrature, + Vector &v, + const unsigned int component) +{ + static const MappingQ1 mapping; + return compute_mean_value(mapping, dof, quadrature, v, component); +} // explicit instantiations template +void VectorTools::interpolate (const Mapping &, + const DoFHandler &, + const Function &, + Vector &); +template +void VectorTools::interpolate (const DoFHandler &, + const Function &, + Vector &); +template +void VectorTools::interpolate(const DoFHandler &, + const DoFHandler &, + const FullMatrix &, + const Vector &, + Vector &); +template +void VectorTools::create_right_hand_side (const Mapping &, + const DoFHandler &, + const Quadrature &, + const Function &, + Vector &); +template +void VectorTools::create_right_hand_side (const DoFHandler &, + const Quadrature &, + const Function &, + Vector &); +template +void VectorTools::integrate_difference (const Mapping &, + const DoFHandler &, + const Vector &, + const Function &, + Vector &, + const Quadrature &, + const NormType &, + const Function *); +template void VectorTools::integrate_difference (const DoFHandler &, const Vector &, const Function &, @@ -1164,34 +1264,30 @@ void VectorTools::project_boundary_values (const DoFHandler const std::map*>&, const Quadrature&, std::map &); - -template -void VectorTools::create_right_hand_side (const DoFHandler &, - const Quadrature &, - const Function &, - Vector &); -template -void VectorTools::interpolate(const DoFHandler &, - const DoFHandler &, - const FullMatrix &, - const Vector &, - Vector &); template -void VectorTools::interpolate (const DoFHandler &, - const Function &, - Vector &); - +double VectorTools::compute_mean_value (const Mapping &, + const DoFHandler &, + const Quadrature &, + Vector &, + const unsigned int); template -double VectorTools::compute_mean_value (const DoFHandler &dof, - const Quadrature &quadrature, - Vector &v, - const unsigned int component); +double VectorTools::compute_mean_value (const DoFHandler &, + const Quadrature &, + Vector &, + const unsigned int); // the following two functions are not derived from a template in 1d // and thus need no explicit instantiation #if deal_II_dimension > 1 template +void VectorTools::interpolate_boundary_values (const Mapping &, + const DoFHandler &, + const unsigned char, + const Function &, + std::map &, + const std::vector &); +template void VectorTools::interpolate_boundary_values (const DoFHandler &, const unsigned char, const Function &,