Hermes2D  3.0
order_permutator.cpp
1 // This file is part of Hermes2D.
2 //
3 // Hermes2D is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 2 of the License, or
6 // (at your option) any later version.
7 //
8 // Hermes2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Hermes2D. If not, see <http://www.gnu.org/licenses/>.
15 #include "global.h"
16 #include "order_permutator.h"
17 
18 namespace Hermes
19 {
20  namespace Hermes2D
21  {
22  namespace RefinementSelectors
23  {
24  OrderPermutator::OrderPermutator(unsigned short start_quad_order, unsigned short end_quad_order, bool iso_p, unsigned short* tgt_quad_order)
25  : start_order_h(H2D_GET_H_ORDER(start_quad_order)), start_order_v(H2D_GET_V_ORDER(start_quad_order))
26  , end_order_h(H2D_GET_H_ORDER(end_quad_order)), end_order_v(H2D_GET_V_ORDER(end_quad_order))
27  , iso_p(iso_p), tgt_quad_order(tgt_quad_order)
28  {
29  reset();
30  }
31 
33  {
34  if (iso_p)
35  {
37  return false;
38 
39  order_h++;
40  order_v++;
41  }
42  else
43  {
45  return false;
46 
47  order_h++;
48  if (order_h > end_order_h)
49  {
51  order_v++;
52  }
53  }
54 
55  if (tgt_quad_order != nullptr)
56  *tgt_quad_order = H2D_MAKE_QUAD_ORDER(order_h, order_v);
57  return true;
58  }
59 
61  {
64  if (tgt_quad_order != nullptr)
65  *tgt_quad_order = H2D_MAKE_QUAD_ORDER(order_h, order_v);
66  }
67 
68  unsigned short OrderPermutator::get_order_h() const
69  {
70  return order_h;
71  }
72 
73  unsigned short OrderPermutator::get_order_v() const
74  {
75  return order_v;
76  }
77 
78  unsigned short OrderPermutator::get_quad_order() const
79  {
80  return H2D_MAKE_QUAD_ORDER(order_h, order_v);
81  }
82 
84  {
85  return H2D_MAKE_QUAD_ORDER(start_order_h, start_order_v);
86  }
87 
88  unsigned short OrderPermutator::get_end_quad_order() const
89  {
90  return H2D_MAKE_QUAD_ORDER(end_order_h, end_order_v);
91  }
92  }
93  }
94 }
unsigned short get_order_v() const
Returns the current vertical order.
Definition: adapt.h:24
unsigned short order_h
The current horizontal order.
unsigned short start_order_v
The starting vertical order.
Common definitions for Hermes2D.
unsigned short get_quad_order() const
Returns the current order in an encoded form.
unsigned short order_v
The current verical order.
unsigned short get_order_h() const
Returns the current horizontal order.
#define H2D_GET_H_ORDER(encoded_order)
Macros for combining quad horizontal and vertical encoded_orders.
Definition: global.h:98
bool next()
Moves to the next permutation of orders.
bool iso_p
True if orders is incresed in both the horizontal order and the vertical order are increased simultan...
unsigned short end_order_v
The ending vertical order.
unsigned short get_start_quad_order() const
Returns the starting order in an encoded form.
unsigned short end_order_h
The ending horizontal order.
unsigned short get_end_quad_order() const
Returns the ending order in an encoded form.
unsigned short * tgt_quad_order
A pointer to which a current order is stored in encoded form. Ignored if nullptr. ...
void reset()
Resets permutator to the starting order.
unsigned short start_order_h
The starting horizontal order.
OrderPermutator(unsigned short start_quad_order=0, unsigned short end_quad_order=0, bool iso_p=false, unsigned short *tgt_quad_order=nullptr)
Constructor.