#include <exact_error_estimator.h>
Public Types | |
typedef Number(* | ValueFunctionPointer) (const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name) |
typedef Gradient(* | GradientFunctionPointer) (const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name) |
typedef Tensor(* | HessianFunctionPointer) (const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name) |
typedef std::map< std::pair< const System *, unsigned int >, ErrorVector * > | ErrorMap |
Public Member Functions | |
ExactErrorEstimator () | |
ExactErrorEstimator (const ExactErrorEstimator &)=delete | |
ExactErrorEstimator & | operator= (const ExactErrorEstimator &)=delete |
ExactErrorEstimator (ExactErrorEstimator &&)=default | |
ExactErrorEstimator & | operator= (ExactErrorEstimator &&)=default |
virtual | ~ExactErrorEstimator ()=default |
void | attach_exact_values (std::vector< FunctionBase< Number > *> f) |
void | attach_exact_value (unsigned int sys_num, FunctionBase< Number > *f) |
void | attach_exact_value (ValueFunctionPointer fptr) |
void | attach_exact_derivs (std::vector< FunctionBase< Gradient > *> g) |
void | attach_exact_deriv (unsigned int sys_num, FunctionBase< Gradient > *g) |
void | attach_exact_deriv (GradientFunctionPointer gptr) |
void | attach_exact_hessians (std::vector< FunctionBase< Tensor > *> h) |
void | attach_exact_hessian (unsigned int sys_num, FunctionBase< Tensor > *h) |
void | attach_exact_hessian (HessianFunctionPointer hptr) |
void | attach_reference_solution (EquationSystems *es_fine) |
void | extra_quadrature_order (const int extraorder) |
virtual void | estimate_error (const System &system, ErrorVector &error_per_cell, const NumericVector< Number > *solution_vector=nullptr, bool estimate_parent_error=false) override |
virtual ErrorEstimatorType | type () const override |
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) |
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) |
Public Attributes | |
SystemNorm | error_norm |
Protected Member Functions | |
void | reduce_error (std::vector< ErrorVectorReal > &error_per_cell, const Parallel::Communicator &comm) const |
Private Member Functions | |
Real | find_squared_element_error (const System &system, const std::string &var_name, const Elem *elem, const DenseVector< Number > &Uelem, FEBase *fe, MeshFunction *fine_values) const |
void | clear_functors () |
Private Attributes | |
ValueFunctionPointer | _exact_value |
GradientFunctionPointer | _exact_deriv |
HessianFunctionPointer | _exact_hessian |
std::vector< std::unique_ptr< FunctionBase< Number > > > | _exact_values |
std::vector< std::unique_ptr< FunctionBase< Gradient > > > | _exact_derivs |
std::vector< std::unique_ptr< FunctionBase< Tensor > > > | _exact_hessians |
EquationSystems * | _equation_systems_fine |
int | _extra_order |
This class implements an "error estimator" based on the difference between the approximate and exact solution. In theory the quadrature error in this estimate should be much lower than the approximation error in other estimates, so this estimator can be used to calculate effectivity.
Definition at line 57 of file exact_error_estimator.h.
|
inherited |
When calculating many error vectors at once, we need a data structure to hold them all
Definition at line 124 of file error_estimator.h.
typedef Gradient(* libMesh::ExactErrorEstimator::GradientFunctionPointer) (const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name) |
Attach an arbitrary function which computes the exact gradient of the solution at any point.
Definition at line 122 of file exact_error_estimator.h.
typedef Tensor(* libMesh::ExactErrorEstimator::HessianFunctionPointer) (const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name) |
Attach an arbitrary function which computes the exact second derivatives of the solution at any point.
Definition at line 145 of file exact_error_estimator.h.
typedef Number(* libMesh::ExactErrorEstimator::ValueFunctionPointer) (const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name) |
Attach an arbitrary function which computes the exact value of the solution at any point.
Definition at line 99 of file exact_error_estimator.h.
libMesh::ExactErrorEstimator::ExactErrorEstimator | ( | ) |
Constructor. Responsible for initializing the _bc_function function pointer to nullptr, and defaulting the norm type to H1.
Definition at line 48 of file exact_error_estimator.C.
References libMesh::ErrorEstimator::error_norm, and libMesh::H1.
|
delete |
This class cannot be (default) copy constructed/assigned because it has containers of unique_ptrs. Explicitly deleting these functions is the best way to document this fact.
|
default |
Defaulted move ctor, move assignment operator, and destructor.
|
virtualdefault |
void libMesh::ExactErrorEstimator::attach_exact_deriv | ( | unsigned int | sys_num, |
FunctionBase< Gradient > * | g | ||
) |
Clone and attach an arbitrary functor which computes the exact gradient of the system sys_num
solution at any point.
Definition at line 125 of file exact_error_estimator.C.
References _exact_derivs, and libMesh::FunctionBase< Output >::clone().
void libMesh::ExactErrorEstimator::attach_exact_deriv | ( | GradientFunctionPointer | gptr | ) |
Definition at line 101 of file exact_error_estimator.C.
References _equation_systems_fine, _exact_deriv, and clear_functors().
void libMesh::ExactErrorEstimator::attach_exact_derivs | ( | std::vector< FunctionBase< Gradient > *> | g | ) |
Clone and attach arbitrary functors which compute the exact gradients of the EquationSystems' solutions at any point.
Definition at line 114 of file exact_error_estimator.C.
References _exact_derivs.
void libMesh::ExactErrorEstimator::attach_exact_hessian | ( | unsigned int | sys_num, |
FunctionBase< Tensor > * | h | ||
) |
Clone and attach an arbitrary functor which computes the exact second derivatives of the system sys_num
solution at any point.
Definition at line 162 of file exact_error_estimator.C.
References _exact_hessians, and libMesh::FunctionBase< Output >::clone().
void libMesh::ExactErrorEstimator::attach_exact_hessian | ( | HessianFunctionPointer | hptr | ) |
Definition at line 138 of file exact_error_estimator.C.
References _equation_systems_fine, _exact_hessian, and clear_functors().
void libMesh::ExactErrorEstimator::attach_exact_hessians | ( | std::vector< FunctionBase< Tensor > *> | h | ) |
Clone and attach arbitrary functors which compute the exact second derivatives of the EquationSystems' solutions at any point.
Definition at line 151 of file exact_error_estimator.C.
References _exact_hessians.
void libMesh::ExactErrorEstimator::attach_exact_value | ( | unsigned int | sys_num, |
FunctionBase< Number > * | f | ||
) |
Clone and attach an arbitrary functor which computes the exact value of the system sys_num
solution at any point.
Definition at line 90 of file exact_error_estimator.C.
References _exact_values, and libMesh::FunctionBase< Output >::clone().
void libMesh::ExactErrorEstimator::attach_exact_value | ( | ValueFunctionPointer | fptr | ) |
Definition at line 66 of file exact_error_estimator.C.
References _equation_systems_fine, _exact_value, and clear_functors().
void libMesh::ExactErrorEstimator::attach_exact_values | ( | std::vector< FunctionBase< Number > *> | f | ) |
Clone and attach arbitrary functors which compute the exact values of the EquationSystems' solutions at any point.
Definition at line 79 of file exact_error_estimator.C.
References _exact_values.
void libMesh::ExactErrorEstimator::attach_reference_solution | ( | EquationSystems * | es_fine | ) |
Attach function similar to system.h which allows the user to attach a second EquationSystems object with a reference fine grid solution.
Definition at line 173 of file exact_error_estimator.C.
References _equation_systems_fine, _exact_deriv, _exact_hessian, _exact_value, and clear_functors().
|
private |
Helper method for cleanup
Definition at line 534 of file exact_error_estimator.C.
References _exact_derivs, _exact_hessians, and _exact_values.
Referenced by attach_exact_deriv(), attach_exact_hessian(), attach_exact_value(), and attach_reference_solution().
|
overridevirtual |
This function uses the exact solution function to estimate the error on each cell. The estimated error is output in the vector error_per_cell
Implements libMesh::ErrorEstimator.
Definition at line 187 of file exact_error_estimator.C.
References _equation_systems_fine, _exact_derivs, _exact_hessians, _exact_values, _extra_order, libMesh::FEGenericBase< OutputType >::build(), libMesh::NumericVector< T >::build(), libMesh::Elem::child_ref_range(), libMesh::FEGenericBase< OutputType >::coarsened_dof_values(), libMesh::ParallelObject::comm(), libMesh::System::current_local_solution, libMesh::System::current_solution(), libMesh::FEType::default_quadrature_rule(), libMesh::DofMap::dof_indices(), libMesh::ErrorEstimator::error_norm, libMesh::ErrorVectorReal, find_squared_element_error(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::EquationSystems::get_system(), libMesh::DofObject::id(), libMesh::libmesh_ignore(), mesh, n_vars, libMesh::System::n_vars(), libMesh::System::name(), libMesh::Elem::parent(), libMesh::ErrorEstimator::reduce_error(), libMesh::SERIAL, libMesh::System::solution, libMesh::NumericVector< T >::swap(), libMesh::System::update_global_solution(), libMesh::System::variable_name(), libMesh::System::variable_number(), libMesh::DofMap::variable_type(), and libMesh::SystemNorm::weight().
|
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(), 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.
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
FIXME: This is a default implementation - derived classes should reimplement it for efficiency.
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::EquationSystems::n_systems(), n_vars, libMesh::System::n_vars(), and libMesh::SystemNorm::type().
|
inline |
Increases or decreases the order of the quadrature rule used for numerical integration.
Definition at line 163 of file exact_error_estimator.h.
References _extra_order.
|
private |
Helper method for calculating on each element
Definition at line 401 of file exact_error_estimator.C.
References _equation_systems_fine, _exact_deriv, _exact_derivs, _exact_hessian, _exact_hessians, _exact_value, _exact_values, libMesh::ErrorEstimator::error_norm, libMesh::FEGenericBase< OutputType >::get_d2phi(), libMesh::FEGenericBase< OutputType >::get_dphi(), libMesh::System::get_equation_systems(), libMesh::FEAbstract::get_JxW(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::FEAbstract::get_xyz(), libMesh::MeshFunction::gradient(), libMesh::H1, libMesh::H1_SEMINORM, libMesh::H2, libMesh::H2_SEMINORM, libMesh::MeshFunction::hessian(), libMesh::L2, libMesh::System::name(), libMesh::TensorTools::norm_sq(), libMesh::TypeVector< T >::norm_sq(), libMesh::TypeTensor< T >::norm_sq(), libMesh::System::number(), libMesh::EquationSystems::parameters, libMesh::Real, libMesh::FEAbstract::reinit(), libMesh::DenseVector< T >::size(), libMesh::System::time, libMesh::SystemNorm::type(), libMesh::System::variable_number(), and libMesh::System::variable_scalar_number().
Referenced by estimate_error().
|
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 libMesh::Parallel::Communicator::sum().
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), and estimate_error().
|
overridevirtual |
Implements libMesh::ErrorEstimator.
Definition at line 60 of file exact_error_estimator.C.
References libMesh::EXACT.
|
private |
Constant pointer to the EquationSystems
object containing a fine grid solution.
Definition at line 229 of file exact_error_estimator.h.
Referenced by attach_exact_deriv(), attach_exact_hessian(), attach_exact_value(), attach_reference_solution(), estimate_error(), and find_squared_element_error().
|
private |
Function pointer to user-provided function which computes the exact derivative of the solution.
Definition at line 199 of file exact_error_estimator.h.
Referenced by attach_exact_deriv(), attach_reference_solution(), and find_squared_element_error().
|
private |
User-provided functors which compute the exact derivative of the solution for each system.
Definition at line 217 of file exact_error_estimator.h.
Referenced by attach_exact_deriv(), attach_exact_derivs(), clear_functors(), estimate_error(), and find_squared_element_error().
|
private |
Function pointer to user-provided function which computes the exact hessian of the solution.
Definition at line 205 of file exact_error_estimator.h.
Referenced by attach_exact_hessian(), attach_reference_solution(), and find_squared_element_error().
|
private |
User-provided functors which compute the exact hessians of the solution for each system.
Definition at line 223 of file exact_error_estimator.h.
Referenced by attach_exact_hessian(), attach_exact_hessians(), clear_functors(), estimate_error(), and find_squared_element_error().
|
private |
Function pointer to user-provided function which computes the exact value of the solution.
Definition at line 193 of file exact_error_estimator.h.
Referenced by attach_exact_value(), attach_reference_solution(), and find_squared_element_error().
|
private |
User-provided functors which compute the exact value of the solution for each system.
Definition at line 211 of file exact_error_estimator.h.
Referenced by attach_exact_value(), attach_exact_values(), clear_functors(), estimate_error(), and find_squared_element_error().
|
private |
Extra order to use for quadrature rule
Definition at line 249 of file exact_error_estimator.h.
Referenced by estimate_error(), and extra_quadrature_order().
|
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 161 of file error_estimator.h.
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::AdjointRefinementEstimator(), libMesh::DiscontinuityMeasure::boundary_side_integration(), libMesh::KellyErrorEstimator::boundary_side_integration(), libMesh::DiscontinuityMeasure::DiscontinuityMeasure(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), estimate_error(), libMesh::ErrorEstimator::estimate_errors(), ExactErrorEstimator(), find_squared_element_error(), libMesh::LaplacianErrorEstimator::init_context(), libMesh::DiscontinuityMeasure::init_context(), libMesh::KellyErrorEstimator::init_context(), libMesh::LaplacianErrorEstimator::internal_side_integration(), libMesh::DiscontinuityMeasure::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().