Hermes2D
3.0
|
A selector that chooses an optimal candidates based on a score. More...
#include <optimum_selector.h>
Classes | |
struct | CandsInfo |
Information about candidates. More... | |
struct | ShapeInx |
A shape index. More... | |
Public Member Functions | |
virtual | ~OptimumSelector () |
Destructor. | |
void | set_dof_score_exponent (double exponent) |
Set the score DOF exponent. | |
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 | |
OptimumSelector (CandList cand_list, int max_order, Shapeset *shapeset, const Range &vertex_order, const Range &edge_bubble_order) | |
Constructor. More... | |
void | update_cands_info (std::vector< Cand > &candidates, CandsInfo &info_h, CandsInfo &info_p, CandsInfo &info_aniso) const |
Updates information about candidates. Initial information is provided. More... | |
void | append_candidates_split (std::vector< Cand > &candidates, const int start_quad_order, const int last_order, const RefinementType split, bool iso_p) |
Appends cancidates of a given refinement and a given range of orders. More... | |
virtual std::vector< Cand > | create_candidates (Element *e, int quad_order) |
Fill a list of candidates. More... | |
void | evaluate_candidates (std::vector< Cand > &candidates, Element *e, MeshFunction< Scalar > *rsln) |
Calculates error, dofs, and score of candidates. More... | |
virtual void | select_best_candidate (std::vector< Cand > &candidates, Element *e, Cand *&best_candidate, Cand *best_candidates_specific_type[4]) |
Sorts and selects the best candidate and the best H-candidate according to the score. More... | |
virtual void | evaluate_cands_error (std::vector< Cand > &candidates, Element *e, MeshFunction< Scalar > *rsln)=0 |
Calculates error of candidates. More... | |
virtual void | evaluate_cands_dof (std::vector< Cand > &candidates, Element *e, MeshFunction< Scalar > *rsln) |
Calculates DOF of candidates. More... | |
virtual void | evaluate_cands_score (std::vector< Cand > &candidates, Element *e) |
Evalutes score of candidates. More... | |
virtual void | get_current_order_range (Element *element, int &min_order, int &max_order)=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, std::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... | |
virtual bool | select_refinement (Element *element, int quad_order, MeshFunction< Scalar > *rsln, ElementToRefine &refinement) |
Selects a refinement. More... | |
Protected Member Functions inherited from Hermes::Hermes2D::RefinementSelectors::Selector< Scalar > | |
Selector (int min_order=1, int max_order=H2DRS_DEFAULT_ORDER) | |
Constructor. More... | |
Static Protected Member Functions | |
static bool | compare_cand_score (const Cand &a, const Cand &b) |
Compares scores. Used to sort scores ascending. More... | |
Protected Attributes | |
CandList | cand_list |
Allowed candidate types. | |
int **** | num_shapes |
Shapeset * | shapeset |
A shapeset used to calculate error. | |
std::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). | |
double | dof_score_exponent |
Score DOF exponent. Used in evaluate_cands_score. | |
Protected Attributes inherited from Hermes::Hermes2D::RefinementSelectors::Selector< Scalar > | |
const int | min_order |
A minimum allowed order. | |
const int | max_order |
A maximum allowed order. | |
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 32 of file function.h.
|
protected |
Constructor.
[in] | cand_list | A predefined list of candidates. |
[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 nullptr. |
[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. |
Why H2DRS_MAX_ORDER + 3? Because H2DRS_MAX_ORDER ( = 9 ) is the max order refinement selectors support (
Definition at line 15 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 64 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 305 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 89 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 272 of file optimum_selector.cpp.
|
staticprotected |
Compares scores. Used to sort scores ascending.
[in] | a | The first candidate. |
[in] | b | The second candidate. |
Definition at line 594 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. |
Definition at line 352 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 where is an error of a candidate. It cannot be nullptr. |
[out] | dev_error | A deviation of where is an error of a candidate. It cannot be nullptr. |
Definition at line 558 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 470 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. |
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. 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 574 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 >.
|
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 where is an error of a candidate. |
[in] | dev_error | A deviation of where is an error of a candidate. |
[out] | best_candidates | Four best candidates \ 0 - overall 1 - 4 : indexed by enum RefinementType. |
Definition at line 600 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 654 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 440 of file optimum_selector.cpp.
Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::evaluate_cands_error().
|
protected |
Number of shape functions for
Definition at line 156 of file optimum_selector.h.
Referenced by Hermes::Hermes2D::RefinementSelectors::ProjBasedSelector< Scalar >::calc_error_cand_element(), and Hermes::Hermes2D::RefinementSelectors::OptimumSelector< Scalar >::OptimumSelector().