Hermes2D
2.0
|
Evaluation of an error between a (coarse) solution and a reference solution and adaptivity. More...
#include <adapt.h>
Classes | |
struct | ElementReference |
A reference to an element. More... | |
class | MatrixFormVolError |
Matrix forms for error calculation. More... | |
Public Member Functions | |
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 | |
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 | |
Exceptions::Exception * | caughtException |
std::queue< ElementReference > | priority_queue |
A queue of priority elements. Elements in this queue are processed before the elements in the Adapt::regular_queue. | |
Hermes::vector< ElementReference > | regular_queue |
A queue of elements which should be processes. The queue had to be filled by the method fill_regular_queue(). | |
std::vector< ElementToRefine > | last_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. | |
MatrixFormVolError * | error_form [H2D_MAX_COMPONENTS][H2D_MAX_COMPONENTS] |
Bilinear forms to calculate error. | |
MatrixFormVolError * | norm_form [H2D_MAX_COMPONENTS][H2D_MAX_COMPONENTS] |
Bilinear forms to calculate norm (set to error_form by default). | |
Static Protected Attributes | |
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(). | |
Evaluation of an error between a (coarse) solution and a reference solution and adaptivity.
The class provides basic functionality necessary to adaptively refine elements. Given a reference solution and a coarse solution, it calculates error estimates and it acts as a container for the calculated errors.
Hermes::Hermes2D::Adapt< Scalar >::Adapt | ( | Hermes::vector< Space< Scalar > * > | spaces, |
Hermes::vector< ProjNormType > | proj_norms = Hermes::vector<ProjNormType>() |
||
) |
bool Hermes::Hermes2D::Adapt< Scalar >::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().
[in] | refinement_selectors | Vector of selectors. |
[in] | thr | A threshold. The meaning of the threshold is defined by the parameter strat. |
[in] | strat | A strategy. It specifies a stop condition which quits processing elements in the Adapt::regular_queue. Possible values are 0, 1, 2, and 3. |
[in] | regularize | Regularizing of a mesh. |
[in] | same_order | True if all element have to have same orders after all refinements are applied. |
[in] | to_be_processed | Error which has to be processed. Used in strategy number 3. |
Definition at line 158 of file adapt.cpp.
Referenced by Hermes::Hermes2D::Adapt< Scalar >::adapt(), and Hermes::Hermes2D::KellyTypeAdapt< Scalar >::adapt().
bool Hermes::Hermes2D::Adapt< Scalar >::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().
[in] | refinement_selector | A pointer to a selector which will select a refinement. |
[in] | thr | A threshold. The meaning of the threshold is defined by the parameter strat. |
[in] | strat | A strategy. It specifies a stop condition which quits processing elements in the Adapt::regular_queue. Possible values are 0, 1, 2, and 3. |
[in] | regularize | Regularizing of a mesh. |
[in] | same_order | True if all element have to have same orders after all refinements are applied. |
[in] | to_be_processed | Error which has to be processed. Used in strategy number 3. |
|
protected |
Apply a single refinement.
[in] | A | refinement to apply. |
Definition at line 828 of file adapt.cpp.
Referenced by Hermes::Hermes2D::Adapt< Scalar >::apply_refinements().
|
protectedvirtual |
double Hermes::Hermes2D::Adapt< Scalar >::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 |
||
) |
Type-safe version of calc_err_est() for one solution.
[in] | solutions_for_adapt | - if sln and rsln are the solutions error of which is used in the function adapt(). |
double Hermes::Hermes2D::Adapt< Scalar >::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 |
||
) |
Calculates the error of the solution. 'n' must be the same as 'num' in the constructor. After that, n coarse solution pointers are passed, followed by n fine solution pointers.
[in] | solutions_for_adapt | - if slns and rslns are the solutions error of which is used in the function adapt(). |
double Hermes::Hermes2D::Adapt< Scalar >::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 |
||
) |
Type-safe version of calc_err_exact() for one solution.
[in] | solutions_for_adapt | - if sln and rsln are the solutions error of which is used in the function adapt(). |
double Hermes::Hermes2D::Adapt< Scalar >::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 |
||
) |
|
protectedvirtual |
Calculates error between a coarse solution and a reference solution and sorts components according to the error.
If overridden, this method has to initialize errors (Array::errors), sum of errors (Array::error_sum), norms of components (Array::norm), number of active elements (Array::num_act_elems). Also, it has to fill the regular queue through the method fill_regular_queue().
[in] | error_flags | Flags which calculates the error. It can be a combination of HERMES_TOTAL_ERROR_REL, HERMES_TOTAL_ERROR_ABS, HERMES_ELEMENT_ERROR_REL, HERMES_ELEMENT_ERROR_ABS. |
Definition at line 1028 of file adapt.cpp.
Referenced by Hermes::Hermes2D::Adapt< Scalar >::calc_err_est(), Hermes::Hermes2D::Adapt< Scalar >::calc_err_exact(), and Hermes::Hermes2D::Adapt< Scalar >::calc_err_internal().
|
protectedvirtual |
Evaluates a square of an absolute error of an active element among a given pair of components.
The method uses a bilinear forms to calculate the error. This is done by supplying a differences (f1 - v1) and (f2 - v2) at integration points to the bilinear form, where f1 and f2 are values of (coarse) solutions of the first and the second component respectively, v1 and v2 are values of reference solutions of the first and the second component respectively.
[in] | form | A bilinear form. |
[in] | sln1 | A (coarse) solution corresponding to the first component. |
[in] | sln2 | A (coarse) solution corresponding to the second component. |
[in] | rsln1 | A reference solution corresponding to the first component. |
[in] | rsln2 | A reference solution corresponding to the second component. |
[in] | rv1 | A reference map of a (coarse) solution sln1. |
[in] | rv2 | A reference map of a (coarse) solution sln2. |
[in] | rrv1 | A reference map of a reference solution rsln1. |
[in] | rrv2 | A reference map of a reference solution rsln2. |
Definition at line 904 of file adapt.cpp.
Referenced by Hermes::Hermes2D::Adapt< Scalar >::calc_err_internal().
|
protectedvirtual |
Evaluates the square of a norm of an active element in the reference solution among a given pair of components.
The method uses a bilinear forms to calculate the norm. This is done by supplying a v1 and v2 at integration points to the bilinear form, where v1 and v2 are values of reference solutions of the first and the second component respectively.
[in] | form | A bilinear form. |
[in] | rsln1 | A reference solution corresponding to the first component. |
[in] | rsln2 | A reference solution corresponding to the second component. |
[in] | rrv1 | A reference map of a reference solution rsln1. |
[in] | rrv2 | A reference map of a reference solution rsln2. |
Definition at line 971 of file adapt.cpp.
Referenced by Hermes::Hermes2D::Adapt< Scalar >::calc_err_internal().
|
protectedvirtual |
Builds an ordered queue of elements that are be examined.
The method fills Adapt::standard_queue by elements sorted accordin to their error descending. The method assumes that Adapt::errors_squared contains valid values. If a special order of elements is requested, this method has to be overridden. /param[in] meshes An array of pointers to meshes of a (coarse) solution. An index into the array is an index of a component. /param[in] meshes An array of pointers to meshes of a reference solution. An index into the array is an index of a component.
Definition at line 1242 of file adapt.cpp.
Referenced by Hermes::Hermes2D::Adapt< Scalar >::calc_err_internal().
|
protected |
Fixes refinements of a mesh which is shared among multiple components of a multimesh.
If a mesh is shared among components, it has to be refined similarly in order to avoid inconsistency.
[in] | meshes | An array of meshes of components. |
[in] | elems_to_refine | A vector of refinements. |
[in] | idx | A 2D array that translates a pair (a component index, an element id) to an index of a refinement in the vector of refinements. If the index is below zero, a given element was not refined. |
[in] | refinement_selector | A selected used by the adaptivity. The selector is used to correct orders of modified refinements using RefinementSelectors::Selector::update_shared_mesh_orders(). |
double Hermes::Hermes2D::Adapt< Scalar >::get_element_error_squared | ( | int | component, |
int | id | ||
) | const |
|
protected |
Returns a vector of refinements generated during the last execution of the method adapt().
|
protected |
|
protected |
void Hermes::Hermes2D::Adapt< Scalar >::set_error_form | ( | int | i, |
int | j, | ||
MatrixFormVolError * | form | ||
) |
Sets user defined bilinear form which is used to calculate error.
By default, all inherited class should set default bilinear forms for each element (i.e. i = j). This method can change it or set forms that can combine components (e.g. energy error).
[in] | i | The first component index. |
[in] | j | The second component index. |
[in] | bi_form | A bilinear form which calculates value. |
[in] | bi_ord | A bilinear form which calculates order. |
|
protected |
method calc_errors_internal() was calls. Initialized in the method calc_errors_internal().
Errors of elements. Meaning of the error depeds on flags used when the
Definition at line 237 of file adapt.h.
Referenced by Hermes::Hermes2D::Adapt< Scalar >::Adapt(), Hermes::Hermes2D::Adapt< Scalar >::calc_err_internal(), and Hermes::Hermes2D::Adapt< Scalar >::get_element_error_squared().