From da049f4a8e931ac2e3f115a55f4529ff35117c0f Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 18 Sep 2015 16:45:04 -0500 Subject: [PATCH] Simplify code. Instead of setting up an InternalData object everywhere, move this into the transform_real_to_unit_cell_internal() function. --- include/deal.II/fe/mapping_q_generic.h | 5 +--- source/fe/mapping_q.cc | 12 +--------- source/fe/mapping_q1.cc | 13 +--------- source/fe/mapping_q_generic.cc | 33 ++++++++++++-------------- 4 files changed, 18 insertions(+), 45 deletions(-) diff --git a/include/deal.II/fe/mapping_q_generic.h b/include/deal.II/fe/mapping_q_generic.h index 0a5838766c..8b876feebf 100644 --- a/include/deal.II/fe/mapping_q_generic.h +++ b/include/deal.II/fe/mapping_q_generic.h @@ -546,14 +546,11 @@ protected: * transformation @p initial_p_unit. Hence this function assumes that @p * mdata already includes the transformation shape values and gradients * computed at @p initial_p_unit. - * - * @p mdata will be changed by this function. */ Point transform_real_to_unit_cell_internal (const typename Triangulation::cell_iterator &cell, const Point &p, - const Point &initial_p_unit, - InternalData &mdata) const; + const Point &initial_p_unit) const; /** * For dim=2,3. Append the support points of all shape diff --git a/source/fe/mapping_q.cc b/source/fe/mapping_q.cc index fc3b674652..400d2998d6 100644 --- a/source/fe/mapping_q.cc +++ b/source/fe/mapping_q.cc @@ -495,17 +495,7 @@ transform_real_to_unit_cell (const typename Triangulation::cell_it // a better starting point to the following iteration initial_p_unit = GeometryInfo::project_to_unit_cell(initial_p_unit); - const Quadrature point_quadrature(initial_p_unit); - - UpdateFlags update_flags = update_quadrature_points | update_jacobians; - if (spacedim>dim) - update_flags |= update_jacobian_grads; - std_cxx11::unique_ptr mdata (get_data(update_flags, - point_quadrature)); - - compute_mapping_support_points (cell, mdata->mapping_support_points); - - return this->transform_real_to_unit_cell_internal(cell, p, initial_p_unit, *mdata); + return this->transform_real_to_unit_cell_internal(cell, p, initial_p_unit); } else return initial_p_unit; diff --git a/source/fe/mapping_q1.cc b/source/fe/mapping_q1.cc index 7e7edcd9ef..54001d53b2 100644 --- a/source/fe/mapping_q1.cc +++ b/source/fe/mapping_q1.cc @@ -430,23 +430,12 @@ transform_real_to_unit_cell (const typename Triangulation::cell_it // cell), then project it back into the reference cell in hopes // that this gives a better starting point to the following // iteration - const Quadrature point_quadrature(initial_p_unit); - - UpdateFlags update_flags = update_quadrature_points | update_jacobians; - if (spacedim>dim) - update_flags |= update_jacobian_grads; - - std_cxx11::unique_ptr::InternalData> - mdata (this->get_data(update_flags, - point_quadrature)); - mdata->mapping_support_points = a; // perform the Newton iteration and // return the result. note that this // statement may throw an exception, which // we simply pass up to the caller - return this->transform_real_to_unit_cell_internal(cell, p, initial_p_unit, - *mdata); + return this->transform_real_to_unit_cell_internal(cell, p, initial_p_unit); } } diff --git a/source/fe/mapping_q_generic.cc b/source/fe/mapping_q_generic.cc index 1e58ee3b82..cefa8671c8 100644 --- a/source/fe/mapping_q_generic.cc +++ b/source/fe/mapping_q_generic.cc @@ -1409,26 +1409,23 @@ template Point MappingQGeneric:: transform_real_to_unit_cell_internal -(const typename Triangulation::cell_iterator &/*cell*/, - const Point &/*p*/, - const Point &/*initial_p_unit*/, - InternalData &/*mdata*/) const +(const typename Triangulation::cell_iterator &cell, + const Point &p, + const Point &initial_p_unit) const { - // default implementation (should never be called) - Assert(false, ExcInternalError()); - return Point(); -} + const Quadrature point_quadrature(initial_p_unit); -template<> -Point<1> -MappingQGeneric<1, 1>:: -transform_real_to_unit_cell_internal -(const Triangulation<1, 1>::cell_iterator &cell, - const Point<1> &p, - const Point<1> &initial_p_unit, - InternalData &mdata) const -{ - return do_transform_real_to_unit_cell_internal(cell, p, initial_p_unit, mdata); + UpdateFlags update_flags = update_quadrature_points | update_jacobians; + if (spacedim>dim) + update_flags |= update_jacobian_grads; + std_cxx11::unique_ptr mdata (get_data(update_flags, + point_quadrature)); + + compute_mapping_support_points (cell, mdata->mapping_support_points); + + // dispatch to the various specializations for spacedim=dim, + // spacedim=dim+1, etc + return do_transform_real_to_unit_cell_internal (cell, p, initial_p_unit, *mdata); } template<> -- 2.39.5