Hermes2D  2.0
Hermes::Hermes2D::KellyTypeAdapt< Scalar > Class Template Reference

A framework for explicit aposteriori error estimators. More...

#include <kelly_type_adapt.h>

+ Inheritance diagram for Hermes::Hermes2D::KellyTypeAdapt< Scalar >:

Classes

class  ErrorEstimatorForm
 

Public Member Functions

 KellyTypeAdapt (Hermes::vector< Space< Scalar > * > spaces, bool ignore_visited_segments=true, Hermes::vector< const InterfaceEstimatorScalingFunction * > interface_scaling_fns_=Hermes::vector< const InterfaceEstimatorScalingFunction * >(), Hermes::vector< ProjNormType > norms_=Hermes::vector< ProjNormType >())
 
 KellyTypeAdapt (Space< Scalar > *space, bool ignore_visited_segments=true, const InterfaceEstimatorScalingFunction *interface_scaling_fn_=NULL, ProjNormType norm_=HERMES_UNSET_NORM)
 
virtual ~KellyTypeAdapt ()
 Destructor.
 
Mesh::ElementMarkersConversion * get_element_markers_conversion ()
 
Mesh::BoundaryMarkersConversion * get_boundary_markers_conversion ()
 
void add_error_estimator_vol (ErrorEstimatorForm *form)
 
void add_error_estimator_surf (ErrorEstimatorForm *form)
 
double calc_err_est (Solution< Scalar > *sln, unsigned int error_flags=HERMES_TOTAL_ERROR_REL|HERMES_ELEMENT_ERROR_REL)
 
double calc_err_est (Hermes::vector< Solution< Scalar > * > slns, Hermes::vector< double > *component_errors=NULL, unsigned int error_flags=HERMES_TOTAL_ERROR_REL|HERMES_ELEMENT_ERROR_REL)
 
bool adapt (double thr, int strat=0, int regularize=-1, double to_be_processed=0.0)
 
void disable_aposteriori_interface_scaling ()
 
void set_volumetric_scaling_const (double C)
 
void set_boundary_scaling_const (double C)
 
- Public Member Functions inherited from Hermes::Hermes2D::Adapt< Scalar >
 Adapt (Hermes::vector< Space< Scalar > * > spaces, Hermes::vector< ProjNormType > proj_norms=Hermes::vector< ProjNormType >())
 
 Adapt (Space< Scalar > *space, ProjNormType proj_norm=HERMES_UNSET_NORM)
 
virtual ~Adapt ()
 Destructor. Deallocates allocated private data.
 
void set_error_form (int i, int j, MatrixFormVolError *form)
 Sets user defined bilinear form which is used to calculate error. More...
 
void set_error_form (MatrixFormVolError *form)
 i = j = 0
 
void set_norm_form (int i, int j, MatrixFormVolError *form)
 
void set_norm_form (MatrixFormVolError *form)
 i = j = 0
 
double calc_err_est (Solution< Scalar > *sln, Solution< Scalar > *rsln, bool solutions_for_adapt=true, unsigned int error_flags=HERMES_TOTAL_ERROR_REL|HERMES_ELEMENT_ERROR_REL)
 
double calc_err_est (Hermes::vector< Solution< Scalar > * > slns, Hermes::vector< Solution< Scalar > * > rslns, Hermes::vector< double > *component_errors=NULL, bool solutions_for_adapt=true, unsigned int error_flags=HERMES_TOTAL_ERROR_REL|HERMES_ELEMENT_ERROR_REL)
 
double calc_err_exact (Solution< Scalar > *sln, Solution< Scalar > *rsln, bool solutions_for_adapt=true, unsigned int error_flags=HERMES_TOTAL_ERROR_REL|HERMES_ELEMENT_ERROR_REL)
 
double calc_err_exact (Hermes::vector< Solution< Scalar > * > slns, Hermes::vector< Solution< Scalar > * > rslns, Hermes::vector< double > *component_errors=NULL, bool solutions_for_adapt=true, unsigned int error_flags=HERMES_TOTAL_ERROR_REL|HERMES_ELEMENT_ERROR_REL)
 
bool adapt (Hermes::vector< RefinementSelectors::Selector< Scalar > * > refinement_selectors, double thr, int strat=0, int regularize=-1, double to_be_processed=0.0)
 Refines elements based on results from calc_err_est(). More...
 
bool adapt (RefinementSelectors::Selector< Scalar > *refinement_selector, double thr, int strat=0, int regularize=-1, double to_be_processed=0.0)
 Refines elements based on results from calc_err_est(). More...
 
double get_element_error_squared (int component, int id) const
 Returns a squared error of an element. More...
 

Protected Member Functions

double eval_volumetric_estimator (typename KellyTypeAdapt::ErrorEstimatorForm *err_est_form, RefMap *rm)
 
double eval_boundary_estimator (typename KellyTypeAdapt::ErrorEstimatorForm *err_est_form, RefMap *rm, SurfPos *surf_pos)
 
double eval_interface_estimator (typename KellyTypeAdapt::ErrorEstimatorForm *err_est_form, RefMap *rm, SurfPos *surf_pos, LightArray< NeighborSearch< Scalar > * > &neighbor_searches, int neighbor_index)
 
double eval_solution_norm (typename Adapt< Scalar >::MatrixFormVolError *form, RefMap *rm, MeshFunction< Scalar > *sln)
 
virtual double calc_err_internal (Hermes::vector< Solution< Scalar > * > slns, Hermes::vector< double > *component_errors, unsigned int error_flags)
 
- Protected Member Functions inherited from Hermes::Hermes2D::Adapt< Scalar >
const Hermes::vector
< ElementReference > & 
get_regular_queue () const
 Returns regular queue of elements. More...
 
void apply_refinement (const ElementToRefine &elem_ref)
 Apply a single refinement. More...
 
virtual void apply_refinements (std::vector< ElementToRefine > &elems_to_refine)
 Apply a vector of refinements. More...
 
const std::vector
< ElementToRefine > & 
get_last_refinements () const
 Returns a vector of refinements generated during the last execution of the method adapt(). More...
 
void fix_shared_mesh_refinements (Mesh **meshes, std::vector< ElementToRefine > &elems_to_refine, int **idx, RefinementSelectors::Selector< Scalar > ***refinement_selectors)
 Fixes refinements of a mesh which is shared among multiple components of a multimesh. More...
 
void homogenize_shared_mesh_orders (Mesh **meshes)
 Enforces the same order to an element of a mesh which is shared among multiple components. More...
 
virtual double calc_err_internal (Hermes::vector< Solution< Scalar > * > slns, Hermes::vector< Solution< Scalar > * > rslns, Hermes::vector< double > *component_errors, bool solutions_for_adapt, unsigned int error_flags)
 Calculates error between a coarse solution and a reference solution and sorts components according to the error. More...
 
virtual double calc_err_internal (Solution< Scalar > *sln, Solution< Scalar > *rsln, Hermes::vector< double > *component_errors, bool solutions_for_adapt, unsigned int error_flags)
 One Space version.
 
virtual double eval_error (MatrixFormVolError *form, MeshFunction< Scalar > *sln1, MeshFunction< Scalar > *sln2, MeshFunction< Scalar > *rsln1, MeshFunction< Scalar > *rsln2)
 Evaluates a square of an absolute error of an active element among a given pair of components. More...
 
virtual double eval_error_norm (MatrixFormVolError *form, MeshFunction< Scalar > *rsln1, MeshFunction< Scalar > *rsln2)
 Evaluates the square of a norm of an active element in the reference solution among a given pair of components. More...
 
virtual void fill_regular_queue (const Mesh **meshes)
 Builds an ordered queue of elements that are be examined. More...
 

Protected Attributes

DiscreteProblem< Scalar > dp
 
Hermes::vector< typename
KellyTypeAdapt::ErrorEstimatorForm * > 
error_estimators_vol
 
Hermes::vector< typename
KellyTypeAdapt::ErrorEstimatorForm * > 
error_estimators_surf
 
Mesh::ElementMarkersConversion element_markers_conversion
 
Mesh::BoundaryMarkersConversion boundary_markers_conversion
 
Hermes::vector< const
InterfaceEstimatorScalingFunction * > 
interface_scaling_fns
 
bool use_aposteriori_interface_scaling
 
double interface_scaling_const
 Constant scaling of the boundary error estimates. More...
 
double volumetric_scaling_const
 Constant scaling of the volumetric error estimates (like the residual norm).
 
double boundary_scaling_const
 Constant scaling of the boundary error estimates.
 
bool ignore_visited_segments
 
- Protected Attributes inherited from Hermes::Hermes2D::Adapt< Scalar >
Exceptions::Exception * caughtException
 
std::queue< ElementReferencepriority_queue
 A queue of priority elements. Elements in this queue are processed before the elements in the Adapt::regular_queue.
 
Hermes::vector< ElementReferenceregular_queue
 A queue of elements which should be processes. The queue had to be filled by the method fill_regular_queue().
 
std::vector< ElementToRefinelast_refinements
 A vector of refinements generated during the last finished execution of the method adapt().
 
int num
 Number of solution components (as in wf->neq).
 
Hermes::vector< Space< Scalar > * > spaces
 Spaces.
 
bool ** own_forms
 
int num_act_elems
 A total number of active elements across all provided meshes.
 
Solution< Scalar > * sln [H2D_MAX_COMPONENTS]
 Coarse solution.
 
Solution< Scalar > * rsln [H2D_MAX_COMPONENTS]
 Reference solutions.
 
bool have_errors
 True if errors of elements were calculated.
 
bool have_coarse_solutions
 True if the coarse solutions were set.
 
bool have_reference_solutions
 True if the reference solutions were set.
 
double * errors [H2D_MAX_COMPONENTS]
 method calc_errors_internal() was calls. Initialized in the method calc_errors_internal(). More...
 
double errors_squared_sum
 Sum of errors in the array Adapt::errors_squared. Used by a method adapt() in some strategies.
 
double error_time
 Time needed to calculate the error.
 
MatrixFormVolErrorerror_form [H2D_MAX_COMPONENTS][H2D_MAX_COMPONENTS]
 Bilinear forms to calculate error.
 
MatrixFormVolErrornorm_form [H2D_MAX_COMPONENTS][H2D_MAX_COMPONENTS]
 Bilinear forms to calculate norm (set to error_form by default).
 

Additional Inherited Members

- Static Protected Attributes inherited from Hermes::Hermes2D::Adapt< Scalar >
static const unsigned char HERMES_TOTAL_ERROR_MASK = 0x0F
 A mask which masks-out total error type. Used by Adapt::calc_err_internal().
 
static const unsigned char HERMES_ELEMENT_ERROR_MASK = 0xF0
 A mask which masks-out element error type. Used by Adapt::calc_err_internal().
 

Detailed Description

template<typename Scalar>
class Hermes::Hermes2D::KellyTypeAdapt< Scalar >

A framework for explicit aposteriori error estimators.

Explicit error estimators estimate the error of approximate solution on an element by evaluating element residuals and jumps of the solution across element edges ([2]). A typical example is the Kelly error estimator ([1]) where a sum of the L2 norms of element residual and jumps of solution gradients across the element boundaries defines the element error.

References: [1] Kelly D. W., Gago O. C., Zienkiewicz O. C., Babuska I.:   A posteriori error analysis and adaptive processes in the finite element method: Part I—error analysis.   Int. J. Numer. Methods Engng. 1983;19:1593–619. [2] Gratsch T., Bathe K. J.:   A posteriori error estimation techniques in practical finite element analysis.   Computers and Structures 83 (2005) 235–265. [3] Zienkiewicz O. C., Taylor R. L., Zhu J. Z.:   The finite element method: its basis and fundamentals (Section 13.7.1).   6th ed. (2005), Elsevier.

Definition at line 65 of file kelly_type_adapt.h.

Constructor & Destructor Documentation

template<typename Scalar >
Hermes::Hermes2D::KellyTypeAdapt< Scalar >::KellyTypeAdapt ( Hermes::vector< Space< Scalar > * >  spaces,
bool  ignore_visited_segments = true,
Hermes::vector< const InterfaceEstimatorScalingFunction * >  interface_scaling_fns_ = Hermes::vector<const InterfaceEstimatorScalingFunction*>(),
Hermes::vector< ProjNormType norms_ = Hermes::vector<ProjNormType>() 
)

Constructor.

Parameters
[in]spaces_Approximation space of each solution component.
[in]ignore_visited_segments_If true, error estimator for each inner edge will be evaluated only   once. It will be added to the total error estimate for both the active   element and its neighbors across that edge, after possibly being scaled by   interface_scaling_fns_ for the current component (with the diameter of   the appropriate element). This saves duplicate evaluations with same   results when the estimator is given e.g. by the jumps of the solution.

  If false, error estimator for each surface of each element will be   evaluated, regardless of whether the neighbor side of the interface   has already been processed.

  Note that if interface_scaling_fns_ is empty (or unspecified) then the   default scaling by element diameter will be always performed unless it is   switched off by a call to disable_aposteriori_interface_scaling.

Parameters
[in]interface_scaling_fns_Specifies functions used for scaling the interface error estimator for   each component. The scale is defined as a real function of the element   diameter (and possibly equation coefficients associated to the element)   and multiplies the result of the interface estimators. It may thus be already   present in the interface estimator forms themselves, in which case call   disable_aposteriori_interface_scaling. In this case, it may also be required   that ignore_visited_segments be false in order to always ensure that the   diameter belongs to the element whose error is being calculated.
[in]norms_Norms used for making relative error estimates.   If not specified, they are defined according to the spaces.

Definition at line 35 of file kelly_type_adapt.cpp.

Member Function Documentation

template<typename Scalar >
bool Hermes::Hermes2D::KellyTypeAdapt< Scalar >::adapt ( double  thr,
int  strat = 0,
int  regularize = -1,
double  to_be_processed = 0.0 
)

Refines the elements selected by the

RefinementSelectors::HOnlySelector

according to the errors calculated by

.

Definition at line 81 of file kelly_type_adapt.cpp.

template<typename Scalar >
void Hermes::Hermes2D::KellyTypeAdapt< Scalar >::add_error_estimator_surf ( ErrorEstimatorForm form)

Append boundary or interface error estimator form.

Interface form is defined by form::area == H2D_DG_INNER_EDGE . The effective types for u_ext, u and e (three of the obligatory parameters of form::value() and form::ord()) will then be, respectively DiscontinuousFunc*[], DiscontinuousFunc* and InterfaceGeom*.

Definition at line 102 of file kelly_type_adapt.cpp.

template<typename Scalar >
void Hermes::Hermes2D::KellyTypeAdapt< Scalar >::add_error_estimator_vol ( ErrorEstimatorForm form)

Append volumetric error estimator form.

For example, element residual norms may be represented by such a form.

Parameters
[in]form... object representing the form. A class derived from KellyTypeAdapt::ErrorEstimatorForm   defines its datatype.

Definition at line 92 of file kelly_type_adapt.cpp.

template<typename Scalar >
double Hermes::Hermes2D::KellyTypeAdapt< Scalar >::calc_err_est ( Solution< Scalar > *  sln,
unsigned int  error_flags = HERMES_TOTAL_ERROR_REL | HERMES_ELEMENT_ERROR_REL 
)
inline

The following two methods calculate the error of the given sln, using

.

Definition at line 268 of file kelly_type_adapt.h.

template<typename Scalar >
double Hermes::Hermes2D::KellyTypeAdapt< Scalar >::calc_err_internal ( Hermes::vector< Solution< Scalar > * >  slns,
Hermes::vector< double > *  component_errors,
unsigned int  error_flags 
)
protectedvirtual

Calculates error estimates for each solution component, the total error estimate, and possibly also their normalizations. If called with a pair of solutions, the version from Adapt is used (this is e.g. done when comparing approximate solution to the exact one - in this case, we do not want to compute the Kelly estimator value, but rather the ordinary difference between the solutions).

Definition at line 112 of file kelly_type_adapt.cpp.

template<typename Scalar >
double Hermes::Hermes2D::KellyTypeAdapt< Scalar >::eval_volumetric_estimator ( typename KellyTypeAdapt< Scalar >::ErrorEstimatorForm err_est_form,
RefMap rm 
)
protected

Functions used for evaluating the actual error estimator forms for an active element or edge segment.

Definition at line 529 of file kelly_type_adapt.cpp.

Member Data Documentation

template<typename Scalar >
Hermes::vector<typename KellyTypeAdapt::ErrorEstimatorForm *> Hermes::Hermes2D::KellyTypeAdapt< Scalar >::error_estimators_vol
protected

Linear forms used to calculate the error estimator value for each component.

Definition at line 147 of file kelly_type_adapt.h.

Referenced by Hermes::Hermes2D::KellyTypeAdapt< Scalar >::KellyTypeAdapt().

template<typename Scalar >
bool Hermes::Hermes2D::KellyTypeAdapt< Scalar >::ignore_visited_segments
protected

Specifies whether the interface error estimator will be evaluated from each side of each interface (when ignore_visited_segments == false ), or only once for each interface (ignore_visited_segments == true).

Definition at line 170 of file kelly_type_adapt.h.

Referenced by Hermes::Hermes2D::KellyTypeAdapt< Scalar >::KellyTypeAdapt().

template<typename Scalar >
double Hermes::Hermes2D::KellyTypeAdapt< Scalar >::interface_scaling_const
protected

Constant scaling of the boundary error estimates.

Constant scaling. Reserved for the derived classes, not to be used by the user explicitly.

Definition at line 163 of file kelly_type_adapt.h.

Referenced by Hermes::Hermes2D::KellyTypeAdapt< Scalar >::KellyTypeAdapt().

template<typename Scalar >
Hermes::vector<const InterfaceEstimatorScalingFunction*> Hermes::Hermes2D::KellyTypeAdapt< Scalar >::interface_scaling_fns
protected

Scaling of the interface error estimates. May be specified by the user during construction.

Definition at line 155 of file kelly_type_adapt.h.

Referenced by Hermes::Hermes2D::KellyTypeAdapt< Scalar >::KellyTypeAdapt().

template<typename Scalar >
bool Hermes::Hermes2D::KellyTypeAdapt< Scalar >::use_aposteriori_interface_scaling
protected
 Specifies whether the interface error estimators for each

component will be multiplied by interface_scaling_fns after being evaluated.

Definition at line 156 of file kelly_type_adapt.h.

Referenced by Hermes::Hermes2D::KellyTypeAdapt< Scalar >::KellyTypeAdapt().


The documentation for this class was generated from the following files: