From 41d9c5cbc6f9c14aaa258b89c9521823d139b6e9 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 22 Jul 2015 16:49:36 -0500 Subject: [PATCH] Make the internal data object of the mapping classes const. Logically, they are input arguments to the fill_fe_values() functions, they are only initialized in get_data() etc. Thus, make them const in the fill_fe_values functions. There are places where mapping classes want to move data across from fill_fe_values in terms of temporary arrays to the transform() function that may be called right afterwards from FiniteElement::fill_fe_values(). In those cases, make these members mutable. --- include/deal.II/fe/mapping.h | 11 +++---- include/deal.II/fe/mapping_cartesian.h | 19 ++++++++---- include/deal.II/fe/mapping_fe_field.h | 28 ++++++++--------- include/deal.II/fe/mapping_q.h | 8 ++--- include/deal.II/fe/mapping_q1.h | 38 +++++++++++------------ source/fe/mapping_cartesian.cc | 20 ++++++------ source/fe/mapping_fe_field.cc | 22 +++++++------- source/fe/mapping_q.cc | 42 ++++++++++++++------------ source/fe/mapping_q1.cc | 24 +++++++-------- 9 files changed, 110 insertions(+), 102 deletions(-) diff --git a/include/deal.II/fe/mapping.h b/include/deal.II/fe/mapping.h index a70abd7b6d..cd5d6cf75a 100644 --- a/include/deal.II/fe/mapping.h +++ b/include/deal.II/fe/mapping.h @@ -324,7 +324,7 @@ public: * The determinant of the Jacobian in each quadrature point. Filled if * #update_volume_elements. */ - std::vector volume_elements; + mutable std::vector volume_elements; /** * The positions of the mapped (generalized) support points. @@ -644,15 +644,14 @@ private: CellSimilarity::Similarity fill_fe_values (const typename Triangulation::cell_iterator &cell, const Quadrature &quadrature, - InternalDataBase &internal, + const InternalDataBase &internal, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &jacobians, std::vector > &jacobian_grads, std::vector > &inverse_jacobians, std::vector > &cell_normal_vectors, - const CellSimilarity::Similarity cell_similarity - ) const=0; + const CellSimilarity::Similarity cell_similarity) const=0; @@ -670,7 +669,7 @@ private: fill_fe_face_values (const typename Triangulation::cell_iterator &cell, const unsigned int face_no, const Quadrature &quadrature, - InternalDataBase &internal, + const InternalDataBase &internal, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &boundary_form, @@ -686,7 +685,7 @@ private: const unsigned int face_no, const unsigned int sub_no, const Quadrature &quadrature, - InternalDataBase &internal, + const InternalDataBase &internal, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &boundary_form, diff --git a/include/deal.II/fe/mapping_cartesian.h b/include/deal.II/fe/mapping_cartesian.h index cb3b7a8505..2d151d82b2 100644 --- a/include/deal.II/fe/mapping_cartesian.h +++ b/include/deal.II/fe/mapping_cartesian.h @@ -73,7 +73,7 @@ public: CellSimilarity::Similarity fill_fe_values (const typename Triangulation::cell_iterator &cell, const Quadrature &quadrature, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &jacobians, @@ -87,7 +87,7 @@ public: fill_fe_face_values (const typename Triangulation::cell_iterator &cell, const unsigned int face_no, const Quadrature& quadrature, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &boundary_form, @@ -99,7 +99,7 @@ public: const unsigned int face_no, const unsigned int sub_no, const Quadrature& quadrature, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &boundary_form, @@ -160,6 +160,13 @@ public: protected: /** * Storage for internal data of the scaling. + * + * This includes data that is computed once when the object is created + * (in get_data()) as well as data the class wants to store from between + * the call to fill_fe_values(), fill_fe_face_values(), or + * fill_fe_subface_values() until possible later calls from the finite + * element to functions such as transform(). The latter class of + * member variables are marked as 'mutable'. */ class InternalData : public Mapping::InternalDataBase { @@ -178,12 +185,12 @@ protected: * Length of the cell in different coordinate directions, * hx, hy, hz. */ - Tensor<1,dim> length; + mutable Tensor<1,dim> length; /** * The volume element */ - double volume_element; + mutable double volume_element; /** * Vector of all quadrature points. Especially, all points on all faces. @@ -198,7 +205,7 @@ protected: const unsigned int face_no, const unsigned int sub_no, const CellSimilarity::Similarity cell_similarity, - InternalData &data, + const InternalData &data, std::vector > &quadrature_points, std::vector > &normal_vectors) const; diff --git a/include/deal.II/fe/mapping_fe_field.h b/include/deal.II/fe/mapping_fe_field.h index 8324e956f4..66ede96660 100644 --- a/include/deal.II/fe/mapping_fe_field.h +++ b/include/deal.II/fe/mapping_fe_field.h @@ -208,8 +208,8 @@ public: * Shape function at quadrature point. Shape functions are in tensor * product order, so vertices must be reordered to obtain transformation. */ - double shape (const unsigned int qpoint, - const unsigned int shape_nr) const; + const double &shape (const unsigned int qpoint, + const unsigned int shape_nr) const; /** * Shape function at quadrature point. See above. @@ -220,8 +220,8 @@ public: /** * Gradient of shape function in quadrature point. See above. */ - Tensor<1,dim> derivative (const unsigned int qpoint, - const unsigned int shape_nr) const; + const Tensor<1,dim> &derivative (const unsigned int qpoint, + const unsigned int shape_nr) const; /** * Gradient of shape function in quadrature point. See above. @@ -277,7 +277,7 @@ public: * * Computed on each cell. */ - std::vector > covariant; + mutable std::vector > covariant; /** * Tensors of contravariant transformation at each of the quadrature @@ -286,7 +286,7 @@ public: * * Computed on each cell. */ - std::vector< DerivativeForm<1,dim,spacedim> > contravariant; + mutable std::vector< DerivativeForm<1,dim,spacedim> > contravariant; /** * Unit tangential vectors. Used for the computation of boundary forms and @@ -306,7 +306,7 @@ public: /** * Auxiliary vectors for internal use. */ - std::vector > > aux; + mutable std::vector > > aux; /** * Number of shape functions. If this is a Q1 mapping, then it is simply @@ -390,7 +390,7 @@ public: const unsigned int npts, const typename QProjector::DataSetDescriptor data_set, const CellSimilarity::Similarity cell_similarity, - InternalData &data, + const InternalData &data, std::vector > &quadrature_points) const; @@ -403,7 +403,7 @@ public: const unsigned int npts, const typename QProjector::DataSetDescriptor data_set, const std::vector &weights, - InternalData &mapping_data, + const InternalData &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &boundary_form, @@ -428,7 +428,7 @@ protected: CellSimilarity::Similarity fill_fe_values (const typename Triangulation::cell_iterator &cell, const Quadrature &quadrature, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, typename std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &jacobians, @@ -444,7 +444,7 @@ protected: fill_fe_face_values (const typename Triangulation::cell_iterator &cell, const unsigned int face_no, const Quadrature& quadrature, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, typename std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &exterior_forms, @@ -460,7 +460,7 @@ protected: const unsigned int face_no, const unsigned int sub_no, const Quadrature& quadrature, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, typename std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &exterior_forms, @@ -627,7 +627,7 @@ private: template inline -double +const double & MappingFEField::InternalData::shape (const unsigned int qpoint, const unsigned int shape_nr) const { @@ -654,7 +654,7 @@ MappingFEField::InternalData::shape (const unsigned int template inline -Tensor<1,dim> +const Tensor<1,dim> & MappingFEField::InternalData::derivative (const unsigned int qpoint, const unsigned int shape_nr) const { diff --git a/include/deal.II/fe/mapping_q.h b/include/deal.II/fe/mapping_q.h index 8bbe509fe5..3e44964e23 100644 --- a/include/deal.II/fe/mapping_q.h +++ b/include/deal.II/fe/mapping_q.h @@ -173,7 +173,7 @@ public: * If this flag is @p true we are on an interior cell and the @p * mapping_q1_data is used. */ - bool use_mapping_q1_on_current_cell; + mutable bool use_mapping_q1_on_current_cell; /** * On interior cells @p MappingQ1 is used. @@ -189,7 +189,7 @@ protected: CellSimilarity::Similarity fill_fe_values (const typename Triangulation::cell_iterator &cell, const Quadrature &quadrature, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, typename std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &jacobians, @@ -205,7 +205,7 @@ protected: fill_fe_face_values (const typename Triangulation::cell_iterator &cell, const unsigned int face_no, const Quadrature& quadrature, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, typename std::vector > &quadrature_points, std::vector &JxW_values, typename std::vector > &exterior_form, @@ -221,7 +221,7 @@ protected: const unsigned int face_no, const unsigned int sub_no, const Quadrature& quadrature, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, typename std::vector > &quadrature_points, std::vector &JxW_values, typename std::vector > &exterior_form, diff --git a/include/deal.II/fe/mapping_q1.h b/include/deal.II/fe/mapping_q1.h index df8276af0a..2b6e7a429d 100644 --- a/include/deal.II/fe/mapping_q1.h +++ b/include/deal.II/fe/mapping_q1.h @@ -167,8 +167,8 @@ public: * Shape function at quadrature point. Shape functions are in tensor * product order, so vertices must be reordered to obtain transformation. */ - double shape (const unsigned int qpoint, - const unsigned int shape_nr) const; + const double &shape (const unsigned int qpoint, + const unsigned int shape_nr) const; /** * Shape function at quadrature point. See above. @@ -179,8 +179,8 @@ public: /** * Gradient of shape function in quadrature point. See above. */ - Tensor<1,dim> derivative (const unsigned int qpoint, - const unsigned int shape_nr) const; + const Tensor<1,dim> &derivative (const unsigned int qpoint, + const unsigned int shape_nr) const; /** * Gradient of shape function in quadrature point. See above. @@ -191,8 +191,8 @@ public: /** * Second derivative of shape function in quadrature point. See above. */ - Tensor<2,dim> second_derivative (const unsigned int qpoint, - const unsigned int shape_nr) const; + const Tensor<2,dim> &second_derivative (const unsigned int qpoint, + const unsigned int shape_nr) const; /** * Second derivative of shape function in quadrature point. See above. @@ -236,7 +236,7 @@ public: * * Computed on each cell. */ - std::vector > covariant; + mutable std::vector > covariant; /** * Tensors of contravariant transformation at each of the quadrature @@ -245,7 +245,7 @@ public: * * Computed on each cell. */ - std::vector< DerivativeForm<1,dim,spacedim> > contravariant; + mutable std::vector< DerivativeForm<1,dim,spacedim> > contravariant; /** * Unit tangential vectors. Used for the computation of boundary forms and @@ -265,18 +265,18 @@ public: /** * Auxiliary vectors for internal use. */ - std::vector > > aux; + mutable std::vector > > aux; /** * Stores the support points of the mapping shape functions on the @p * cell_of_current_support_points. */ - std::vector > mapping_support_points; + mutable std::vector > mapping_support_points; /** * Stores the cell of which the @p mapping_support_points are stored. */ - typename Triangulation::cell_iterator cell_of_current_support_points; + mutable typename Triangulation::cell_iterator cell_of_current_support_points; /** * Default value of this flag is @p true. If *this is an object @@ -308,7 +308,7 @@ public: CellSimilarity::Similarity fill_fe_values (const typename Triangulation::cell_iterator &cell, const Quadrature &quadrature, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, typename std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &jacobians, @@ -324,7 +324,7 @@ public: fill_fe_face_values (const typename Triangulation::cell_iterator &cell, const unsigned int face_no, const Quadrature &quadrature, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, typename std::vector > &quadrature_points, std::vector &JxW_values, typename std::vector > &boundary_form, @@ -340,7 +340,7 @@ public: const unsigned int face_no, const unsigned int sub_no, const Quadrature& quadrature, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, typename std::vector > &quadrature_points, std::vector &JxW_values, typename std::vector > &boundary_form, @@ -386,7 +386,7 @@ public: const unsigned int npts, const DataSetDescriptor data_set, const CellSimilarity::Similarity cell_similarity, - InternalData &data, + const InternalData &data, std::vector > &quadrature_points) const; /** @@ -398,7 +398,7 @@ public: const unsigned int npts, const DataSetDescriptor data_set, const std::vector &weights, - InternalData &mapping_data, + const InternalData &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &boundary_form, @@ -633,7 +633,7 @@ struct StaticMappingQ1 template inline -double +const double & MappingQ1::InternalData::shape (const unsigned int qpoint, const unsigned int shape_nr) const { @@ -660,7 +660,7 @@ MappingQ1::InternalData::shape (const unsigned int qpoint, template inline -Tensor<1,dim> +const Tensor<1,dim> & MappingQ1::InternalData::derivative (const unsigned int qpoint, const unsigned int shape_nr) const { @@ -687,7 +687,7 @@ MappingQ1::InternalData::derivative (const unsigned int qpoint, template inline -Tensor<2,dim> +const Tensor<2,dim> & MappingQ1::InternalData::second_derivative (const unsigned int qpoint, const unsigned int shape_nr) const { diff --git a/source/fe/mapping_cartesian.cc b/source/fe/mapping_cartesian.cc index 78600e6de3..a2ae39b483 100644 --- a/source/fe/mapping_cartesian.cc +++ b/source/fe/mapping_cartesian.cc @@ -136,7 +136,7 @@ MappingCartesian::compute_fill (const typename Triangulation > &quadrature_points, std::vector > &normal_vectors) const { @@ -319,7 +319,7 @@ CellSimilarity::Similarity MappingCartesian:: fill_fe_values (const typename Triangulation::cell_iterator &cell, const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector< DerivativeForm<1,dim,spacedim> > &jacobians, @@ -332,8 +332,8 @@ fill_fe_values (const typename Triangulation::cell_iterator &cell, // data for this class. fails with // an exception if that is not // possible - Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); - InternalData &data = static_cast (mapping_data); + Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); + const InternalData &data = static_cast (mapping_data); std::vector > dummy; @@ -398,7 +398,7 @@ MappingCartesian::fill_fe_face_values ( const typename Triangulation::cell_iterator &cell, const unsigned int face_no, const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &boundary_forms, @@ -410,9 +410,9 @@ MappingCartesian::fill_fe_face_values ( // data for this class. fails with // an exception if that is not // possible - Assert (dynamic_cast (&mapping_data) != 0, + Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); - InternalData &data = static_cast (mapping_data); + const InternalData &data = static_cast (mapping_data); compute_fill (cell, face_no, invalid_face_number, CellSimilarity::none, @@ -471,7 +471,7 @@ MappingCartesian::fill_fe_subface_values ( const unsigned int face_no, const unsigned int sub_no, const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &boundary_forms, @@ -483,8 +483,8 @@ MappingCartesian::fill_fe_subface_values ( // data for this class. fails with // an exception if that is not // possible - Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); - InternalData &data = static_cast (mapping_data); + Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); + const InternalData &data = static_cast (mapping_data); compute_fill (cell, face_no, sub_no, CellSimilarity::none, data, diff --git a/source/fe/mapping_fe_field.cc b/source/fe/mapping_fe_field.cc index 703c5eb706..0acb705a55 100644 --- a/source/fe/mapping_fe_field.cc +++ b/source/fe/mapping_fe_field.cc @@ -376,7 +376,7 @@ CellSimilarity::Similarity MappingFEField::fill_fe_values ( const typename Triangulation::cell_iterator &cell, const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &jacobians, @@ -387,8 +387,8 @@ MappingFEField::fill_fe_values ( { // convert data object to internal data for this class. fails with an // exception if that is not possible - Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); - InternalData &data = static_cast (mapping_data); + Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); + const InternalData &data = static_cast (mapping_data); const unsigned int n_q_points=q.size(); const CellSimilarity::Similarity updated_cell_similarity @@ -554,7 +554,7 @@ MappingFEField::fill_fe_face_values ( const typename Triangulation::cell_iterator &cell, const unsigned int face_no, const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &exterior_forms, @@ -564,9 +564,9 @@ MappingFEField::fill_fe_face_values ( { // convert data object to internal data for this class. fails with an // exception if that is not possible - Assert (dynamic_cast (&mapping_data) != 0, + Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); - InternalData &data = static_cast (mapping_data); + const InternalData &data = static_cast (mapping_data); const unsigned int n_q_points=q.size(); this->compute_fill_face (cell, face_no, numbers::invalid_unsigned_int, @@ -591,7 +591,7 @@ MappingFEField::fill_fe_subface_values (const typename T const unsigned int face_no, const unsigned int sub_no, const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &exterior_forms, @@ -601,9 +601,9 @@ MappingFEField::fill_fe_subface_values (const typename T { // convert data object to internal data for this class. fails with an // exception if that is not possible - Assert (dynamic_cast (&mapping_data) != 0, + Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); - InternalData &data = static_cast (mapping_data); + const InternalData &data = static_cast (mapping_data); const unsigned int n_q_points=q.size(); this->compute_fill_face (cell, face_no, sub_no, @@ -967,7 +967,7 @@ MappingFEField::compute_fill ( const unsigned int n_q_points, const typename QProjector::DataSetDescriptor data_set, const CellSimilarity::Similarity cell_similarity, - InternalData &data, + const InternalData &data, std::vector > &quadrature_points) const { const UpdateFlags update_flags(data.current_update_flags()); @@ -1064,7 +1064,7 @@ MappingFEField::compute_fill_face ( const unsigned int n_q_points,//npts const typename QProjector::DataSetDescriptor data_set, const std::vector &weights, - InternalData &data, + const InternalData &data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &boundary_forms, diff --git a/source/fe/mapping_q.cc b/source/fe/mapping_q.cc index 5c60da03d7..048d611715 100644 --- a/source/fe/mapping_q.cc +++ b/source/fe/mapping_q.cc @@ -250,7 +250,7 @@ CellSimilarity::Similarity MappingQ::fill_fe_values ( const typename Triangulation::cell_iterator &cell, const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &jacobians, @@ -261,8 +261,8 @@ MappingQ::fill_fe_values ( { // convert data object to internal data for this class. fails with an // exception if that is not possible - Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); - InternalData &data = static_cast (mapping_data); + Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); + const InternalData &data = static_cast (mapping_data); // check whether this cell needs the full mapping or can be treated by a // reduced Q1 mapping, e.g. if the cell is in the interior of the domain @@ -271,7 +271,7 @@ MappingQ::fill_fe_values ( // depending on this result, use this or the other data object for the // mapping. - typename MappingQ1::InternalData * + const typename MappingQ1::InternalData * p_data = (data.use_mapping_q1_on_current_cell ? &data.mapping_q1_data @@ -309,7 +309,7 @@ MappingQ::fill_fe_face_values ( const typename Triangulation::cell_iterator &cell, const unsigned int face_no, const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &exterior_forms, @@ -319,9 +319,9 @@ MappingQ::fill_fe_face_values ( { // convert data object to internal data for this class. fails with an // exception if that is not possible - Assert (dynamic_cast (&mapping_data) != 0, + Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); - InternalData &data = static_cast (mapping_data); + const InternalData &data = static_cast (mapping_data); // check whether this cell needs the full mapping or can be treated by a // reduced Q1 mapping, e.g. if the cell is entirely in the interior of the @@ -334,11 +334,12 @@ MappingQ::fill_fe_face_values ( // depending on this result, use this or the other data object for the // mapping - typename MappingQ1::InternalData *p_data=0; - if (data.use_mapping_q1_on_current_cell) - p_data=&data.mapping_q1_data; - else - p_data=&data; + const typename MappingQ1::InternalData *p_data + = (data.use_mapping_q1_on_current_cell + ? + &data.mapping_q1_data + : + &data); const unsigned int n_q_points=q.size(); this->compute_fill_face (cell, face_no, numbers::invalid_unsigned_int, @@ -363,7 +364,7 @@ MappingQ::fill_fe_subface_values (const typename Triangulation &q, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &exterior_forms, @@ -373,9 +374,9 @@ MappingQ::fill_fe_subface_values (const typename Triangulation (&mapping_data) != 0, + Assert (dynamic_cast (&mapping_data) != 0, ExcInternalError()); - InternalData &data = static_cast (mapping_data); + const InternalData &data = static_cast (mapping_data); // check whether this cell needs the full mapping or can be treated by a // reduced Q1 mapping, e.g. if the cell is entirely in the interior of the @@ -388,11 +389,12 @@ MappingQ::fill_fe_subface_values (const typename Triangulation::InternalData *p_data=0; - if (data.use_mapping_q1_on_current_cell) - p_data=&data.mapping_q1_data; - else - p_data=&data; + const typename MappingQ1::InternalData *p_data + = (data.use_mapping_q1_on_current_cell + ? + &data.mapping_q1_data + : + &data); const unsigned int n_q_points=q.size(); this->compute_fill_face (cell, face_no, sub_no, diff --git a/source/fe/mapping_q1.cc b/source/fe/mapping_q1.cc index f2b6ce4537..a2d077e749 100644 --- a/source/fe/mapping_q1.cc +++ b/source/fe/mapping_q1.cc @@ -608,7 +608,7 @@ MappingQ1::compute_fill (const typename Triangulation > &quadrature_points) const { const UpdateFlags update_flags(data.current_update_flags()); @@ -736,7 +736,7 @@ CellSimilarity::Similarity MappingQ1::fill_fe_values ( const typename Triangulation::cell_iterator &cell, const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &jacobians, @@ -746,9 +746,9 @@ MappingQ1::fill_fe_values ( const CellSimilarity::Similarity cell_similarity) const { // ensure that the following static_cast is really correct: - Assert (dynamic_cast(&mapping_data) != 0, + Assert (dynamic_cast(&mapping_data) != 0, ExcInternalError()); - InternalData &data = static_cast(mapping_data); + const InternalData &data = static_cast(mapping_data); const unsigned int n_q_points=q.size(); @@ -926,7 +926,7 @@ namespace internal const unsigned int subface_no, const unsigned int n_q_points, const std::vector &weights, - typename dealii::MappingQ1::InternalData &data, + const typename dealii::MappingQ1::InternalData &data, std::vector &JxW_values, std::vector > &boundary_forms, std::vector > &normal_vectors, @@ -1071,7 +1071,7 @@ MappingQ1::compute_fill_face ( const unsigned int n_q_points, const DataSetDescriptor data_set, const std::vector &weights, - InternalData &data, + const InternalData &data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &boundary_forms, @@ -1095,7 +1095,7 @@ MappingQ1:: fill_fe_face_values (const typename Triangulation::cell_iterator &cell, const unsigned int face_no, const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &boundary_forms, @@ -1105,9 +1105,9 @@ fill_fe_face_values (const typename Triangulation::cell_iterator & { // ensure that the following cast // is really correct: - Assert (dynamic_cast(&mapping_data) != 0, + Assert (dynamic_cast(&mapping_data) != 0, ExcInternalError()); - InternalData &data = static_cast(mapping_data); + const InternalData &data = static_cast(mapping_data); const unsigned int n_q_points = q.size(); @@ -1137,7 +1137,7 @@ fill_fe_subface_values (const typename Triangulation::cell_iterato const unsigned int face_no, const unsigned int sub_no, const Quadrature &q, - typename Mapping::InternalDataBase &mapping_data, + const typename Mapping::InternalDataBase &mapping_data, std::vector > &quadrature_points, std::vector &JxW_values, std::vector > &boundary_forms, @@ -1147,9 +1147,9 @@ fill_fe_subface_values (const typename Triangulation::cell_iterato { // ensure that the following cast // is really correct: - Assert (dynamic_cast(&mapping_data) != 0, + Assert (dynamic_cast(&mapping_data) != 0, ExcInternalError()); - InternalData &data = static_cast(mapping_data); + const InternalData &data = static_cast(mapping_data); const unsigned int n_q_points = q.size(); -- 2.39.5