libMesh
|
This class implements a "brute force" goal-oriented error estimator which computes an estimate of error in a quantity of interest based on the residual of the current coarse grid primal solution as weighted against an adjoint solution on a uniformly refined (in h and/or p, for an arbitrary number of levels) grid. More...
#include <adjoint_refinement_estimator.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 | |
AdjointRefinementEstimator () | |
Constructor. More... | |
AdjointRefinementEstimator (const AdjointRefinementEstimator &)=default | |
Copy/move ctor, copy/move assignment operator, and destructor are all explicitly defaulted for this class. More... | |
AdjointRefinementEstimator (AdjointRefinementEstimator &&)=default | |
AdjointRefinementEstimator & | operator= (const AdjointRefinementEstimator &)=default |
AdjointRefinementEstimator & | operator= (AdjointRefinementEstimator &&)=default |
virtual | ~AdjointRefinementEstimator ()=default |
QoISet & | qoi_set () |
Access to the QoISet (default: weight all QoIs equally) to use when computing errors. More... | |
const QoISet & | qoi_set () const |
Access to the QoISet (default: weight all QoIs equally) to use when computing errors. More... | |
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 does uniform refinements and an adjoint solve to get an adjoint solution on each cell, then estimates the error by finding the weighted residual of the coarse solution with the fine adjoint solution. More... | |
Number & | get_global_QoI_error_estimate (unsigned int qoi_index) |
This is an accessor function to access the computed global QoI error estimates. More... | |
virtual ErrorEstimatorType | type () const override |
DifferentiablePhysics * | get_residual_evaluation_physics () |
void | set_residual_evaluation_physics (DifferentiablePhysics *set_physics) |
Set the _residual_evaluation_physics member to argument. More... | |
DifferentiablePhysics * | get_adjoint_evaluation_physics () |
void | set_adjoint_evaluation_physics (DifferentiablePhysics *set_physics) |
Set the _adjoint_evaluation_physics member to argument. 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 | |
unsigned char | number_h_refinements |
How many h refinements to perform to get the fine grid. More... | |
unsigned char | number_p_refinements |
How many p refinements to perform to get the fine grid. 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 | |
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 | |
DifferentiablePhysics * | _residual_evaluation_physics |
Pointer to object to use for physics assembly evaluations. More... | |
DifferentiablePhysics * | _adjoint_evaluation_physics |
Pointer to object to use for adjoint assembly. More... | |
std::vector< Number > | computed_global_QoI_errors |
QoISet | _qoi_set |
A QoISet to handle cases with multiple QoIs available. More... | |
This class implements a "brute force" goal-oriented error estimator which computes an estimate of error in a quantity of interest based on the residual of the current coarse grid primal solution as weighted against an adjoint solution on a uniformly refined (in h and/or p, for an arbitrary number of levels) grid.
Definition at line 50 of file adjoint_refinement_estimator.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::AdjointRefinementEstimator::AdjointRefinementEstimator | ( | ) |
Constructor.
Sets the most common default parameter values.
Definition at line 73 of file adjoint_refinement_estimator.C.
References libMesh::ErrorEstimator::error_norm, and libMesh::INVALID_NORM.
|
default |
Copy/move ctor, copy/move assignment operator, and destructor are all explicitly defaulted for this class.
|
default |
|
virtualdefault |
|
overridevirtual |
This function does uniform refinements and an adjoint solve to get an adjoint solution on each cell, then estimates the error by finding the weighted residual of the coarse solution with the fine adjoint solution.
system.solve() and system.assembly() must be called, and so should have no side effects.
Only the provided system is solved on the refined mesh; we don't support adjoint solves on loosely coupled collections of Systems.
The estimated error is output in the vector error_per_cell
Implements libMesh::ErrorEstimator.
Definition at line 91 of file adjoint_refinement_estimator.C.
References _adjoint_evaluation_physics, _qoi_set, _residual_evaluation_physics, std::abs(), libMesh::System::add_vector(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::as_range(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::build(), libMesh::NumericVector< T >::clear(), libMesh::DifferentiableSystem::clone(), libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), computed_global_QoI_errors, libMesh::System::current_local_solution, libMesh::DofMap::dof_indices(), libMesh::NumericVector< T >::dot(), libMesh::DofMap::enforce_adjoint_constraints_exactly(), libMesh::ErrorVectorReal, libMesh::NumericVector< T >::get(), libMesh::System::get_adjoint_solution(), libMesh::System::get_dof_map(), libMesh::System::get_equation_systems(), libMesh::EquationSystems::get_mesh(), libMesh::System::get_project_with_constraints(), libMesh::DofMap::get_send_list(), libMesh::System::get_vector(), libMesh::GHOSTED, libMesh::DofMap::has_adjoint_dirichlet_boundaries(), libMesh::QoISet::has_index(), libMesh::DofObject::id(), libMesh::TriangleWrapper::init(), libMesh::System::is_adjoint_already_solved(), libMesh::libmesh_assert(), libMesh::NumericVector< T >::localize(), libMesh::make_range(), mesh, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::System::n_qois(), libMesh::System::number(), number_h_refinements, number_p_refinements, libMesh::Elem::parent(), libMesh::System::project_solution_on_reinit(), libMesh::Real, libMesh::ErrorEstimator::reduce_error(), libMesh::EquationSystems::reinit(), libMesh::System::remove_vector(), libMesh::System::set_project_with_constraints(), libMesh::System::set_vector_preservation(), libMesh::System::solution, libMesh::NumericVector< T >::swap(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::MeshRefinement::uniformly_p_coarsen(), libMesh::MeshRefinement::uniformly_p_refine(), libMesh::MeshRefinement::uniformly_refine(), libMesh::System::update(), libMesh::System::vector_name(), libMesh::System::vector_preservation(), libMesh::System::vectors_begin(), libMesh::System::vectors_end(), and libMesh::QoISet::weight().
Referenced by libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), and libMesh::SteadySolver::integrate_adjoint_refinement_error_estimate().
|
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().
|
inline |
nullptr
if no external Physics object is attached. Definition at line 140 of file adjoint_refinement_estimator.h.
References _adjoint_evaluation_physics.
|
inline |
This is an accessor function to access the computed global QoI error estimates.
Definition at line 106 of file adjoint_refinement_estimator.h.
References computed_global_QoI_errors.
Referenced by libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), and libMesh::SteadySolver::integrate_adjoint_refinement_error_estimate().
|
inline |
nullptr
if no external Physics object is attached. Definition at line 127 of file adjoint_refinement_estimator.h.
References _residual_evaluation_physics.
|
default |
|
default |
|
inline |
Access to the QoISet (default: weight all QoIs equally) to use when computing errors.
Definition at line 73 of file adjoint_refinement_estimator.h.
References _qoi_set.
Referenced by libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::TwostepTimeSolver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), and libMesh::SteadySolver::integrate_adjoint_refinement_error_estimate().
|
inline |
Access to the QoISet (default: weight all QoIs equally) to use when computing errors.
Definition at line 79 of file adjoint_refinement_estimator.h.
References _qoi_set.
|
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(), estimate_error(), and libMesh::ExactErrorEstimator::estimate_error().
|
inline |
Set the _adjoint_evaluation_physics member to argument.
Definition at line 146 of file adjoint_refinement_estimator.h.
References _adjoint_evaluation_physics.
|
inline |
Set the _residual_evaluation_physics member to argument.
Definition at line 133 of file adjoint_refinement_estimator.h.
References _residual_evaluation_physics.
|
overridevirtual |
Implements libMesh::ErrorEstimator.
Definition at line 86 of file adjoint_refinement_estimator.C.
References libMesh::ADJOINT_REFINEMENT.
|
protected |
Pointer to object to use for adjoint assembly.
Defaults to nullptr for backwards compatibility.
Definition at line 161 of file adjoint_refinement_estimator.h.
Referenced by estimate_error(), get_adjoint_evaluation_physics(), and set_adjoint_evaluation_physics().
|
protected |
A QoISet to handle cases with multiple QoIs available.
Definition at line 169 of file adjoint_refinement_estimator.h.
Referenced by estimate_error(), and qoi_set().
|
protected |
Pointer to object to use for physics assembly evaluations.
Defaults to nullptr for backwards compatibility.
Definition at line 155 of file adjoint_refinement_estimator.h.
Referenced by estimate_error(), get_residual_evaluation_physics(), and set_residual_evaluation_physics().
|
protected |
Definition at line 164 of file adjoint_refinement_estimator.h.
Referenced by estimate_error(), and get_global_QoI_error_estimate().
|
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(), AdjointRefinementEstimator(), libMesh::DiscontinuityMeasure::boundary_side_integration(), libMesh::KellyErrorEstimator::boundary_side_integration(), libMesh::DiscontinuityMeasure::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(), 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().
unsigned char libMesh::AdjointRefinementEstimator::number_h_refinements |
How many h refinements to perform to get the fine grid.
Definition at line 116 of file adjoint_refinement_estimator.h.
Referenced by estimate_error().
unsigned char libMesh::AdjointRefinementEstimator::number_p_refinements |
How many p refinements to perform to get the fine grid.
Definition at line 121 of file adjoint_refinement_estimator.h.
Referenced by estimate_error().