libMesh
|
This class measures discontinuities between elements for debugging purposes. More...
#include <discontinuity_measure.h>
Public Types | |
typedef std::map< std::pair< const System *, unsigned int >, std::unique_ptr< ErrorVector > > | ErrorMap |
When calculating many error vectors at once, we need a data structure to hold them all. More... | |
Public Member Functions | |
DiscontinuityMeasure () | |
Constructor. More... | |
DiscontinuityMeasure (const DiscontinuityMeasure &)=delete | |
This class cannot be (default) copy constructed/assigned because its base class has unique_ptr members. More... | |
DiscontinuityMeasure & | operator= (const DiscontinuityMeasure &)=delete |
DiscontinuityMeasure (DiscontinuityMeasure &&)=default | |
Defaulted move ctor, move assignment operator, and destructor. More... | |
DiscontinuityMeasure & | operator= (DiscontinuityMeasure &&)=default |
virtual | ~DiscontinuityMeasure ()=default |
void | attach_essential_bc_function (std::pair< bool, Real > fptr(const System &system, const Point &p, const std::string &var_name)) |
Register a user function to use in computing the essential BCs. More... | |
virtual ErrorEstimatorType | type () const override |
virtual void | estimate_error (const System &system, ErrorVector &error_per_cell, const NumericVector< Number > *solution_vector=nullptr, bool estimate_parent_error=false) override |
This function uses the derived class's jump error estimate formula to estimate the error on each cell. More... | |
virtual void | estimate_errors (const EquationSystems &equation_systems, ErrorVector &error_per_cell, const std::map< const System *, SystemNorm > &error_norms, const std::map< const System *, const NumericVector< Number > *> *solution_vectors=nullptr, bool estimate_parent_error=false) |
This virtual function can be redefined in derived classes, but by default computes the sum of the error_per_cell for each system in the equation_systems. More... | |
virtual void | estimate_errors (const EquationSystems &equation_systems, ErrorMap &errors_per_cell, const std::map< const System *, const NumericVector< Number > *> *solution_vectors=nullptr, bool estimate_parent_error=false) |
This virtual function can be redefined in derived classes, but by default it calls estimate_error repeatedly to calculate the requested error vectors. More... | |
Public Attributes | |
bool | scale_by_n_flux_faces |
This boolean flag allows you to scale the error indicator result for each element by the number of "flux faces" the element actually has. More... | |
bool | use_unweighted_quadrature_rules |
This boolean flag allows you to use "unweighted" quadrature rules (sized to exactly integrate unweighted shape functions in master element space) rather than "default" quadrature rules (sized to exactly integrate polynomials of one higher degree than mass matrix terms). More... | |
SystemNorm | error_norm |
When estimating the error in a single system, the error_norm is used to control the scaling and norm choice for each variable. More... | |
Protected Member Functions | |
virtual void | init_context (FEMContext &c) override |
An initialization function, for requesting specific data from the FE objects. More... | |
virtual void | internal_side_integration () override |
The function which calculates a normal derivative jump based error term on an internal side. More... | |
virtual bool | boundary_side_integration () override |
The function which calculates a normal derivative jump based error term on a boundary side. More... | |
void | reinit_sides () |
A utility function to reinit the finite element data on elements sharing a side. More... | |
float | coarse_n_flux_faces_increment () |
A utility function to correctly increase n_flux_faces for the coarse element. More... | |
void | reduce_error (std::vector< ErrorVectorReal > &error_per_cell, const Parallel::Communicator &comm) const |
This method takes the local error contributions in error_per_cell from each processor and combines them to get the global error vector. More... | |
Protected Attributes | |
std::pair< bool, Real >(* | _bc_function )(const System &system, const Point &p, const std::string &var_name) |
Pointer to function that provides BC information. More... | |
bool | integrate_boundary_sides |
A boolean flag, by default false, to be set to true if integrations with boundary_side_integration() should be performed. More... | |
std::unique_ptr< FEMContext > | fine_context |
Context objects for integrating on the fine and coarse elements sharing a face. More... | |
std::unique_ptr< FEMContext > | coarse_context |
Real | fine_error |
The fine and coarse error values to be set by each side_integration();. More... | |
Real | coarse_error |
unsigned int | var |
The variable number currently being evaluated. More... | |
This class measures discontinuities between elements for debugging purposes.
It derives from ErrorEstimator just in case someone finds it useful in a DG framework.
Definition at line 49 of file discontinuity_measure.h.
|
inherited |
When calculating many error vectors at once, we need a data structure to hold them all.
Definition at line 121 of file error_estimator.h.
libMesh::DiscontinuityMeasure::DiscontinuityMeasure | ( | ) |
Constructor.
Responsible for initializing the _bc_function function pointer to nullptr. Defaults to L2 norm; changes to system norm are ignored.
Definition at line 41 of file discontinuity_measure.C.
References libMesh::ErrorEstimator::error_norm, and libMesh::L2.
|
delete |
This class cannot be (default) copy constructed/assigned because its base class has unique_ptr members.
|
default |
Defaulted move ctor, move assignment operator, and destructor.
|
virtualdefault |
void libMesh::DiscontinuityMeasure::attach_essential_bc_function | ( | std::pair< bool, Real > | fptrconst System &system, const Point &p, const std::string &var_name | ) |
Register a user function to use in computing the essential BCs.
Definition at line 200 of file discontinuity_measure.C.
References _bc_function, fptr(), and libMesh::JumpErrorEstimator::integrate_boundary_sides.
|
overrideprotectedvirtual |
The function which calculates a normal derivative jump based error term on a boundary side.
true
if the flux bc function is in fact defined on the current side. Reimplemented from libMesh::JumpErrorEstimator.
Definition at line 129 of file discontinuity_measure.C.
References _bc_function, libMesh::Elem::dim(), libMesh::ErrorEstimator::error_norm, libMesh::JumpErrorEstimator::fine_context, libMesh::JumpErrorEstimator::fine_error, libMesh::FEAbstract::get_JxW(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::FEAbstract::get_xyz(), libMesh::Elem::hmax(), libMesh::FEAbstract::n_quadrature_points(), libMesh::TensorTools::norm_sq(), libMesh::Real, libMesh::JumpErrorEstimator::var, and libMesh::SystemNorm::weight().
|
protectedinherited |
A utility function to correctly increase n_flux_faces for the coarse element.
Definition at line 488 of file jump_error_estimator.C.
References libMesh::JumpErrorEstimator::coarse_context, dim, and libMesh::JumpErrorEstimator::fine_context.
Referenced by libMesh::JumpErrorEstimator::estimate_error().
|
overridevirtualinherited |
This function uses the derived class's jump error estimate formula to estimate the error on each cell.
The estimated error is output in the vector error_per_cell
Conventions for assigning the direction of the normal:
Case (1.) Elements are at the same level, e<f Compute the flux jump on the face and add it as a contribution to error_per_cell[e] and error_per_cell[f]
| | |
f | |
---|---|
e | —> n |
Case (2.) The neighbor is at a higher level. Compute the flux jump on e's face and add it as a contribution to error_per_cell[e] and error_per_cell[f]
| | | | | | e |—> n | | | | | |--------—| f |
Implements libMesh::ErrorEstimator.
Definition at line 56 of file jump_error_estimator.C.
References libMesh::Elem::active(), libMesh::ElemInternal::active_family_tree_by_neighbor(), libMesh::JumpErrorEstimator::boundary_side_integration(), libMesh::Elem::child_ref_range(), libMesh::JumpErrorEstimator::coarse_context, libMesh::JumpErrorEstimator::coarse_error, libMesh::JumpErrorEstimator::coarse_n_flux_faces_increment(), libMesh::FEGenericBase< OutputType >::coarsened_dof_values(), dim, libMesh::ErrorEstimator::error_norm, libMesh::ErrorVectorReal, libMesh::JumpErrorEstimator::fine_context, libMesh::JumpErrorEstimator::fine_error, libMesh::NumericVector< T >::get(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::FEAbstract::get_xyz(), libMesh::DofObject::id(), libMesh::index_range(), libMesh::JumpErrorEstimator::init_context(), libMesh::JumpErrorEstimator::integrate_boundary_sides, libMesh::JumpErrorEstimator::internal_side_integration(), libMesh::Elem::level(), libMesh::libmesh_ignore(), mesh, n_vars, libMesh::System::n_vars(), libMesh::Elem::neighbor_ptr(), libMesh::Elem::parent(), libMesh::ErrorEstimator::reduce_error(), libMesh::JumpErrorEstimator::reinit_sides(), libMesh::SCALAR, libMesh::JumpErrorEstimator::scale_by_n_flux_faces, libMesh::Elem::side_index_range(), libMesh::DenseVector< T >::size(), libMesh::System::solution, std::sqrt(), libMesh::NumericVector< T >::swap(), libMesh::JumpErrorEstimator::use_unweighted_quadrature_rules, libMesh::JumpErrorEstimator::var, and libMesh::SystemNorm::weight().
Referenced by assemble_and_solve(), and main().
|
virtualinherited |
This virtual function can be redefined in derived classes, but by default computes the sum of the error_per_cell for each system in the equation_systems.
Currently this function ignores the error_norm member variable, and uses the function argument error_norms instead.
This function is named estimate_errors instead of estimate_error because otherwise C++ can get confused.
Reimplemented in libMesh::UniformRefinementEstimator.
Definition at line 47 of file error_estimator.C.
References libMesh::ErrorEstimator::error_norm, libMesh::ErrorEstimator::estimate_error(), libMesh::EquationSystems::get_system(), libMesh::index_range(), libMesh::make_range(), and libMesh::EquationSystems::n_systems().
|
virtualinherited |
This virtual function can be redefined in derived classes, but by default it calls estimate_error repeatedly to calculate the requested error vectors.
FIXME: This is a default implementation - derived classes should reimplement it for efficiency.
Currently this function ignores the error_norm.weight() values because it calculates each variable's error individually, unscaled.
The user selects which errors get computed by filling a map with error vectors: If errors_per_cell[&system][v] exists, it will be filled with the error values in variable v
of system
Reimplemented in libMesh::UniformRefinementEstimator.
Definition at line 93 of file error_estimator.C.
References libMesh::ErrorEstimator::error_norm, libMesh::ErrorEstimator::estimate_error(), libMesh::EquationSystems::get_system(), libMesh::make_range(), libMesh::EquationSystems::n_systems(), n_vars, libMesh::System::n_vars(), and libMesh::SystemNorm::type().
|
overrideprotectedvirtual |
An initialization function, for requesting specific data from the FE objects.
Reimplemented from libMesh::JumpErrorEstimator.
Definition at line 59 of file discontinuity_measure.C.
References dim, libMesh::FEMContext::elem_dimensions(), libMesh::ErrorEstimator::error_norm, libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::FEMContext::get_side_fe(), libMesh::DiffContext::n_vars(), n_vars, and libMesh::SystemNorm::weight().
|
overrideprotectedvirtual |
The function which calculates a normal derivative jump based error term on an internal side.
Implements libMesh::JumpErrorEstimator.
Definition at line 86 of file discontinuity_measure.C.
References libMesh::JumpErrorEstimator::coarse_context, libMesh::JumpErrorEstimator::coarse_error, libMesh::Elem::dim(), libMesh::ErrorEstimator::error_norm, libMesh::JumpErrorEstimator::fine_context, libMesh::JumpErrorEstimator::fine_error, libMesh::FEAbstract::get_JxW(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::Elem::hmax(), libMesh::FEAbstract::n_quadrature_points(), libMesh::TensorTools::norm_sq(), libMesh::Real, libMesh::JumpErrorEstimator::var, and libMesh::SystemNorm::weight().
|
delete |
|
default |
|
protectedinherited |
This method takes the local error contributions in error_per_cell
from each processor and combines them to get the global error vector.
Definition at line 32 of file error_estimator.C.
References TIMPI::Communicator::sum().
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::ExactErrorEstimator::estimate_error().
|
protectedinherited |
A utility function to reinit the finite element data on elements sharing a side.
Definition at line 450 of file jump_error_estimator.C.
References libMesh::JumpErrorEstimator::coarse_context, dim, libMesh::ErrorEstimator::error_norm, libMesh::JumpErrorEstimator::fine_context, libMesh::FEMap::inverse_map(), n_vars, libMesh::FEAbstract::reinit(), libMesh::SCALAR, and libMesh::SystemNorm::weight().
Referenced by libMesh::JumpErrorEstimator::estimate_error().
|
overridevirtual |
Implements libMesh::ErrorEstimator.
Definition at line 51 of file discontinuity_measure.C.
References libMesh::DISCONTINUITY_MEASURE.
|
protected |
Pointer to function that provides BC information.
Definition at line 108 of file discontinuity_measure.h.
Referenced by attach_essential_bc_function(), and boundary_side_integration().
|
protectedinherited |
Definition at line 158 of file jump_error_estimator.h.
Referenced by libMesh::JumpErrorEstimator::coarse_n_flux_faces_increment(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::KellyErrorEstimator::init_context(), libMesh::LaplacianErrorEstimator::internal_side_integration(), internal_side_integration(), libMesh::KellyErrorEstimator::internal_side_integration(), and libMesh::JumpErrorEstimator::reinit_sides().
|
protectedinherited |
Definition at line 163 of file jump_error_estimator.h.
Referenced by libMesh::JumpErrorEstimator::estimate_error(), libMesh::LaplacianErrorEstimator::internal_side_integration(), internal_side_integration(), and libMesh::KellyErrorEstimator::internal_side_integration().
|
inherited |
When estimating the error in a single system, the error_norm
is used to control the scaling and norm choice for each variable.
Not all estimators will support all norm choices. The default scaling is for all variables to be weighted equally. The default norm choice depends on the error estimator.
Part of this functionality was supported via component_scale and sobolev_order in older libMesh versions, and a small part was supported via component_mask in even older versions. Hopefully the encapsulation here will allow us to avoid changing this API again.
Definition at line 158 of file error_estimator.h.
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::AdjointRefinementEstimator(), boundary_side_integration(), libMesh::KellyErrorEstimator::boundary_side_integration(), DiscontinuityMeasure(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactErrorEstimator::ExactErrorEstimator(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::LaplacianErrorEstimator::init_context(), init_context(), libMesh::KellyErrorEstimator::init_context(), libMesh::LaplacianErrorEstimator::internal_side_integration(), internal_side_integration(), libMesh::KellyErrorEstimator::internal_side_integration(), libMesh::KellyErrorEstimator::KellyErrorEstimator(), libMesh::LaplacianErrorEstimator::LaplacianErrorEstimator(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::PatchRecoveryErrorEstimator(), libMesh::JumpErrorEstimator::reinit_sides(), and libMesh::UniformRefinementEstimator::UniformRefinementEstimator().
|
protectedinherited |
Context objects for integrating on the fine and coarse elements sharing a face.
Definition at line 158 of file jump_error_estimator.h.
Referenced by boundary_side_integration(), libMesh::KellyErrorEstimator::boundary_side_integration(), libMesh::JumpErrorEstimator::coarse_n_flux_faces_increment(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::LaplacianErrorEstimator::internal_side_integration(), internal_side_integration(), libMesh::KellyErrorEstimator::internal_side_integration(), and libMesh::JumpErrorEstimator::reinit_sides().
|
protectedinherited |
The fine and coarse error values to be set by each side_integration();.
Definition at line 163 of file jump_error_estimator.h.
Referenced by boundary_side_integration(), libMesh::KellyErrorEstimator::boundary_side_integration(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::LaplacianErrorEstimator::internal_side_integration(), internal_side_integration(), and libMesh::KellyErrorEstimator::internal_side_integration().
|
protectedinherited |
A boolean flag, by default false, to be set to true if integrations with boundary_side_integration() should be performed.
Definition at line 152 of file jump_error_estimator.h.
Referenced by attach_essential_bc_function(), libMesh::KellyErrorEstimator::attach_flux_bc_function(), and libMesh::JumpErrorEstimator::estimate_error().
|
inherited |
This boolean flag allows you to scale the error indicator result for each element by the number of "flux faces" the element actually has.
This tends to weight more evenly cells which are on the boundaries and thus have fewer contributions to their flux. The value is initialized to false, simply set it to true if you want to use the feature.
Definition at line 99 of file jump_error_estimator.h.
Referenced by libMesh::JumpErrorEstimator::estimate_error().
|
inherited |
This boolean flag allows you to use "unweighted" quadrature rules (sized to exactly integrate unweighted shape functions in master element space) rather than "default" quadrature rules (sized to exactly integrate polynomials of one higher degree than mass matrix terms).
The results with the former, lower-order rules will be somewhat less accurate in many cases but will be much cheaper to compute.
The value is initialized to false, simply set it to true if you want to use the feature.
Definition at line 113 of file jump_error_estimator.h.
Referenced by libMesh::JumpErrorEstimator::estimate_error(), and main().
|
protectedinherited |
The variable number currently being evaluated.
Definition at line 168 of file jump_error_estimator.h.
Referenced by boundary_side_integration(), libMesh::KellyErrorEstimator::boundary_side_integration(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::LaplacianErrorEstimator::internal_side_integration(), internal_side_integration(), and libMesh::KellyErrorEstimator::internal_side_integration().