]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make the CellSimilarity argument const also in Mapping. 1173/head
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 21 Jul 2015 14:28:51 +0000 (09:28 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 22 Jul 2015 12:42:16 +0000 (07:42 -0500)
Logically, these arguments are intended to be input arguments, so make them
const. Also, don't make them a reference as they are simply integral values.

That said, the original intention of having a reference was so that
mappings can indicate situations where cell similarity has to be
disregarded. Consequently, let the fill_fe_values() functions return a
cell similarity value that will then simply be assigned to the same
variable again.

14 files changed:
include/deal.II/fe/mapping.h
include/deal.II/fe/mapping_cartesian.h
include/deal.II/fe/mapping_fe_field.h
include/deal.II/fe/mapping_q.h
include/deal.II/fe/mapping_q1.h
include/deal.II/fe/mapping_q1_eulerian.h
include/deal.II/fe/mapping_q_eulerian.h
source/fe/fe_values.cc
source/fe/mapping_cartesian.cc
source/fe/mapping_fe_field.cc
source/fe/mapping_q.cc
source/fe/mapping_q1.cc
source/fe/mapping_q1_eulerian.cc
source/fe/mapping_q_eulerian.cc

index 83620efdda995e5de43cd344c6e7fa17b86c6a52..a70abd7b6d51b38ecc402a7c205393890bcda607 100644 (file)
@@ -640,7 +640,8 @@ private:
    * The function above adjusted with the variable cell_normal_vectors for the
    * case of codimension 1
    */
-  virtual void
+  virtual
+  CellSimilarity::Similarity
   fill_fe_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
                   const Quadrature<dim>                         &quadrature,
                   InternalDataBase                              &internal,
@@ -650,7 +651,7 @@ private:
                   std::vector<DerivativeForm<2,dim,spacedim>  > &jacobian_grads,
                   std::vector<DerivativeForm<1,spacedim,dim>  > &inverse_jacobians,
                   std::vector<Point<spacedim> >                 &cell_normal_vectors,
-                  CellSimilarity::Similarity                    &cell_similarity
+                  const CellSimilarity::Similarity                    cell_similarity
                  ) const=0;
 
 
index 4c34310afb6cfd009cc236aba7fa8ca2cdee4949..57e61bb60f46a3696d954b7968d26719823bf950 100644 (file)
@@ -69,7 +69,8 @@ public:
   get_subface_data (const UpdateFlags flags,
                     const Quadrature<dim-1>& quadrature) const;
 
-  virtual void
+  virtual
+  CellSimilarity::Similarity
   fill_fe_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
                   const Quadrature<dim>                             &quadrature,
                   typename Mapping<dim, spacedim>::InternalDataBase &mapping_data,
@@ -79,7 +80,7 @@ public:
                   std::vector<DerivativeForm<2,dim,spacedim> >      &jacobian_grads,
                   std::vector<DerivativeForm<1,spacedim,dim> >      &inverse_jacobians,
                   std::vector<Point<spacedim> > &,
-                  CellSimilarity::Similarity                        &cell_similarity) const ;
+                  const CellSimilarity::Similarity                        cell_similarity) const ;
 
 
   virtual void
index 23fbcdf404d10a7d435f534f0c2596e412afb0d6..450a617d86ca4fb45bed76fc4dcd4ea1bdfb0bdb 100644 (file)
@@ -412,7 +412,8 @@ protected:
   /**
    * Implementation of the interface in Mapping.
    */
-  virtual void
+  virtual
+  CellSimilarity::Similarity
   fill_fe_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
                   const Quadrature<dim>                                     &quadrature,
                   typename Mapping<dim,spacedim>::InternalDataBase          &mapping_data,
@@ -422,7 +423,7 @@ protected:
                   std::vector<DerivativeForm<2,dim,spacedim> >       &jacobian_grads,
                   std::vector<DerivativeForm<1,spacedim,dim> >      &inverse_jacobians,
                   std::vector<Point<spacedim> >                             &cell_normal_vectors,
-                  CellSimilarity::Similarity                           &cell_similarity) const ;
+                  const CellSimilarity::Similarity                           cell_similarity) const ;
 
   /**
    * Implementation of the interface in Mapping.
index 2efd1563f80865da77415dbf3153e21ac885db06..ff30ce782d9339ac5481b4546d99e32f67da8173 100644 (file)
@@ -193,7 +193,8 @@ protected:
   /**
    * Implementation of the interface in Mapping.
    */
-  virtual void
+  virtual
+  CellSimilarity::Similarity
   fill_fe_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
                   const Quadrature<dim>                            &quadrature,
                   typename Mapping<dim,spacedim>::InternalDataBase &mapping_data,
@@ -203,7 +204,7 @@ protected:
                   std::vector<DerivativeForm<2,dim,spacedim> >     &jacobian_grads,
                   std::vector<DerivativeForm<1,spacedim,dim> >     &inverse_jacobians,
                   std::vector<Point<spacedim> >                    &cell_normal_vectors,
-                  CellSimilarity::Similarity                       &cell_similarity) const ;
+                  const CellSimilarity::Similarity                       cell_similarity) const ;
 
   /**
    * Implementation of the interface in Mapping.
index 5134eb81431c6fa02e0888b75de1cded65c8e201..5ac2510d8b442ec68a64251df7215c87977ca025 100644 (file)
@@ -304,7 +304,8 @@ public:
   /**
    * Implementation of the interface in Mapping.
    */
-  virtual void
+  virtual
+  CellSimilarity::Similarity
   fill_fe_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
                   const Quadrature<dim>                        &quadrature,
                   typename Mapping<dim,spacedim>::InternalDataBase &mapping_data,
@@ -314,7 +315,7 @@ public:
                   std::vector<DerivativeForm<2,dim,spacedim> > &jacobian_grads,
                   std::vector<DerivativeForm<1,spacedim,dim> > &inverse_jacobians,
                   std::vector<Point<spacedim> >                &cell_normal_vectors,
-                  CellSimilarity::Similarity                   &cell_similarity) const;
+                  const CellSimilarity::Similarity                   cell_similarity) const;
 
   /**
    * Implementation of the interface in Mapping.
index 4fde32ddcb805189e93136fd463e019775f3235a..f3b2da30978f1ba3c85a72a551a159e43282d4a7 100644 (file)
@@ -125,7 +125,8 @@ protected:
    * Implementation of the interface in MappingQ1. Overrides the function in
    * the base class, since we cannot use any cell similarity for this class.
    */
-  virtual void
+  virtual
+  CellSimilarity::Similarity
   fill_fe_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
                   const Quadrature<dim>                                     &quadrature,
                   typename Mapping<dim,spacedim>::InternalDataBase          &mapping_data,
@@ -135,7 +136,7 @@ protected:
                   std::vector<DerivativeForm<2,dim,spacedim>  >       &jacobian_grads,
                   std::vector<DerivativeForm<1,spacedim,dim>  >       &inverse_jacobians,
                   std::vector<Point<spacedim> >                             &cell_normal_vectors,
-                  CellSimilarity::Similarity                           &cell_similarity) const;
+                  const CellSimilarity::Similarity                           cell_similarity) const;
 
   /**
    * Reference to the vector of shifts.
index 723220360d76cfeffae225b8ee4a0957fe426020..e03f1f503570d2535eb2766f0ec2899ae3c3f616 100644 (file)
@@ -140,7 +140,8 @@ protected:
    * Implementation of the interface in MappingQ. Overrides the function in
    * the base class, since we cannot use any cell similarity for this class.
    */
-  virtual void
+  virtual
+  CellSimilarity::Similarity
   fill_fe_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
                   const Quadrature<dim>                                     &quadrature,
                   typename Mapping<dim,spacedim>::InternalDataBase          &mapping_data,
@@ -150,7 +151,7 @@ protected:
                   std::vector<DerivativeForm<2,dim,spacedim> >      &jacobian_grads,
                   std::vector<DerivativeForm<1,spacedim,dim> >      &inverse_jacobians,
                   std::vector<Point<spacedim> >                             &cell_normal_vectors,
-                  CellSimilarity::Similarity                           &cell_similarity) const;
+                  const CellSimilarity::Similarity                           cell_similarity) const;
 
   /**
    * Reference to the vector of shifts.
index 4bb89384ebcb4288e6da05ebaae7a6d2f660fdfe..2cbedfbbba3c2f5db79c41e1c553df2109066c7c 100644 (file)
@@ -3512,17 +3512,26 @@ FEValues<dim,spacedim>::reinit (const TriaIterator<DoFCellAccessor<DH, lda> > &c
 template <int dim, int spacedim>
 void FEValues<dim,spacedim>::do_reinit ()
 {
-  this->get_mapping().fill_fe_values(*this->present_cell,
-                                     quadrature,
-                                     *this->mapping_data,
-                                     this->quadrature_points,
-                                     this->JxW_values,
-                                     this->jacobians,
-                                     this->jacobian_grads,
-                                     this->inverse_jacobians,
-                                     this->normal_vectors,
-                                     this->cell_similarity);
-
+  // first call the mapping and let it generate the data
+  // specific to the mapping. also let it inspect the
+  // cell similarity flag and, if necessary, update
+  // it
+  this->cell_similarity
+    = this->get_mapping().fill_fe_values(*this->present_cell,
+                                         quadrature,
+                                         *this->mapping_data,
+                                         this->quadrature_points,
+                                         this->JxW_values,
+                                         this->jacobians,
+                                         this->jacobian_grads,
+                                         this->inverse_jacobians,
+                                         this->normal_vectors,
+                                         this->cell_similarity);
+
+  // then call the finite element and, with the data
+  // already filled by the mapping, let it compute the
+  // data for the mapped shape function values, gradients,
+  // etc.
   this->get_fe().fill_fe_values(this->get_mapping(),
                                 *this->present_cell,
                                 quadrature,
index 82fc6e53ef7d8a5640920fd0bae43bf25dc9b561..78600e6de3eb5cdcd0929ec3061b5121e2f932f1 100644 (file)
@@ -315,7 +315,7 @@ MappingCartesian<dim, spacedim>::compute_fill (const typename Triangulation<dim,
 
 
 template<int dim, int spacedim>
-void
+CellSimilarity::Similarity
 MappingCartesian<dim, spacedim>::
 fill_fe_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
                 const Quadrature<dim> &q,
@@ -326,7 +326,7 @@ fill_fe_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
                 std::vector<DerivativeForm<2,dim,spacedim> >      &jacobian_grads,
                 std::vector<DerivativeForm<1,spacedim,dim> >      &inverse_jacobians,
                 std::vector<Point<spacedim> > &,
-                CellSimilarity::Similarity &cell_similarity) const
+                const CellSimilarity::Similarity cell_similarity) const
 {
   // convert data object to internal
   // data for this class. fails with
@@ -386,6 +386,8 @@ fill_fe_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
           for (unsigned int j=0; j<dim; ++j)
             inverse_jacobians[j][j]=1./data.length[j];
         }
+
+  return cell_similarity;
 }
 
 
index a218480ab7ac30d070d0c4cea598b1e17f2e9141..624bec326299e4cf7041d29545b28787e61e165c 100644 (file)
@@ -373,7 +373,7 @@ MappingFEField<dim,spacedim,VECTOR,DH>::get_subface_data (const UpdateFlags upda
 // Note that the CellSimilarity flag is modifyable, since MappingFEField can need to
 // recalculate data even when cells are similar.
 template<int dim, int spacedim, class VECTOR, class DH>
-void
+CellSimilarity::Similarity
 MappingFEField<dim,spacedim,VECTOR,DH>::fill_fe_values (
   const typename Triangulation<dim,spacedim>::cell_iterator &cell,
   const Quadrature<dim>                                     &q,
@@ -384,7 +384,7 @@ MappingFEField<dim,spacedim,VECTOR,DH>::fill_fe_values (
   std::vector<DerivativeForm<2,dim,spacedim>    >           &jacobian_grads,
   std::vector<DerivativeForm<1,spacedim,dim>    >           &inverse_jacobians,
   std::vector<Point<spacedim> >                             &normal_vectors,
-  CellSimilarity::Similarity                                &cell_similarity) const
+  const CellSimilarity::Similarity                                cell_similarity) const
 {
   AssertDimension(fe->dofs_per_cell, local_dof_values.get().size());
   Assert(local_dof_values.get().size()>0, ExcMessage("Cannot do anything with zero degrees of freedom"));
@@ -394,12 +394,16 @@ MappingFEField<dim,spacedim,VECTOR,DH>::fill_fe_values (
   Assert (dynamic_cast<InternalData *> (&mapping_data) != 0, ExcInternalError());
   InternalData &data = static_cast<InternalData &> (mapping_data);
 
-  if (get_degree() > 1)
-    cell_similarity = CellSimilarity::invalid_next_cell;
-
   const unsigned int n_q_points=q.size();
-
-  compute_fill (cell, n_q_points, QProjector<dim>::DataSetDescriptor::cell (), cell_similarity,
+  const  CellSimilarity::Similarity updated_cell_similarity
+    = (get_degree() == 1
+       ?
+       cell_similarity
+       :
+       CellSimilarity::invalid_next_cell);
+
+  compute_fill (cell, n_q_points, QProjector<dim>::DataSetDescriptor::cell (),
+                updated_cell_similarity,
                 data, quadrature_points);
 
   const UpdateFlags update_flags(data.current_update_flags());
@@ -543,6 +547,7 @@ MappingFEField<dim,spacedim,VECTOR,DH>::fill_fe_values (
           inverse_jacobians[point] = data.covariant[point].transpose();
     }
 
+  return updated_cell_similarity;
 }
 
 
index 9065f1ece125c4a8ef89d5eb5de9c5af8ae5f03f..d3ab6751692f9f3917f015c99c61e14e548cfbb2 100644 (file)
@@ -247,7 +247,7 @@ MappingQ<dim,spacedim>::get_subface_data (const UpdateFlags update_flags,
 // Note that the CellSimilarity flag is modifyable, since MappingQ can need to
 // recalculate data even when cells are similar.
 template<int dim, int spacedim>
-void
+CellSimilarity::Similarity
 MappingQ<dim,spacedim>::fill_fe_values (
   const typename Triangulation<dim,spacedim>::cell_iterator &cell,
   const Quadrature<dim>                                     &q,
@@ -258,7 +258,7 @@ MappingQ<dim,spacedim>::fill_fe_values (
   std::vector<DerivativeForm<2,dim,spacedim>    >   &jacobian_grads,
   std::vector<DerivativeForm<1,spacedim,dim>    >   &inverse_jacobians,
   std::vector<Point<spacedim> >                             &normal_vectors,
-  CellSimilarity::Similarity                           &cell_similarity) const
+  const CellSimilarity::Similarity                           cell_similarity) const
 {
   // convert data object to internal data for this class. fails with an
   // exception if that is not possible
@@ -271,27 +271,35 @@ MappingQ<dim,spacedim>::fill_fe_values (
                                           || cell->has_boundary_lines());
 
   // depending on this result, use this or the other data object for the
-  // mapping. furthermore, we need to ensure that the flag indicating whether
+  // mapping.
+  typename MappingQ1<dim,spacedim>::InternalData *
+  p_data = (data.use_mapping_q1_on_current_cell
+            ?
+            &data.mapping_q1_data
+            :
+            &data);
+
+  // call the base class. we need to ensure that the flag indicating whether
   // we can use some similarity has to be modified - for a general MappingQ,
   // the data needs to be recomputed anyway since then the mapping changes the
   // data. this needs to be known also for later operations, so modify the
   // variable here. this also affects the calculation of the next cell -- if
   // we use Q1 data on the next cell, the data will still be invalid.
-  typename MappingQ1<dim,spacedim>::InternalData *p_data=0;
-  if (data.use_mapping_q1_on_current_cell)
-    p_data=&data.mapping_q1_data;
-  else
-    {
-      p_data=&data;
-      if (get_degree() > 1)
-        cell_similarity = CellSimilarity::invalid_next_cell;
-    }
-
+  const CellSimilarity::Similarity updated_cell_similarity
+    = ((data.use_mapping_q1_on_current_cell == false)
+       &&
+       (get_degree() > 1)
+       ?
+       CellSimilarity::invalid_next_cell
+       :
+       cell_similarity);
   MappingQ1<dim,spacedim>::fill_fe_values(cell, q, *p_data,
                                           quadrature_points, JxW_values,
                                           jacobians, jacobian_grads, inverse_jacobians,
-                                          normal_vectors, cell_similarity);
+                                          normal_vectors,
+                                          updated_cell_similarity);
 
+  return updated_cell_similarity;
 }
 
 
index 5927a3e70e982141e9e40d39f985ba9b8755d6bf..73dea53ebfdda4d6e318c13509960fedbe757c59 100644 (file)
@@ -732,7 +732,7 @@ MappingQ1<dim,spacedim>::compute_mapping_support_points(
 
 
 template<int dim, int spacedim>
-void
+CellSimilarity::Similarity
 MappingQ1<dim,spacedim>::fill_fe_values (
   const typename Triangulation<dim,spacedim>::cell_iterator &cell,
   const Quadrature<dim>                        &q,
@@ -743,7 +743,7 @@ MappingQ1<dim,spacedim>::fill_fe_values (
   std::vector<DerivativeForm<2,dim,spacedim> > &jacobian_grads,
   std::vector<DerivativeForm<1,spacedim,dim> > &inverse_jacobians,
   std::vector<Point<spacedim> >                &normal_vectors,
-  CellSimilarity::Similarity                   &cell_similarity) const
+  const CellSimilarity::Similarity                   cell_similarity) const
 {
   // ensure that the following static_cast is really correct:
   Assert (dynamic_cast<InternalData *>(&mapping_data) != 0,
@@ -906,6 +906,7 @@ MappingQ1<dim,spacedim>::fill_fe_values (
           inverse_jacobians[point] = data.covariant[point].transpose();
     }
 
+  return cell_similarity;
 }
 
 
index f30ef43d46651c794ac8f62021561ffd4615b264..dc7a768dd83cb35f40c6609f5f65da959f649e37 100644 (file)
@@ -111,7 +111,7 @@ MappingQ1Eulerian<dim, EulerVectorType, spacedim>::clone () const
 
 
 template<int dim, class EulerVectorType, int spacedim>
-void
+CellSimilarity::Similarity
 MappingQ1Eulerian<dim,EulerVectorType,spacedim>::fill_fe_values (
   const typename Triangulation<dim,spacedim>::cell_iterator &cell,
   const Quadrature<dim>                                     &q,
@@ -122,16 +122,20 @@ MappingQ1Eulerian<dim,EulerVectorType,spacedim>::fill_fe_values (
   std::vector<DerivativeForm<2,dim,spacedim>    >   &jacobian_grads,
   std::vector<DerivativeForm<1,spacedim,dim>    >   &inverse_jacobians,
   std::vector<Point<spacedim> >                             &normal_vectors,
-  CellSimilarity::Similarity                           &cell_similarity) const
+  const CellSimilarity::Similarity) const
 {
-  // disable any previously detected
-  // similarity and then enter the
-  // respective function of the base class.
-  cell_similarity = CellSimilarity::invalid_next_cell;
+  // call the function of the base class, but ignoring
+  // any potentially detected cell similarity between
+  // the current and the previous cell
   MappingQ1<dim,spacedim>::fill_fe_values (cell, q, mapping_data,
                                            quadrature_points, JxW_values, jacobians,
                                            jacobian_grads, inverse_jacobians,
-                                           normal_vectors, cell_similarity);
+                                           normal_vectors,
+                                           CellSimilarity::invalid_next_cell);
+  // also return the updated flag since any detected
+  // similarity wasn't based on the mapped field, but
+  // the original vertices which are meaningless
+  return CellSimilarity::invalid_next_cell;
 }
 
 
index 6082fa9157db952fc20c59cc3e91bc7354abb80a..69444b69944e905e252fc106cf9e5cbb672145a2 100644 (file)
@@ -176,7 +176,7 @@ compute_mapping_support_points
 
 
 template<int dim, class EulerVectorType, int spacedim>
-void
+CellSimilarity::Similarity
 MappingQEulerian<dim,EulerVectorType,spacedim>::fill_fe_values (
   const typename Triangulation<dim,spacedim>::cell_iterator &cell,
   const Quadrature<dim>                                     &q,
@@ -187,15 +187,20 @@ MappingQEulerian<dim,EulerVectorType,spacedim>::fill_fe_values (
   std::vector<DerivativeForm<2,dim,spacedim>  >     &jacobian_grads,
   std::vector<DerivativeForm<1,spacedim,dim>  >     &inverse_jacobians,
   std::vector<Point<spacedim> >                             &normal_vectors,
-  CellSimilarity::Similarity                           &cell_similarity) const
+  const CellSimilarity::Similarity                           ) const
 {
-  // disable any previously detected similarity and hand on to the respective
-  // function of the base class.
-  cell_similarity = CellSimilarity::invalid_next_cell;
+  // call the function of the base class, but ignoring
+  // any potentially detected cell similarity between
+  // the current and the previous cell
   MappingQ<dim,spacedim>::fill_fe_values (cell, q, mapping_data,
                                           quadrature_points, JxW_values, jacobians,
                                           jacobian_grads, inverse_jacobians,
-                                          normal_vectors, cell_similarity);
+                                          normal_vectors,
+                                          CellSimilarity::invalid_next_cell);
+  // also return the updated flag since any detected
+  // similarity wasn't based on the mapped field, but
+  // the original vertices which are meaningless
+  return CellSimilarity::invalid_next_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.