16 #ifndef __H2D_REFINEMENT_OPTIMUM_SELECTOR_H
17 #define __H2D_REFINEMENT_OPTIMUM_SELECTOR_H
20 #include "order_permutator.h"
22 #include "../shapeset/shapeset.h"
28 namespace RefinementSelectors {
67 template<
typename Scalar>
68 class HERMES_API OptimumSelector :
public Selector<Scalar> {
77 virtual void set_option(
const SelOption option,
bool enable);
91 : dofs(-1), split(split), score(0) {
92 p[0] = order_elems[0];
93 p[1] = order_elems[1];
94 p[2] = order_elems[2];
95 p[3] = order_elems[3];
104 Cand(
const int split,
const int order_elem0,
const int order_elem1 = 0,
const int order_elem2 = 0,
const int order_elem3 = 0)
105 : dofs(-1), split(split), score(0) {
116 case H2D_REFINEMENT_H:
return 4;
117 case H2D_REFINEMENT_P:
return 1;
118 case H2D_REFINEMENT_ANISO_H:
119 case H2D_REFINEMENT_ANISO_V:
122 throw Hermes::Exceptions::Exception(
"Invalid refinement type %d.", split);
131 const Hermes::vector<Cand>& get_candidates()
const {
return candidates; };
148 CandsInfo() : uniform_orders(true), min_quad_order(-1), max_quad_order(-1) {};
152 bool is_empty()
const {
return (min_quad_order < 0 || max_quad_order < 0); };
172 void append_candidates_split(
const int start_quad_order,
const int last_order,
const int split,
bool iso_p);
182 virtual void create_candidates(
Element* e,
int quad_order,
int max_ha_quad_order,
int max_p_quad_order);
205 virtual void select_best_candidate(
Element* e,
const double avg_error,
const double dev_error,
int* selected_cand,
int* selected_h_cand);
213 virtual void evaluate_cands_error(
Element* e,
Solution<Scalar>* rsln,
double* avg_error,
double* dev_error) = 0;
231 virtual void evaluate_cands_score(
Element* e);
238 static bool compare_cand_score(
const Cand& a,
const Cand& b);
248 virtual void set_current_order_range(
Element* element) = 0;
254 H2DST_HORIZ_EDGE = 0x02,
255 H2DST_VERT_EDGE = 0x04,
256 H2DST_TRI_EDGE = 0x08,
282 ShapeInx(
int order_h,
int order_v,
int inx,
ShapeType type) : order_h(order_h), order_v(order_v), inx(inx), type(type) {};
293 Range(
const int& lower_bound,
const int& upper_bound);
295 const int& lower()
const;
296 const int& upper()
const;
297 bool is_in_closed(
const Range& range)
const;
298 bool is_in_closed(
const int& value)
const;
299 bool is_in_open(
const int& value)
const;
300 void enlarge_to_include(
const int& value);
329 void add_bubble_shape_index(
int order_h,
int order_v, std::map<int, bool>& used_shape_index, Hermes::vector<ShapeInx>& indices, ElementMode2D mode);
337 void build_shape_indices(
const ElementMode2D mode,
const Range& vertex_order,
const Range& edge_bubble_order);
345 int calc_num_shapes(
int mode,
int order_h,
int order_v,
int allowed_type_mask);
367 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);