]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Update DataPostprocessor in examples 3528/head
authorDaniel Arndt <d.arndt@math.uni-goettingen.de>
Fri, 11 Nov 2016 13:31:46 +0000 (14:31 +0100)
committerDaniel Arndt <d.arndt@math.uni-goettingen.de>
Fri, 11 Nov 2016 23:39:01 +0000 (00:39 +0100)
examples/step-29/step-29.cc
examples/step-32/step-32.cc
examples/step-33/step-33.cc
examples/step-47/step-47.cc

index 155a34c63e1b3faf8fb99b115c8b3f1a34a4d87e..4732319ecc158001f84ae1b2dd53543f5fba7a1a 100644 (file)
@@ -298,14 +298,13 @@ namespace Step29
   public:
     ComputeIntensity ();
 
+    using DataPostprocessorScalar<dim>::compute_derived_quantities_vector;
+
     virtual
     void
-    compute_derived_quantities_vector (const std::vector<Vector<double> >               &solution_values,
-                                       const std::vector<std::vector<Tensor<1, dim> > > &solution_gradients,
-                                       const std::vector<std::vector<Tensor<2, dim> > > &solution_hessians,
-                                       const std::vector<Point<dim> >                   &normals,
-                                       const std::vector<Point<dim> >                   &evaluation_points,
-                                       std::vector<Vector<double> >                     &computed_quantities) const;
+    compute_derived_quantities_vector
+    (const DataPostprocessorInputs::Vector<dim> &inputs,
+     std::vector<Vector<double> >               &computed_quantities) const;
   };
 
   // In the constructor, we need to call the constructor of the base class
@@ -330,33 +329,26 @@ namespace Step29
   {}
 
 
-  // The actual postprocessing happens in the following function.  Its inputs
-  // are a vector representing values of the function (which is here
-  // vector-valued) representing the data vector given to
-  // DataOut::add_data_vector, evaluated at all evaluation points where we
-  // generate output, and some tensor objects representing derivatives (that
-  // we don't use here since $|u|$ is computed from just $v$ and $w$, and for
-  // which we assign no name to the corresponding function argument).  The
-  // derived quantities are returned in the <code>computed_quantities</code>
-  // vector.  Remember that this function may only use data for which the
-  // respective update flag is specified by
+  // The actual postprocessing happens in the following function. Its input is
+  // an object that stores values of the function (which is here vector-valued)
+  // representing the data vector given to DataOut::add_data_vector, evaluated
+  // at all evaluation points where we generate output, and some tensor objects
+  // representing derivatives (that we don't use here since $|u|$ is computed
+  // from just $v$ and $w$). The derived quantities are returned in the
+  // <code>computed_quantities</code> vector. Remember that this function may
+  // only use data for which the respective update flag is specified by
   // <code>get_needed_update_flags</code>. For example, we may not use the
   // derivatives here, since our implementation of
   // <code>get_needed_update_flags</code> requests that only function values
   // are provided.
   template <int dim>
   void
-  ComputeIntensity<dim>::compute_derived_quantities_vector (
-    const std::vector<Vector<double> >                 &solution_values,
-    const std::vector<std::vector<Tensor<1, dim> > >   & /*solution_gradients*/,
-    const std::vector<std::vector<Tensor<2, dim> > >   & /*solution_hessians*/,
-    const std::vector<Point<dim> >                     & /*normals*/,
-    const std::vector<Point<dim> >                     & /*evaluation_points*/,
-    std::vector<Vector<double> >                       &computed_quantities
-  ) const
+  ComputeIntensity<dim>::compute_derived_quantities_vector
+  (const DataPostprocessorInputs::Vector<dim> &inputs,
+   std::vector<Vector<double> >               &computed_quantities) const
   {
-    Assert(computed_quantities.size() == solution_values.size(),
-           ExcDimensionMismatch (computed_quantities.size(), solution_values.size()));
+    Assert(computed_quantities.size() == inputs.solution_values.size(),
+           ExcDimensionMismatch (computed_quantities.size(), inputs.solution_values.size()));
 
     // The computation itself is straightforward: We iterate over each entry
     // in the output vector and compute $|u|$ from the corresponding values of
@@ -365,9 +357,12 @@ namespace Step29
       {
         Assert(computed_quantities[i].size() == 1,
                ExcDimensionMismatch (computed_quantities[i].size(), 1));
-        Assert(solution_values[i].size() == 2, ExcDimensionMismatch (solution_values[i].size(), 2));
+        Assert(inputs.solution_values[i].size() == 2,
+               ExcDimensionMismatch (inputs.solution_values[i].size(), 2));
 
-        computed_quantities[i](0) = std::sqrt(solution_values[i](0)*solution_values[i](0) + solution_values[i](1)*solution_values[i](1));
+        computed_quantities[i](0)
+          = std::sqrt(inputs.solution_values[i](0)*inputs.solution_values[i](0)
+                      + inputs.solution_values[i](1)*inputs.solution_values[i](1));
       }
   }
 
index 2bf00cf58e3e7e461c5003fa7968f464fda058f9..0347787b85cd1905526590c9123236b0d3396d3b 100644 (file)
@@ -1,6 +1,6 @@
 /* ---------------------------------------------------------------------
  *
- * Copyright (C) 2008 - 2015 by the deal.II authors
+ * Copyright (C) 2008 - 2016 by the deal.II authors
  *
  * This file is part of the deal.II library.
  *
@@ -3148,14 +3148,13 @@ namespace Step32
     Postprocessor (const unsigned int partition,
                    const double       minimal_pressure);
 
+    using DataPostprocessor<dim>::compute_derived_quantities_vector;
+
     virtual
     void
-    compute_derived_quantities_vector (const std::vector<Vector<double> >              &solution_values,
-                                       const std::vector<std::vector<Tensor<1,dim> > > &solution_gradients,
-                                       const std::vector<std::vector<Tensor<2,dim> > > &solution_hessians,
-                                       const std::vector<Point<dim> >                  &normals,
-                                       const std::vector<Point<dim> >                  &evaluation_points,
-                                       std::vector<Vector<double> >                    &computed_quantities) const;
+    compute_derived_quantities_vector
+    (const DataPostprocessorInputs::Vector<dim> &inputs,
+     std::vector<Vector<double> >               &computed_quantities) const;
 
     virtual std::vector<std::string> get_names () const;
 
@@ -3237,38 +3236,37 @@ namespace Step32
   //
   // The quantities we output here are more for illustration, rather than for
   // actual scientific value. We come back to this briefly in the results
-  // section of this program and explain what one may in fact be interested
-  // in.
+  // section of this program and explain what one may in fact be interested in.
   template <int dim>
   void
   BoussinesqFlowProblem<dim>::Postprocessor::
-  compute_derived_quantities_vector (const std::vector<Vector<double> >              &solution_values,
-                                     const std::vector<std::vector<Tensor<1,dim> > > &solution_gradients,
-                                     const std::vector<std::vector<Tensor<2,dim> > > &/*solution_hessians*/,
-                                     const std::vector<Point<dim> >                  &/*normals*/,
-                                     const std::vector<Point<dim> >                  &/*evaluation_points*/,
-                                     std::vector<Vector<double> >                    &computed_quantities) const
+  compute_derived_quantities_vector
+  (const DataPostprocessorInputs::Vector<dim> &inputs,
+   std::vector<Vector<double> >               &computed_quantities) const
   {
-    const unsigned int n_quadrature_points = solution_values.size();
-    Assert (solution_gradients.size() == n_quadrature_points,                  ExcInternalError());
-    Assert (computed_quantities.size() == n_quadrature_points,  ExcInternalError());
-    Assert (solution_values[0].size() == dim+2,                              ExcInternalError());
+    const unsigned int n_quadrature_points = inputs.solution_values.size();
+    Assert (inputs.solution_gradients.size() == n_quadrature_points,
+            ExcInternalError());
+    Assert (computed_quantities.size() == n_quadrature_points,
+            ExcInternalError());
+    Assert (inputs.solution_values[0].size() == dim+2,
+            ExcInternalError());
 
     for (unsigned int q=0; q<n_quadrature_points; ++q)
       {
         for (unsigned int d=0; d<dim; ++d)
           computed_quantities[q](d)
-            = (solution_values[q](d) *  EquationData::year_in_seconds * 100);
+            = (inputs.solution_values[q](d) *  EquationData::year_in_seconds * 100);
 
-        const double pressure = (solution_values[q](dim)-minimal_pressure);
+        const double pressure = (inputs.solution_values[q](dim)-minimal_pressure);
         computed_quantities[q](dim) = pressure;
 
-        const double temperature = solution_values[q](dim+1);
+        const double temperature = inputs.solution_values[q](dim+1);
         computed_quantities[q](dim+1) = temperature;
 
         Tensor<2,dim> grad_u;
         for (unsigned int d=0; d<dim; ++d)
-          grad_u[d] = solution_gradients[q][d];
+          grad_u[d] = inputs.solution_gradients[q][d];
         const SymmetricTensor<2,dim> strain_rate = symmetrize (grad_u);
         computed_quantities[q](dim+2) = 2 * EquationData::eta *
                                         strain_rate * strain_rate;
index 454934fa75357af121096a7da6cbaa5970ad6607..1ce831f0fa38ffb69e094b97d0ffc779862233cc 100644 (file)
@@ -1,6 +1,6 @@
 /* ---------------------------------------------------------------------
  *
- * Copyright (C) 2007 - 2015 by the deal.II authors
+ * Copyright (C) 2007 - 2016 by the deal.II authors
  *
  * This file is part of the deal.II library.
  *
@@ -541,14 +541,13 @@ namespace Step33
     public:
       Postprocessor (const bool do_schlieren_plot);
 
+      using DataPostprocessor<dim>::compute_derived_quantities_vector;
+
       virtual
       void
-      compute_derived_quantities_vector (const std::vector<Vector<double> >              &solution_values,
-                                         const std::vector<std::vector<Tensor<1,dim> > > &solution_gradients,
-                                         const std::vector<std::vector<Tensor<2,dim> > > &solution_hessians,
-                                         const std::vector<Point<dim> >                  &normals,
-                                         const std::vector<Point<dim> >                  &evaluation_points,
-                                         std::vector<Vector<double> >                    &computed_quantities) const;
+      compute_derived_quantities_vector
+      (const DataPostprocessorInputs::Vector<dim> &inputs,
+       std::vector<Vector<double> >               &computed_quantities) const;
 
       virtual std::vector<std::string> get_names () const;
 
@@ -579,22 +578,19 @@ namespace Step33
 
   // This is the only function worth commenting on. When generating graphical
   // output, the DataOut and related classes will call this function on each
-  // cell, with values, gradients, Hessians, and normal vectors (in case we're
-  // working on faces) at each quadrature point. Note that the data at each
-  // quadrature point is itself vector-valued, namely the conserved
+  // cell, with access to values, gradients, Hessians, and normal vectors (in
+  // case we're working on faces) at each quadrature point. Note that the data
+  // at each quadrature point is itself vector-valued, namely the conserved
   // variables. What we're going to do here is to compute the quantities we're
   // interested in at each quadrature point. Note that for this we can ignore
-  // the Hessians ("solution_hessians") and normal vectors; to avoid compiler warnings
-  // about unused variables, we comment out their names.
+  // the Hessians ("inputs.solution_hessians") and normal vectors
+  // ("inputs.normals").
   template <int dim>
   void
   EulerEquations<dim>::Postprocessor::
-  compute_derived_quantities_vector (const std::vector<Vector<double> >              &solution_values,
-                                     const std::vector<std::vector<Tensor<1,dim> > > &solution_gradients,
-                                     const std::vector<std::vector<Tensor<2,dim> > > &/*solution_hessians*/,
-                                     const std::vector<Point<dim> >                  &/*normals*/,
-                                     const std::vector<Point<dim> >                  &/*evaluation_points*/,
-                                     std::vector<Vector<double> >                    &computed_quantities) const
+  compute_derived_quantities_vector
+  (const DataPostprocessorInputs::Vector<dim> &inputs,
+   std::vector<Vector<double> >               &computed_quantities) const
   {
     // At the beginning of the function, let us make sure that all variables
     // have the correct sizes, so that we can access individual vector
@@ -604,16 +600,16 @@ namespace Step33
     // we say so in the <code>get_needed_update_flags()</code> function
     // below). For the inner vectors, we check that at least the first element
     // of the outer vector has the correct inner size:
-    const unsigned int n_quadrature_points = solution_values.size();
+    const unsigned int n_quadrature_points = inputs.solution_values.size();
 
     if (do_schlieren_plot == true)
-      Assert (solution_gradients.size() == n_quadrature_points,
+      Assert (inputs.solution_gradients.size() == n_quadrature_points,
               ExcInternalError());
 
     Assert (computed_quantities.size() == n_quadrature_points,
             ExcInternalError());
 
-    Assert (solution_values[0].size() == n_components,
+    Assert (inputs.solution_values[0].size() == n_components,
             ExcInternalError());
 
     if (do_schlieren_plot == true)
@@ -630,17 +626,17 @@ namespace Step33
     // <code>density_component</code> information:
     for (unsigned int q=0; q<n_quadrature_points; ++q)
       {
-        const double density = solution_values[q](density_component);
+        const double density = inputs.solution_values[q](density_component);
 
         for (unsigned int d=0; d<dim; ++d)
           computed_quantities[q](d)
-            = solution_values[q](first_momentum_component+d) / density;
+            = inputs.solution_values[q](first_momentum_component+d) / density;
 
-        computed_quantities[q](dim) = compute_pressure (solution_values[q]);
+        computed_quantities[q](dim) = compute_pressure (inputs.solution_values[q]);
 
         if (do_schlieren_plot == true)
-          computed_quantities[q](dim+1) = solution_gradients[q][density_component] *
-                                          solution_gradients[q][density_component];
+          computed_quantities[q](dim+1) = inputs.solution_gradients[q][density_component] *
+                                          inputs.solution_gradients[q][density_component];
       }
   }
 
index eceafa87f715eefbfbd69d653388eba59afb85f0..226c03f70ee04b4214c9c074a609afc9e357ecdb 100644 (file)
@@ -1,6 +1,6 @@
 /* ---------------------------------------------------------------------
  *
- * Copyright (C) 2011 - 2015 by the deal.II authors
+ * Copyright (C) 2011 - 2016 by the deal.II authors
  *
  * This file is part of the deal.II library.
  *
@@ -903,14 +903,13 @@ namespace Step47
   class Postprocessor : public DataPostprocessor<dim>
   {
   public:
+    using DataPostprocessor<dim>::compute_derived_quantities_vector;
+
     virtual
     void
-    compute_derived_quantities_vector (const std::vector<Vector<double> >              &solution_values,
-                                       const std::vector<std::vector<Tensor<1,dim> > > &solution_gradients,
-                                       const std::vector<std::vector<Tensor<2,dim> > > &solution_hessians,
-                                       const std::vector<Point<dim> >                  &normals,
-                                       const std::vector<Point<dim> >                  &evaluation_points,
-                                       std::vector<Vector<double> >                    &computed_quantities) const;
+    compute_derived_quantities_vector
+    (const dealii::DataPostprocessorInputs::Vector<dim> &inputs,
+     std::vector<Vector<double> >                       &computed_quantities) const;
 
     virtual std::vector<std::string> get_names () const;
 
@@ -955,28 +954,27 @@ namespace Step47
   template <int dim>
   void
   Postprocessor<dim>::
-  compute_derived_quantities_vector (const std::vector<Vector<double> >              &solution_values,
-                                     const std::vector<std::vector<Tensor<1,dim> > > &/*solution_gradients*/,
-                                     const std::vector<std::vector<Tensor<2,dim> > > &/*solution_hessians*/,
-                                     const std::vector<Point<dim> >                  &/*normals*/,
-                                     const std::vector<Point<dim> >                  &evaluation_points,
-                                     std::vector<Vector<double> >                    &computed_quantities) const
+  compute_derived_quantities_vector
+  (const dealii::DataPostprocessorInputs::Vector<dim> &inputs,
+   std::vector<Vector<double> >                       &computed_quantities) const
   {
-    const unsigned int n_quadrature_points = solution_values.size();
-    Assert (computed_quantities.size() == n_quadrature_points,  ExcInternalError());
-    Assert (solution_values[0].size() == 2,                                  ExcInternalError());
+    const unsigned int n_quadrature_points = inputs.solution_values.size();
+    Assert (computed_quantities.size() == n_quadrature_points,
+            ExcInternalError());
+    Assert (inputs.solution_values[0].size() == 2,
+            ExcInternalError());
 
     for (unsigned int q=0; q<n_quadrature_points; ++q)
       {
         computed_quantities[q](0)
-          = (solution_values[q](0)
+          = (inputs.solution_values[q](0)
              +
 //TODO: shift in weight function is missing!
-             solution_values[q](1) * std::fabs(level_set(evaluation_points[q])));
+             inputs.solution_values[q](1) * std::fabs(level_set(inputs.evaluation_points[q])));
         computed_quantities[q](1)
           = (computed_quantities[q](0)
              -
-             exact_solution (evaluation_points[q]));
+             exact_solution (inputs.evaluation_points[q]));
       }
   }
 

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.