$extrastylesheet
#include <system_norm.h>
Public Member Functions | |
| SystemNorm () | |
| SystemNorm (const FEMNormType &t) | |
| SystemNorm (const std::vector< FEMNormType > &norms) | |
| SystemNorm (const std::vector< FEMNormType > &norms, std::vector< Real > &weights) | |
| SystemNorm (const std::vector< FEMNormType > &norms, std::vector< std::vector< Real > > &weights) | |
| SystemNorm (const SystemNorm &s) | |
| bool | is_discrete () const |
| Real | calculate_norm (const std::vector< Real > &v) |
| Real | calculate_norm (const std::vector< Real > &v1, const std::vector< Real > &v2) |
| bool | is_identity () |
| FEMNormType | type (unsigned int var) const |
| void | set_type (unsigned int var, const FEMNormType &t) |
| Real | weight (unsigned int var) const |
| void | set_weight (unsigned int var, Real w) |
| void | set_off_diagonal_weight (unsigned int i, unsigned int j, Real w) |
| Real | weight_sq (unsigned int var) const |
Private Attributes | |
| std::vector< FEMNormType > | _norms |
| std::vector< Real > | _weights |
| std::vector< Real > | _weights_sq |
| std::vector< std::vector< Real > > | _off_diagonal_weights |
This class defines a norm/seminorm to be applied to a NumericVector which contains coefficients in a finite element space.
Discrete vector norms and weighted l2 combinations of Sobolev norms and seminorms are representable.
Definition at line 47 of file system_norm.h.
| libMesh::SystemNorm::SystemNorm | ( | ) | [inline] |
Constructor, defaults to DISCRETE_L2
Definition at line 172 of file system_norm.h.
: _norms(1, DISCRETE_L2), _weights(1, 1.0), _weights_sq(1, 1.0) { }
| libMesh::SystemNorm::SystemNorm | ( | const FEMNormType & | t | ) | [inline] |
Constructor, for discrete vector norms, systems with one variable, and systems for which the same norm type should be used with a weight of one on each variable.
This is deliberately an implicit constructor; we want user code to be able to include lines like "error_norm = L2"
Definition at line 179 of file system_norm.h.
: _norms(1, t), _weights(1, 1.0), _weights_sq(1, 1.0) { }
| libMesh::SystemNorm::SystemNorm | ( | const std::vector< FEMNormType > & | norms | ) | [inline, explicit] |
Constructor, for unweighted sobolev norms on systems with multiple variables.
For a system with n variables, the final norm will be the l2 norm of the n-vector of the norms in each variable.
Definition at line 186 of file system_norm.h.
References _norms, and libMesh::DISCRETE_L2.
: _norms(norms), _weights(1, 1.0), _weights_sq(1, 1.0) { if (_norms.empty()) _norms.push_back(DISCRETE_L2); }
| libMesh::SystemNorm::SystemNorm | ( | const std::vector< FEMNormType > & | norms, |
| std::vector< Real > & | weights | ||
| ) | [inline] |
Constructor, for weighted sobolev norms on systems with multiple variables.
For a system with n variables, the final norm will be the l2 norm of the n-vector of the norms in each variable, each multiplied by weight.
Definition at line 195 of file system_norm.h.
References _norms, _weights, _weights_sq, and libMesh::DISCRETE_L2.
: _norms(norms), _weights(weights), _weights_sq(_weights.size(), 0.0) { if (_norms.empty()) _norms.push_back(DISCRETE_L2); if (_weights.empty()) { _weights.push_back(1.0); _weights_sq.push_back(1.0); } else for (std::size_t i=0; i != _weights.size(); ++i) _weights_sq[i] = _weights[i] * _weights[i]; }
| libMesh::SystemNorm::SystemNorm | ( | const std::vector< FEMNormType > & | norms, |
| std::vector< std::vector< Real > > & | weights | ||
| ) | [inline] |
Constructor, for weighted sobolev norms on systems with multiple variables and their adjoints
For a system with n variables, the final norm computed will be of the form norm_u^T*R*norm_z where R is a scaling matrix
Definition at line 213 of file system_norm.h.
References _norms, _off_diagonal_weights, _weights, _weights_sq, and libMesh::DISCRETE_L2.
: _norms(norms), _weights(weights.size()), _weights_sq(weights.size()), _off_diagonal_weights(weights) { if(_norms.empty()) _norms.push_back(DISCRETE_L2); if (_weights.empty()) { _weights.push_back(1.0); _weights_sq.push_back(1.0); } else { // Loop over the entries of the user provided matrix and store its entries in // the _off_diagonal_weights or _diagonal_weights for(std::size_t i=0; i!=_off_diagonal_weights.size(); ++i) { if(_off_diagonal_weights[i].size() > i) { _weights[i] = _off_diagonal_weights[i][i]; _off_diagonal_weights[i][i] = 0; } else _weights[i] = 1.0; } for (std::size_t i=0; i != _weights.size(); ++i) _weights_sq[i] = _weights[i] * _weights[i]; } }
| libMesh::SystemNorm::SystemNorm | ( | const SystemNorm & | s | ) | [inline] |
Copy Constructor
Definition at line 248 of file system_norm.h.
: _norms(s._norms), _weights(s._weights), _weights_sq(s._weights_sq) { }
| Real libMesh::SystemNorm::calculate_norm | ( | const std::vector< Real > & | v | ) | [inline] |
Returns the weighted norm v^T*W*v where W represents our weights matrix or weights vector times identity matrix.
Definition at line 393 of file system_norm.h.
Referenced by libMesh::AdjointResidualErrorEstimator::estimate_error().
{
return this->calculate_norm(v1,v1);
}
| Real libMesh::SystemNorm::calculate_norm | ( | const std::vector< Real > & | v1, |
| const std::vector< Real > & | v2 | ||
| ) | [inline] |
Returns the weighted inner product v1^T*W*v2 where R is our weights
Definition at line 346 of file system_norm.h.
References _off_diagonal_weights, _weights, and libMesh::Real.
{
// The vectors are assumed to both be vectors of the (same number
// of) components
std::size_t vsize = v1.size();
libmesh_assert_equal_to (vsize, v2.size());
// We'll support implicitly defining weights, but if the user sets
// more weights than he uses then something's probably wrong
std::size_t diagsize = this->_weights.size();
libmesh_assert_greater_equal (vsize, diagsize);
// Initialize the variable val
Real val = 0.;
// Loop over all the components of the system with explicit
// weights
for(std::size_t i = 0; i != diagsize; i++)
{
val += this->_weights[i] * v1[i] * v2[i];
}
// Loop over all the components of the system with implicit
// weights
for(std::size_t i = diagsize; i < vsize; i++)
{
val += v1[i] * v2[i];
}
// Loop over the components of the system
std::size_t nrows = this->_off_diagonal_weights.size();
libmesh_assert_less_equal (vsize, nrows);
for(std::size_t i = 0; i != nrows; i++)
{
std::size_t ncols = this->_off_diagonal_weights[i].size();
for(std::size_t j=0; j != ncols; j++)
{
// Note that the diagonal weights here were set to zero
// in the constructor
val += this->_off_diagonal_weights[i][j] * v1[i] * v2[j];
}
}
return(val);
}
| bool libMesh::SystemNorm::is_discrete | ( | ) | const [inline] |
Returns true if this is purely a discrete norm
Definition at line 255 of file system_norm.h.
References _norms, libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, and libMesh::libmesh_assert().
Referenced by libMesh::System::calculate_norm().
{
libmesh_assert (!_norms.empty());
if (_norms[0] == DISCRETE_L1 ||
_norms[0] == DISCRETE_L2 ||
_norms[0] == DISCRETE_L_INF)
return true;
return false;
}
| bool libMesh::SystemNorm::is_identity | ( | ) | [inline] |
Returns true if no weight matrix W is specified or an identiy matrix is specified, otherwise returns false
Definition at line 399 of file system_norm.h.
References _off_diagonal_weights, and _weights.
Referenced by libMesh::AdjointResidualErrorEstimator::estimate_error().
{
std::size_t nrows = this->_off_diagonal_weights.size();
// If any of the off-diagonal elements is not 0, then we are in the non-identity case
for(std::size_t i = 0; i != nrows; i++)
{
std::size_t ncols = this->_off_diagonal_weights[i].size();
for(std::size_t j = 0; j != ncols; j++)
{
if(_off_diagonal_weights[i][j] != 0)
{
return(false);
}
}
}
// If any of the diagonal elements is not 1, then we are in the non-identity case
nrows = this->_weights.size();
for(std::size_t i = 0; i != nrows; i++)
if(_weights[i] != 1)
return(false);
// If all the off-diagonals elements are 0, and diagonal elements 1, then we are in an identity case
return(true);
}
| void libMesh::SystemNorm::set_off_diagonal_weight | ( | unsigned int | i, |
| unsigned int | j, | ||
| Real | w | ||
| ) | [inline] |
Sets the weight corresponding to the norm from the variable pair v1(var1) coming from v2(var2). See calculate_norm
Definition at line 317 of file system_norm.h.
References _off_diagonal_weights, _weights, and libMesh::libmesh_assert().
{
libmesh_assert (!_weights.empty());
if (i >= _off_diagonal_weights.size())
{
_off_diagonal_weights.resize(i+1);
}
if (j >= _off_diagonal_weights[i].size())
{
_off_diagonal_weights[i].resize(j+1, 0.);
}
_off_diagonal_weights[i][j] = w;
}
| void libMesh::SystemNorm::set_type | ( | unsigned int | var, |
| const FEMNormType & | t | ||
| ) | [inline] |
Sets the type of the norm in variable var
Definition at line 281 of file system_norm.h.
References _norms, and libMesh::libmesh_assert().
{
libmesh_assert (!_norms.empty());
if (var >= _norms.size())
_norms.resize(var+1, t);
_norms[var] = t;
}
| void libMesh::SystemNorm::set_weight | ( | unsigned int | var, |
| Real | w | ||
| ) | [inline] |
Sets the weight corresponding to the norm in variable var
Definition at line 302 of file system_norm.h.
References _weights, _weights_sq, and libMesh::libmesh_assert().
{
libmesh_assert (!_weights.empty());
if (var >= _weights.size())
{
_weights.resize(var+1, 1.0);
_weights_sq.resize(var+1, 1.0);
}
_weights[var] = w;
_weights_sq[var] = w*w;
}
| FEMNormType libMesh::SystemNorm::type | ( | unsigned int | var | ) | const [inline] |
Returns the type of the norm in variable var
Definition at line 269 of file system_norm.h.
References _norms, and libMesh::libmesh_assert().
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::System::calculate_norm(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), and libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()().
{
libmesh_assert (!_norms.empty());
std::size_t i = (var < _norms.size()) ? var : _norms.size() - 1;
return _norms[i];
}
| Real libMesh::SystemNorm::weight | ( | unsigned int | var | ) | const [inline] |
Returns the weight corresponding to the norm in variable var
Definition at line 293 of file system_norm.h.
References _weights, and libMesh::libmesh_assert().
Referenced by libMesh::DiscontinuityMeasure::boundary_side_integration(), libMesh::KellyErrorEstimator::boundary_side_integration(), libMesh::System::calculate_norm(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::LaplacianErrorEstimator::internal_side_integration(), libMesh::DiscontinuityMeasure::internal_side_integration(), libMesh::KellyErrorEstimator::internal_side_integration(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), and libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()().
{
libmesh_assert (!_weights.empty());
return (var < _weights.size()) ? _weights[var] : 1.0;
}
| Real libMesh::SystemNorm::weight_sq | ( | unsigned int | var | ) | const [inline] |
Returns the squared weight corresponding to the norm in variable var. We cache that at construction time to save a few flops.
Definition at line 337 of file system_norm.h.
References _weights_sq, and libMesh::libmesh_assert().
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::System::calculate_norm(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), and libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()().
{
libmesh_assert (!_weights_sq.empty());
return (var < _weights_sq.size()) ? _weights_sq[var] : 1.0;
}
std::vector<FEMNormType> libMesh::SystemNorm::_norms [private] |
Definition at line 154 of file system_norm.h.
Referenced by is_discrete(), set_type(), SystemNorm(), and type().
std::vector<std::vector<Real> > libMesh::SystemNorm::_off_diagonal_weights [private] |
One more data structure needed to store the off diagonal components for the generalize SystemNorm case
Definition at line 163 of file system_norm.h.
Referenced by calculate_norm(), is_identity(), set_off_diagonal_weight(), and SystemNorm().
std::vector<Real> libMesh::SystemNorm::_weights [private] |
Definition at line 156 of file system_norm.h.
Referenced by calculate_norm(), is_identity(), set_off_diagonal_weight(), set_weight(), SystemNorm(), and weight().
std::vector<Real> libMesh::SystemNorm::_weights_sq [private] |
Definition at line 157 of file system_norm.h.
Referenced by set_weight(), SystemNorm(), and weight_sq().