From: Wolfgang Bangerth Date: Mon, 24 Aug 2015 02:35:41 +0000 (-0500) Subject: Move a bunch of internal functions into anonymous namespaces. X-Git-Tag: v8.4.0-rc2~550^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b63747c36c882daeb7bc79dc4720c40cef4e5d5;p=dealii.git Move a bunch of internal functions into anonymous namespaces. The MappingQ1 class had a bunch of internal functions that were part of the class declaration but are in fact only ever used internally and do not need a whole lot of information from the class itself. Move these functions into an anonymous namespace in the .cc file so as to keep the external interface of the class as small as possible. --- diff --git a/include/deal.II/fe/mapping_q1.h b/include/deal.II/fe/mapping_q1.h index 14a1cba1cb..c735f065ae 100644 --- a/include/deal.II/fe/mapping_q1.h +++ b/include/deal.II/fe/mapping_q1.h @@ -103,6 +103,7 @@ public: const typename Mapping::InternalDataBase &internal, const MappingType type) const; + // for documentation, see the Mapping base class virtual void transform (const VectorSlice > > input, @@ -110,6 +111,7 @@ public: const typename Mapping::InternalDataBase &internal, const MappingType type) const; + // for documentation, see the Mapping base class virtual void transform (const VectorSlice > > input, @@ -117,6 +119,7 @@ public: const typename Mapping::InternalDataBase &internal, const MappingType type) const; + // for documentation, see the Mapping base class virtual void transform (const VectorSlice > > input, @@ -124,58 +127,17 @@ public: const typename Mapping::InternalDataBase &internal, const MappingType type) const; + // for documentation, see the Mapping base class virtual void transform (const VectorSlice > > input, VectorSlice > > output, const typename Mapping::InternalDataBase &internal, const MappingType type) const; - // for documentation, see the Mapping base class - - -protected: - /** - * This function and the next ones allow to generate the transform required by the - * virtual transform() in mapping, but unfortunately in C++ one cannot - * declare a virtual template function. - */ - template < int rank > - void - transform_fields(const VectorSlice > > input, - VectorSlice< std::vector > > output, - const typename Mapping::InternalDataBase &internal, - const MappingType type) const; /** - * see doc in transform_fields - */ - template < int rank > - void - transform_gradients(const VectorSlice > > input, - VectorSlice< std::vector > > output, - const typename Mapping::InternalDataBase &internal, - const MappingType type) const; - - /** - * see doc in transform_fields - */ - void - transform_hessians(const VectorSlice > > input, - VectorSlice > > output, - const typename Mapping::InternalDataBase &internal, - const MappingType mapping_type) const; - - /** - * see doc in transform_fields + * @} */ - template < int rank > - void - transform_differential_forms( - const VectorSlice > > input, - VectorSlice > > output, - const typename Mapping::InternalDataBase &internal, - const MappingType type) const; - /** * @name Interface with FEValues diff --git a/source/fe/mapping_q1.cc b/source/fe/mapping_q1.cc index 3de4e63f44..b1e4ec2a6e 100644 --- a/source/fe/mapping_q1.cc +++ b/source/fe/mapping_q1.cc @@ -1298,6 +1298,305 @@ fill_fe_subface_values (const typename Triangulation::cell_iterato +namespace +{ + template + void + transform_fields(const VectorSlice > > input, + VectorSlice > > output, + const typename Mapping::InternalDataBase &mapping_data, + const MappingType mapping_type) + { + AssertDimension (input.size(), output.size()); + Assert ((dynamic_cast::InternalData *>(&mapping_data) != 0), + ExcInternalError()); + const typename MappingQ1::InternalData + &data = static_cast::InternalData &>(mapping_data); + + switch (mapping_type) + { + case mapping_contravariant: + { + Assert (data.update_each & update_contravariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField("update_contravariant_transformation")); + + for (unsigned int i=0; i::ExcAccessToUninitializedField("update_contravariant_transformation")); + Assert (data.update_each & update_volume_elements, + typename FEValuesBase::ExcAccessToUninitializedField("update_volume_elements")); + Assert (rank==1, ExcMessage("Only for rank 1")); + if (rank!=1) + return; + + for (unsigned int i=0; i::ExcAccessToUninitializedField("update_covariant_transformation")); + + for (unsigned int i=0; i + void + transform_gradients(const VectorSlice > > input, + VectorSlice > > output, + const typename Mapping::InternalDataBase &mapping_data, + const MappingType mapping_type) + { + AssertDimension (input.size(), output.size()); + Assert ((dynamic_cast::InternalData *>(&mapping_data) != 0), + ExcInternalError()); + const typename MappingQ1::InternalData + &data = static_cast::InternalData &>(mapping_data); + + switch (mapping_type) + { + case mapping_contravariant_gradient: + { + Assert (data.update_each & update_covariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField("update_covariant_transformation")); + Assert (data.update_each & update_contravariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField("update_contravariant_transformation")); + Assert (rank==2, ExcMessage("Only for rank 2")); + + for (unsigned int i=0; i A = + apply_transformation(data.contravariant[i], transpose(input[i]) ); + output[i] = apply_transformation(data.covariant[i], A.transpose() ); + } + + return; + } + + case mapping_covariant_gradient: + { + Assert (data.update_each & update_covariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField("update_covariant_transformation")); + Assert (rank==2, ExcMessage("Only for rank 2")); + + for (unsigned int i=0; i A = + apply_transformation(data.covariant[i], transpose(input[i]) ); + output[i] = apply_transformation(data.covariant[i], A.transpose() ); + } + + return; + } + + case mapping_piola_gradient: + { + Assert (data.update_each & update_covariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField("update_covariant_transformation")); + Assert (data.update_each & update_contravariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField("update_contravariant_transformation")); + Assert (data.update_each & update_volume_elements, + typename FEValuesBase::ExcAccessToUninitializedField("update_volume_elements")); + Assert (rank==2, ExcMessage("Only for rank 2")); + + for (unsigned int i=0; i A = + apply_transformation(data.covariant[i], input[i] ); + Tensor<2,spacedim> T = + apply_transformation(data.contravariant[i], A.transpose() ); + + output[i] = transpose(T); + output[i] /= data.volume_elements[i]; + } + + return; + } + + default: + Assert(false, ExcNotImplemented()); + } + } + + + + + template + void + transform_hessians(const VectorSlice > > input, + VectorSlice > > output, + const typename Mapping::InternalDataBase &mapping_data, + const MappingType mapping_type) + { + AssertDimension (input.size(), output.size()); + Assert ((dynamic_cast::InternalData *>(&mapping_data) != 0), + ExcInternalError()); + const typename MappingQ1::InternalData + &data = static_cast::InternalData &>(mapping_data); + + switch (mapping_type) + { + case mapping_contravariant_hessian: + { + Assert (data.update_each & update_covariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField("update_covariant_transformation")); + Assert (data.update_each & update_contravariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField("update_contravariant_transformation")); + + for (unsigned int q=0; q::ExcAccessToUninitializedField("update_covariant_transformation")); + + for (unsigned int q=0; q::ExcAccessToUninitializedField("update_covariant_transformation")); + Assert (data.update_each & update_contravariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField("update_contravariant_transformation")); + Assert (data.update_each & update_volume_elements, + typename FEValuesBase::ExcAccessToUninitializedField("update_volume_elements")); + + for (unsigned int q=0; q + void + transform_differential_forms(const VectorSlice > > input, + VectorSlice > > output, + const typename Mapping::InternalDataBase &mapping_data, + const MappingType mapping_type) + { + AssertDimension (input.size(), output.size()); + Assert ((dynamic_cast::InternalData *>(&mapping_data) != 0), + ExcInternalError()); + const typename MappingQ1::InternalData + &data = static_cast::InternalData &>(mapping_data); + + switch (mapping_type) + { + case mapping_covariant: + { + Assert (data.update_each & update_contravariant_transformation, + typename FEValuesBase::ExcAccessToUninitializedField("update_covariant_transformation")); + + for (unsigned int i=0; i void MappingQ1::transform ( @@ -1319,9 +1618,7 @@ MappingQ1::transform ( const typename Mapping::InternalDataBase &mapping_data, const MappingType mapping_type) const { - transform_differential_forms(input, output, mapping_data, mapping_type); - } @@ -1334,7 +1631,6 @@ MappingQ1::transform ( const typename Mapping::InternalDataBase &mapping_data, const MappingType mapping_type) const { - switch (mapping_type) { case mapping_contravariant: @@ -1349,7 +1645,6 @@ MappingQ1::transform ( default: Assert(false, ExcNotImplemented()); } - } @@ -1395,12 +1690,14 @@ MappingQ1::transform ( } return; } + default: Assert(false, ExcNotImplemented()); } - } + + template void MappingQ1::transform ( @@ -1423,302 +1720,6 @@ MappingQ1::transform ( } -template -template < int rank > -void MappingQ1::transform_fields( - const VectorSlice > > input, - VectorSlice > > output, - const typename Mapping::InternalDataBase &mapping_data, - const MappingType mapping_type) const -{ - AssertDimension (input.size(), output.size()); - Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); - const InternalData &data = static_cast(mapping_data); - - switch (mapping_type) - { - case mapping_contravariant: - { - Assert (data.update_each & update_contravariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField("update_contravariant_transformation")); - - for (unsigned int i=0; i::ExcAccessToUninitializedField("update_contravariant_transformation")); - Assert (data.update_each & update_volume_elements, - typename FEValuesBase::ExcAccessToUninitializedField("update_volume_elements")); - Assert (rank==1, ExcMessage("Only for rank 1")); - if (rank!=1) - return; - - for (unsigned int i=0; i::ExcAccessToUninitializedField("update_covariant_transformation")); - - for (unsigned int i=0; i -template < int rank > -void MappingQ1::transform_gradients( - const VectorSlice > > input, - VectorSlice > > output, - const typename Mapping::InternalDataBase &mapping_data, - const MappingType mapping_type) const -{ - AssertDimension (input.size(), output.size()); - Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); - const InternalData &data = static_cast(mapping_data); - - switch (mapping_type) - { - case mapping_contravariant_gradient: - { - Assert (data.update_each & update_covariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField("update_covariant_transformation")); - Assert (data.update_each & update_contravariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField("update_contravariant_transformation")); - Assert (rank==2, ExcMessage("Only for rank 2")); - - for (unsigned int i=0; i A = - apply_transformation(data.contravariant[i], transpose(input[i]) ); - output[i] = apply_transformation(data.covariant[i], A.transpose() ); - } - - return; - } - - case mapping_covariant_gradient: - { - Assert (data.update_each & update_covariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField("update_covariant_transformation")); - Assert (rank==2, ExcMessage("Only for rank 2")); - - for (unsigned int i=0; i A = - apply_transformation(data.covariant[i], transpose(input[i]) ); - output[i] = apply_transformation(data.covariant[i], A.transpose() ); - } - - return; - } - - case mapping_piola_gradient: - { - Assert (data.update_each & update_covariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField("update_covariant_transformation")); - Assert (data.update_each & update_contravariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField("update_contravariant_transformation")); - Assert (data.update_each & update_volume_elements, - typename FEValuesBase::ExcAccessToUninitializedField("update_volume_elements")); - Assert (rank==2, ExcMessage("Only for rank 2")); - - for (unsigned int i=0; i A = - apply_transformation(data.covariant[i], input[i] ); - Tensor<2,spacedim> T = - apply_transformation(data.contravariant[i], A.transpose() ); - - output[i] = transpose(T); - output[i] /= data.volume_elements[i]; - } - - return; - } - - default: - Assert(false, ExcNotImplemented()); - } -} - - - - -template -void MappingQ1::transform_hessians( - const VectorSlice > > input, - VectorSlice > > output, - const typename Mapping::InternalDataBase &mapping_data, - const MappingType mapping_type) const -{ - AssertDimension (input.size(), output.size()); - Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); - const InternalData &data = static_cast(mapping_data); - - switch (mapping_type) - { - case mapping_contravariant_hessian: - { - Assert (data.update_each & update_covariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField("update_covariant_transformation")); - Assert (data.update_each & update_contravariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField("update_contravariant_transformation")); - - for (unsigned int q=0; q::ExcAccessToUninitializedField("update_covariant_transformation")); - - for (unsigned int q=0; q::ExcAccessToUninitializedField("update_covariant_transformation")); - Assert (data.update_each & update_contravariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField("update_contravariant_transformation")); - Assert (data.update_each & update_volume_elements, - typename FEValuesBase::ExcAccessToUninitializedField("update_volume_elements")); - - for (unsigned int q=0; q -template < int rank > -void MappingQ1::transform_differential_forms( - const VectorSlice > > input, - VectorSlice > > output, - const typename Mapping::InternalDataBase &mapping_data, - const MappingType mapping_type) const -{ - - AssertDimension (input.size(), output.size()); - Assert (dynamic_cast(&mapping_data) != 0, - ExcInternalError()); - const InternalData &data = static_cast(mapping_data); - - switch (mapping_type) - { - case mapping_covariant: - { - Assert (data.update_each & update_contravariant_transformation, - typename FEValuesBase::ExcAccessToUninitializedField("update_covariant_transformation")); - - for (unsigned int i=0; i