Go to the documentation of this file.
   25 #include "libmesh/libmesh_common.h" 
   26 #include "libmesh/jump_error_estimator.h" 
   27 #include "libmesh/dof_map.h" 
   28 #include "libmesh/elem.h" 
   29 #include "libmesh/error_vector.h" 
   30 #include "libmesh/fe_base.h" 
   31 #include "libmesh/fe_interface.h" 
   32 #include "libmesh/fem_context.h" 
   33 #include "libmesh/libmesh_logging.h" 
   34 #include "libmesh/mesh_base.h" 
   35 #include "libmesh/quadrature_gauss.h" 
   36 #include "libmesh/system.h" 
   37 #include "libmesh/dense_vector.h" 
   38 #include "libmesh/numeric_vector.h" 
   39 #include "libmesh/int_range.h" 
   40 #include "libmesh/auto_ptr.h"  
   56                                          bool estimate_parent_error)
 
   58   LOG_SCOPE(
"estimate_error()", 
"JumpErrorEstimator");
 
  106 #ifdef LIBMESH_ENABLE_AMR 
  112   error_per_cell.resize (
mesh.max_elem_id());
 
  113   std::fill (error_per_cell.begin(), error_per_cell.end(), 0.);
 
  127   std::vector<float> n_flux_faces;
 
  129     n_flux_faces.resize(error_per_cell.size(), 0);
 
  133   if (solution_vector && solution_vector != system.
solution.get())
 
  137       System & sys = const_cast<System &>(system);
 
  138       newsol->
swap(*sys.solution);
 
  161       FEBase * side_fe = 
nullptr;
 
  163       const std::set<unsigned char> & elem_dims =
 
  166       for (
const auto & 
dim : elem_dims)
 
  179   for (
const auto & e : 
mesh.active_local_element_ptr_range())
 
  183 #ifdef LIBMESH_ENABLE_AMR 
  190       bool compute_on_parent = 
true;
 
  191       if (!parent || !estimate_parent_error)
 
  192         compute_on_parent = 
false;
 
  196             compute_on_parent = 
false;
 
  198       if (compute_on_parent &&
 
  199           !error_per_cell[parent->
id()])
 
  204             (*(system.
solution), dof_map, parent, Uparent, 
false);
 
  212                   std::vector<const Elem *> active_neighbors;
 
  217                   for (std::size_t a=0,
 
  218                         n_active_neighbors = active_neighbors.size();
 
  219                        a != n_active_neighbors; ++a)
 
  221                       const Elem * f = active_neighbors[a];
 
  228                           libmesh_assert_equal_to
 
  262                   libmesh_assert_equal_to
 
  274                   bool found_boundary_flux = 
false;
 
  284                             found_boundary_flux = 
true;
 
  293 #endif // #ifdef LIBMESH_ENABLE_AMR 
  299       for (
auto n_e : e->side_index_range())
 
  301           if ((e->neighbor_ptr(n_e) != 
nullptr) ||
 
  308           if (e->neighbor_ptr(n_e) != 
nullptr) 
 
  314               if ((f->
active() && (f->
level() == e->level()) && (e_id < f_id))
 
  315                   || (f->
level() < e->level()))
 
  356               bool found_boundary_flux = 
false;
 
  365                       found_boundary_flux = 
true;
 
  388     if (error_per_cell[i] != 0.)
 
  389       error_per_cell[i] = 
std::sqrt(error_per_cell[i]);
 
  400       for (
const auto & val : n_flux_faces)
 
  401         libmesh_assert_equal_to (val, static_cast<float>(static_cast<unsigned int>(val)));
 
  407           if (n_flux_faces[i] == 0.0) 
 
  410           error_per_cell[i] /= static_cast<ErrorVectorReal>(n_flux_faces[i]);
 
  416   if (solution_vector && solution_vector != system.
solution.get())
 
  420       System & sys = const_cast<System &>(system);
 
  421       newsol->
swap(*sys.solution);
 
  436   FEBase * fe_fine = 
nullptr;
 
  440   std::vector<Point> qface_point = fe_fine->get_xyz();
 
  443   FEBase * fe_coarse = 
nullptr;
 
  446   std::vector<Point> qp_coarse;
 
  456   for (
unsigned int v=0; v<
n_vars; v++)
 
  473   const unsigned int divisor =
 
  485   return 1.0f / static_cast<float>(divisor);
 
  
void reinit_sides()
A utility function to reinit the finite element data on elements sharing a side.
 
Manages consistently variables, degrees of freedom, and coefficient vectors.
 
std::unique_ptr< FEMContext > coarse_context
 
bool integrate_boundary_sides
A boolean flag, by default false, to be set to true if integrations with boundary_side_integration() ...
 
unsigned int n_vars() const
 
const std::vector< Point > & get_xyz() const
 
virtual void init_context(FEMContext &c)
An initialization function, to give derived classes a chance to request specific data from the FE obj...
 
FEFamily family
The type of finite element.
 
SystemNorm error_norm
When estimating the error in a single system, the error_norm is used to control the scaling and norm ...
 
unsigned int level() const
 
SimpleRange< ChildRefIter > child_ref_range()
Returns a range with all children of a parent element, usable in range-based for loops.
 
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...
 
virtual void swap(NumericVector< T > &v)
Swaps the contents of this with v.
 
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
 
The libMesh namespace provides an interface to certain functionality in the library.
 
unsigned int var
The variable number currently being evaluated.
 
This class forms the foundation from which generic finite elements may be derived.
 
int extra_quadrature_order
A member int that can be employed to indicate increased or reduced quadrature order.
 
Real fine_error
The fine and coarse error values to be set by each side_integration();.
 
MetaPhysicL::DualNumber< T, D > sqrt(const MetaPhysicL::DualNumber< T, D > &in)
 
const Parallel::Communicator & comm() const
 
Real weight(unsigned int var) const
 
bool scale_by_n_flux_faces
This boolean flag allows you to scale the error indicator result for each element by the number of "f...
 
float coarse_n_flux_faces_increment()
A utility function to correctly increase n_flux_faces for the coarse element.
 
virtual bool boundary_side_integration()
The function, to be implemented by derived classes, which calculates an error term on a boundary side...
 
This is the MeshBase class.
 
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
 
std::unique_ptr< FEMContext > fine_context
Context objects for integrating on the fine and coarse elements sharing a face.
 
const MeshBase & get_mesh() const
 
void libmesh_ignore(const Args &...)
 
The ErrorVector is a specialization of the StatisticsVector for error data computed on a finite eleme...
 
virtual unsigned int size() const override
 
static void coarsened_dof_values(const NumericVector< Number > &global_vector, const DofMap &dof_map, const Elem *coarse_elem, DenseVector< Number > &coarse_dofs, const unsigned int var, const bool use_old_dof_indices=false)
Creates a local projection on coarse_elem, based on the DoF values in global_vector for it's children...
 
void active_family_tree_by_neighbor(T elem, std::vector< T > &family, T neighbor_in, bool reset=true)
 
const FEType & variable_type(const unsigned int i) const
 
const Elem * parent() const
 
virtual void internal_side_integration()=0
The function, to be implemented by derived classes, which calculates an error term on an internal sid...
 
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
 
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 th...
 
This class handles the numbering of degrees of freedom on a mesh.
 
IntRange< unsigned short > side_index_range() const
 
This is the base class from which all geometric element types are derived.
 
bool use_unweighted_quadrature_rules
This boolean flag allows you to use "unweighted" quadrature rules (sized to exactly integrate unweigh...
 
const DofMap & get_dof_map() const
 
const Elem * neighbor_ptr(unsigned int i) const
 
virtual void reinit(const Elem *elem, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)=0
This is at the core of this class.
 
This class provides all data required for a physics package (e.g.