libMesh
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
libMesh::ErrorVector Class Reference

The ErrorVector is a specialization of the StatisticsVector for error data computed on a finite element mesh. More...

#include <error_vector.h>

Inheritance diagram for libMesh::ErrorVector:
[legend]

Public Member Functions

 ErrorVector (dof_id_type i=0, MeshBase *mesh=nullptr)
 ErrorVector constructor; sets initial length to i. More...
 
 ErrorVector (dof_id_type i, ErrorVectorReal val)
 ErrorVector constructor; sets initial length to i and initial values to val. More...
 
virtual ErrorVectorReal minimum () const override
 
virtual Real mean () const override
 
virtual Real median () override
 
virtual Real median () const override
 A const version of the median function. More...
 
virtual Real variance () const override
 
virtual Real variance (const Real mean) const override
 
virtual std::vector< dof_id_typecut_below (Real cut) const override
 
virtual std::vector< dof_id_typecut_above (Real cut) const override
 
void plot_error (const std::string &filename, const MeshBase &mesh) const
 Plots a data file, of a type determined by looking at the file extension in filename, of the error values on the active elements of mesh. More...
 
virtual Real l2_norm () const
 
virtual ErrorVectorReal maximum () const
 
virtual Real stddev () const
 
virtual Real stddev (const Real known_mean) const
 
void normalize ()
 Divides all entries by the largest entry and stores the result. More...
 
virtual void histogram (std::vector< dof_id_type > &bin_members, unsigned int n_bins=10)
 
virtual void histogram (std::vector< dof_id_type > &bin_members, unsigned int n_bins=10) const
 A const version of the histogram function. More...
 
void plot_histogram (const processor_id_type my_procid, const std::string &filename, unsigned int n_bins)
 Generates a Matlab/Octave style file which can be used to make a plot of the histogram having the desired number of bins. More...
 

Protected Member Functions

bool is_active_elem (dof_id_type i) const
 Utility function to decide whether element i is active. More...
 

Protected Attributes

MeshBase_mesh
 Pointer to the mesh, which may be used to decide which elements are active. More...
 

Detailed Description

The ErrorVector is a specialization of the StatisticsVector for error data computed on a finite element mesh.

In general, when computing the error on a mesh only the active elements are considered, but the ErrorVector is sized according to the total number of elements in the mesh. The ErrorVector is thus padded with zeros for all the inactive elements, and this must be taken into account when calculating the statistics. Since the error is a positive quantity this class assumes it contains positive data (i.e. min_val >= 0.).

Author
Benjamin S. Kirk
Date
2003

Definition at line 50 of file error_vector.h.

Constructor & Destructor Documentation

◆ ErrorVector() [1/2]

libMesh::ErrorVector::ErrorVector ( dof_id_type  i = 0,
MeshBase mesh = nullptr 
)

ErrorVector constructor; sets initial length to i.

If mesh is not null, MeshBase::elem() and Elem::is_active() will be used to distinguish active and inactive elements. If mesh is null, ErrorVector will assume that all 0.0 error values correspond to inactive elements and all non-zero error values correspond to active elements.

Definition at line 62 of file error_vector.h.

62  :
63  StatisticsVector<ErrorVectorReal> (i),
64  _mesh(mesh)
65  {}
MeshBase * _mesh
Pointer to the mesh, which may be used to decide which elements are active.
Definition: error_vector.h:163

◆ ErrorVector() [2/2]

libMesh::ErrorVector::ErrorVector ( dof_id_type  i,
ErrorVectorReal  val 
)

ErrorVector constructor; sets initial length to i and initial values to val.

If mesh is not null, MeshBase::elem() and Elem::is_active() will be used to distinguish active and inactive elements. If mesh is null, ErrorVector will assume that all 0.0 error values correspond to inactive elements and all non-zero error values correspond to active elements.

Definition at line 75 of file error_vector.h.

75  :
76  StatisticsVector<ErrorVectorReal> (i,val) {}

Member Function Documentation

◆ cut_above()

virtual std::vector<dof_id_type> libMesh::ErrorVector::cut_above ( Real  cut) const
overridevirtual
Returns
A vector of dof_id_types which correspond to the indices of every member of the data set above the cutoff value cut ignoring inactive elements.

Reimplemented from libMesh::StatisticsVector< ErrorVectorReal >.

◆ cut_below()

virtual std::vector<dof_id_type> libMesh::ErrorVector::cut_below ( Real  cut) const
overridevirtual
Returns
A vector of dof_id_types which correspond to the indices of every member of the data set below the cutoff value cut ignoring inactive elements.

Reimplemented from libMesh::StatisticsVector< ErrorVectorReal >.

◆ histogram() [1/2]

virtual void libMesh::StatisticsVector< ErrorVectorReal >::histogram ( std::vector< dof_id_type > &  bin_members,
unsigned int  n_bins = 10 
)
virtualinherited
Returns
A histogram with n_bins bins for the data set.

For simplicity, the bins are assumed to be of uniform size. Upon return, the bin_members vector will contain unsigned integers which give the number of members in each bin. WARNING: This non-const function sorts the vector, changing its order. Source: GNU Scientific Library.

◆ histogram() [2/2]

virtual void libMesh::StatisticsVector< ErrorVectorReal >::histogram ( std::vector< dof_id_type > &  bin_members,
unsigned int  n_bins = 10 
) const
virtualinherited

A const version of the histogram function.

◆ is_active_elem()

bool libMesh::ErrorVector::is_active_elem ( dof_id_type  i) const
protected

Utility function to decide whether element i is active.

◆ l2_norm()

virtual Real libMesh::StatisticsVector< ErrorVectorReal >::l2_norm ( ) const
virtualinherited
Returns
The l2 norm of the data set.

◆ maximum()

virtual ErrorVectorReal libMesh::StatisticsVector< ErrorVectorReal >::maximum ( ) const
virtualinherited
Returns
The maximum value in the data set.

◆ mean()

virtual Real libMesh::ErrorVector::mean ( ) const
overridevirtual
Returns
The mean value of the data set. Ignores zero values.

Reimplemented from libMesh::StatisticsVector< ErrorVectorReal >.

Referenced by variance().

◆ median() [1/2]

virtual Real libMesh::ErrorVector::median ( )
overridevirtual
Returns
The median (e.g. the middle) value of the data set, ignoring inactive elements.

This function modifies the original data by sorting, so it can't be called on const objects. Source: GNU Scientific Library

Reimplemented from libMesh::StatisticsVector< ErrorVectorReal >.

◆ median() [2/2]

virtual Real libMesh::ErrorVector::median ( ) const
overridevirtual

A const version of the median function.

Requires twice the memory of original data set but does not change the original.

Reimplemented from libMesh::StatisticsVector< ErrorVectorReal >.

◆ minimum()

virtual ErrorVectorReal libMesh::ErrorVector::minimum ( ) const
overridevirtual
Returns
The minimum nonzero value in the data set.

Reimplemented from libMesh::StatisticsVector< ErrorVectorReal >.

◆ normalize()

void libMesh::StatisticsVector< ErrorVectorReal >::normalize ( )
inherited

Divides all entries by the largest entry and stores the result.

◆ plot_error()

void libMesh::ErrorVector::plot_error ( const std::string &  filename,
const MeshBase mesh 
) const

Plots a data file, of a type determined by looking at the file extension in filename, of the error values on the active elements of mesh.

◆ plot_histogram()

void libMesh::StatisticsVector< ErrorVectorReal >::plot_histogram ( const processor_id_type  my_procid,
const std::string &  filename,
unsigned int  n_bins 
)
inherited

Generates a Matlab/Octave style file which can be used to make a plot of the histogram having the desired number of bins.

Uses the histogram(...) function in this class WARNING: The histogram(...) function is non-const, and changes the order of the vector.

◆ stddev() [1/2]

virtual Real libMesh::StatisticsVector< ErrorVectorReal >::stddev ( ) const
virtualinherited
Returns
The standard deviation of the data set, which is simply the square-root of the variance.

Definition at line 154 of file statistics.h.

References libMesh::StatisticsVector< T >::variance().

155  { return std::sqrt(this->variance()); }

◆ stddev() [2/2]

virtual Real libMesh::StatisticsVector< ErrorVectorReal >::stddev ( const Real  known_mean) const
virtualinherited
Returns
Computes the standard deviation of the data set, which is simply the square-root of the variance.

This method can be used for efficiency when the mean has already been computed.

Definition at line 164 of file statistics.h.

References libMesh::StatisticsVector< T >::variance().

165  { return std::sqrt(this->variance(known_mean)); }

◆ variance() [1/2]

virtual Real libMesh::ErrorVector::variance ( ) const
overridevirtual
Returns
The variance of the data set ignoring inactive elements.

Uses a recurrence relation to prevent data overflow for large sums.

Note
The variance is equal to the standard deviation squared. The variance is normalized by N in this case. Source: GNU Scientific Library.

Reimplemented from libMesh::StatisticsVector< ErrorVectorReal >.

Definition at line 115 of file error_vector.h.

References mean().

116  { return this->variance(this->mean()); }
virtual Real variance() const override
Definition: error_vector.h:115
virtual Real mean() const override

◆ variance() [2/2]

virtual Real libMesh::ErrorVector::variance ( const Real  mean) const
overridevirtual
Returns
The variance of the data set ignoring inactive elements and given the mean.

This is useful for efficiency when you have already calculated the mean. Uses a recurrence relation to prevent data overflow for large sums.

Note
The variance is equal to the standard deviation squared. Source: GNU Scientific Library.

Reimplemented from libMesh::StatisticsVector< ErrorVectorReal >.

Member Data Documentation

◆ _mesh

MeshBase* libMesh::ErrorVector::_mesh
protected

Pointer to the mesh, which may be used to decide which elements are active.

Definition at line 163 of file error_vector.h.


The documentation for this class was generated from the following file: