]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use dynamic_unique_cast 6176/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Tue, 3 Apr 2018 21:55:10 +0000 (23:55 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Fri, 6 Apr 2018 17:48:20 +0000 (19:48 +0200)
include/deal.II/fe/fe_enriched.h
source/fe/fe_enriched.cc
source/fe/mapping_q.cc
source/fe/mapping_q_generic.cc

index 8e6bc535ecc5c6931b29a193d8df860bd68e63c0..0bb960451baa074e5aec87cff5b8145a746e864a 100644 (file)
@@ -476,7 +476,7 @@ protected:
      * ownership), we store the cast result in a std::unique_ptr to indicate
      * that InternalData owns the object.
      */
-    InternalData ( std::unique_ptr<typename FESystem<dim,spacedim>::InternalData> fesystem_data);
+    InternalData (std::unique_ptr<typename FESystem<dim,spacedim>::InternalData> fesystem_data);
 
     /**
      * Give read-access to the pointer to a @p InternalData of the @p
@@ -553,7 +553,7 @@ protected:
    */
   template <int dim_1>
   std::unique_ptr<typename FiniteElement<dim,spacedim>::InternalDataBase>
-  setup_data (std::unique_ptr<typename FiniteElement<dim,spacedim>::InternalDataBase> &&fes_data,
+  setup_data (std::unique_ptr<typename FESystem<dim,spacedim>::InternalData> fes_data,
               const UpdateFlags      flags,
               const Quadrature<dim_1> &quadrature) const;
 
index 164daa8a2fc05203ffc51a741610247336179971..67f191c07848d4f792d2d11c9bb1614d0fc98b55 100644 (file)
@@ -289,21 +289,17 @@ FE_Enriched<dim,spacedim>::requires_update_flags (const UpdateFlags flags) const
 template <int dim, int spacedim>
 template <int dim_1>
 std::unique_ptr<typename FiniteElement<dim,spacedim>::InternalDataBase>
-FE_Enriched<dim,spacedim>::setup_data (std::unique_ptr<typename FiniteElement<dim,spacedim>::InternalDataBase> &&fes_data,
+FE_Enriched<dim,spacedim>::setup_data (std::unique_ptr<typename FESystem<dim,spacedim>::InternalData> fes_data,
                                        const UpdateFlags      flags,
                                        const Quadrature<dim_1> &quadrature) const
 {
-  Assert ((dynamic_cast<typename FESystem<dim,spacedim>::InternalData *> (fes_data.get()) != nullptr),
-          ExcInternalError());
-
   // Pass ownership of the FiniteElement::InternalDataBase object
   // that fes_data points to, to the new InternalData object.
-  typename FESystem<dim,spacedim>::InternalData *data_fesystem =
-    static_cast<typename FESystem<dim,spacedim>::InternalData *> (fes_data.release());
-  auto data = std_cxx14::make_unique<InternalData>(std::unique_ptr<typename FESystem<dim,spacedim>::InternalData>(data_fesystem));
+  auto update_each_flags = fes_data->update_each;
+  auto data = std_cxx14::make_unique<InternalData>(std::move(fes_data));
 
   // copy update_each from FESystem data:
-  data->update_each = data_fesystem->update_each;
+  data->update_each = update_each_flags;
 
   // resize cache array according to requested flags
   data->enrichment.resize(this->n_base_elements());
@@ -337,7 +333,8 @@ FE_Enriched<dim,spacedim>::get_face_data (const UpdateFlags      update_flags,
                                           const Quadrature<dim-1> &quadrature,
                                           internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim >        &output_data) const
 {
-  return setup_data(std::unique_ptr<typename FiniteElement<dim,spacedim>::InternalDataBase>(fe_system->get_face_data(update_flags,mapping,quadrature,output_data)),
+  auto data = fe_system->get_face_data(update_flags,mapping,quadrature,output_data);
+  return setup_data(Utilities::dynamic_unique_cast<typename FESystem<dim,spacedim>::InternalData>(std::move(data)),
                     update_flags,
                     quadrature);
 }
@@ -350,7 +347,8 @@ FE_Enriched<dim,spacedim>::get_subface_data (const UpdateFlags      update_flags
                                              const Quadrature<dim-1> &quadrature,
                                              dealii::internal::FEValuesImplementation::FiniteElementRelatedData<dim, spacedim> &output_data) const
 {
-  return setup_data(std::unique_ptr<typename FiniteElement<dim,spacedim>::InternalDataBase>(fe_system->get_subface_data(update_flags,mapping,quadrature,output_data)),
+  auto data = fe_system->get_subface_data(update_flags,mapping,quadrature,output_data);
+  return setup_data(Utilities::dynamic_unique_cast<typename FESystem<dim,spacedim>::InternalData>(std::move(data)),
                     update_flags,
                     quadrature);
 }
@@ -363,7 +361,8 @@ FE_Enriched<dim,spacedim>::get_data (const UpdateFlags      flags,
                                      const Quadrature<dim> &quadrature,
                                      internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim >   &output_data) const
 {
-  return setup_data(std::unique_ptr<typename FiniteElement<dim,spacedim>::InternalDataBase>(fe_system->get_data(flags,mapping,quadrature,output_data)),
+  auto data = fe_system->get_data(flags,mapping,quadrature,output_data);
+  return setup_data(Utilities::dynamic_unique_cast<typename FESystem<dim,spacedim>::InternalData>(std::move(data)),
                     flags,
                     quadrature);
 }
index 136dc8e7ab2ab7d3ee649cb374175dcb06ad97fb..58647c239dcf30f09a0a042e1c7e5b21341824ec 100644 (file)
@@ -164,7 +164,6 @@ MappingQ<dim,spacedim>::get_data (const UpdateFlags update_flags,
   // wait for the task above to finish and use returned value
   data->mapping_qp_data = Utilities::dynamic_unique_cast<typename MappingQGeneric<dim,spacedim>::InternalData>
                           (std::move(do_get_data.return_value()));
-
   return std::move(data);
 }
 
index 077f0c07c3da9af80463ce68d73be9b1f04129d3..80db371403a5a73e4350bd963a2d1fcd31fce24f 100644 (file)
@@ -2222,8 +2222,8 @@ 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) const
+ const Point<1>                          &p,
+ const Point<1>                          &initial_p_unit) const
 {
   const int dim = 1;
   const int spacedim = 1;
@@ -2233,8 +2233,8 @@ transform_real_to_unit_cell_internal
   UpdateFlags update_flags = update_quadrature_points | update_jacobians;
   if (spacedim>dim)
     update_flags |= update_jacobian_grads;
-  std::unique_ptr<InternalData> mdata (dynamic_cast<InternalData *>(get_data(update_flags,
-                                       point_quadrature).release()));
+  auto mdata = Utilities::dynamic_unique_cast<InternalData>(get_data(update_flags,
+                                                            point_quadrature));
 
   mdata->mapping_support_points = this->compute_mapping_support_points (cell);
 
@@ -2248,8 +2248,8 @@ Point<2>
 MappingQGeneric<2, 2>::
 transform_real_to_unit_cell_internal
 (const Triangulation<2, 2>::cell_iterator &cell,
- const Point<2>                            &p,
- const Point<2>                                 &initial_p_unit) const
+ const Point<2>                           &p,
+ const Point<2>                           &initial_p_unit) const
 {
   const int dim = 2;
   const int spacedim = 2;
@@ -2259,8 +2259,8 @@ transform_real_to_unit_cell_internal
   UpdateFlags update_flags = update_quadrature_points | update_jacobians;
   if (spacedim>dim)
     update_flags |= update_jacobian_grads;
-  std::unique_ptr<InternalData> mdata (dynamic_cast<InternalData *>(get_data(update_flags,
-                                       point_quadrature).release()));
+  auto mdata = Utilities::dynamic_unique_cast<InternalData>(get_data(update_flags,
+                                                            point_quadrature));
 
   mdata->mapping_support_points = this->compute_mapping_support_points (cell);
 
@@ -2285,8 +2285,8 @@ transform_real_to_unit_cell_internal
   UpdateFlags update_flags = update_quadrature_points | update_jacobians;
   if (spacedim>dim)
     update_flags |= update_jacobian_grads;
-  std::unique_ptr<InternalData> mdata (dynamic_cast<InternalData *>(get_data(update_flags,
-                                       point_quadrature).release()));
+  auto mdata = Utilities::dynamic_unique_cast<InternalData>(get_data(update_flags,
+                                                            point_quadrature));
 
   mdata->mapping_support_points = this->compute_mapping_support_points (cell);
 
@@ -2313,8 +2313,8 @@ transform_real_to_unit_cell_internal
   UpdateFlags update_flags = update_quadrature_points | update_jacobians;
   if (spacedim>dim)
     update_flags |= update_jacobian_grads;
-  std::unique_ptr<InternalData> mdata (dynamic_cast<InternalData *>(get_data(update_flags,
-                                       point_quadrature).release()));
+  auto mdata = Utilities::dynamic_unique_cast<InternalData>(get_data(update_flags,
+                                                            point_quadrature));
 
   mdata->mapping_support_points = this->compute_mapping_support_points (cell);
 
@@ -2341,8 +2341,8 @@ transform_real_to_unit_cell_internal
   UpdateFlags update_flags = update_quadrature_points | update_jacobians;
   if (spacedim>dim)
     update_flags |= update_jacobian_grads;
-  std::unique_ptr<InternalData> mdata (dynamic_cast<InternalData *>(get_data(update_flags,
-                                       point_quadrature).release()));
+  auto mdata = Utilities::dynamic_unique_cast<InternalData>(get_data(update_flags,
+                                                            point_quadrature));
 
   mdata->mapping_support_points = this->compute_mapping_support_points (cell);
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.