Hermes2D  3.0
candidates.cpp
1 #include "refinement_selectors/candidates.h"
2 
3 namespace Hermes
4 {
5  namespace Hermes2D
6  {
7  namespace RefinementSelectors
8  {
9  HERMES_API const char* get_cand_list_str(const CandList cand_list)
10  {
11  switch (cand_list)
12  {
13  case H2D_NONE: return "Custom";
14  case H2D_P_ISO: return "P_ISO";
15  case H2D_P_ANISO: return "P_ANISO";
16  case H2D_H_ISO: return "H_ISO";
17  case H2D_H_ANISO: return "H_ANISO";
18  case H2D_HP_ISO: return "HP_ISO";
19  case H2D_HP_ANISO_H: return "HP_ANISO_H";
20  case H2D_HP_ANISO_P: return "HP_ANISO_P";
21  case H2D_HP_ANISO: return "HP_ANISO";
22  default:
23  throw Hermes::Exceptions::Exception("Invalid adapt type %d.", cand_list);
24  return nullptr;
25  }
26  }
27 
28  HERMES_API bool is_hp(const CandList cand_list)
29  {
30  switch (cand_list)
31  {
32  case H2D_P_ISO:
33  case H2D_P_ANISO:
34  case H2D_H_ISO:
35  case H2D_H_ANISO: return false; break;
36  case H2D_NONE:
37  case H2D_HP_ISO:
38  case H2D_HP_ANISO_H:
39  case H2D_HP_ANISO_P:
40  case H2D_HP_ANISO: return true; break;
41  default: throw Hermes::Exceptions::Exception("Invalid adapt type %d.", cand_list); return false;
42  }
43  }
44 
45  HERMES_API bool is_p(const CandList cand_list)
46  {
47  switch (cand_list)
48  {
49  case H2D_H_ISO:
50  case H2D_H_ANISO: return false; break;
51  case H2D_NONE:
52  case H2D_P_ISO:
53  case H2D_P_ANISO:
54  case H2D_HP_ISO:
55  case H2D_HP_ANISO_H:
56  case H2D_HP_ANISO_P:
57  case H2D_HP_ANISO: return true; break;
58  default: throw Hermes::Exceptions::Exception("Invalid adapt type %d.", cand_list); return false;
59  }
60  }
61 
62  HERMES_API bool is_p_aniso(const CandList cand_list)
63  {
64  switch (cand_list)
65  {
66  case H2D_NONE: return false;
67  case H2D_P_ISO: return false;
68  case H2D_P_ANISO: return true;
69  case H2D_H_ISO: return false;
70  case H2D_H_ANISO: return false;
71  case H2D_HP_ISO: return false;
72  case H2D_HP_ANISO_H: return false;
73  case H2D_HP_ANISO_P: return true;
74  case H2D_HP_ANISO: return true;
75  default: throw Hermes::Exceptions::Exception("Invalid adapt type %d.", cand_list); return false;
76  }
77  }
78 
79  Cand::Cand(const RefinementType split, const unsigned short order_elems[H2D_MAX_ELEMENT_SONS])
80  : dofs(-1), split(split), score(0) {
81  p[0] = order_elems[0];
82  p[1] = order_elems[1];
83  p[2] = order_elems[2];
84  p[3] = order_elems[3];
85  };
86 
87  Cand::Cand(const RefinementType split, const unsigned short order_elem0, const unsigned short order_elem1, const unsigned short order_elem2, const unsigned short order_elem3)
88  : dofs(-1), split(split), score(0) {
89  p[0] = order_elem0;
90  p[1] = order_elem1;
91  p[2] = order_elem2;
92  p[3] = order_elem3;
93  };
94 
95  unsigned char Cand::get_num_elems() const {
96  switch (split) {
97  case H2D_REFINEMENT_H: return 4;
98  case H2D_REFINEMENT_P: return 1;
101  return 2;
102  default:
103  throw Hermes::Exceptions::Exception("Invalid refinement type %d.", split);
104  return 0;
105  break;
106  }
107  }
108  };
109  }
110 }
RefinementType split
A refinement, see the enum RefinementType.
Definition: candidates.h:90
HERMES_API bool is_p_aniso(const CandList cand_list)
Returns true if a predefined candidate list may contain candidates with an anisotropic change of orde...
Definition: candidates.cpp:62
Definition: adapt.h:24
Cand(const RefinementType split, const unsigned short order_elems[H2D_MAX_ELEMENT_SONS])
Constructor.
Definition: candidates.cpp:79
P-candidates only. Hermes::Orders are modified non-uniformly.
Definition: candidates.h:49
H-candidates only. Hermes::Orders are not modified.
Definition: candidates.h:50
HERMES_API const char * get_cand_list_str(const CandList cand_list)
Returns a string representation of a predefined candidate list.
Definition: candidates.cpp:9
RefinementType
Possible refinements of an element.
HERMES_API bool is_hp(const CandList cand_list)
Returns true if a predefined candidate list may contain candidates that are HP.
Definition: candidates.cpp:28
H-, ANISO- and P-candidates. Hermes::Orders are modified non-uniformly.
Definition: candidates.h:55
H- and ANISO-candidates only. Hermes::Orders are not modified.
Definition: candidates.h:51
CandList
Predefined list of candidates.
Definition: candidates.h:46
ANISO-refienement. The element is split along the vertical axis. Quadrilaterals only.
H- and P-candidates only. Hermes::Orders are modified non-uniformly.
Definition: candidates.h:54
H- and P-candidates only. Hermes::Orders are modified uniformly.
Definition: candidates.h:52
No adaptivity. (Used only in modules.)
Definition: candidates.h:47
HERMES_API bool is_p(const CandList cand_list)
Returns true if a predefined candidate list may contain candidates that increase P.
Definition: candidates.cpp:45
unsigned short p[H2D_MAX_ELEMENT_SONS]
Encoded orders of sons, see ::H2D_MAKE_QUAD_ORDER. In a case of a triangle, the vertical order is equ...
Definition: candidates.h:92
ANISO-refienement. The element is split along the horizontal axis. Quadrilaterals only...
#define H2D_MAX_ELEMENT_SONS
Macros.
Definition: global.h:30
H-, ANISO- and P-candidates. Hermes::Orders are modified uniformly.
Definition: candidates.h:53
unsigned char get_num_elems() const
Returns a number of elements of a candidate.
Definition: candidates.cpp:95
P-candidates only. Hermes::Orders are modified uniformly.
Definition: candidates.h:48