Hermes2D
2.0
|
A selector that chooses an optimal candidates based on a score. More...
#include <optimum_selector.h>
Classes | |
struct | Cand |
A candidate. More... | |
struct | CandsInfo |
Information about candidates. More... | |
class | Range |
Range of values. More... | |
struct | ShapeInx |
A shape index. More... | |
Public Member Functions | |
virtual void | set_option (const SelOption option, bool enable) |
Enables or disables an option. More... | |
const Hermes::vector< Cand > & | get_candidates () const |
Returns a vector of the last generated candidates. More... | |
virtual | ~OptimumSelector () |
Destructor. | |
Public Attributes | |
int **** | num_shapes |
Protected Types | |
enum | ShapeType { H2DST_VERTEX = 0x01, H2DST_HORIZ_EDGE = 0x02, H2DST_VERT_EDGE = 0x04, H2DST_TRI_EDGE = 0x08, H2DST_BUBBLE = 0x10 } |
A shape function type. More... | |
enum | ShapeTypeInt { H2DSI_VERTEX, H2DSI_HORIZ_EDGE, H2DSI_VERT_EDGE, H2DSI_TRI_EDGE, H2DSI_BUBBLE, H2DSI_ANY } |
Protected Member Functions | |
void | update_cands_info (CandsInfo &info_h, CandsInfo &info_p, CandsInfo &info_aniso) const |
Updates information about candidates. Initial information is provided. More... | |
void | append_candidates_split (const int start_quad_order, const int last_order, const int split, bool iso_p) |
Appends cancidates of a given refinement and a given range of orders. More... | |
virtual void | create_candidates (Element *e, int quad_order, int max_ha_quad_order, int max_p_quad_order) |
Fill a list of candidates. More... | |
void | evaluate_candidates (Element *e, Solution< Scalar > *rsln, double *avg_error, double *dev_error) |
Calculates error, dofs, and score of candidates. More... | |
virtual void | select_best_candidate (Element *e, const double avg_error, const double dev_error, int *selected_cand, int *selected_h_cand) |
Sorts and selects the best candidate and the best H-candidate according to the score. More... | |
virtual void | evaluate_cands_error (Element *e, Solution< Scalar > *rsln, double *avg_error, double *dev_error)=0 |
Calculates error of candidates. More... | |
virtual void | evaluate_cands_dof (Element *e, Solution< Scalar > *rsln) |
Calculates DOF of candidates. More... | |
virtual void | evaluate_cands_score (Element *e) |
Evalutes score of candidates. More... | |
virtual void | set_current_order_range (Element *element)=0 |
Sets OptimumSelector::current_max_order and OptimumSelector::current_min_order. More... | |
void | add_bubble_shape_index (int order_h, int order_v, std::map< int, bool > &used_shape_index, Hermes::vector< ShapeInx > &indices, ElementMode2D mode) |
Adds an index (or indices) of a bubble function of a given order if the shape index was not used yet. More... | |
void | build_shape_indices (const ElementMode2D mode, const Range &vertex_order, const Range &edge_bubble_order) |
Builds shape index table OptimumSelector::shape_indices. More... | |
int | calc_num_shapes (int mode, int order_h, int order_v, int allowed_type_mask) |
Returns a number of shapes that may be contained in an element of a given order. More... | |
OptimumSelector (CandList cand_list, double conv_exp, int max_order, Shapeset *shapeset, const Range &vertex_order, const Range &edge_bubble_order) | |
Constructor. More... | |
virtual bool | select_refinement (Element *element, int quad_order, Solution< Scalar > *rsln, ElementToRefine &refinement) |
Selects a refinement. More... | |
virtual void | generate_shared_mesh_orders (const Element *element, const int orig_quad_order, const int refinement, int tgt_quad_orders[H2D_MAX_ELEMENT_SONS], const int *suggested_quad_orders) |
Generates orders of elements which will be created due to a proposed refinement in another component that shares the same a mesh. More... | |
![]() | |
Selector (int max_order=H2DRS_DEFAULT_ORDER) | |
Constructor. More... | |
virtual Selector< Scalar > * | clone ()=0 |
Cloning for paralelism. | |
Protected Attributes | |
bool | opt_symmetric_mesh |
True if H2D_PREFER_SYMMETRIC_MESH is set. True by default. | |
bool | opt_apply_exp_dof |
True if H2D_APPLY_CONV_EXP_DOF is set. False by default. | |
CandList | cand_list |
Allowed candidate types. | |
double | conv_exp |
Convergence power. Modifies difference between DOFs before they are used to calculate the score. | |
Hermes::vector< Cand > | candidates |
A vector of candidates. The first candidate has to be equal to the original element with a refinement ::H2D_REFINEMENT_P. | |
int | current_max_order |
Current maximum order. | |
int | current_min_order |
Current minimum order. | |
Shapeset * | shapeset |
A shapeset used to calculate error. | |
Hermes::vector< ShapeInx > | shape_indices [H2D_NUM_MODES] |
Shape indices. The first index is a mode (ElementMode2D). | |
int | max_shape_inx [H2D_NUM_MODES] |
A maximum index of a shape function. The first index is a mode (ElementMode2D). | |
int | next_order_shape [H2D_NUM_MODES][H2DRS_MAX_ORDER+1] |
An index to the array OptimumSelector::shape_indices of a shape function of the next uniform order. The first index is a mode (ElementMode2D), the second index is an order. | |
bool | has_vertex_shape [H2D_NUM_MODES] |
True if the shapeset OptimumSelector::shapeset contains vertex functions. The index is a mode (ElementMode2D). | |
bool | has_edge_shape [H2D_NUM_MODES] |
True if the shapeset OptimumSelector::shapeset contains edge functions. The index is a mode (ElementMode2D). | |
bool | has_bubble_shape [H2D_NUM_MODES] |
True if the shapeset OptimumSelector::shapeset contains bubble functions. The index is a mode (ElementMode2D). | |
![]() | |
const int | max_order |
bool | isAClone |
Internal. | |
A selector that chooses an optimal candidates based on a score.
This is a base class for all selectors that chooses an candidate based on some evaluated criteria. Currently, the criteria is based on an error change per DOF.
Definition at line 33 of file function.h.
|
protected |
A shape function type.
Enumerator | |
---|---|
H2DST_VERTEX |
Vertex function. |
H2DST_HORIZ_EDGE |
Horizontal edge function. |
H2DST_VERT_EDGE |
Verical edge function. |
H2DST_TRI_EDGE |
Triangle edge. |
H2DST_BUBBLE |
Bubble function. |
Definition at line 252 of file optimum_selector.h.
|
protected |
Constructor.
[in] | cand_list | A predefined list of candidates. |
[in] | conv_exp | A conversion exponent, see evaluate_cands_score(). |
[in] | max_order | A maximum order which considered. If H2DRS_DEFAULT_ORDER, a maximum order supported by the selector is used. |
[in] | shapeset | A shapeset. It cannot be NULL. |
[in] | vertex_order | A range of orders for vertex functions. Use an empty range (i.e. Range()) to skip vertex functions. |
[in] | edge_bubble_order | A range of orders for edge and bubble functions. Use an empty range (i.e. Range()) to skip edge and bubble functions. |
Definition at line 68 of file optimum_selector.cpp.
|
protected |
Adds an index (or indices) of a bubble function of a given order if the shape index was not used yet.
This function adds indices of bubble functions that were not added yet on a quadrilateral. Since a shapeset allows only to retrieve a list of all possible bubbles based on an order of an element, this functions allows to create a back-mapping table which converts shape index to the smallest element order that uses the shape function. The function assumes that all shapes of a lower element order than a given combinations were already added. Used by build_shape_indices().
[in] | order_h | A horizontal order of an element. |
[in] | order_v | A vertical order of an element. |
[in,out] | used_shape_index | A vector of used shape indices. If a shape index is present in the map, a shape was already added and it will not be added again. |
[in,out] | indices | A vector of shape indices. The vector is updated by the function. |
Definition at line 123 of file optimum_selector.cpp.
|
protected |
Appends cancidates of a given refinement and a given range of orders.
If either borders or a ranges is invalid (i.e. smaller than zero) or if a upper boundary is below the lower boudary, no candidate is appended.
[in] | start_quad_order | A lower boundary of a range in a form of an encoded order. |
[in] | last_order | The upper boundery of a range in a form of an encoded order. |
[in] | split | A refinement, see the enum RefinementTypes. |
[in] | iso_p | True if both orders (horizontal and vertical) should be modified uniformly. Used in a case of a triangle. |
Definition at line 361 of file optimum_selector.cpp.
|
protected |
Builds shape index table OptimumSelector::shape_indices.
The method fills the array OptimumSelector::shape_indices for a given mode. The method is called by the constructor.
[in] | mode | A mode (ElementMode2D). |
[in] | vertex_order | A range of orders in which to search for vertex functions. |
[in] | edge_bubble_order | A range of order in which to search for edge and bubble functions. |
Definition at line 148 of file optimum_selector.cpp.
Referenced by Hermes::Hermes2D::RefinementSelectors::OptimumSelector< Scalar >::OptimumSelector().
|
protected |
Returns a number of shapes that may be contained in an element of a given order.
[in] | mode | A mode (ElementMode2D). |
[in] | order_h | A horizontal order of the element. If H2DRS_ORDER_ANY, any order is allowed. |
[in] | order_v | A horizontal order of the element. If H2DRS_ORDER_ANY, any order is allowed. |
[in] | allowed_type_mask | A combination of flags specifying which orders are allowed. Flags are defined in the enum ShapeType. |
Definition at line 328 of file optimum_selector.cpp.
|
protectedvirtual |
Fill a list of candidates.
Override to generate or adjust generated candidates. The method has to initialize the array OptimumSelector::candidates. If triangle, all generated candidates have to have the vertical order equal to the horizontal order. An order of any element of any candidate has to fit into a range[OptimumSelector::current_min_order, OptimumSelector::current_max_order].
[in] | e | An element that is being refined. |
[in] | quad_order | An encoded order of the element. If triangle, the vertical order is equal to the horizontal order. |
[in] | max_ha_quad_order | A maximum encoded order of an element of a H-candidate or an ANISO-candidate. In the case of ANIO-candidates, the maximum is applied only to modified orders. |
[in] | max_p_quad_order | A maximum encoded order of an element of a P-candidate. |
Reimplemented in Hermes::Hermes2D::RefinementSelectors::L2ProjBasedSelector< Scalar >.
Definition at line 407 of file optimum_selector.cpp.
|
protected |
Calculates error, dofs, and score of candidates.
[in] | e | An element that is being refined. |
[in] | rsln | A reference solution which is used to calculate the error. |
[out] | avg_error | An average of ![]() ![]() |
[out] | dev_error | A deviation of ![]() ![]() |
Definition at line 597 of file optimum_selector.cpp.
|
protectedvirtual |
Calculates DOF of candidates.
It uses a list of shape indices (OptimumSelector::shape_indices) to count a number of DOFs. No number of DOFs cannot be zero.
[in] | e | An element that is being refined. |
[in] | rsln | A reference solution which is used to calculate the error. |
Definition at line 519 of file optimum_selector.cpp.
|
protectedpure virtual |
Calculates error of candidates.
This method has to be implemented in inherited classes.
[in] | e | An element that is being refined. |
[in] | rsln | A reference solution which is used to calculate the error. |
[out] | avg_error | An average of ![]() ![]() |
[out] | dev_error | A deviation of ![]() ![]() |
Implemented in Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >.
|
protectedvirtual |
Evalutes score of candidates.
It calculates score of a candidate as
where and
are errors of a candidate and the original element (i.e. a candidate at the index 0) respectively,
and
are number of DOFs of a candidate and the original element (i.e. a candidate at the index 0) respectively, and
is a convergence exponent (OptimumSelector::conv_exp). If the score is zero, the score is invalid.
If overridden, the higher score the better candidate.
[in] | e | An element that is being refined. |
Definition at line 607 of file optimum_selector.cpp.
|
protectedvirtual |
Generates orders of elements which will be created due to a proposed refinement in another component that shares the same a mesh.
Overriden function. For details, see Selector::generate_shared_mesh_orders(). Updates orders of a refinement in another multimesh component which shares a mesh.
Implements Hermes::Hermes2D::RefinementSelectors::Selector< Scalar >.
Definition at line 748 of file optimum_selector.cpp.
|
inline |
Returns a vector of the last generated candidates.
Definition at line 131 of file optimum_selector.h.
|
protectedvirtual |
Sorts and selects the best candidate and the best H-candidate according to the score.
Any two candidates with the same score are skipped since it is not possible to decide between them. The method assumes that the candidate at the index 0 is the original element therefore it skips this candidate. The selected H-candidate is used to handle a case when a mesh is shared amond multiple components.
Override to redefined the algoritm of the selecting. If overridden, the implementation has to select both the best candidate and the best H-candidate.
[in] | e | An element that is being refined. |
[in] | avg_error | An average of ![]() ![]() |
[in] | dev_error | A deviation of ![]() ![]() |
[out] | selected_cand | A pointer to a selected index of the best candidate. If the index is 0, the algorithm was not able to decide. |
[out] | selected_h_cand | A pointer to a selected index of the best H-candidate. If the index is 0, the algorithm was not able to decide. |
Definition at line 636 of file optimum_selector.cpp.
|
protectedvirtual |
Selects a refinement.
Overriden function. For details, see Selector::select_refinement(). Selects refinement.
Implements Hermes::Hermes2D::RefinementSelectors::Selector< Scalar >.
Definition at line 678 of file optimum_selector.cpp.
|
protectedpure virtual |
Sets OptimumSelector::current_max_order and OptimumSelector::current_min_order.
This method has to be implemented by derived classes and it is mean to be space dependent, i.e., it should differ in a case of H1, L2, and Hcurl.
[in] | element | An element that is being refined. |
Implemented in Hermes::Hermes2D::RefinementSelectors::HcurlProjBasedSelector< Scalar >, Hermes::Hermes2D::RefinementSelectors::H1ProjBasedSelector< Scalar >, and Hermes::Hermes2D::RefinementSelectors::L2ProjBasedSelector< Scalar >.
|
virtual |
Enables or disables an option.
If overridden, the implementation has to call a parent implementation.
[in] | option | An option that is going to be enabled. For possible values, see SelOption. |
[in] | enable | True to enable, false to disable. |
Definition at line 788 of file optimum_selector.cpp.
|
protected |
Updates information about candidates. Initial information is provided.
[in,out] | info_h | Information about all H-candidates. |
[in,out] | info_p | Information about all P-candidates. |
[in,out] | info_aniso | Information about all ANISO-candidates. |
Definition at line 486 of file optimum_selector.cpp.
Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::evaluate_cands_error().
int**** Hermes::Hermes2D::RefinementSelectors::OptimumSelector< Scalar >::num_shapes |
Number of shape functions for
Definition at line 131 of file optimum_selector.h.
Referenced by Hermes::Hermes2D::Adapt< Scalar >::adapt(), Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::calc_error_cand_element(), and Hermes::Hermes2D::RefinementSelectors::OptimumSelector< Scalar >::OptimumSelector().