50 _exact_value(nullptr),
51 _exact_deriv(nullptr),
52 _exact_hessian(nullptr),
53 _equation_systems_fine(nullptr),
103 libmesh_assert(gptr);
140 libmesh_assert(hptr);
175 libmesh_assert(es_fine);
190 bool estimate_parent_error)
199 const unsigned int dim =
mesh.mesh_dimension();
209 error_per_cell.resize (
mesh.max_elem_id());
210 std::fill (error_per_cell.begin(), error_per_cell.end(), 0.);
214 if (solution_vector && solution_vector != system.
solution.get())
219 newsol->
swap(*sys.solution);
224 for (
unsigned int var=0; var<
n_vars; var++)
238 std::unique_ptr<QBase> qrule =
242 fe->attach_quadrature_rule (qrule.get());
245 std::unique_ptr<MeshFunction> fine_values;
251 std::vector<Number> global_soln;
257 (cast_int<numeric_index_type>(global_soln.size()),
true,
259 (*fine_soln) = global_soln;
261 fine_values = std::unique_ptr<MeshFunction>
286 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES 291 #ifdef LIBMESH_ENABLE_AMR 294 std::vector<bool> computed_var_on_parent;
296 if (estimate_parent_error)
297 computed_var_on_parent.resize(error_per_cell.size(),
false);
306 for (
const auto & elem :
mesh.active_local_element_ptr_range())
310 #ifdef LIBMESH_ENABLE_AMR 317 bool compute_on_parent =
true;
318 if (!parent || !estimate_parent_error)
319 compute_on_parent =
false;
323 compute_on_parent =
false;
325 if (compute_on_parent &&
326 !computed_var_on_parent[parent->
id()])
328 computed_var_on_parent[parent->
id()] =
true;
333 dof_map, parent, Uparent,
336 error_per_cell[parent->
id()] +=
346 std::vector<dof_id_type> dof_indices;
348 const unsigned int n_dofs =
349 cast_int<unsigned int>(dof_indices.size());
351 for (
unsigned int i=0; i != n_dofs; ++i)
354 error_per_cell[e_id] +=
378 LOG_SCOPE(
"std::sqrt()",
"ExactErrorEstimator");
379 for (
auto & val : error_per_cell)
382 libmesh_assert_greater (val, 0.);
383 val = std::sqrt(val);
389 if (solution_vector && solution_vector != system.
solution.get())
394 newsol->
swap(*sys.solution);
402 const std::string & var_name,
409 const std::string & sys_name = system.
name();
410 const unsigned int sys_num = system.
number();
413 const unsigned int var_component =
423 const std::vector<Real> & JxW = fe->
get_JxW();
424 const std::vector<std::vector<Real>> & phi_values = fe->
get_phi();
425 const std::vector<std::vector<RealGradient>> & dphi_values = fe->
get_dphi();
426 const std::vector<Point> & q_point = fe->
get_xyz();
427 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES 428 const std::vector<std::vector<RealTensor>> & d2phi_values = fe->
get_d2phi();
432 const unsigned int n_sf =
433 cast_int<unsigned int>(Uelem.
size());
436 const unsigned int n_qp =
437 cast_int<unsigned int>(JxW.size());
443 for (
unsigned int qp=0; qp<n_qp; qp++)
451 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES 459 for (
unsigned int i=0; i<n_sf; i++)
462 u_h += phi_values[i][qp]*Uelem(i);
463 grad_u_h += dphi_values[i][qp]*Uelem(i);
464 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES 465 grad2_u_h += d2phi_values[i][qp]*Uelem(i);
476 val_error -=
_exact_value(q_point[qp],parameters,sys_name,var_name);
479 component(var_component, q_point[qp], system.
time);
481 val_error -= (*fine_values)(q_point[qp]);
495 grad_error -=
_exact_deriv(q_point[qp],parameters,sys_name,var_name);
498 component(var_component, q_point[qp], system.
time);
500 grad_error -= fine_values->
gradient(q_point[qp]);
502 error_val += JxW[qp]*grad_error.
norm_sq();
506 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES 512 Tensor grad2_error = grad2_u_h;
514 grad2_error -=
_exact_hessian(q_point[qp],parameters,sys_name,var_name);
517 component(var_component, q_point[qp], system.
time);
519 grad2_error -= fine_values->
hessian(q_point[qp]);
521 error_val += JxW[qp]*grad2_error.
norm_sq();
527 libmesh_assert_greater_equal (error_val, 0.);
Manages the family, order, etc. parameters for a given FE.
virtual unsigned int size() const override
HessianFunctionPointer _exact_hessian
Manages multiples systems of equations.
void attach_exact_hessian(unsigned int sys_num, FunctionBase< Tensor > *h)
const Elem * parent() const
unsigned int variable_scalar_number(const std::string &var, unsigned int component) const
void update_global_solution(std::vector< Number > &global_soln) const
const std::vector< Point > & get_xyz() const
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
std::vector< std::unique_ptr< FunctionBase< Tensor > > > _exact_hessians
void attach_exact_hessians(std::vector< FunctionBase< Tensor > *> h)
const T_sys & get_system(const std::string &name) const
const FEType & variable_type(const unsigned int c) const
const EquationSystems & get_equation_systems() const
The base class for all geometric element types.
Gradient gradient(const Point &p, const Real time=0.)
const Parallel::Communicator & comm() const
const unsigned int n_vars
ValueFunctionPointer _exact_value
void attach_exact_value(unsigned int sys_num, FunctionBase< Number > *f)
const MeshBase & get_mesh() const
DIE A HORRIBLE DEATH HERE typedef float ErrorVectorReal
std::vector< std::unique_ptr< FunctionBase< Gradient > > > _exact_derivs
SimpleRange< ChildRefIter > child_ref_range()
Number current_solution(const dof_id_type global_dof_number) const
virtual void estimate_error(const System &system, ErrorVector &error_per_cell, const NumericVector< Number > *solution_vector=nullptr, bool estimate_parent_error=false) 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)
virtual ErrorEstimatorType type() const override
Manages the degrees of freedom (DOFs) in a simulation.
std::unique_ptr< QBase > default_quadrature_rule(const unsigned int dim, const int extraorder=0) const
const std::vector< std::vector< OutputGradient > > & get_dphi() const
void libmesh_ignore(const Args &...)
unsigned int number() const
Manages consistently variables, degrees of freedom, and coefficient vectors.
unsigned short int variable_number(const std::string &var) const
const std::vector< Real > & get_JxW() const
FEMNormType type(unsigned int var) const
std::unique_ptr< NumericVector< Number > > solution
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
virtual void reinit(const Elem *elem, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)=0
const std::string & variable_name(const unsigned int i) const
void reduce_error(std::vector< ErrorVectorReal > &error_per_cell, const Parallel::Communicator &comm) const
const std::vector< std::vector< OutputTensor > > & get_d2phi() const
void attach_exact_derivs(std::vector< FunctionBase< Gradient > *> g)
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Real weight(unsigned int var) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
GradientFunctionPointer _exact_deriv
EquationSystems * _equation_systems_fine
virtual void swap(NumericVector< T > &v)
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
std::unique_ptr< NumericVector< Number > > current_local_solution
virtual std::unique_ptr< FunctionBase< Output > > clone() const =0
void attach_exact_values(std::vector< FunctionBase< Number > *> f)
const std::string & name() const
void attach_reference_solution(EquationSystems *es_fine)
void attach_exact_deriv(unsigned int sys_num, FunctionBase< Gradient > *g)
unsigned int n_vars() const
const DofMap & get_dof_map() const
Tensor hessian(const Point &p, const Real time=0.)
std::vector< std::unique_ptr< FunctionBase< Number > > > _exact_values
const std::vector< std::vector< OutputShape > > & get_phi() const