/usr/include/deal.II/numerics/data_postprocessor.h is in libdeal.ii-dev 8.1.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | // ---------------------------------------------------------------------
// $Id: data_postprocessor.h 30162 2013-07-26 16:31:42Z bangerth $
//
// Copyright (C) 2007 - 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------
#ifndef __deal2__data_postprocessor_h
#define __deal2__data_postprocessor_h
#include <deal.II/base/subscriptor.h>
#include <deal.II/base/tensor.h>
#include <deal.II/lac/vector.h>
#include <deal.II/fe/fe_update_flags.h>
#include <deal.II/numerics/data_component_interpretation.h>
#include <vector>
#include <string>
DEAL_II_NAMESPACE_OPEN
/**
* For the (graphical) output of a FE solution one frequently wants to include
* derived quantities, which are calculated from the values of the solution
* and possibly the first and second derivates of the solution. Examples are
* the calculation Mach numbers from velocity and density in supersonic flow
* computations, or the computation of the magnitude of a complex-valued
* solution as demonstrated in step-29. Other uses are shown in step-32 and
* step-33. This class offers the interface to perform such
* postprocessing. Given the values and derivatives of the solution at those
* points where we want to generated output, the functions of this class can
* be overloaded to compute new quantities.
*
* A data vector and an object of a derived class can be given to the
* DataOut::add_data_vector() function, which will write the derived
* quantities instead of the provided data to the output file. Note, that the
* DataPostprocessor has to live until DataOut::build_patches has been
* called. DataOutFaces and DataOutRotation can be used as well.
*
* In order not to perform needless calculations, DataPostprocessor
* has to provide information which input data is needed for the
* calculation of the derived quantities, i.e. whether it needs the
* values, the first derivative and/or the second derivative of the
* provided data. DataPostprocessor objects which are used in
* combination with a DataOutFaces object can also ask for the normal
* vectors at each point. The information which data is needed has to
* be provided via the UpdateFlags returned by the virtual function
* get_needed_update_flags(). It is your responsibility to use only
* those values which were updated in the calculation of derived
* quantities. The DataOut object will provide references to the
* requested data in the call to compute_derived_quantities_scalar()
* or compute_derived_quantities_vector() (DataOut decides which of
* the two functions to call depending on whether the finite element
* in use has only a single, or multiple vector components; note that
* this is only determined by the number of components in the finite
* element in use, and not by whether the data computed by a class
* derived from the current one is scalar or vector valued).
*
* Furthermore, derived classes have to implement the get_names()
* function, where the number of output variables returned
* by the latter function has to match the size of the vector returned by the
* former. Furthermore, this number has to match the number of computed
* quantities, of course.
*
*
* <h3>Use in simpler cases</h3>
*
* Deriving from the current class allows to implement very general postprocessors.
* For example, in the step-32 program, we implement a postprocessor that
* takes a solution that consists of velocity, pressure and temperature (dim+2
* components) and computes a variety of output quantities, some of which
* are vector valued and some of which are scalar. On the other hand,
* in step-29 we implement a postprocessor that only computes the magnitude
* of a complex number given by a two-component finite element. It seems silly
* to have to implement four virtual functions for this
* (compute_derived_quantities_scalar() or compute_derived_quantities_vector(),
* get_names(), get_update_flags() and get_data_component_interpretation()).
*
* To this end there are two classes DataPostprocessorScalar and
* DataPostprocessorVector that are meant to be used if the output quantity
* is either a single scalar or a single vector (here used meaning to have
* exactly dim components). When using these classes, one only has to write a
* constructor that passes the name of the output variable and the update
* flags to the constructor of the base class and overload the function
* that actually computes the results.
*
* @ingroup output
* @author Tobias Leicht, 2007
*/
template <int dim>
class DataPostprocessor: public Subscriptor
{
public:
/**
* Virtual desctructor for safety. Does not
* do anything.
*/
virtual ~DataPostprocessor ();
/**
* @deprecated
*
* This function only exists for backward
* compatibility as this is the interface
* provided by previous versions of the
* library. The default implementation of
* the other function of same name below
* calls this function by simply dropping
* the argument that denotes the
* evaluation points. Since this function
* might at one point go away, you should
* overload the other function instead.
*/
virtual
void
compute_derived_quantities_scalar (const std::vector<double> &uh,
const std::vector<Tensor<1,dim> > &duh,
const std::vector<Tensor<2,dim> > &dduh,
const std::vector<Point<dim> > &normals,
std::vector<Vector<double> > &computed_quantities) const DEAL_II_DEPRECATED;
/**
* This is the main function which actually
* performs the postprocessing. The last
* argument is a reference to the
* postprocessed data which has correct
* size already and must be filled by this
* function. @p uh is a reference to a
* vector of data values at all points, @p
* duh the same for gradients, @p dduh for
* second derivatives and @p normals is a
* reference to the normal vectors. Note,
* that the last four references will only
* contain valid data, if the respective
* flags are returned by @p
* get_needed_update_flags, otherwise those
* vectors will be in an unspecified
* state. @p normals will always be an
* empty vector when working on cells, not
* on faces.
*
* This function is called when
* the original data vector
* represents scalar data,
* i.e. the finite element in use
* has only a single vector
* component.
*/
virtual
void
compute_derived_quantities_scalar (const std::vector<double> &uh,
const std::vector<Tensor<1,dim> > &duh,
const std::vector<Tensor<2,dim> > &dduh,
const std::vector<Point<dim> > &normals,
const std::vector<Point<dim> > &evaluation_points,
std::vector<Vector<double> > &computed_quantities) const;
/**
* @deprecated
*
* This function only exists for backward
* compatibility as this is the interface
* provided by previous versions of the
* library. The default implementation of
* the other function of same name below
* calls this function by simply dropping
* the argument that denotes the
* evaluation points. Since this function
* might at one point go away, you should
* overload the other function instead.
*/
virtual
void
compute_derived_quantities_vector (const std::vector<Vector<double> > &uh,
const std::vector<std::vector<Tensor<1,dim> > > &duh,
const std::vector<std::vector<Tensor<2,dim> > > &dduh,
const std::vector<Point<dim> > &normals,
std::vector<Vector<double> > &computed_quantities) const DEAL_II_DEPRECATED;
/**
* Same as the
* compute_derived_quantities_scalar()
* function, but this function is called
* when the original data vector
* represents vector data, i.e. the
* finite element in use has multiple
* vector components.
*/
virtual
void
compute_derived_quantities_vector (const std::vector<Vector<double> > &uh,
const std::vector<std::vector<Tensor<1,dim> > > &duh,
const std::vector<std::vector<Tensor<2,dim> > > &dduh,
const std::vector<Point<dim> > &normals,
const std::vector<Point<dim> > &evaluation_points,
std::vector<Vector<double> > &computed_quantities) const;
/**
* Return the vector of strings describing
* the names of the computed quantities.
*/
virtual std::vector<std::string> get_names () const = 0;
/**
* This functions returns
* information about how the
* individual components of
* output files that consist of
* more than one data set are to
* be interpreted.
*
* For example, if one has a finite
* element for the Stokes equations in
* 2d, representing components (u,v,p),
* one would like to indicate that the
* first two, u and v, represent a
* logical vector so that later on when
* we generate graphical output we can
* hand them off to a visualization
* program that will automatically know
* to render them as a vector field,
* rather than as two separate and
* independent scalar fields.
*
* The default implementation of this
* function returns a vector of values
* DataComponentInterpretation::component_is_scalar,
* indicating that all output components
* are independent scalar
* fields. However, if a derived class
* produces data that represents vectors,
* it may return a vector that contains
* values
* DataComponentInterpretation::component_is_part_of_vector. In
* the example above, one would return a
* vector with components
* (DataComponentInterpretation::component_is_part_of_vector,
* DataComponentInterpretation::component_is_part_of_vector,
* DataComponentInterpretation::component_is_scalar)
* for (u,v,p).
*/
virtual
std::vector<DataComponentInterpretation::DataComponentInterpretation>
get_data_component_interpretation () const;
/**
* Return, which data has to be provided to
* compute the derived quantities. This has
* to be a combination of @p update_values,
* @p update_gradients and @p
* update_hessians. If the
* DataPostprocessor is to be used in
* combination with DataOutFaces, you may
* also ask for a update of normals via the
* @p update_normal_vectors flag.
*/
virtual UpdateFlags get_needed_update_flags () const = 0;
};
/**
* This class provides a simpler interface to the functionality offered by
* the DataPostprocessor class in case one wants to compute only a
* single scalar quantity from the finite element field passed to the
* DataOut class. For this particular case, it is clear what the returned
* value of DataPostprocessor::get_data_component_interpretation() should
* be and we pass the values returned by get_names() and get_needed_update_flags()
* to the constructor so that derived classes do not have to implement these
* functions by hand.
*
* All derived classes have to do is implement a constructor and overload
* either DataPostprocessor::compute_derived_quantities_scalar() or
* DataPostprocessor::compute_derived_quantities_vector().
*
* An example of how this class can be used can be found in step-29.
*
* @ingroup output
* @author Wolfgang Bangerth, 2011
*/
template <int dim>
class DataPostprocessorScalar : public DataPostprocessor<dim>
{
public:
/**
* Constructor. Take the name of the single scalar variable
* computed by classes derived from the current one, as well
* as the update flags necessary to compute this quantity.
*
* @param name The name by which the scalar variable
* computed by this class should be made available in
* graphical output files.
* @param update_flags This has
* to be a combination of @p update_values,
* @p update_gradients and @p
* update_hessians. If the
* DataPostprocessor is to be used in
* combination with DataOutFaces, you may
* also ask for a update of normals via the
* @p update_normal_vectors flag.
**/
DataPostprocessorScalar (const std::string &name,
const UpdateFlags update_flags);
/**
* Return the vector of strings describing
* the names of the computed quantities.
* Given the purpose of this class, this
* is a vector with a single entry equal
* to the name given to the constructor.
*/
virtual std::vector<std::string> get_names () const;
/**
* This functions returns
* information about how the
* individual components of
* output files that consist of
* more than one data set are to
* be interpreted. Since the current
* class is meant to be used for a
* single scalar result variable,
* the returned value is obviously
* DataComponentInterpretation::component_is_scalar.
*/
virtual
std::vector<DataComponentInterpretation::DataComponentInterpretation>
get_data_component_interpretation () const;
/**
* Return, which data has to be provided to
* compute the derived quantities.
* The flags returned here are the ones
* passed to the constructor of this
* class.
*/
virtual UpdateFlags get_needed_update_flags () const;
private:
/**
* Copies of the two arguments given to the constructor of this
* class.
*/
const std::string name;
const UpdateFlags update_flags;
};
/**
* This class provides a simpler interface to the functionality offered by
* the DataPostprocessor class in case one wants to compute only a
* single vector quantity (defined as having exactly dim components)
* from the finite element field passed to the
* DataOut class. For this particular case, it is clear what the returned
* value of DataPostprocessor::get_data_component_interpretation() should
* be and we pass the values returned by get_names() and get_needed_update_flags()
* to the constructor so that derived classes do not have to implement these
* functions by hand.
*
* All derived classes have to do is implement a constructor and overload
* either DataPostprocessor::compute_derived_quantities_scalar() or
* DataPostprocessor::compute_derived_quantities_vector().
*
* An example of how the closely related class DataPostprocessorScalar is
* used can be found in step-29.
*
* @ingroup output
* @author Wolfgang Bangerth, 2011
*/
template <int dim>
class DataPostprocessorVector : public DataPostprocessor<dim>
{
public:
/**
* Constructor. Take the name of the single vector variable
* computed by classes derived from the current one, as well
* as the update flags necessary to compute this quantity.
*
* @param name The name by which the vector variable
* computed by this class should be made available in
* graphical output files.
* @param update_flags This has
* to be a combination of @p update_values,
* @p update_gradients and @p
* update_hessians. If the
* DataPostprocessor is to be used in
* combination with DataOutFaces, you may
* also ask for a update of normals via the
* @p update_normal_vectors flag.
**/
DataPostprocessorVector (const std::string &name,
const UpdateFlags update_flags);
/**
* Return the vector of strings describing
* the names of the computed quantities.
* Given the purpose of this class, this
* is a vector with dim entries all equal
* to the name given to the constructor.
*/
virtual std::vector<std::string> get_names () const;
/**
* This functions returns
* information about how the
* individual components of
* output files that consist of
* more than one data set are to
* be interpreted. Since the current
* class is meant to be used for a
* single vector result variable,
* the returned value is obviously
* DataComponentInterpretation::component_is_part
* repeated dim times.
*/
virtual
std::vector<DataComponentInterpretation::DataComponentInterpretation>
get_data_component_interpretation () const;
/**
* Return which data has to be provided to
* compute the derived quantities.
* The flags returned here are the ones
* passed to the constructor of this
* class.
*/
virtual UpdateFlags get_needed_update_flags () const;
private:
/**
* Copies of the two arguments given to the constructor of this
* class.
*/
const std::string name;
const UpdateFlags update_flags;
};
DEAL_II_NAMESPACE_CLOSE
#endif
|