Hermes2D  3.0
element_to_refine.cpp
1 #include "element_to_refine.h"
2 
3 namespace Hermes
4 {
5  namespace Hermes2D
6  {
7  bool HERMES_API is_refin_aniso(const RefinementType refin_type)
8  {
9  if (refin_type == H2D_REFINEMENT_H_ANISO_H || refin_type == H2D_REFINEMENT_H_ANISO_V)
10  return true;
11  else
12  return false;
13  }
14 
15  int HERMES_API get_refin_sons(const RefinementType refin_type)
16  {
17  switch (refin_type)
18  {
19  case H2D_REFINEMENT_P: return 1; break;
20  case H2D_REFINEMENT_H: return 4; break;
22  case H2D_REFINEMENT_H_ANISO_V: return 2; break;
23  default: throw Hermes::Exceptions::Exception("Invalid refinement type %d", (int)refin_type); return -1;
24  }
25  }
26 
27  const HERMES_API std::string get_refin_str(const RefinementType refin_type)
28  {
29  switch (refin_type)
30  {
31  case H2D_REFINEMENT_P: return "P"; break;
32  case H2D_REFINEMENT_H: return "H"; break;
33  case H2D_REFINEMENT_H_ANISO_H: return "AnisoH"; break;
34  case H2D_REFINEMENT_H_ANISO_V: return "AnisoV"; break;
35  default:
36  std::stringstream str;
37  str << "Unknown(" << refin_type << ")";
38  return str.str();
39  }
40  }
41 
43  {
44  };
45 
46  ElementToRefine::ElementToRefine(int id, unsigned short comp, bool space_only) : id(id), comp(comp), split(H2D_REFINEMENT_H), valid(true), space_only(space_only)
47  {
48  };
49 
50  unsigned short ElementToRefine::get_num_sons() const
51  {
52  return get_refin_sons(split);
53  };
54 
55  void ElementToRefine::copy_orders(unsigned short* dest, const unsigned short* src)
56  {
57  memcpy(dest, src, sizeof(unsigned short)* H2D_MAX_ELEMENT_SONS);
58  }
59 
60  void ElementToRefine::copy_errors(double* dest, const double* src)
61  {
62  memcpy(dest, src, sizeof(double)* H2D_MAX_ELEMENT_SONS);
63  }
64 
66  {
67  id = orig.id;
68  comp = orig.comp;
69  split = orig.split;
70  valid = orig.valid;
72  for (int i = 0; i < 5; i++)
74  return *this;
75  }
76  }
77 }
Definition: adapt.h:24
unsigned short comp
An index of the component.
unsigned short get_num_sons() const
Returns a number of sons.
RefinementType
Possible refinements of an element.
unsigned short refinement_polynomial_order[H2D_MAX_ELEMENT_SONS]
Encoded orders of sons.
HERMES_API const std::string get_refin_str(const RefinementType refin_type)
Returns a string representation of the refinement.
ElementToRefine()
Constructor. Creates an invalid refinement.
ANISO-refienement. The element is split along the vertical axis. Quadrilaterals only.
static void copy_orders(unsigned short *dest, const unsigned short *src)
Copies array of orders.
RefinementType split
Proposed refinement. Possible values are defined in the enum RefinementType.
int id
An ID of the element.
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.
HERMES_API int get_refin_sons(const RefinementType refin_type)
Returns a maximum number of sons that will be generated if a given refinement is applied.
ANISO-refienement. The element is split along the horizontal axis. Quadrilaterals only...
#define H2D_MAX_ELEMENT_SONS
Macros.
Definition: global.h:30
ElementToRefine & operator=(const ElementToRefine &orig)
Assignment operator.
HERMES_API bool is_refin_aniso(const RefinementType refin_type)
Retuns true if a given refinement is an ANISO-refinement.
unsigned short best_refinement_polynomial_order_type[4][H2D_MAX_ELEMENT_SONS]