From: Daniel Arndt Date: Fri, 11 Nov 2016 13:31:46 +0000 (+0100) Subject: Update DataPostprocessor in examples X-Git-Tag: v8.5.0-rc1~411^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb9f42f9af30554571964b19265fa40e20bce77f;p=dealii.git Update DataPostprocessor in examples --- diff --git a/examples/step-29/step-29.cc b/examples/step-29/step-29.cc index 155a34c63e..4732319ecc 100644 --- a/examples/step-29/step-29.cc +++ b/examples/step-29/step-29.cc @@ -298,14 +298,13 @@ namespace Step29 public: ComputeIntensity (); + using DataPostprocessorScalar::compute_derived_quantities_vector; + virtual void - compute_derived_quantities_vector (const std::vector > &solution_values, - const std::vector > > &solution_gradients, - const std::vector > > &solution_hessians, - const std::vector > &normals, - const std::vector > &evaluation_points, - std::vector > &computed_quantities) const; + compute_derived_quantities_vector + (const DataPostprocessorInputs::Vector &inputs, + std::vector > &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 computed_quantities - // 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 + // computed_quantities vector. Remember that this function may + // only use data for which the respective update flag is specified by // get_needed_update_flags. For example, we may not use the // derivatives here, since our implementation of // get_needed_update_flags requests that only function values // are provided. template void - ComputeIntensity::compute_derived_quantities_vector ( - const std::vector > &solution_values, - const std::vector > > & /*solution_gradients*/, - const std::vector > > & /*solution_hessians*/, - const std::vector > & /*normals*/, - const std::vector > & /*evaluation_points*/, - std::vector > &computed_quantities - ) const + ComputeIntensity::compute_derived_quantities_vector + (const DataPostprocessorInputs::Vector &inputs, + std::vector > &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)); } } diff --git a/examples/step-32/step-32.cc b/examples/step-32/step-32.cc index 2bf00cf58e..0347787b85 100644 --- a/examples/step-32/step-32.cc +++ b/examples/step-32/step-32.cc @@ -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::compute_derived_quantities_vector; + virtual void - compute_derived_quantities_vector (const std::vector > &solution_values, - const std::vector > > &solution_gradients, - const std::vector > > &solution_hessians, - const std::vector > &normals, - const std::vector > &evaluation_points, - std::vector > &computed_quantities) const; + compute_derived_quantities_vector + (const DataPostprocessorInputs::Vector &inputs, + std::vector > &computed_quantities) const; virtual std::vector 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 void BoussinesqFlowProblem::Postprocessor:: - compute_derived_quantities_vector (const std::vector > &solution_values, - const std::vector > > &solution_gradients, - const std::vector > > &/*solution_hessians*/, - const std::vector > &/*normals*/, - const std::vector > &/*evaluation_points*/, - std::vector > &computed_quantities) const + compute_derived_quantities_vector + (const DataPostprocessorInputs::Vector &inputs, + std::vector > &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 grad_u; for (unsigned int d=0; d strain_rate = symmetrize (grad_u); computed_quantities[q](dim+2) = 2 * EquationData::eta * strain_rate * strain_rate; diff --git a/examples/step-33/step-33.cc b/examples/step-33/step-33.cc index 454934fa75..1ce831f0fa 100644 --- a/examples/step-33/step-33.cc +++ b/examples/step-33/step-33.cc @@ -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::compute_derived_quantities_vector; + virtual void - compute_derived_quantities_vector (const std::vector > &solution_values, - const std::vector > > &solution_gradients, - const std::vector > > &solution_hessians, - const std::vector > &normals, - const std::vector > &evaluation_points, - std::vector > &computed_quantities) const; + compute_derived_quantities_vector + (const DataPostprocessorInputs::Vector &inputs, + std::vector > &computed_quantities) const; virtual std::vector 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 void EulerEquations::Postprocessor:: - compute_derived_quantities_vector (const std::vector > &solution_values, - const std::vector > > &solution_gradients, - const std::vector > > &/*solution_hessians*/, - const std::vector > &/*normals*/, - const std::vector > &/*evaluation_points*/, - std::vector > &computed_quantities) const + compute_derived_quantities_vector + (const DataPostprocessorInputs::Vector &inputs, + std::vector > &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 get_needed_update_flags() 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 // density_component information: for (unsigned int q=0; q { public: + using DataPostprocessor::compute_derived_quantities_vector; + virtual void - compute_derived_quantities_vector (const std::vector > &solution_values, - const std::vector > > &solution_gradients, - const std::vector > > &solution_hessians, - const std::vector > &normals, - const std::vector > &evaluation_points, - std::vector > &computed_quantities) const; + compute_derived_quantities_vector + (const dealii::DataPostprocessorInputs::Vector &inputs, + std::vector > &computed_quantities) const; virtual std::vector get_names () const; @@ -955,28 +954,27 @@ namespace Step47 template void Postprocessor:: - compute_derived_quantities_vector (const std::vector > &solution_values, - const std::vector > > &/*solution_gradients*/, - const std::vector > > &/*solution_hessians*/, - const std::vector > &/*normals*/, - const std::vector > &evaluation_points, - std::vector > &computed_quantities) const + compute_derived_quantities_vector + (const dealii::DataPostprocessorInputs::Vector &inputs, + std::vector > &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