Hermes2D  3.0
traverse.h
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 
16 #ifndef __H2D_TRAVERSE_H
17 #define __H2D_TRAVERSE_H
18 
19 #include "hermes_common.h"
20 #include "mesh.h"
21 
22 namespace Hermes
23 {
24  namespace Hermes2D
25  {
30  struct SurfPos
31  {
33  int marker;
35  int surf_num;
36 
39 
41  int v1, v2;
43  double t;
45  double lo, hi;
46  };
47 
48  class Mesh;
49  class Transformable;
50  struct Rect;
51 
52  struct UniData
53  {
54  Element* e;
55  uint64_t idx;
56  };
57 
58  static const uint64_t ONE = (uint64_t)1 << 63;
59 
60  struct Rect
61  {
62  uint64_t l, b, r, t;
63  };
64 
69  class HERMES_API Traverse : public Hermes::Mixins::Loggable
70  {
71  public:
72  Traverse(int spaces_size);
73  class State
74  {
75  public:
76  Element** e;
77  uint64_t* sub_idx;
78  bool bnd[H2D_MAX_NUMBER_EDGES];
79  bool isBnd;
80  unsigned char isurf;
81  Element* rep;
82  unsigned short rep_i;
83  ~State();
84  unsigned short num;
85  static State* clone(const State * other);
86  private:
87  State();
88  //void operator=(const State * other);
89  void push_transform(unsigned char son, unsigned char i, bool is_triangle = false);
90  bool is_triangle();
91  uint64_t get_transform(unsigned char i);
92  bool visited;
93  Rect cr;
94  Rect* er;
95  friend class Traverse;
96  template<typename Scalar> friend class DiscreteProblem;
97  template<typename T> friend class DiscreteProblemDGAssembler;
98  template<typename T> friend class DiscreteProblemThreadAssembler;
99  };
100 
105  State** get_states(std::vector<MeshSharedPtr> meshes, unsigned int& states_count);
106  State** get_states(MeshSharedPtr* meshes, unsigned short meshes_count, unsigned int& states_count);
107 
110  template<typename Scalar>
111  State** get_states(std::vector<MeshFunctionSharedPtr<Scalar> > mesh_functions, unsigned int& states_count);
112 
113  private:
115  void begin(int n);
117  void finish();
119  void init_transforms(State* s, unsigned char i);
120 
121 #pragma region union-mesh
122  static UniData** construct_union_mesh(unsigned char n, MeshSharedPtr* meshes, MeshSharedPtr unimesh);
123  void union_recurrent(Rect* cr, Element** e, Rect* er, uint64_t* idx, Element* uni);
124  uint64_t init_idx(Rect* cr, Rect* er);
125 
126  UniData** unidata;
127  int udsize;
128 #pragma endregion
129 
131  unsigned short num;
133  State* stack;
135  int top, size;
136 
138  State* push_state(int* top_by_ref = nullptr);
140  void set_boundary_info(State* s);
142  void free_state(State* state);
144  unsigned char spaces_size;
145 
146  MeshSharedPtr unimesh;
147  template<typename T> friend class Adapt;
148  template<typename T> friend class KellyTypeAdapt;
149  template<typename T> friend class DiscreteProblem;
150  template<typename T> friend class DiscreteProblemDGAssembler;
151  template<typename T> friend class DiscreteProblemIntegrationOrderCalculator;
152  template<typename T> friend class Filter;
153  template<typename T> friend class SimpleFilter;
154  friend class Views::Orderizer;
155  };
156  }
157 }
158 #endif
Definition: adapt.h:24
double lo
H2D only: for internal use.
Definition: traverse.h:45
Stores one element of a mesh.
Definition: element.h:107
Represents a finite element mesh. Typical usage: MeshSharedPtr mesh; Hermes::Hermes2D::MeshReaderH2DX...
Definition: mesh.h:61
int surf_num
local element surface number
Definition: traverse.h:35
Element * base
for internal use
Definition: traverse.h:38
#define H2D_MAX_NUMBER_EDGES
A maximum number of edges of an element.
Definition: global.h:31
Determines the position on an element surface (edge in 2D and Face in 3D).
Definition: traverse.h:30
int marker
surface marker (surface = edge in 2D and face in 3D)
Definition: traverse.h:33
This class is a one-thread (non-DG) assembly worker.
double t
H2D only: position between v1 and v2 in the range[0..1].
Definition: traverse.h:43
int v1
H2D only: edge endpoint vertex id numbers.
Definition: traverse.h:41