RefinementSelectors::OptimumSelector Class Reference
[Refinement Selectors]

A selector that chooses an optimal candidates based on a score. More...

#include <optimum_selector.h>

Inherits RefinementSelectors::Selector.

Inherited by RefinementSelectors::ProjBasedSelector.

List of all members.

Classes

struct  Cand
 A candidate. More...
struct  CandsInfo
 Information about candidates. More...
struct  ShapeInx
 A shape index. More...

Public Member Functions

virtual void set_option (const SelOption option, bool enable)
 Enables or disables an option.
const std::vector< Cand > & get_candidates () const
 Returns a vector of the last generated candidates.
virtual ~OptimumSelector ()
 Destructor.
virtual bool select_refinement (Element *element, int quad_order, Solution *rsln, ElementToRefine &refinement)
 Selects a refinement.
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.

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...

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.
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.
virtual void create_candidates (Element *e, int quad_order, int max_ha_quad_order, int max_p_quad_order)
 Fill a list of candidates.
void evaluate_candidates (Element *e, Solution *rsln, double *avg_error, double *dev_error)
 Calculates error, dofs, and score of candidates.
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.
virtual void evaluate_cands_error (Element *e, Solution *rsln, double *avg_error, double *dev_error)=0
 Calculates error of candidates.
virtual void evaluate_cands_dof (Element *e, Solution *rsln)
 Calculates DOF of candidates.
virtual void evaluate_cands_score (Element *e)
 Evalutes score of candidates.
virtual void set_current_order_range (Element *element)=0
 Sets OptimumSelector::current_max_order and OptimumSelector::current_min_order.
void add_bubble_shape_index (int order_h, int order_v, std::map< int, bool > &used_shape_index, std::vector< ShapeInx > &indices)
 Adds an index (or indices) of a bubble function of a given order if the shape index was not used yet.
void build_shape_indices (const int mode, const Range< int > &vertex_order, const Range< int > &edge_bubble_order)
 Builds shape index table OptimumSelector::shape_indices.
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.
 OptimumSelector (CandList cand_list, double conv_exp, int max_order, Shapeset *shapeset, const Range< int > &vertex_order, const Range< int > &edge_bubble_order)
 Constructor.

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.
std::vector< Candcandidates
 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.
Shapesetshapeset
 A shapeset used to calculate error.
std::vector< ShapeInxshape_indices [H2D_NUM_MODES]
 Shape indices. The first index is a mode (ElementMode).
int max_shape_inx [H2D_NUM_MODES]
 A maximum index of a shape function. The first index is a mode (ElementMode).
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 (ElementMode), 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 (ElementMode).
bool has_edge_shape [H2D_NUM_MODES]
 True if the shapeset OptimumSelector::shapeset contains edge functions. The index is a mode (ElementMode).
bool has_bubble_shape [H2D_NUM_MODES]
 True if the shapeset OptimumSelector::shapeset contains bubble functions. The index is a mode (ElementMode).

Detailed Description

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.


Member Enumeration Documentation

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.


Constructor & Destructor Documentation

RefinementSelectors::OptimumSelector::OptimumSelector ( CandList  cand_list,
double  conv_exp,
int  max_order,
Shapeset shapeset,
const Range< int > &  vertex_order,
const Range< int > &  edge_bubble_order 
) [protected]

Constructor.

Note:
Parameters vertex_order and edge_bubble_order fixes the fact that a shapeset returns a valid index even though a given shape is not invalid in the space.
Parameters:
[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<int>()) to skip vertex functions.
[in] edge_bubble_order A range of orders for edge and bubble functions. Use an empty range (i.e. Range<int>()) to skip edge and bubble functions.
virtual RefinementSelectors::OptimumSelector::~OptimumSelector (  )  [inline, virtual]

Destructor.


Member Function Documentation

void RefinementSelectors::OptimumSelector::add_bubble_shape_index ( int  order_h,
int  order_v,
std::map< int, bool > &  used_shape_index,
std::vector< ShapeInx > &  indices 
) [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().

Parameters:
[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.
void RefinementSelectors::OptimumSelector::append_candidates_split ( const int  start_quad_order,
const int  last_order,
const int  split,
bool  iso_p 
) [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.

Parameters:
[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.
void RefinementSelectors::OptimumSelector::build_shape_indices ( const int  mode,
const Range< int > &  vertex_order,
const Range< int > &  edge_bubble_order 
) [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.

Parameters:
[in] mode A mode (ElementMode).
[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.
int RefinementSelectors::OptimumSelector::calc_num_shapes ( int  mode,
int  order_h,
int  order_v,
int  allowed_type_mask 
) [protected]

Returns a number of shapes that may be contained in an element of a given order.

Parameters:
[in] mode A mode (ElementMode).
[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.
Returns:
Returns a number of shape functions that satisfies given parameters.
void RefinementSelectors::OptimumSelector::create_candidates ( Element e,
int  quad_order,
int  max_ha_quad_order,
int  max_p_quad_order 
) [protected, virtual]

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].

Parameters:
[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.

Todo:
Find and why is iro_cache compared with the number 8. What does the number 8 mean?

void RefinementSelectors::OptimumSelector::evaluate_candidates ( Element e,
Solution rsln,
double *  avg_error,
double *  dev_error 
) [protected]

Calculates error, dofs, and score of candidates.

Parameters:
[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 $\log_{10} e$ where $e$ is an error of a candidate. It cannot be NULL.
[out] dev_error A deviation of $\log_{10} e$ where $e$ is an error of a candidate. It cannot be NULL.
void RefinementSelectors::OptimumSelector::evaluate_cands_dof ( Element e,
Solution rsln 
) [protected, virtual]

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.

Parameters:
[in] e An element that is being refined.
[in] rsln A reference solution which is used to calculate the error.
virtual void RefinementSelectors::OptimumSelector::evaluate_cands_error ( Element e,
Solution rsln,
double *  avg_error,
double *  dev_error 
) [protected, pure virtual]

Calculates error of candidates.

This method has to be implemented in inherited classes.

Parameters:
[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 $\log_{10} e$ where $e$ is an error of a candidate. It cannot be NULL.
[out] dev_error A deviation of $\log_{10} e$ where $e$ is an error of a candidate. It cannot be NULL.

Implemented in RefinementSelectors::ProjBasedSelector.

void RefinementSelectors::OptimumSelector::evaluate_cands_score ( Element e  )  [protected, virtual]

Evalutes score of candidates.

It calculates score $s$ of a candidate as

\[s = \frac{\log_{10} e_0 - \log_{10} e}{(d - d_0)^c},\]

where $e$ and $e_0$ are errors of a candidate and the original element (i.e. a candidate at the index 0) respectively, $d$ and $d_0$ are number of DOFs of a candidate and the original element (i.e. a candidate at the index 0) respectively, and $c$ is a convergence exponent (OptimumSelector::conv_exp). If the score is zero, the score is invalid.

If overriden, the higher score the better candidate.

Parameters:
[in] e An element that is being refined.
void RefinementSelectors::OptimumSelector::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 
) [virtual]

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 RefinementSelectors::Selector.

const std::vector<Cand>& RefinementSelectors::OptimumSelector::get_candidates (  )  const [inline]

Returns a vector of the last generated candidates.

Returns:
A vector of last generated candidates. The vector will change if a new list is generated.
void RefinementSelectors::OptimumSelector::select_best_candidate ( Element e,
const double  avg_error,
const double  dev_error,
int *  selected_cand,
int *  selected_h_cand 
) [protected, virtual]

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 overriden, the implementation has to select both the best candidate and the best H-candidate.

Parameters:
[in] e An element that is being refined.
[in] avg_error An average of $\log_{10} e$ where $e$ is an error of a candidate.
[in] dev_error A deviation of $\log_{10} e$ where $e$ is an error of a candidate.
[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.
bool RefinementSelectors::OptimumSelector::select_refinement ( Element element,
int  quad_order,
Solution rsln,
ElementToRefine refinement 
) [virtual]

Selects a refinement.

Overriden function. For details, see Selector::select_refinement(). Selects refinement.

Implements RefinementSelectors::Selector.

virtual void RefinementSelectors::OptimumSelector::set_current_order_range ( Element element  )  [protected, pure 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.

Parameters:
[in] element An element that is being refined.

Implemented in RefinementSelectors::H1ProjBasedSelector, and RefinementSelectors::L2ProjBasedSelector.

void RefinementSelectors::OptimumSelector::set_option ( const SelOption  option,
bool  enable 
) [virtual]

Enables or disables an option.

If overriden, the implementation has to call a parent implementation.

Parameters:
[in] option An option that is going to be enabled. For possible values, see SelOption.
[in] enable True to enable, false to disable.
void RefinementSelectors::OptimumSelector::update_cands_info ( CandsInfo info_h,
CandsInfo info_p,
CandsInfo info_aniso 
) const [protected]

Updates information about candidates. Initial information is provided.

Parameters:
[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.

Member Data Documentation

Allowed candidate types.

A vector of candidates. The first candidate has to be equal to the original element with a refinement H2D_REFINEMENT_P.

Convergence power. Modifies difference between DOFs before they are used to calculate the score.

Current maximum order.

Current minimum order.

True if the shapeset OptimumSelector::shapeset contains bubble functions. The index is a mode (ElementMode).

True if the shapeset OptimumSelector::shapeset contains edge functions. The index is a mode (ElementMode).

True if the shapeset OptimumSelector::shapeset contains vertex functions. The index is a mode (ElementMode).

A maximum index of a shape function. The first index is a mode (ElementMode).

int RefinementSelectors::OptimumSelector::next_order_shape[H2D_NUM_MODES][H2DRS_MAX_ORDER+1] [protected]

An index to the array OptimumSelector::shape_indices of a shape function of the next uniform order. The first index is a mode (ElementMode), the second index is an order.

True if H2D_APPLY_CONV_EXP_DOF is set. False by default.

True if H2D_PREFER_SYMMETRIC_MESH is set. True by default.

std::vector<ShapeInx> RefinementSelectors::OptimumSelector::shape_indices[H2D_NUM_MODES] [protected]

Shape indices. The first index is a mode (ElementMode).

A shapeset used to calculate error.


The documentation for this class was generated from the following files:
Generated on Sat Jun 5 15:17:44 2010 for Hermes2D Library: Real Version by  doxygen 1.6.3