libMesh::SystemNorm Class Reference
#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 |
Detailed Description
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 48 of file system_norm.h.
Constructor & Destructor Documentation
| libMesh::SystemNorm::SystemNorm | ( | ) | [inline] |
Constructor, defaults to DISCRETE_L2
Definition at line 173 of file system_norm.h.
00173 : 00174 _norms(1, DISCRETE_L2), _weights(1, 1.0), _weights_sq(1, 1.0) 00175 { 00176 }
| 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 180 of file system_norm.h.
00180 : 00181 _norms(1, t), _weights(1, 1.0), _weights_sq(1, 1.0) 00182 { 00183 }
| 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 187 of file system_norm.h.
References _norms, and libMeshEnums::DISCRETE_L2.
00187 : 00188 _norms(norms), _weights(1, 1.0), _weights_sq(1, 1.0) 00189 { 00190 if (_norms.empty()) 00191 _norms.push_back(DISCRETE_L2); 00192 }
| 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 196 of file system_norm.h.
References _norms, _weights, _weights_sq, and libMeshEnums::DISCRETE_L2.
00197 : 00198 _norms(norms), _weights(weights), _weights_sq(_weights.size(), 0.0) 00199 { 00200 if (_norms.empty()) 00201 _norms.push_back(DISCRETE_L2); 00202 00203 if (_weights.empty()) 00204 { 00205 _weights.push_back(1.0); 00206 _weights_sq.push_back(1.0); 00207 } 00208 else 00209 for (std::size_t i=0; i != _weights.size(); ++i) 00210 _weights_sq[i] = _weights[i] * _weights[i]; 00211 }
| 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 214 of file system_norm.h.
References _norms, _off_diagonal_weights, _weights, _weights_sq, and libMeshEnums::DISCRETE_L2.
00215 : 00216 _norms(norms), _weights(weights.size()), _off_diagonal_weights(weights) 00217 { 00218 if(_norms.empty()) 00219 _norms.push_back(DISCRETE_L2); 00220 00221 if (_weights.empty()) 00222 { 00223 _weights.push_back(1.0); 00224 _weights_sq.push_back(1.0); 00225 } 00226 else 00227 { 00228 // Loop over the entries of the user provided matrix and store its entries in 00229 // the _off_diagonal_weights or _diagonal_weights 00230 for(std::size_t i=0; i!=_off_diagonal_weights.size(); ++i) 00231 { 00232 if(_off_diagonal_weights[i].size() > i) 00233 { 00234 _weights[i] = _off_diagonal_weights[i][i]; 00235 _off_diagonal_weights[i][i] = 0; 00236 } 00237 else 00238 _weights[i] = 1.0; 00239 } 00240 for (std::size_t i=0; i != _weights.size(); ++i) 00241 _weights_sq[i] = _weights[i] * _weights[i]; 00242 } 00243 }
| libMesh::SystemNorm::SystemNorm | ( | const SystemNorm & | s | ) | [inline] |
Copy Constructor
Definition at line 246 of file system_norm.h.
00246 : 00247 _norms(s._norms), _weights(s._weights), _weights_sq(s._weights_sq) 00248 { 00249 }
Member Function Documentation
| 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 344 of file system_norm.h.
References _off_diagonal_weights, _weights, and libMesh::Real.
00345 { 00346 // The vectors are assumed to both be vectors of the (same number 00347 // of) components 00348 std::size_t vsize = v1.size(); 00349 libmesh_assert_equal_to (vsize, v2.size()); 00350 00351 // We'll support implicitly defining weights, but if the user sets 00352 // more weights than he uses then something's probably wrong 00353 std::size_t diagsize = this->_weights.size(); 00354 libmesh_assert_greater_equal (vsize, diagsize); 00355 00356 // Initialize the variable val 00357 Real val = 0.; 00358 00359 // Loop over all the components of the system with explicit 00360 // weights 00361 for(std::size_t i = 0; i != diagsize; i++) 00362 { 00363 val += this->_weights[i] * v1[i] * v2[i]; 00364 } 00365 // Loop over all the components of the system with implicit 00366 // weights 00367 for(std::size_t i = diagsize; i < vsize; i++) 00368 { 00369 val += v1[i] * v2[i]; 00370 } 00371 00372 // Loop over the components of the system 00373 std::size_t nrows = this->_off_diagonal_weights.size(); 00374 libmesh_assert_less_equal (vsize, nrows); 00375 00376 for(std::size_t i = 0; i != nrows; i++) 00377 { 00378 std::size_t ncols = this->_off_diagonal_weights[i].size(); 00379 for(std::size_t j=0; j != ncols; j++) 00380 { 00381 // Note that the diagonal weights here were set to zero 00382 // in the constructor 00383 val += this->_off_diagonal_weights[i][j] * v1[i] * v2[j]; 00384 } 00385 } 00386 00387 return(val); 00388 }
Returns the weighted norm v^T*W*v where W represents our weights matrix or weights vector times identity matrix.
Definition at line 391 of file system_norm.h.
Referenced by libMesh::AdjointResidualErrorEstimator::estimate_error().
00392 { 00393 return this->calculate_norm(v1,v1); 00394 }
| bool libMesh::SystemNorm::is_discrete | ( | ) | const [inline] |
Returns true if this is purely a discrete norm
Definition at line 253 of file system_norm.h.
References _norms, libMeshEnums::DISCRETE_L1, libMeshEnums::DISCRETE_L2, and libMeshEnums::DISCRETE_L_INF.
Referenced by libMesh::System::calculate_norm().
00254 { 00255 libmesh_assert (!_norms.empty()); 00256 00257 if (_norms[0] == DISCRETE_L1 || 00258 _norms[0] == DISCRETE_L2 || 00259 _norms[0] == DISCRETE_L_INF) 00260 return true; 00261 00262 return false; 00263 }
| 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 397 of file system_norm.h.
References _off_diagonal_weights, and _weights.
Referenced by libMesh::AdjointResidualErrorEstimator::estimate_error().
00398 { 00399 std::size_t nrows = this->_off_diagonal_weights.size(); 00400 00401 // If any of the off-diagonal elements is not 0, then we are in the non-identity case 00402 for(std::size_t i = 0; i != nrows; i++) 00403 { 00404 std::size_t ncols = this->_off_diagonal_weights[i].size(); 00405 for(std::size_t j = 0; j != ncols; j++) 00406 { 00407 if(_off_diagonal_weights[i][j] != 0) 00408 { 00409 return(false); 00410 } 00411 } 00412 } 00413 00414 // If any of the diagonal elements is not 1, then we are in the non-identity case 00415 nrows = this->_weights.size(); 00416 for(std::size_t i = 0; i != nrows; i++) 00417 if(_weights[i] != 1) 00418 return(false); 00419 00420 // If all the off-diagonals elements are 0, and diagonal elements 1, then we are in an identity case 00421 return(true); 00422 }
| 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 315 of file system_norm.h.
References _off_diagonal_weights, and _weights.
00316 { 00317 libmesh_assert (!_weights.empty()); 00318 00319 if (i >= _off_diagonal_weights.size()) 00320 { 00321 _off_diagonal_weights.resize(i+1); 00322 } 00323 00324 if (j >= _off_diagonal_weights[i].size()) 00325 { 00326 _off_diagonal_weights[i].resize(j+1, 0.); 00327 } 00328 00329 _off_diagonal_weights[i][j] = w; 00330 00331 }
| void libMesh::SystemNorm::set_type | ( | unsigned int | var, | |
| const FEMNormType & | t | |||
| ) | [inline] |
| void libMesh::SystemNorm::set_weight | ( | unsigned int | var, | |
| Real | w | |||
| ) | [inline] |
Sets the weight corresponding to the norm in variable var
Definition at line 300 of file system_norm.h.
References _weights, and _weights_sq.
00301 { 00302 libmesh_assert (!_weights.empty()); 00303 00304 if (var >= _weights.size()) 00305 { 00306 _weights.resize(var+1, 1.0); 00307 _weights_sq.resize(var+1, 1.0); 00308 } 00309 00310 _weights[var] = w; 00311 _weights_sq[var] = w*w; 00312 }
| FEMNormType libMesh::SystemNorm::type | ( | unsigned int | var | ) | const [inline] |
Returns the type of the norm in variable var
Definition at line 267 of file system_norm.h.
References _norms.
Referenced by libMesh::System::calculate_norm(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), and libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()().
| Real libMesh::SystemNorm::weight | ( | unsigned int | var | ) | const [inline] |
Returns the weight corresponding to the norm in variable var
Definition at line 291 of file system_norm.h.
References _weights.
Referenced by libMesh::KellyErrorEstimator::boundary_side_integration(), libMesh::DiscontinuityMeasure::boundary_side_integration(), libMesh::System::calculate_norm(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::KellyErrorEstimator::internal_side_integration(), libMesh::LaplacianErrorEstimator::internal_side_integration(), libMesh::DiscontinuityMeasure::internal_side_integration(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), and libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()().
| 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 335 of file system_norm.h.
References _weights_sq.
Referenced by libMesh::System::calculate_norm(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), and libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()().
00336 { 00337 libmesh_assert (!_weights_sq.empty()); 00338 00339 return (var < _weights_sq.size()) ? _weights_sq[var] : 1.0; 00340 }
Member Data Documentation
std::vector<FEMNormType> libMesh::SystemNorm::_norms [private] |
Definition at line 155 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 164 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 157 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 158 of file system_norm.h.
Referenced by set_weight(), SystemNorm(), and weight_sq().
The documentation for this class was generated from the following file:
Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:40 UTC
Hosted By: